generated from Embedded_Projects/Fire_RT1021_EVK_Template
Initial LCD driver support.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
4751f0f16c
commit
5a5a3d67ca
|
@ -14,4 +14,4 @@ steps:
|
|||
commands:
|
||||
- mkdir build && cd build
|
||||
- cmake -DCMAKE_TOOLCHAIN_FILE=arm-none-eabi.cmake ..
|
||||
- make fire_rt1021_evk_template_FLASH.elf
|
||||
- make fire_rt1021_watch_FLASH.elf
|
||||
|
|
|
@ -4,3 +4,6 @@
|
|||
[submodule "lib/freertos"]
|
||||
path = lib/freertos
|
||||
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
|
||||
[submodule "lib/lcd"]
|
||||
path = lib/lcd
|
||||
url = https://git.minori.work/Embedded_Drivers/epd-spi.git
|
||||
|
|
|
@ -90,6 +90,7 @@ set(TARGET_SOURCES
|
|||
"board/dcd.c"
|
||||
"board/peripherals.c"
|
||||
"board/pin_mux.c"
|
||||
"src/app_lcd_impl.c"
|
||||
"src/main.c"
|
||||
"xip/fire_rt1021_evk_flexspi_nor_config.c"
|
||||
)
|
||||
|
@ -125,6 +126,7 @@ set(TARGET_C_INCLUDES
|
|||
|
||||
# Shared libraries linked with application
|
||||
set(TARGET_LIBS
|
||||
"epd-spi"
|
||||
"freertos_kernel"
|
||||
"c"
|
||||
"m"
|
||||
|
@ -160,6 +162,8 @@ set(FREERTOS_PORT GCC_ARM_CM4F CACHE STRING "")
|
|||
set(FREERTOS_HEAP "4" CACHE STRING "")
|
||||
add_subdirectory(lib/freertos)
|
||||
|
||||
add_subdirectory(lib/lcd)
|
||||
|
||||
# Shared sources, includes and definitions
|
||||
add_compile_definitions(${TARGET_C_DEFINES})
|
||||
include_directories(${TARGET_C_INCLUDES})
|
||||
|
|
|
@ -163,6 +163,7 @@
|
|||
<pin_feature name="gpio_init_state" value="true"/>
|
||||
<pin_feature name="open_drain" value="Enable"/>
|
||||
<pin_feature name="speed" value="MHZ_50"/>
|
||||
<pin_feature name="pull_keeper_enable" value="Disable"/>
|
||||
</pin_features>
|
||||
</pin>
|
||||
</pins>
|
||||
|
|
|
@ -123,7 +123,8 @@ void BOARD_InitLCDTPPins(void) {
|
|||
BOARD_InitLEDPins:
|
||||
- options: {callFromInitBoot: 'true', coreID: core0, enableClock: 'true'}
|
||||
- pin_list:
|
||||
- {pin_num: '76', peripheral: GPIO1, signal: 'gpio_io, 29', pin_signal: GPIO_AD_B1_13, direction: OUTPUT, gpio_init_state: 'true', open_drain: Enable, speed: MHZ_50}
|
||||
- {pin_num: '76', peripheral: GPIO1, signal: 'gpio_io, 29', pin_signal: GPIO_AD_B1_13, direction: OUTPUT, gpio_init_state: 'true', open_drain: Enable, speed: MHZ_50,
|
||||
pull_keeper_enable: Disable}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********
|
||||
*/
|
||||
|
||||
|
@ -146,7 +147,7 @@ void BOARD_InitLEDPins(void) {
|
|||
GPIO_PinInit(GPIO1, 29U, &LEDA_config);
|
||||
|
||||
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B1_13_GPIO1_IO29, 0U);
|
||||
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B1_13_GPIO1_IO29, 0x1830U);
|
||||
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B1_13_GPIO1_IO29, 0x0830U);
|
||||
}
|
||||
/***********************************************************************************************************************
|
||||
* EOF
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
/* Memory allocation related definitions. */
|
||||
#define configSUPPORT_STATIC_ALLOCATION 0
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||
#define configTOTAL_HEAP_SIZE ((size_t)(48 * 1024))
|
||||
#define configTOTAL_HEAP_SIZE ((size_t)(32 * 1024))
|
||||
#define configAPPLICATION_ALLOCATED_HEAP 0
|
||||
|
||||
/* Hook function related definitions. */
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef APP_LCD_IMPL_H
|
||||
#define APP_LCD_IMPL_H
|
||||
|
||||
#include "epd-spi/epd_common.h"
|
||||
|
||||
int app_lcd_impl_init(void *handle);
|
||||
epd_ret_t app_lcd_impl_write_command(void *handle, uint8_t *command, uint32_t len);
|
||||
epd_ret_t app_lcd_impl_write_data(void *handle, const uint8_t *data, uint32_t len);
|
||||
epd_ret_t app_lcd_impl_delay(void *handle, uint32_t msec);
|
||||
|
||||
#endif // APP_LCD_IMPL_H
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 9fe29d33414911a8ae6ca0a347d1bd9af05be3b4
|
|
@ -0,0 +1,79 @@
|
|||
/* FreeRTOS */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* SDK drivers */
|
||||
#include "fsl_lpspi.h"
|
||||
|
||||
/* Board */
|
||||
#include "board.h"
|
||||
#include "clock_config.h"
|
||||
#include "peripherals.h"
|
||||
#include "pin_mux.h"
|
||||
|
||||
/* LCD */
|
||||
#include "app_lcd_impl.h"
|
||||
|
||||
int app_lcd_impl_init(void *handle) {
|
||||
CLOCK_EnableClock(kCLOCK_Lpspi4);
|
||||
|
||||
lpspi_master_config_t spi_cfg;
|
||||
LPSPI_MasterGetDefaultConfig(&spi_cfg);
|
||||
|
||||
spi_cfg.baudRate = 24000000UL;
|
||||
|
||||
LPSPI_MasterInit(LPSPI4, &spi_cfg, CLOCK_GetClockRootFreq(kCLOCK_LpspiClkRoot));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
epd_ret_t app_lcd_impl_write_command(void *handle, uint8_t *command, uint32_t len) {
|
||||
lpspi_transfer_t xfer = {
|
||||
.txData = command,
|
||||
.dataSize = 1U,
|
||||
.configFlags = kLPSPI_MasterPcsContinuous,
|
||||
};
|
||||
|
||||
GPIO_WritePinOutput(BOARD_LCD_DC_GPIO, BOARD_INITLCDSPIPINS_DC_PIN, 0U);
|
||||
|
||||
status_t ret = LPSPI_MasterTransferBlocking(LPSPI4, &xfer);
|
||||
if (ret != kStatus_Success) {
|
||||
return EPD_FAIL;
|
||||
}
|
||||
|
||||
if (len > 1) {
|
||||
GPIO_WritePinOutput(BOARD_LCD_DC_GPIO, BOARD_INITLCDSPIPINS_DC_PIN, 1U);
|
||||
xfer.txData = &command[1];
|
||||
xfer.dataSize = len - 1;
|
||||
|
||||
ret = LPSPI_MasterTransferBlocking(LPSPI4, &xfer);
|
||||
if (ret != kStatus_Success) {
|
||||
return EPD_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return EPD_OK;
|
||||
}
|
||||
|
||||
epd_ret_t app_lcd_impl_write_data(void *handle, const uint8_t *data, uint32_t len) {
|
||||
lpspi_transfer_t xfer = {
|
||||
.txData = (uint8_t *)data,
|
||||
.dataSize = len,
|
||||
.configFlags = kLPSPI_MasterPcsContinuous,
|
||||
};
|
||||
|
||||
GPIO_WritePinOutput(BOARD_LCD_DC_GPIO, BOARD_INITLCDSPIPINS_DC_PIN, 1U);
|
||||
|
||||
status_t ret = LPSPI_MasterTransferBlocking(LPSPI4, &xfer);
|
||||
if (ret != kStatus_Success) {
|
||||
return EPD_FAIL;
|
||||
}
|
||||
|
||||
return EPD_OK;
|
||||
}
|
||||
|
||||
epd_ret_t app_lcd_impl_delay(void *handle, uint32_t msec) {
|
||||
vTaskDelay(pdMS_TO_TICKS(msec));
|
||||
|
||||
return EPD_OK;
|
||||
}
|
35
src/main.c
35
src/main.c
|
@ -17,6 +17,14 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* LCD */
|
||||
#include "epd-spi/panel/lcd_tk0096f611.h"
|
||||
|
||||
/* App */
|
||||
#include "app_lcd_impl.h"
|
||||
|
||||
static uint16_t s_display_buf[160 * 80];
|
||||
|
||||
static void app_task_initialization(void *arguments);
|
||||
|
||||
int main(void) {
|
||||
|
@ -40,6 +48,33 @@ dead_loop:
|
|||
}
|
||||
|
||||
static void app_task_initialization(void *arguments) {
|
||||
lcd_st7789_t lcd = {
|
||||
.cb =
|
||||
{
|
||||
.write_command_cb = app_lcd_impl_write_command,
|
||||
.write_data_cb = app_lcd_impl_write_data,
|
||||
.delay_cb = app_lcd_impl_delay,
|
||||
},
|
||||
};
|
||||
|
||||
app_lcd_impl_init(NULL);
|
||||
|
||||
lcd_st7789_init(&lcd, &lcd_tk0096_panel_config);
|
||||
lcd_st7789_set_direction(&lcd, LCD_ST7789_DIR_90);
|
||||
lcd_st7789_set_pixel_format(&lcd, LCD_ST7789_RGB565);
|
||||
lcd_st7789_enable_display(&lcd, true);
|
||||
|
||||
memset(s_display_buf, 0xDD, sizeof(s_display_buf));
|
||||
|
||||
epd_coord_t coord = {
|
||||
.x_start = 0,
|
||||
.x_end = 159,
|
||||
.y_start = 0,
|
||||
.y_end = 79,
|
||||
};
|
||||
|
||||
lcd_st7789_load(&lcd, &coord, (const uint8_t *)s_display_buf);
|
||||
|
||||
for (;;) {
|
||||
GPIO_PortToggle(BOARD_INITLEDPINS_LEDA_GPIO, BOARD_INITLEDPINS_LEDA_PIN_MASK);
|
||||
vTaskDelay(pdMS_TO_TICKS(250));
|
||||
|
|
Loading…
Reference in New Issue