Extract LED driver bridge slave handler into bridge_slave_led_driver_handler.[ch]
This commit is contained in:
@@ -1,19 +1,13 @@
|
|||||||
#include "fsl_i2c.h"
|
#include "fsl_i2c.h"
|
||||||
#include "led_driver.h"
|
|
||||||
#include "bridge_protocol_scheduler.h"
|
#include "bridge_protocol_scheduler.h"
|
||||||
#include "slot.h"
|
#include "slot.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "bridge_slave_led_driver_handler.h"
|
||||||
|
#include "i2c.h"
|
||||||
|
#include "i2c_addresses.h"
|
||||||
|
|
||||||
#define BUFFER_SIZE (LED_DRIVER_LED_COUNT + 1)
|
|
||||||
|
|
||||||
uint8_t ledsBuffer[BUFFER_SIZE] = {FRAME_REGISTER_PWM_FIRST};
|
|
||||||
uint8_t currentBridgeSlaveId = 0;
|
uint8_t currentBridgeSlaveId = 0;
|
||||||
|
|
||||||
bool BridgeSlaveLedDriverHandler(uint8_t ledDriverId) {
|
|
||||||
I2cAsyncWrite(I2C_ADDRESS_LED_DRIVER_LEFT, ledsBuffer, BUFFER_SIZE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BridgeSlaveUhkModuleHandler(uint8_t uhkModuleId) {
|
bool BridgeSlaveUhkModuleHandler(uint8_t uhkModuleId) {
|
||||||
I2cAsyncRead(I2C_ADDRESS_LEFT_KEYBOARD_HALF, CurrentKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], LEFT_KEYBOARD_HALF_KEY_COUNT);
|
I2cAsyncRead(I2C_ADDRESS_LEFT_KEYBOARD_HALF, CurrentKeyStates[SLOT_ID_LEFT_KEYBOARD_HALF], LEFT_KEYBOARD_HALF_KEY_COUNT);
|
||||||
return true;
|
return true;
|
||||||
@@ -43,10 +37,5 @@ void InitBridgeProtocolScheduler()
|
|||||||
{
|
{
|
||||||
SetLeds(0xff);
|
SetLeds(0xff);
|
||||||
I2C_MasterTransferCreateHandle(I2C_MAIN_BUS_BASEADDR, &I2cMasterHandle, bridgeProtocolCallback, NULL);
|
I2C_MasterTransferCreateHandle(I2C_MAIN_BUS_BASEADDR, &I2cMasterHandle, bridgeProtocolCallback, NULL);
|
||||||
I2cAsyncWrite(I2C_ADDRESS_LED_DRIVER_LEFT, ledsBuffer, BUFFER_SIZE);
|
bridgeSlaves[0].slaveHandler(bridgeSlaves[0].moduleId);
|
||||||
}
|
|
||||||
|
|
||||||
void SetLeds(uint8_t ledBrightness)
|
|
||||||
{
|
|
||||||
memset(ledsBuffer+1, ledBrightness, LED_DRIVER_LED_COUNT);
|
|
||||||
}
|
}
|
||||||
|
|||||||
16
right/src/bridge_slave_led_driver_handler.c
Normal file
16
right/src/bridge_slave_led_driver_handler.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#include "bridge_slave_led_driver_handler.h"
|
||||||
|
#include "led_driver.h"
|
||||||
|
|
||||||
|
#define BUFFER_SIZE (LED_DRIVER_LED_COUNT + 1)
|
||||||
|
|
||||||
|
uint8_t ledsBuffer[BUFFER_SIZE] = {FRAME_REGISTER_PWM_FIRST};
|
||||||
|
|
||||||
|
bool BridgeSlaveLedDriverHandler(uint8_t ledDriverId) {
|
||||||
|
I2cAsyncWrite(I2C_ADDRESS_LED_DRIVER_LEFT, ledsBuffer, BUFFER_SIZE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetLeds(uint8_t ledBrightness)
|
||||||
|
{
|
||||||
|
memset(ledsBuffer+1, ledBrightness, LED_DRIVER_LED_COUNT);
|
||||||
|
}
|
||||||
13
right/src/bridge_slave_led_driver_handler.h
Normal file
13
right/src/bridge_slave_led_driver_handler.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef __BRIDGE_SLAVE_LED_DRIVER_HANDLER_H__
|
||||||
|
#define __BRIDGE_SLAVE_LED_DRIVER_HANDLER_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include "fsl_common.h"
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
extern bool BridgeSlaveLedDriverHandler(uint8_t ledDriverId);
|
||||||
|
extern void SetLeds(uint8_t ledBrightness);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user