Test JLX LCD.

This commit is contained in:
imi415 2022-01-22 20:15:28 +08:00
parent eda51c959f
commit 1938063a29
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
8 changed files with 62 additions and 42 deletions

View File

@ -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"

13
Core/Inc/epd_impl.h Normal file
View File

@ -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

View File

@ -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);
}
}

View File

@ -26,7 +26,8 @@
#include <stdio.h>
#include <string.h>
#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 */
}

View File

@ -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).
/

View File

@ -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

@ -1 +1 @@
Subproject commit 3f1f782faa7453fab6bfb81b777266de21cf5973
Subproject commit 3d497800bbb4a069a62d989623ab16ce550ab312

View File

@ -15,4 +15,5 @@ def will_init_target(target, init_sequence):
seq.insert_before('find_components',
('set_traceclken', set_traceclken)
)
)
)