From 2aa74853b54c9e21b557f4508f8ef6860d01bc92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Fri, 22 Sep 2017 03:13:53 +0200 Subject: [PATCH] Add UhkModulePhase_ProcessKeystates and extract relevant code into its section. --- right/src/slave_drivers/uhk_module_driver.c | 7 +++++-- right/src/slave_drivers/uhk_module_driver.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/right/src/slave_drivers/uhk_module_driver.c b/right/src/slave_drivers/uhk_module_driver.c index d43adf9..2621aae 100644 --- a/right/src/slave_drivers/uhk_module_driver.c +++ b/right/src/slave_drivers/uhk_module_driver.c @@ -33,12 +33,15 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleId) break; case UhkModulePhase_ReceiveKeystates: status = I2cAsyncRead(I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE, rxBuffer, KEY_STATE_BUFFER_SIZE); - uhkModulePhase = UhkModulePhase_SetLedPwmBrightness; + uhkModulePhase = UhkModulePhase_ProcessKeystates; break; - case UhkModulePhase_SetLedPwmBrightness: + case UhkModulePhase_ProcessKeystates: if (CRC16_IsMessageValid(rxBuffer, KEY_STATE_SIZE)) { BoolBitsToBytes(rxBuffer, CurrentKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], LEFT_KEYBOARD_HALF_KEY_COUNT); } + uhkModulePhase = UhkModulePhase_SetLedPwmBrightness; + break; + case UhkModulePhase_SetLedPwmBrightness: txBuffer[0] = SlaveCommand_SetLedPwmBrightness; txBuffer[1] = uhkModuleInternalState->ledPwmBrightness; status = I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE, txBuffer, 2); diff --git a/right/src/slave_drivers/uhk_module_driver.h b/right/src/slave_drivers/uhk_module_driver.h index 52cb87c..3a081d7 100644 --- a/right/src/slave_drivers/uhk_module_driver.h +++ b/right/src/slave_drivers/uhk_module_driver.h @@ -23,6 +23,7 @@ typedef enum { UhkModulePhase_RequestKeyStates, UhkModulePhase_ReceiveKeystates, + UhkModulePhase_ProcessKeystates, UhkModulePhase_SetLedPwmBrightness, UhkModulePhase_SetTestLed, } uhk_module_phase_t;