Make the LED driver power every LED at full blast.
This commit is contained in:
56
right/main.c
56
right/main.c
@@ -3,10 +3,63 @@
|
||||
#include "include/board/board.h"
|
||||
#include "include/board/pin_mux.h"
|
||||
#include "usb_composite_device.h"
|
||||
#include "i2c.h"
|
||||
#include "main.h"
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_port.h"
|
||||
|
||||
void main(void)
|
||||
void tx(uint8_t txBuffer[], uint8_t size)
|
||||
{
|
||||
i2c_master_transfer_t masterXfer;
|
||||
masterXfer.slaveAddress = LEFT_LED_DRIVER_ADDRESS_7BIT;
|
||||
masterXfer.direction = kI2C_Write;
|
||||
masterXfer.subaddress = 0;
|
||||
masterXfer.subaddressSize = 0;
|
||||
masterXfer.data = txBuffer;
|
||||
masterXfer.dataSize = size;
|
||||
masterXfer.flags = kI2C_TransferDefaultFlag;
|
||||
I2C_MasterTransferBlocking(EXAMPLE_I2C_MASTER_BASEADDR, &masterXfer);
|
||||
masterXfer.slaveAddress = RIGHT_LED_DRIVER_ADDRESS_7BIT;
|
||||
I2C_MasterTransferBlocking(EXAMPLE_I2C_MASTER_BASEADDR, &masterXfer);
|
||||
}
|
||||
|
||||
void write(uint8_t reg, uint8_t val)
|
||||
{
|
||||
uint8_t txBuffer[] = {0, 0};
|
||||
txBuffer[0] = reg;
|
||||
txBuffer[1] = val;
|
||||
tx(txBuffer, sizeof(txBuffer));
|
||||
}
|
||||
|
||||
void InitLedDisplay()
|
||||
{
|
||||
PORT_SetPinMux(PORTA, 2U, kPORT_MuxAsGpio);
|
||||
|
||||
gpio_pin_config_t led_config = {
|
||||
.pinDirection = kGPIO_DigitalOutput,
|
||||
.outputLogic = 0,
|
||||
};
|
||||
|
||||
GPIO_PinInit(GPIOA, 2U, &led_config);
|
||||
GPIO_SetPinsOutput(GPIOA, 0 << 2U);
|
||||
|
||||
write(0xfd, 0x0b); // point to page 9
|
||||
write(0x0a, 0x01); // set shutdown mode to normal
|
||||
write(0xfd, 0x00); // point to page 0
|
||||
|
||||
uint8_t i;
|
||||
for (i=0x00; i<=0x11; i++) {
|
||||
write(i, 0xff);
|
||||
}
|
||||
for (i=0x12; i<=0x23; i++) {
|
||||
write(i, 0x00);
|
||||
}
|
||||
for (i=0x24; i<=0xb3; i++) {
|
||||
write(i, 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
BOARD_InitPins();
|
||||
BOARD_BootClockRUN();
|
||||
BOARD_InitDebugConsole();
|
||||
@@ -18,6 +71,7 @@ void main(void)
|
||||
sourceClock = CLOCK_GetFreq(I2C_MASTER_CLK_SRC);
|
||||
I2C_MasterInit(EXAMPLE_I2C_MASTER_BASEADDR, &masterConfig, sourceClock);
|
||||
|
||||
InitLedDisplay();
|
||||
InitUsb();
|
||||
|
||||
while (1);
|
||||
|
||||
Reference in New Issue
Block a user