Add I2C addresses for add-ons and touchpad modules.

This commit is contained in:
László Monda
2017-09-20 02:21:39 +02:00
parent d7b3aee50e
commit 4d5214fdc9
3 changed files with 35 additions and 27 deletions

View File

@@ -50,7 +50,7 @@ void InitI2c(void) {
i2c_slave_handle_t slaveHandle; i2c_slave_handle_t slaveHandle;
I2C_SlaveGetDefaultConfig(&slaveConfig); I2C_SlaveGetDefaultConfig(&slaveConfig);
slaveConfig.slaveAddress = I2C_ADDRESS_LEFT_KEYBOARD_HALF; slaveConfig.slaveAddress = I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE;
I2C_SlaveInit(I2C_BUS_BASEADDR, &slaveConfig); I2C_SlaveInit(I2C_BUS_BASEADDR, &slaveConfig);
I2C_SlaveTransferCreateHandle(I2C_BUS_BASEADDR, &slaveHandle, i2cSlaveCallback, NULL); I2C_SlaveTransferCreateHandle(I2C_BUS_BASEADDR, &slaveHandle, i2cSlaveCallback, NULL);
slaveHandle.eventMask |= kI2C_SlaveCompletionEvent; slaveHandle.eventMask |= kI2C_SlaveCompletionEvent;

View File

@@ -28,11 +28,11 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleId)
switch (uhkModulePhase) { switch (uhkModulePhase) {
case UhkModulePhase_SendKeystatesRequestCommand: case UhkModulePhase_SendKeystatesRequestCommand:
txBuffer[0] = SlaveCommand_GetKeyStates; txBuffer[0] = SlaveCommand_GetKeyStates;
status = I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 1); status = I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE, txBuffer, 1);
uhkModulePhase = UhkModulePhase_ReceiveKeystates; uhkModulePhase = UhkModulePhase_ReceiveKeystates;
break; break;
case UhkModulePhase_ReceiveKeystates: case UhkModulePhase_ReceiveKeystates:
status = I2cAsyncRead(I2C_ADDRESS_LEFT_KEYBOARD_HALF, rxBuffer, KEY_STATE_BUFFER_SIZE); status = I2cAsyncRead(I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE, rxBuffer, KEY_STATE_BUFFER_SIZE);
uhkModulePhase = UhkModulePhase_SendPwmBrightnessCommand; uhkModulePhase = UhkModulePhase_SendPwmBrightnessCommand;
break; break;
case UhkModulePhase_SendPwmBrightnessCommand: case UhkModulePhase_SendPwmBrightnessCommand:
@@ -41,13 +41,13 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleId)
} }
txBuffer[0] = SlaveCommand_SetLedPwmBrightness; txBuffer[0] = SlaveCommand_SetLedPwmBrightness;
txBuffer[1] = uhkModuleInternalState->ledPwmBrightness; txBuffer[1] = uhkModuleInternalState->ledPwmBrightness;
status = I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2); status = I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE, txBuffer, 2);
uhkModulePhase = UhkModulePhase_SendTestLedCommand; uhkModulePhase = UhkModulePhase_SendTestLedCommand;
break; break;
case UhkModulePhase_SendTestLedCommand: case UhkModulePhase_SendTestLedCommand:
txBuffer[0] = SlaveCommand_SetTestLed; txBuffer[0] = SlaveCommand_SetTestLed;
txBuffer[1] = uhkModuleInternalState->isTestLedOn; txBuffer[1] = uhkModuleInternalState->isTestLedOn;
status = I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF, txBuffer, 2); status = I2cAsyncWrite(I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE, txBuffer, 2);
uhkModulePhase = UhkModulePhase_SendKeystatesRequestCommand; uhkModulePhase = UhkModulePhase_SendKeystatesRequestCommand;
break; break;
} }

View File

@@ -16,28 +16,36 @@
// equal to a continuous block of 8 addresses, this strategy allows a lot of room when // equal to a continuous block of 8 addresses, this strategy allows a lot of room when
// adding further I2C slaves. // adding further I2C slaves.
// Reserved for general call address 0x00 // Reserved for general call address 0x00
// Reserved for CBUS compatibility 0x01 // Reserved for CBUS compatibility 0x01
// Reserved for different bus formats 0x02 // Reserved for different bus formats 0x02
// Reserved for future purposes 0x03 // Reserved for future purposes 0x03
// Reserved for high-speed mode master 0x04 // Reserved for high-speed mode master 0x04
// Reserved for high-speed mode master 0x05 // Reserved for high-speed mode master 0x05
// Reserved for high-speed mode master 0x06 // Reserved for high-speed mode master 0x06
// Reserved for high-speed mode master 0x07 // Reserved for high-speed mode master 0x07
#define I2C_ADDRESS_LEFT_KEYBOARD_HALF 0x08 #define I2C_ADDRESS_LEFT_KEYBOARD_HALF_FIRMWARE 0x08
#define I2C_ADDRESS_LED_DRIVER_LEFT 0x74 #define I2C_ADDRESS_LEFT_KEYBOARD_HALF_BOOTLOADER 0x10
// LED driver / touchpad 0x75 #define I2C_ADDRESS_RIGHT_TOUCHPAD_FIRMWARE 0x15
// LED driver / touchpad 0x76 #define I2C_ADDRESS_LEFT_ADDON_FIRMWARE 0x18
#define I2C_ADDRESS_LED_DRIVER_RIGHT 0x77 #define I2C_ADDRESS_LEFT_ADDON_BOOTLOADER 0x20
// Touchpad 0b00001XX #define I2C_ADDRESS_LEFT_TOUCHPAD_FIRMWARE 0x25
// Reserved for 10-bit addressing 0x78 #define I2C_ADDRESS_RIGHT_ADDON_FIRMWARE 0x28
// Reserved for 10-bit addressing 0x79 #define I2C_ADDRESS_RIGHT_ADDON_BOOTLOADER 0x30
// Reserved for 10-bit addressing 0x7A #define I2C_ADDRESS_RIGHT_TOUCHPAD_BOOTLOADER 0x55
// Reserved for 10-bit addressing 0x7B #define I2C_ADDRESS_LEFT_TOUCHPAD_BOOTLOADER 0x65
// Reserved for future purposes 0x7C #define I2C_ADDRESS_LED_DRIVER_LEFT 0x74
// Reserved for future purposes 0x7D // Let's reserve this for another LED driver 0x75
// Reserved for future purposes 0x7E // Let's reserve this for another LED driver 0x76
// Reserved for future purposes 0x7F #define I2C_ADDRESS_LED_DRIVER_RIGHT 0x77
// Reserved for 10-bit addressing 0x78
// Reserved for 10-bit addressing 0x79
// Reserved for 10-bit addressing 0x7A
// Reserved for 10-bit addressing 0x7B
// Reserved for future purposes 0x7C
// Reserved for future purposes 0x7D
// Reserved for future purposes 0x7E
// Reserved for future purposes 0x7F
// The EEPROM is featured separately as it's not connected to the main I2C bus. // The EEPROM is featured separately as it's not connected to the main I2C bus.
#define I2C_ADDRESS_EEPROM 0b1010000 #define I2C_ADDRESS_EEPROM 0b1010000