/* Drivers */ #include "fsl_clock.h" #include "fsl_common.h" #include "fsl_edma.h" #include "fsl_gpio.h" /* Board */ #include "peripherals.h" #include "pin_mux.h" /* LCD panel */ #include "epd-spi/panel/lcd_generic_ssd1289.h" #define IMPL_LCD_COMMAND_BASE (*(uint16_t *)0x70000000) #define IMPL_LCD_DATA_BASE (*(uint16_t *)0x78000000) epd_ret_t epd_impl_write_command(void *handle, uint8_t *command, uint32_t len) { uint32_t param_len = (len - 1) / 2; IMPL_LCD_COMMAND_BASE = command[0]; for (uint32_t i = 0; i < param_len; i++) { uint16_t le_param = (command[2 * i + 1] << 8) | command[2 * i + 2]; IMPL_LCD_DATA_BASE = le_param; } return EPD_OK; } epd_ret_t epd_impl_write_data(void *handle, uint8_t *data, uint32_t len) { uint32_t data_len = (len / 2); for (uint32_t i = 0; i < data_len; i++) { IMPL_LCD_DATA_BASE = ((uint16_t *)data)[i]; } return EPD_OK; } epd_ret_t epd_impl_reset(void *handle) { uint32_t delay = CLOCK_GetCoreSysClkFreq() / 50; /* 20 msec */ GPIO_WritePinOutput(BOARD_INITPINS_TFT_RESET_GPIO, BOARD_INITPINS_TFT_RESET_PIN, 0U); for (uint32_t i = 0; i < delay; i++) { asm("nop"); } GPIO_WritePinOutput(BOARD_INITPINS_TFT_RESET_GPIO, BOARD_INITPINS_TFT_RESET_PIN, 1U); return EPD_OK; }