diff --git a/CMakeLists.txt b/CMakeLists.txt index bb84aa9..9f56635 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ set(TARGET_C_SOURCES "Core/Src/libc-hooks.c" "Core/Src/libc-lock.c" "Core/Src/main.c" - "Core/Src/oled_impl.c" + "Core/Src/epd_impl.c" "Core/Src/stm32h7xx_it.c" "Core/Src/stm32h7xx_hal_msp.c" "Core/Src/stm32h7xx_hal_timebase_tim.c" @@ -66,6 +66,7 @@ set(TARGET_C_SOURCES "Middlewares/Third_Party/FatFs/src/diskio.c" "Middlewares/Third_Party/FatFs/src/ff.c" "Middlewares/Third_Party/FatFs/src/ff_gen_drv.c" + "Middlewares/Third_Party/FatFs/src/option/ccsbcs.c" "Middlewares/Third_Party/FatFs/src/option/syscall.c" "Middlewares/Third_Party/FreeRTOS/Source/croutine.c" "Middlewares/Third_Party/FreeRTOS/Source/event_groups.c" diff --git a/Core/Inc/epd_impl.h b/Core/Inc/epd_impl.h new file mode 100644 index 0000000..6416150 --- /dev/null +++ b/Core/Inc/epd_impl.h @@ -0,0 +1,13 @@ +#ifndef EPD_IMPL_H +#define EPD_IMPL_H + +#include "epd_common.h" + +#define EPD_IMPL_CMD_DC_CHANGE_AT_PARAM 1 + +int epd_impl_init(void); +epd_ret_t epd_impl_reset_cb(void *handle); +epd_ret_t epd_impl_write_cmd_cb(void *handle, uint8_t *cmd, uint32_t len); +epd_ret_t epd_impl_write_data_cb(void *handle, uint8_t *data, uint32_t len); + +#endif \ No newline at end of file diff --git a/Core/Src/oled_impl.c b/Core/Src/epd_impl.c similarity index 56% rename from Core/Src/oled_impl.c rename to Core/Src/epd_impl.c index f10234e..cc1b683 100644 --- a/Core/Src/oled_impl.c +++ b/Core/Src/epd_impl.c @@ -1,5 +1,6 @@ +#include "epd_impl.h" + #include "cmsis_os.h" -#include "oled_panel_elw1501aa.h" #include "main.h" #include "stm32h7xx_hal.h" @@ -7,13 +8,12 @@ extern SPI_HandleTypeDef hspi1; static osSemaphoreId_t s_spi_semphr; -int ewl_impl_init(void) { +int epd_impl_init(void) { s_spi_semphr = osSemaphoreNew(1, 0, NULL); - return 0; } -epd_ret_t ewl_impl_reset_cb(void *handle) { +epd_ret_t epd_impl_reset_cb(void *handle) { HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_SET); osDelay(10); HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); @@ -24,22 +24,31 @@ epd_ret_t ewl_impl_reset_cb(void *handle) { return EPD_OK; } -epd_ret_t ewl_impl_write_cmd_cb(void *handle, uint8_t *cmd, uint32_t len) { +epd_ret_t epd_impl_write_cmd_cb(void *handle, uint8_t *cmd, uint32_t len) { HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET); - HAL_StatusTypeDef ret = HAL_SPI_Transmit_DMA(&hspi1, cmd, len); - if(ret != HAL_OK) { - return EPD_FAIL; + HAL_StatusTypeDef ret; +#if EPD_IMPL_CMD_DC_CHANGE_AT_PARAM + ret = HAL_SPI_Transmit(&hspi1, cmd, 0x01, 1000); + if (ret != HAL_OK) return EPD_FAIL; + if(len > 1) { + HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_SET); + ret = HAL_SPI_Transmit_DMA(&hspi1, &cmd[1], len - 1); + if(ret != HAL_OK) return EPD_FAIL; + osSemaphoreAcquire(s_spi_semphr, osWaitForever); } - +#else + ret = HAL_SPI_Transmit_DMA(&hspi1, cmd, len); + if(ret != HAL_OK) return EPD_FAIL; osSemaphoreAcquire(s_spi_semphr, osWaitForever); - +#endif + return EPD_OK; } -epd_ret_t ewl_impl_write_data_cb(void *handle, uint8_t *data, uint32_t len) { +epd_ret_t epd_impl_write_data_cb(void *handle, uint8_t *data, uint32_t len) { HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_SET); HAL_StatusTypeDef ret = HAL_SPI_Transmit_DMA(&hspi1, data, len); - if(ret != HAL_OK) { + if (ret != HAL_OK) { return EPD_FAIL; } @@ -49,7 +58,7 @@ epd_ret_t ewl_impl_write_data_cb(void *handle, uint8_t *data, uint32_t len) { } void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) { - if(hspi->Instance == SPI1) { + if (hspi->Instance == SPI1) { osSemaphoreRelease(s_spi_semphr); } } \ No newline at end of file diff --git a/Core/Src/main.c b/Core/Src/main.c index f9627be..22a4aa7 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -26,7 +26,8 @@ #include #include -#include "oled_panel_elw1501aa.h" +#include "epd_impl.h" +#include "lcd_panel_jlx256128g_920.h" /* USER CODE END Includes */ @@ -407,18 +408,18 @@ static void MX_GPIO_Init(void) } /* USER CODE BEGIN 4 */ -int ewl_impl_init(void); -epd_ret_t ewl_impl_reset_cb(void *handle); -epd_ret_t ewl_impl_write_cmd_cb(void *handle, uint8_t *cmd, uint32_t len); -epd_ret_t ewl_impl_write_data_cb(void *handle, uint8_t *data, uint32_t len); -static oled_ewl1501aa_t s_oled = { +static lcd_jlx256128g_t s_lcd = { .cb = { - .reset_cb = ewl_impl_reset_cb, - .write_command_cb = ewl_impl_write_cmd_cb, - .write_data_cb = ewl_impl_write_data_cb, + .reset_cb = epd_impl_reset_cb, + .write_command_cb = epd_impl_write_cmd_cb, + .write_data_cb = epd_impl_write_data_cb, }, .user_data = NULL, + .config = { + .contrast = 310, + .mode = LCD_JLX256128G_MODE_GS, + }, }; static uint8_t s_frame[8192]; @@ -435,19 +436,15 @@ static uint8_t s_frame[8192]; void StartDefaultTask(void *argument) { /* USER CODE BEGIN 5 */ - ewl_impl_init(); - oled_ewl1501aa_init(&s_oled); - oled_ewl1501aa_power(&s_oled, 1); + epd_impl_init(); + lcd_jlx256128g_init(&s_lcd); - memset(s_frame, 0xAA, 8192); - epd_coord_t coord = { - .x_start = 0, - .x_end = 63, - .y_start = 0, - .y_end = 127, - }; + memset(s_frame, 0x00, 256); + memset(&s_frame[256], 0x55, 256); + memset(&s_frame[512], 0xAA, 256); + memset(&s_frame[768], 0xFF, 256); - oled_ewl1501aa_upload(&s_oled, &coord, s_frame); + lcd_jlx256128g_upload(&s_lcd, NULL, s_frame); osDelay(1000); @@ -457,7 +454,7 @@ void StartDefaultTask(void *argument) } FIL apple_fd; - if(f_open(&apple_fd, "0:/apple/apple.bin", FA_READ) != FR_OK) { + if(f_open(&apple_fd, "0:/apple/apple_st75256.bin", FA_READ) != FR_OK) { printf("Apple not found.\r\n"); goto dead_loop; } @@ -468,7 +465,7 @@ void StartDefaultTask(void *argument) if(f_read(&apple_fd, s_frame, 8192, &br) != FR_OK) { printf("Read failed.\r\n"); } - oled_ewl1501aa_upload(&s_oled, NULL, s_frame); + lcd_jlx256128g_upload(&s_lcd, NULL, s_frame); HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); uint32_t frame_end = osKernelGetTickCount(); if(frame_end - frame_start < 33) { @@ -478,12 +475,11 @@ void StartDefaultTask(void *argument) dead_loop: osDelay(5000); - oled_ewl1501aa_power(&s_oled, 0); /* Infinite loop */ for(;;) { - osDelay(1); + osThreadSuspend(defaultTaskHandle); } /* USER CODE END 5 */ } diff --git a/FATFS/Target/ffconf.h b/FATFS/Target/ffconf.h index ced3043..654180c 100644 --- a/FATFS/Target/ffconf.h +++ b/FATFS/Target/ffconf.h @@ -110,7 +110,7 @@ / 950 - Traditional Chinese (DBCS) */ -#define _USE_LFN 0 /* 0 to 3 */ +#define _USE_LFN 2 /* 0 to 3 */ #define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */ /* The _USE_LFN switches the support of long file name (LFN). / diff --git a/STM32H750VB_APPLE.ioc b/STM32H750VB_APPLE.ioc index fe57092..de47372 100644 --- a/STM32H750VB_APPLE.ioc +++ b/STM32H750VB_APPLE.ioc @@ -51,7 +51,7 @@ FATFS._USE_FASTSEEK=1 FATFS._USE_FIND=0 FATFS._USE_FORWARD=0 FATFS._USE_LABEL=0 -FATFS._USE_LFN=0 +FATFS._USE_LFN=2 FATFS._USE_MKFS=1 FATFS._USE_MUTEX=1 FATFS._USE_STRFUNC=2 diff --git a/lib/epd-spi b/lib/epd-spi index 3f1f782..3d49780 160000 --- a/lib/epd-spi +++ b/lib/epd-spi @@ -1 +1 @@ -Subproject commit 3f1f782faa7453fab6bfb81b777266de21cf5973 +Subproject commit 3d497800bbb4a069a62d989623ab16ce550ab312 diff --git a/pyocd_user.py b/pyocd_user.py index 16c258f..fe94082 100644 --- a/pyocd_user.py +++ b/pyocd_user.py @@ -15,4 +15,5 @@ def will_init_target(target, init_sequence): seq.insert_before('find_components', ('set_traceclken', set_traceclken) ) - ) \ No newline at end of file + ) +