1414
1515#include <SI_EFM8UB1_Defs.h>
1616#include <stdint.h>
17+ #include <efm8_usb.h>
1718
18- // Astrokey USB protocol
19+ //////////////////////////
20+ // Device Serial Number //
21+ //////////////////////////
22+
23+ // Converts a nibble to a hex character
24+ #define NIBBLE_TO_ASCII (x ) ((x) >= 10? (x) - 10 + 'A' : (x) + '0')
25+
26+ // Struct for non-const string descriptors
27+ #define UTF16LE_PACKED_STRING_DESC (__name , __size ) \
28+ SI_SEGMENT_VARIABLE(__name, USB_StringDescriptor_TypeDef, SI_SEG_XDATA) = \
29+ { USB_STRING_DESCRIPTOR_UTF16LE_PACKED, __size * 2, USB_STRING_DESCRIPTOR }
30+
31+ // Serial number string descriptor
32+ extern SI_SEGMENT_VARIABLE (serDesc [], USB_StringDescriptor_TypeDef , SI_SEG_XDATA ) ;
33+
34+ // MCU UUID Flash Address
35+ #define UUID_ADDR 0xFFC0
36+
37+ // MCU UUID Length in Bytes
38+ #define UUID_LEN 16
39+
40+ // Length of serial number string (2 characters per byte)
41+ #define SER_STR_LEN (UUID_LEN * 2)
42+
43+ // MCU UUID
44+ SI_VARIABLE_SEGMENT_POINTER (UUID , static const uint8_t , SI_SEG_CODE ) = UUID_ADDR ;
45+
46+ ///////////////////////////
47+ // Astrokey USB protocol //
48+ ///////////////////////////
1949
2050// wIndex values
2151#define ASTROKEY_SET_WORKFLOW 0x01
2252#define ASTROKEY_GET_WORKFLOW 0x02
2353
54+ ///////////////////////
55+ // Device Parameters //
56+ ///////////////////////
57+
2458// Switch configuration
2559#define NUM_SWITCHES 5
2660#define S0 P0_B0
3266// Switch pressed
3367#define PRESSED (x ) (!x)
3468
35- // No macro running
69+ ////////////////////////
70+ // Workflow Constants //
71+ ////////////////////////
72+
73+ // No workflow running
3674#define NO_WORKFLOW 0xFF
3775
38- // Macro action types
76+ // Workflow action types
3977#define WORKFLOW_ACTION_DOWN 1
4078#define WORKFLOW_ACTION_UP 2
4179#define WORKFLOW_ACTION_PRESS 3
5391#define MODIFIER_LEFTALT 0x04
5492#define MODIFIER_LEFTGUI 0x08
5593
56- // Macro action struct
94+ // Workflow action struct
5795typedef struct {
5896 uint8_t actionType ;
5997 uint8_t value ;
@@ -74,15 +112,27 @@ typedef struct {
74112
75113#define WORKFLOW_FLASH_ADDR USER_START_ADDR
76114
115+ ////////////////////////
116+ // Workflow Functions //
117+ ////////////////////////
118+
77119void saveWorkflow (Action_TypeDef * workflowData , uint8_t saveIndex );
78120void loadWorkflow (Action_TypeDef * workflowData , uint8_t loadIndex );
79121
122+ ////////////////////////
123+ // Workflow Variables //
124+ ////////////////////////
125+
80126extern Action_TypeDef SI_SEG_XDATA workflow [WORKFLOW_MAX_SIZE ];
81127extern uint8_t workflowNumActions ;
82128
83129extern Action_TypeDef SI_SEG_XDATA tmpWorkflow [WORKFLOW_MAX_SIZE ];
84130extern volatile int8_t workflowUpdated ;
85131
132+ ////////////////////////
133+ // Astrokey Functions //
134+ ////////////////////////
135+
86136void astrokeyInit ();
87137void astrokeyPoll ();
88138
0 commit comments