From a76a690a982632569bac341e8e9ef03a9d81d5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Tue, 10 Jan 2017 01:19:29 +0100 Subject: [PATCH] Rename UsbKeyboadTask() to updateUsbReports() and move it to main.c --- right/src/main.c | 23 +++++++++++++++++++++-- right/src/usb_interface_keyboard.c | 18 ------------------ right/src/usb_interface_keyboard.h | 2 -- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/right/src/main.c b/right/src/main.c index 7c3f11d..b2229f9 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -4,6 +4,7 @@ #include "usb_composite_device.h" #include "led_driver.h" #include "deserialize.h" +#include "action.h" key_matrix_t KeyMatrix = { .colNum = KEYBOARD_MATRIX_COLS_NUM, @@ -58,18 +59,36 @@ static const uint8_t testData[] = 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 updateUsbReports() +{ + ResetActiveUsbKeyboardReport(); + + KeyMatrix_Scan(&KeyMatrix); + memcpy(CurrentKeyStates[SLOT_ID_RIGHT_KEYBOARD_HALF], KeyMatrix.keyStates, MAX_KEY_COUNT_PER_MODULE); + + uint8_t txData[] = {0}; + bzero(CurrentKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], MAX_KEY_COUNT_PER_MODULE); + if (I2cWrite(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, txData, sizeof(txData)) == kStatus_Success) { + I2cRead(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, CurrentKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], LEFT_KEYBOARD_HALF_KEY_COUNT); + } + + HandleKeyboardEvents(ActiveUsbKeyboardReport, &UsbMouseReport); + + SwitchActiveUsbKeyboardReport(); +} + void main() { InitPeripherials(); InitClock(); LedDriver_InitAllLeds(1); KeyMatrix_Init(&KeyMatrix); - UsbKeyboadTask(); + updateUsbReports(); InitUsb(); // deserialize_Layer(testData, 0); while (1) { - UsbKeyboadTask(); + updateUsbReports(); asm("wfi"); } } diff --git a/right/src/usb_interface_keyboard.c b/right/src/usb_interface_keyboard.c index 9367565..98923f2 100644 --- a/right/src/usb_interface_keyboard.c +++ b/right/src/usb_interface_keyboard.c @@ -58,24 +58,6 @@ void ResetActiveUsbKeyboardReport() bzero(ActiveUsbKeyboardReport, USB_KEYBOARD_REPORT_LENGTH); } -void UsbKeyboadTask() -{ - ResetActiveUsbKeyboardReport(); - - KeyMatrix_Scan(&KeyMatrix); - memcpy(CurrentKeyStates[SLOT_ID_RIGHT_KEYBOARD_HALF], KeyMatrix.keyStates, MAX_KEY_COUNT_PER_MODULE); - - uint8_t txData[] = {0}; - bzero(CurrentKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], MAX_KEY_COUNT_PER_MODULE); - if (I2cWrite(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, txData, sizeof(txData)) == kStatus_Success) { - I2cRead(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, CurrentKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], LEFT_KEYBOARD_HALF_KEY_COUNT); - } - - HandleKeyboardEvents(ActiveUsbKeyboardReport, &UsbMouseReport); - - SwitchActiveUsbKeyboardReport(); -} - static usb_status_t UsbKeyboardAction(void) { return USB_DeviceHidSend(UsbCompositeDevice.keyboardHandle, USB_KEYBOARD_ENDPOINT_INDEX, diff --git a/right/src/usb_interface_keyboard.h b/right/src/usb_interface_keyboard.h index bbf728c..5b94930 100644 --- a/right/src/usb_interface_keyboard.h +++ b/right/src/usb_interface_keyboard.h @@ -40,6 +40,4 @@ extern void ResetActiveUsbKeyboardReport(); extern void SwitchActiveUsbKeyboardReport(); - extern void UsbKeyboadTask(); - #endif