Files
firmware/right/src/main.c
Gergely Nagy 3c817f0b1b deserialize: Initial layer deserialization
So far, the code is able to deserialize and apply a single layer, as saved by
the Agent in binary format. It does not support macros and keymap switching
yet (it parses the latter, but will choke on the former), but the rest should be
handled fine.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2017-01-06 09:05:00 +01:00

76 lines
2.7 KiB
C

#include "main.h"
#include "init_clock.h"
#include "init_peripherials.h"
#include "usb_composite_device.h"
#include "led_driver.h"
#include "deserialize.h"
key_matrix_t KeyMatrix = {
.colNum = KEYBOARD_MATRIX_COLS_NUM,
.rowNum = KEYBOARD_MATRIX_ROWS_NUM,
#if UHK_PCB_MAJOR_VERSION == 7
.cols = (key_matrix_pin_t[]){
{PORTA, GPIOA, kCLOCK_PortA, 5},
{PORTB, GPIOB, kCLOCK_PortB, 16},
{PORTB, GPIOB, kCLOCK_PortB, 17},
{PORTB, GPIOB, kCLOCK_PortB, 18},
{PORTB, GPIOB, kCLOCK_PortB, 19},
{PORTA, GPIOA, kCLOCK_PortA, 1},
{PORTB, GPIOB, kCLOCK_PortB, 1}
},
.rows = (key_matrix_pin_t[]){
{PORTA, GPIOA, kCLOCK_PortA, 12},
{PORTA, GPIOA, kCLOCK_PortA, 13},
{PORTC, GPIOC, kCLOCK_PortC, 1},
{PORTC, GPIOC, kCLOCK_PortC, 0},
{PORTD, GPIOD, kCLOCK_PortD, 5}
}
#else
.cols = (key_matrix_pin_t[]){
{PORTA, GPIOA, kCLOCK_PortA, 5},
{PORTB, GPIOB, kCLOCK_PortB, 3},
{PORTB, GPIOB, kCLOCK_PortB, 16},
{PORTB, GPIOB, kCLOCK_PortB, 17},
{PORTB, GPIOB, kCLOCK_PortB, 18},
{PORTA, GPIOA, kCLOCK_PortA, 1},
{PORTB, GPIOB, kCLOCK_PortB, 0}
},
.rows = (key_matrix_pin_t[]){
{PORTA, GPIOA, kCLOCK_PortA, 12},
{PORTA, GPIOA, kCLOCK_PortA, 13},
{PORTC, GPIOC, kCLOCK_PortC, 0},
{PORTB, GPIOB, kCLOCK_PortB, 19},
{PORTD, GPIOD, kCLOCK_PortD, 6}
}
#endif
};
uint8_t PreviousKeyStates[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
uint8_t CurrentKeyStates[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
static const uint8_t testData[] =
{0x03, 0x00, 0x01, 0x22, 0x02, 0x24, 0x02, 0x25, 0x02, 0x26, 0x02, 0x27, 0x02, 0x2d, 0x02, 0x2e, 0x02, 0x2a, 0x02,
0x1c, 0x02, 0x18, 0x02, 0x0c, 0x02, 0x12, 0x04, 0x13, 0x22, 0x02, 0x2f, 0x02, 0x30, 0x02, 0x31, 0x02, 0x0b, 0x02,
0x0d, 0x02, 0x0e, 0x02, 0x0f, 0x02, 0x33, 0x02, 0x34, 0x02, 0x28, 0x02, 0x11, 0x02, 0x10, 0x02, 0x36, 0x02, 0x37,
0x02, 0x38, 0x0a, 0x03, 0x02, 0x2c, 0x02, 0x1c, 0x02, 0x1b, 0x02, 0x1a, 0x02, 0x14, 0x02, 0x1d, 0x01, 0x01, 0x1f,
0x02, 0x35, 0x02, 0x1e, 0x02, 0x1f, 0x02, 0x20, 0x02, 0x21, 0x02, 0x22, 0x02, 0x23, 0x06, 0x29, 0x09, 0x02, 0x14,
0x02, 0x1a, 0x02, 0x08, 0x02, 0x15, 0x02, 0x17, 0x02, 0x2b, 0x02, 0x04, 0x02, 0x16, 0x02, 0x07, 0x02, 0x09, 0x02,
0x0a, 0x02, 0x2d, 0x02, 0x1d, 0x02, 0x1b, 0x02, 0x06, 0x02, 0x19, 0x02, 0x05, 0x02, 0x04, 0x02, 0x05, 0x02, 0x06,
0x02, 0x07, 0x02, 0x08, 0x02, 0x09, 0x02, 0x02, 0x00 };
void main() {
InitPeripherials();
InitClock();
LedDriver_InitAllLeds(1);
KeyMatrix_Init(&KeyMatrix);
UsbKeyboadTask();
InitUsb();
// deserialize_Layer(testData, 0);
while (1) {
UsbKeyboadTask();
asm("wfi");
}
}