#ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H
static const I2CConfig i2ccfg = {
400000 };
static const uint8_t led_mask[] = {
0xFF, 0x00,
0xFF, 0x00,
0xFF, 0x00,
0xFF, 0x00,
0xFF, 0x00,
0xFF, 0x00,
0xFF, 0x00,
0xFF, 0x00,
0xFF, 0x00,
};
#define LA(c, r) (c + r * 16 )
#define NA LA(8, 8)
static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = {
{ LA(0, 0), LA(1, 0), LA(2, 0), LA(3, 0), LA(4, 0), LA(5, 0), LA(6, 0), LA(7, 0), LA(0, 1), LA(1, 1), LA(2, 1), LA(3, 1), LA(4, 1), LA(5, 1), LA(6, 1), LA(7, 1)},
{ LA(0, 2), LA(1, 2), LA(2, 2), LA(3, 2), LA(4, 2), LA(5, 2), LA(6, 2), LA(7, 2), LA(0, 3), LA(1, 3), NA, LA(2, 3), LA(3, 3), LA(4, 3), LA(5, 3), LA(6, 3)},
{ LA(7, 3), LA(0, 4), LA(1, 4), LA(2, 4), LA(3, 4), LA(4, 4), LA(5, 4), LA(6, 4), LA(7, 4), LA(0, 5), NA, LA(1, 5), LA(2, 5), LA(3, 5), LA(4, 5), LA(5, 5)},
{ LA(6, 5), LA(7, 5), LA(0, 6), LA(1, 6), LA(2, 6), LA(3, 6), LA(4, 6), LA(5, 6), LA(6, 6), LA(7, 6), NA, LA(0, 7), LA(1, 7), LA(2, 7), LA(3, 7), LA(4, 7)},
{ LA(5, 7), LA(6, 7), LA(7, 7), NA, NA, NA, LA(0, 8), NA, NA, NA, LA(1, 8), LA(2, 8), LA(3, 8), LA(4, 8), LA(5, 8), LA(6, 8)},
};
#define IS31_ADDR_DEFAULT 0x74
#define IS31_TIMEOUT 5000
static GFXINLINE void init_board(GDisplay *g) {
(void) g;
palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL);
palClearPad(GPIOB, 16);
i2cStart(&I2CD1, &i2ccfg);
I2CD1.i2c->C2 |= I2Cx_C2_HDRS;
I2CD1.i2c->FLT = 4;
}
static GFXINLINE void post_init_board(GDisplay *g) {
(void) g;
}
static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) {
(void) g;
return led_mask;
}
static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y)
{
(void) g;
return led_mapping[y][x];
}
static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) {
(void) g;
if(!shutdown) {
palSetPad(GPIOB, 16);
}
else {
palClearPad(GPIOB, 16);
}
}
static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
(void) g;
i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, TIME_US2I(IS31_TIMEOUT));
}
#endif