Implement the write LED driver protocol command.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
#include "usb_protocol_handler.h"
|
#include "usb_protocol_handler.h"
|
||||||
#include "system_properties.h"
|
#include "system_properties.h"
|
||||||
#include "test_led.h"
|
#include "test_led.h"
|
||||||
|
#include "i2c_addresses.h"
|
||||||
|
#include "led_driver.h"
|
||||||
|
|
||||||
void SetError(uint8_t error);
|
void SetError(uint8_t error);
|
||||||
void SetGenericError();
|
void SetGenericError();
|
||||||
@@ -96,6 +98,20 @@ void GetSetTestLed()
|
|||||||
|
|
||||||
void WriteLedDriver()
|
void WriteLedDriver()
|
||||||
{
|
{
|
||||||
|
uint8_t i2cAddress = GenericHidInBuffer[1];
|
||||||
|
uint8_t i2cPayloadSize = GenericHidInBuffer[2];
|
||||||
|
|
||||||
|
if (!IS_I2C_LED_DRIVER_ADDRESS(i2cAddress)) {
|
||||||
|
SetError(WRITE_LED_DRIVER_RESPONSE_INVALID_ADDRESS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i2cPayloadSize > USB_GENERIC_HID_OUT_BUFFER_LENGTH-3) {
|
||||||
|
SetError(WRITE_LED_DRIVER_RESPONSE_INVALID_PAYLOAD_SIZE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LedDriver_WriteBuffer(i2cAddress, GenericHidInBuffer+3, i2cPayloadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadLedDriver()
|
void ReadLedDriver()
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
#define USB_COMMAND_JUMP_TO_BOOTLOADER 1
|
#define USB_COMMAND_JUMP_TO_BOOTLOADER 1
|
||||||
#define USB_COMMAND_TEST_LED 2
|
#define USB_COMMAND_TEST_LED 2
|
||||||
#define USB_COMMAND_WRITE_LED_DRIVER 3
|
#define USB_COMMAND_WRITE_LED_DRIVER 3
|
||||||
|
#define WRITE_LED_DRIVER_RESPONSE_INVALID_ADDRESS 1
|
||||||
|
#define WRITE_LED_DRIVER_RESPONSE_INVALID_PAYLOAD_SIZE 2
|
||||||
#define USB_COMMAND_READ_LED_DRIVER 4
|
#define USB_COMMAND_READ_LED_DRIVER 4
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|||||||
@@ -5,11 +5,10 @@
|
|||||||
|
|
||||||
#define I2C_ADDRESS_LEFT_KEYBOARD_HALF 8
|
#define I2C_ADDRESS_LEFT_KEYBOARD_HALF 8
|
||||||
|
|
||||||
// IS31FL3731 LED drivers range from 0x74 to 0x77
|
|
||||||
#define I2C_ADDRESS_LED_DRIVER_LEFT 0b1110100
|
#define I2C_ADDRESS_LED_DRIVER_LEFT 0b1110100
|
||||||
#define I2C_ADDRESS_LED_DRIVER_RIGHT 0b1110111
|
#define I2C_ADDRESS_LED_DRIVER_RIGHT 0b1110111
|
||||||
|
|
||||||
#define IS_I2C_LED_DRIVER_ADDRESS (address) \
|
#define IS_I2C_LED_DRIVER_ADDRESS(address) \
|
||||||
(I2C_ADDRESS_LED_DRIVER_LEFT <= address && address <= I2C_ADDRESS_LED_DRIVER_RIGHT)
|
(I2C_ADDRESS_LED_DRIVER_LEFT <= (address) && (address) <= I2C_ADDRESS_LED_DRIVER_RIGHT)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user