Skip to content

Commit

Permalink
Integrated CW keyer mode control over USB
Browse files Browse the repository at this point in the history
  • Loading branch information
bubnikv committed Nov 14, 2017
1 parent 931dcf6 commit db3e563
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 17 deletions.
Binary file modified basic.cydsn/TopDesign/TopDesign.cysch
Binary file not shown.
42 changes: 36 additions & 6 deletions basic.cydsn/basic.cyprj
Original file line number Diff line number Diff line change
Expand Up @@ -1517,14 +1517,14 @@
<CyGuid_ebc4f06d-207f-49c2-a540-72acf4adabc0 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFolder" version="2">
<CyGuid_2f73275c-45bf-46ba-b3b1-00a2fe0c8dd8 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtBaseContainer" version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="KeyerControl" persistent="">
<Hidden v="False" />
<Hidden v="True" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileGenerated" version="1">
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3" xml_contents_version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="KeyerControl.h" persistent=".\Generated_Source\PSoC3\KeyerControl.h">
<Hidden v="False" />
<Hidden v="True" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
<PropertyDeltas />
Expand All @@ -1533,7 +1533,7 @@
<CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileGenerated" version="1">
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3" xml_contents_version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="KeyerControl.c" persistent=".\Generated_Source\PSoC3\KeyerControl.c">
<Hidden v="False" />
<Hidden v="True" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="DP8051_C_FILE" />
<PropertyDeltas />
Expand All @@ -1542,7 +1542,7 @@
<CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileGenerated" version="1">
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3" xml_contents_version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="KeyerControl_PM.c" persistent=".\Generated_Source\PSoC3\KeyerControl_PM.c">
<Hidden v="False" />
<Hidden v="True" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="DP8051_C_FILE" />
<PropertyDeltas />
Expand Down Expand Up @@ -2234,14 +2234,14 @@
<CyGuid_ebc4f06d-207f-49c2-a540-72acf4adabc0 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFolder" version="2">
<CyGuid_2f73275c-45bf-46ba-b3b1-00a2fe0c8dd8 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtBaseContainer" version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="iambic_1" persistent="">
<Hidden v="False" />
<Hidden v="True" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileGenerated" version="1">
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3" xml_contents_version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="iambic_1_iambic.c" persistent=".\Generated_Source\PSoC3\iambic_1_iambic.c">
<Hidden v="False" />
<Hidden v="True" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="DP8051_C_FILE" />
<PropertyDeltas />
Expand All @@ -2250,6 +2250,36 @@
<CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileGenerated" version="1">
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3" xml_contents_version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="iambic_1_iambic.h" persistent=".\Generated_Source\PSoC3\iambic_1_iambic.h">
<Hidden v="True" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
</CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d>
</dependencies>
</CyGuid_0820c2e7-528d-4137-9a08-97257b946089>
</CyGuid_2f73275c-45bf-46ba-b3b1-00a2fe0c8dd8>
<filters />
</CyGuid_ebc4f06d-207f-49c2-a540-72acf4adabc0>
<CyGuid_ebc4f06d-207f-49c2-a540-72acf4adabc0 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFolder" version="2">
<CyGuid_2f73275c-45bf-46ba-b3b1-00a2fe0c8dd8 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtBaseContainer" version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="IambicKeyer" persistent="">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileGenerated" version="1">
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3" xml_contents_version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="IambicKeyer_iambic.c" persistent=".\Generated_Source\PSoC3\IambicKeyer_iambic.c">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="DP8051_C_FILE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
</CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d>
<CyGuid_405e30c3-81d4-4133-98d6-c3ecf21fec0d type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFileGenerated" version="1">
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3" xml_contents_version="1">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="IambicKeyer_iambic.h" persistent=".\Generated_Source\PSoC3\IambicKeyer_iambic.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
Expand Down
1 change: 1 addition & 0 deletions basic.cydsn/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions basic.cydsn/iambic/API/iambic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
13 changes: 12 additions & 1 deletion basic.cydsn/iambic/API/iambic.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@
void `$INSTANCE_NAME`_SetSpeed(uint8);
uint8 `$INSTANCE_NAME`_GetSpeed();

#endif
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
Binary file modified basic.cydsn/iambic/iambic.cysym
Binary file not shown.
21 changes: 18 additions & 3 deletions basic.cydsn/iambic/iambic.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,22 @@ along with IambicV. If not, see <http://www.gnu.org/licenses/>.
// 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;
Expand All @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions basic.cydsn/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions basic.cydsn/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
5 changes: 5 additions & 0 deletions basic.cydsn/usbvend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit db3e563

Please sign in to comment.