Rename *bridge* identifiers to *slave*

This commit is contained in:
László Monda
2017-05-29 22:14:11 +02:00
parent 2b0094f29c
commit 1daf6db53c
5 changed files with 43 additions and 43 deletions

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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