diff --git a/left/src/init_peripherals.c b/left/src/init_peripherals.c index 5c2aefe..f856549 100644 --- a/left/src/init_peripherals.c +++ b/left/src/init_peripherals.c @@ -14,14 +14,14 @@ static void i2cSlaveCallback(I2C_Type *base, i2c_slave_transfer_t *xfer, void *u switch (xfer->event) { case kI2C_SlaveTransmitEvent: - BridgeProtocolHandler(); - xfer->data = BridgeTxBuffer; - xfer->dataSize = BridgeTxSize; + SlaveProtocolHandler(); + xfer->data = SlaveTxBuffer; + xfer->dataSize = SlaveTxSize; break; case kI2C_SlaveReceiveEvent: - BridgeProtocolHandler(); - xfer->data = BridgeRxBuffer; - xfer->dataSize = BRIDGE_RX_BUFFER_SIZE; + SlaveProtocolHandler(); + xfer->data = SlaveRxBuffer; + xfer->dataSize = SLAVE_RX_BUFFER_SIZE; break; case kI2C_SlaveCompletionEvent: xfer->data = NULL; diff --git a/left/src/slave_protocol_handler.c b/left/src/slave_protocol_handler.c index d783293..9e44b41 100644 --- a/left/src/slave_protocol_handler.c +++ b/left/src/slave_protocol_handler.c @@ -13,7 +13,7 @@ void SetGenericError(void); void SetResponseByte(uint8_t response); void SetError(uint8_t error) { - BridgeTxBuffer[0] = error; + SlaveTxBuffer[0] = error; } void SetGenericError(void) @@ -24,34 +24,34 @@ void SetGenericError(void) // Set a single byte as the response. void SetResponseByte(uint8_t response) { - BridgeTxBuffer[1] = response; + SlaveTxBuffer[1] = response; } -void BridgeProtocolHandler(void) +void SlaveProtocolHandler(void) { - uint8_t commandId = BridgeRxBuffer[0]; + uint8_t commandId = SlaveRxBuffer[0]; switch (commandId) { - case BridgeCommand_GetKeyStates: - BridgeTxSize = KEYBOARD_MATRIX_COLS_NUM*KEYBOARD_MATRIX_ROWS_NUM; - memcpy(BridgeTxBuffer, keyMatrix.keyStates, BridgeTxSize); + case SlaveCommand_GetKeyStates: + SlaveTxSize = KEYBOARD_MATRIX_COLS_NUM*KEYBOARD_MATRIX_ROWS_NUM; + memcpy(SlaveTxBuffer, keyMatrix.keyStates, SlaveTxSize); break; - case BridgeCommand_SetTestLed: - BridgeTxSize = 0; - bool isLedOn = BridgeRxBuffer[1]; + case SlaveCommand_SetTestLed: + SlaveTxSize = 0; + bool isLedOn = SlaveRxBuffer[1]; TEST_LED_SET(isLedOn); break; - case BridgeCommand_SetLedPwmBrightness: - BridgeTxSize = 0; - uint8_t brightnessPercent = BridgeRxBuffer[1]; + case SlaveCommand_SetLedPwmBrightness: + SlaveTxSize = 0; + uint8_t brightnessPercent = SlaveRxBuffer[1]; LedPwm_SetBrightness(brightnessPercent); break; - case BridgeCommand_SetDisableKeyMatrixScanState: - BridgeTxSize = 0; - DisableKeyMatrixScanState = BridgeRxBuffer[1]; + case SlaveCommand_SetDisableKeyMatrixScanState: + SlaveTxSize = 0; + DisableKeyMatrixScanState = SlaveRxBuffer[1]; break; - case BridgeCommand_SetDisableLedSdb: - BridgeTxSize = 0; - GPIO_WritePinOutput(LED_DRIVER_SDB_GPIO, LED_DRIVER_SDB_PIN, BridgeRxBuffer[1] ? 0 : 1); + case SlaveCommand_SetDisableLedSdb: + SlaveTxSize = 0; + GPIO_WritePinOutput(LED_DRIVER_SDB_GPIO, LED_DRIVER_SDB_PIN, SlaveRxBuffer[1] ? 0 : 1); break; } } diff --git a/left/src/slave_protocol_handler.h b/left/src/slave_protocol_handler.h index fecadb3..b773c23 100644 --- a/left/src/slave_protocol_handler.h +++ b/left/src/slave_protocol_handler.h @@ -7,20 +7,20 @@ // Macros: - #define BRIDGE_RX_BUFFER_SIZE 100 - #define BRIDGE_TX_BUFFER_SIZE 100 + #define SLAVE_RX_BUFFER_SIZE 100 + #define SLAVE_TX_BUFFER_SIZE 100 #define PROTOCOL_RESPONSE_SUCCESS 0 #define PROTOCOL_RESPONSE_GENERIC_ERROR 1 // Variables: - uint8_t BridgeRxBuffer[BRIDGE_RX_BUFFER_SIZE]; - uint8_t BridgeTxBuffer[BRIDGE_TX_BUFFER_SIZE]; - uint8_t BridgeTxSize; + uint8_t SlaveRxBuffer[SLAVE_RX_BUFFER_SIZE]; + uint8_t SlaveTxBuffer[SLAVE_TX_BUFFER_SIZE]; + uint8_t SlaveTxSize; // Functions: - extern void BridgeProtocolHandler(void); + extern void SlaveProtocolHandler(void); #endif diff --git a/right/src/slave_drivers/slave_driver_uhk_module.c b/right/src/slave_drivers/slave_driver_uhk_module.c index f8e0fc9..b9d9f8f 100644 --- a/right/src/slave_drivers/slave_driver_uhk_module.c +++ b/right/src/slave_drivers/slave_driver_uhk_module.c @@ -27,7 +27,7 @@ void UhkModuleSlaveDriver_Update(uint8_t uhkModuleId) switch (currentUhkModuleField) { case UhkModuleField_SendKeystatesRequestCommand: - txBuffer[0] = BridgeCommand_GetKeyStates; + txBuffer[0] = SlaveCommand_GetKeyStates; I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 1); currentUhkModuleField = UhkModuleField_ReceiveKeystates; break; @@ -36,31 +36,31 @@ void UhkModuleSlaveDriver_Update(uint8_t uhkModuleId) currentUhkModuleField = UhkModuleField_SendPwmBrightnessCommand; break; case UhkModuleField_SendPwmBrightnessCommand: - txBuffer[0] = BridgeCommand_SetLedPwmBrightness; + txBuffer[0] = SlaveCommand_SetLedPwmBrightness; txBuffer[1] = uhkModuleInternalState->ledPwmBrightness; I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2); currentUhkModuleField = UhkModuleField_SendTestLedCommand; break; case UhkModuleField_SendTestLedCommand: - txBuffer[0] = BridgeCommand_SetTestLed; + txBuffer[0] = SlaveCommand_SetTestLed; txBuffer[1] = uhkModuleInternalState->isTestLedOn; I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2); currentUhkModuleField = UhkModuleField_SendDisableKeyMatrixScanState; break; case UhkModuleField_SendDisableKeyMatrixScanState: - txBuffer[0] = BridgeCommand_SetDisableKeyMatrixScanState; + txBuffer[0] = SlaveCommand_SetDisableKeyMatrixScanState; txBuffer[1] = TestStates.disableKeyMatrixScan; I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2); currentUhkModuleField = UhkModuleField_SendLedPwmBrightness; break; case UhkModuleField_SendLedPwmBrightness: - txBuffer[0] = BridgeCommand_SetDisableKeyMatrixScanState; + txBuffer[0] = SlaveCommand_SetDisableKeyMatrixScanState; txBuffer[1] = TestStates.disableKeyMatrixScan; I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2); currentUhkModuleField = UhkModuleField_DisableLedSdb; break; case UhkModuleField_DisableLedSdb: - txBuffer[0] = BridgeCommand_SetDisableLedSdb; + txBuffer[0] = SlaveCommand_SetDisableLedSdb; txBuffer[1] = TestStates.disableLedSdb; I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2); currentUhkModuleField = UhkModuleField_SendKeystatesRequestCommand; diff --git a/shared/bridge_protocol.h b/shared/bridge_protocol.h index 8a865c1..111e610 100644 --- a/shared/bridge_protocol.h +++ b/shared/bridge_protocol.h @@ -4,11 +4,11 @@ // Typedefs: typedef enum { - BridgeCommand_GetKeyStates, - BridgeCommand_SetTestLed, - BridgeCommand_SetLedPwmBrightness, - BridgeCommand_SetDisableKeyMatrixScanState, - BridgeCommand_SetDisableLedSdb, - } bridge_command_t; + SlaveCommand_GetKeyStates, + SlaveCommand_SetTestLed, + SlaveCommand_SetLedPwmBrightness, + SlaveCommand_SetDisableKeyMatrixScanState, + SlaveCommand_SetDisableLedSdb, + } slave_command_t; #endif