diff --git a/basic.cydsn/TopDesign/TopDesign.cysch b/basic.cydsn/TopDesign/TopDesign.cysch index fc9bd5b..9e3c0cc 100644 Binary files a/basic.cydsn/TopDesign/TopDesign.cysch and b/basic.cydsn/TopDesign/TopDesign.cysch differ diff --git a/basic.cydsn/basic.cyprj b/basic.cydsn/basic.cyprj index 5825f01..2c6b10e 100644 --- a/basic.cydsn/basic.cyprj +++ b/basic.cydsn/basic.cyprj @@ -1517,14 +1517,14 @@ - + - + @@ -1533,7 +1533,7 @@ - + @@ -1542,7 +1542,7 @@ - + @@ -2234,14 +2234,14 @@ - + - + @@ -2250,6 +2250,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/basic.cydsn/basic.h b/basic.cydsn/basic.h index aa2d8bb..080791c 100644 --- a/basic.cydsn/basic.h +++ b/basic.cydsn/basic.h @@ -103,6 +103,7 @@ uint8* PCM3060_RxBuf(void); void Settings_Init(void); void Settings_Main(void); extern uint8 keyer_cntr; +extern uint8 keyer_mode; // sidetone.c void Tone_Init(void); diff --git a/basic.cydsn/iambic/API/iambic.c b/basic.cydsn/iambic/API/iambic.c index 00e0cd5..69d4e08 100644 --- a/basic.cydsn/iambic/API/iambic.c +++ b/basic.cydsn/iambic/API/iambic.c @@ -15,3 +15,15 @@ uint8 `$INSTANCE_NAME`_GetSpeed() // return CY_GET_REG8(`$INSTANCE_NAME`_cntr8_D0_PTR); return CY_GET_REG8(`$INSTANCE_NAME`_cntr8_u0__D0_REG); } + +void `$INSTANCE_NAME`_SetMode(uint8 val) +{ +// CY_SET_REG8(`$INSTANCE_NAME`_cntr8_D0_PTR,val); + CY_SET_REG8(`$INSTANCE_NAME`_IAMBIC_CONTROL__CONTROL_REG,val); +} + +uint8 `$INSTANCE_NAME`_GetMode() +{ +// return CY_GET_REG8(`$INSTANCE_NAME`_cntr8_D0_PTR); + return CY_GET_REG8(`$INSTANCE_NAME`_IAMBIC_CONTROL__CONTROL_REG); +} \ No newline at end of file diff --git a/basic.cydsn/iambic/API/iambic.h b/basic.cydsn/iambic/API/iambic.h index 553c49c..2f222f6 100644 --- a/basic.cydsn/iambic/API/iambic.h +++ b/basic.cydsn/iambic/API/iambic.h @@ -6,4 +6,15 @@ void `$INSTANCE_NAME`_SetSpeed(uint8); uint8 `$INSTANCE_NAME`_GetSpeed(); -#endif \ No newline at end of file +void `$INSTANCE_NAME`_SetMode(uint8); +uint8 `$INSTANCE_NAME`_GetMode(); + +#ifndef IAMBIC_H +#define IAMBIC_H +#define IAMBIC_MODE_B (1 << 0) +#define IAMBIC_SKEY (1 << 1) +#define IAMBIC_AUTOSPACE (1 << 2) +#define IAMBIC_RST_N (1 << 7) +#endif + +#endif diff --git a/basic.cydsn/iambic/iambic.cysym b/basic.cydsn/iambic/iambic.cysym index 179fadc..b8fd6c0 100644 Binary files a/basic.cydsn/iambic/iambic.cysym and b/basic.cydsn/iambic/iambic.cysym differ diff --git a/basic.cydsn/iambic/iambic.v b/basic.cydsn/iambic/iambic.v index 06f8d87..5000196 100644 --- a/basic.cydsn/iambic/iambic.v +++ b/basic.cydsn/iambic/iambic.v @@ -42,7 +42,22 @@ along with IambicV. If not, see . // key - Morse code keyed output // -module iambic(input rst_n, input clk, input modeb, input skey, input dit, input dah, output key); +module iambic(input clk, input dit, input dah, output key); + + // Definition of the control register. + wire [7:0] iambic_control; + wire modeb; + wire skey; + wire autospace; + wire rst_n; + assign modeb = iambic_control[0]; + assign skey = iambic_control[1]; + assign autospace = iambic_control[2]; + assign rst_n = iambic_control[7]; + cy_psoc3_control #(.cy_init_value(8'b10000001), .cy_force_order(`TRUE)) + IAMBIC_CONTROL(.control(iambic_control)); + + reg [1:0] reps; wire start, nextDah; @@ -57,8 +72,8 @@ module iambic(input rst_n, input clk, input modeb, input skey, input dit, input wire cntr8_f1_load; wire cntr8_route_si; wire cntr8_route_ci; - wire [2:0] cntr8_select; - + wire [2:0] cntr8_select; + /* ==================== Assignment of Combinatorial Variables ==================== */ assign cntr8_d0_load = (1'b0); assign cntr8_d1_load = (1'b0); diff --git a/basic.cydsn/main.c b/basic.cydsn/main.c index 4b9db8a..05db589 100644 --- a/basic.cydsn/main.c +++ b/basic.cydsn/main.c @@ -40,11 +40,6 @@ void main_init() { TONE_CLK_SetDividerRegister(625, 1); // 1200Hz sidetone TONE_CLK_SetDividerRegister(625/2, 1); - -// speed = (f(clk) * 60) / (wpm * 50) (Using PARIS standard timing.) -// At 1000 Hz clk, 12 wpm is speed=100, 5 wpm is speed = 240, and 20 wpm is speed = 60 -// KeyerSpeed_Write(70); - iambic_1_SetSpeed(250); } // A compliant USB device is required to monitor diff --git a/basic.cydsn/settings.c b/basic.cydsn/settings.c index 1e46c52..f9e6310 100644 --- a/basic.cydsn/settings.c +++ b/basic.cydsn/settings.c @@ -43,8 +43,12 @@ void Settings_Init(void) { } +// speed = (f(clk) * 60) / (wpm * 50) (Using PARIS standard timing.) +// At 1000 Hz clk, 12 wpm is speed=100, 5 wpm is speed = 240, and 20 wpm is speed = 60 uint8 keyer_cntr_current = 0; -uint8 keyer_cntr = 18; +uint8 keyer_cntr = 60; // 20 WPM +uint8 keyer_mode_current = IAMBIC_RST_N; +uint8 keyer_mode = IAMBIC_MODE_B | IAMBIC_SKEY | IAMBIC_RST_N; void Settings_Main(void) { uint8 i; @@ -62,6 +66,10 @@ void Settings_Main(void) { if (keyer_cntr != keyer_cntr_current) { keyer_cntr_current = keyer_cntr; - iambic_1_SetSpeed(keyer_cntr_current); + IambicKeyer_SetSpeed(keyer_cntr_current); + } + if (keyer_mode != keyer_mode_current) { + keyer_mode_current = keyer_mode; + IambicKeyer_SetMode(keyer_mode_current); } } diff --git a/basic.cydsn/usbvend.c b/basic.cydsn/usbvend.c index ecfdb13..2b9f3de 100644 --- a/basic.cydsn/usbvend.c +++ b/basic.cydsn/usbvend.c @@ -138,6 +138,11 @@ uint8 USBFS_HandleVendorRqst(void) USBFS_currentTD.count = 1; requestHandled = USBFS_InitControlWrite(); break; + case 0x66: // CMD_SET_CW_KEYER_MODE + USBFS_currentTD.pData = (void *)&keyer_mode; + USBFS_currentTD.count = 1; + requestHandled = USBFS_InitControlWrite(); + break; } }