summaryrefslogtreecommitdiff
path: root/fw/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/src/main.c')
-rw-r--r--fw/src/main.c200
1 files changed, 15 insertions, 185 deletions
diff --git a/fw/src/main.c b/fw/src/main.c
index 982b1c2..f4a34d7 100644
--- a/fw/src/main.c
+++ b/fw/src/main.c
@@ -104,21 +104,6 @@ int main(void)
}
}
-void __libc_init_array(void);
-void __libc_init_array() {
- /* FIXME Do we even need this? */
-}
-
-void _init(void);
-void _init() {
- /* FIXME Do we even need this? */
-}
-
-void __assert_func (const char *file, int line, const char * func, const char * exp) {
- asm volatile ("bkpt");
- while (1);
-}
-
static uint32_t poll_encoders() {
static bool tx_vol_reset = 0;
static uint16_t tim1_last = 0, tim3_last = 0; /* timers init to 0 */
@@ -173,176 +158,6 @@ static uint32_t poll_keys() {
return keybits;
}
-const uint8_t _asciimap[128] =
-{
- 0x00, // NUL
- 0x00, // SOH
- 0x00, // STX
- 0x00, // ETX
- 0x00, // EOT
- 0x00, // ENQ
- 0x00, // ACK
- 0x00, // BEL
- 0x2a, // BS Backspace
- 0x2b, // TAB Tab
- 0x28, // LF Enter
- 0x00, // VT
- 0x00, // FF
- 0x00, // CR
- 0x00, // SO
- 0x00, // SI
- 0x00, // DEL
- 0x00, // DC1
- 0x00, // DC2
- 0x00, // DC3
- 0x00, // DC4
- 0x00, // NAK
- 0x00, // SYN
- 0x00, // ETB
- 0x00, // CAN
- 0x00, // EM
- 0x00, // SUB
- 0x00, // ESC
- 0x00, // FS
- 0x00, // GS
- 0x00, // RS
- 0x00, // US
-
- 0x2c, // ' '
- 0x1e|0x80, // !
- 0x34|0x80, // "
- 0x20|0x80, // #
- 0x21|0x80, // $
- 0x22|0x80, // %
- 0x24|0x80, // &
- 0x34, // '
- 0x26|0x80, // (
- 0x27|0x80, // )
- 0x25|0x80, // *
- 0x2e|0x80, // +
- 0x36, // ,
- 0x2d, // -
- 0x37, // .
- 0x38, // /
- 0x27, // 0
- 0x1e, // 1
- 0x1f, // 2
- 0x20, // 3
- 0x21, // 4
- 0x22, // 5
- 0x23, // 6
- 0x24, // 7
- 0x25, // 8
- 0x26, // 9
- 0x33|0x80, // :
- 0x33, // ;
- 0x36|0x80, // <
- 0x2e, // =
- 0x37|0x80, // >
- 0x38|0x80, // ?
- 0x1f|0x80, // @
- 0x04|0x80, // A
- 0x05|0x80, // B
- 0x06|0x80, // C
- 0x07|0x80, // D
- 0x08|0x80, // E
- 0x09|0x80, // F
- 0x0a|0x80, // G
- 0x0b|0x80, // H
- 0x0c|0x80, // I
- 0x0d|0x80, // J
- 0x0e|0x80, // K
- 0x0f|0x80, // L
- 0x10|0x80, // M
- 0x11|0x80, // N
- 0x12|0x80, // O
- 0x13|0x80, // P
- 0x14|0x80, // Q
- 0x15|0x80, // R
- 0x16|0x80, // S
- 0x17|0x80, // T
- 0x18|0x80, // U
- 0x19|0x80, // V
- 0x1a|0x80, // W
- 0x1b|0x80, // X
- 0x1c|0x80, // Y
- 0x1d|0x80, // Z
- 0x2f, // [
- 0x31, // bslash
- 0x30, // ]
- 0x23|0x80, // ^
- 0x2d|0x80, // _
- 0x35, // `
- 0x04, // a
- 0x05, // b
- 0x06, // c
- 0x07, // d
- 0x08, // e
- 0x09, // f
- 0x0a, // g
- 0x0b, // h
- 0x0c, // i
- 0x0d, // j
- 0x0e, // k
- 0x0f, // l
- 0x10, // m
- 0x11, // n
- 0x12, // o
- 0x13, // p
- 0x14, // q
- 0x15, // r
- 0x16, // s
- 0x17, // t
- 0x18, // u
- 0x19, // v
- 0x1a, // w
- 0x1b, // x
- 0x1c, // y
- 0x1d, // z
- 0x2f|0x80, // {
- 0x31|0x80, // |
- 0x30|0x80, // }
- 0x35|0x80, // ~
- 0 // DEL
-};
-
-
-void sendChar(uint8_t ch){
- if( ch > 128 ) ch -=128;
-
- key.id = 1;
- key.keycode[0]=_asciimap[ch]&0x7F;
- key.keycode[1]=0;
-
- if ( _asciimap[ch] & 0x80) key.modifier |= 0x02;
-
- for(int i=0; i< 4;i++){
- USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t *)&key, sizeof(key));
- HAL_Delay(10);
- }
- memset(key.keycode, 0 , sizeof(key.keycode));
- key.modifier = 0;
- USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t *)&key, sizeof(key));
- HAL_Delay(10);
-}
-
-void sendCharWrong(uint8_t ch){
- key.id = 1;
- key.keycode[0]=ch&0x7F;
- key.keycode[1]=0;
-
- if ( _asciimap[ch] & 0x80) key.modifier |= 0x02;
-
- for(int i=0; i< 4;i++){
- USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t *)&key, sizeof(key));
- HAL_Delay(10);
- }
- memset(key.keycode, 0 , sizeof(key.keycode));
- key.modifier = 0;
- USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t *)&key, sizeof(key));
- HAL_Delay(10);
-}
-
void sendKeybits(uint8_t keybits){
uint8_t report[2];
report[0]= HID_MEDIA_REPORT;
@@ -477,3 +292,18 @@ void Error_Handler(void)
}
}
+void __libc_init_array(void);
+void __libc_init_array() {
+ /* FIXME Do we even need this? */
+}
+
+void _init(void);
+void _init() {
+ /* FIXME Do we even need this? */
+}
+
+void __assert_func (const char *file, int line, const char * func, const char * exp) {
+ asm volatile ("bkpt");
+ while (1);
+}
+