#include "led_driver.h" void LedDriver_WriteBuffer(uint8_t i2cAddress, uint8_t buffer[], uint8_t size) { i2c_master_transfer_t masterXfer; masterXfer.slaveAddress = i2cAddress; masterXfer.direction = kI2C_Write; masterXfer.subaddress = 0; masterXfer.subaddressSize = 0; masterXfer.data = buffer; masterXfer.dataSize = size; masterXfer.flags = kI2C_TransferDefaultFlag; I2C_MasterTransferBlocking(I2C_MAIN_BUS_BASEADDR, &masterXfer); } void LedDriver_WriteRegister(uint8_t i2cAddress, uint8_t reg, uint8_t val) { uint8_t buffer[] = {reg, val}; LedDriver_WriteBuffer(i2cAddress, buffer, sizeof(buffer)); } void LedDriver_InitAllLeds(char isEnabled) { CLOCK_EnableClock(LED_DRIVER_SDB_CLOCK); PORT_SetPinMux(LED_DRIVER_SDB_PORT, LED_DRIVER_SDB_PIN, kPORT_MuxAsGpio); GPIO_PinInit(GPIOA, LED_DRIVER_SDB_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 0}); GPIO_WritePinOutput(LED_DRIVER_SDB_GPIO, LED_DRIVER_SDB_PIN, 1); LedDriver_SetAllLedsTo(isEnabled ? 0xFF : 0x00); } void LedDriver_SetAllLedsTo(uint8_t val) { uint8_t ledDriverAddresses[] = {I2C_ADDRESS_LED_DRIVER_LEFT, I2C_ADDRESS_LED_DRIVER_RIGHT}; for (uint8_t addressId=0; addressId