Use epd-spi submodule.
This commit is contained in:
parent
aca2a4a487
commit
5625371519
|
@ -0,0 +1,11 @@
|
|||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
AlignConsecutiveMacros: AcrossEmptyLines
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterEnum: false
|
||||
AfterStruct: false
|
||||
SplitEmptyFunction: false
|
||||
ColumnLimit: 120
|
|
@ -0,0 +1,6 @@
|
|||
/Makefile
|
||||
/cmake-build-*
|
||||
/lib/mruby/build_config.rb.lock
|
||||
/lib/mruby/build
|
||||
/.mxproject
|
||||
/.vscode
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "lib/epd-spi"]
|
||||
path = lib/epd-spi
|
||||
url = https://github.com/imi415/epd-spi.git
|
|
@ -113,7 +113,7 @@ set(TARGET_C_INCLUDES
|
|||
|
||||
# Shared libraries linked with application
|
||||
set(TARGET_LIBS
|
||||
"ewl1501aa"
|
||||
"epd-spi"
|
||||
)
|
||||
|
||||
# Shared library and linker script search paths
|
||||
|
@ -142,7 +142,7 @@ set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${TARGET_CMAKE_C_FLAGS} -x assemb
|
|||
set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -Wl,--gc-sections -lc -lm -lnosys ${TARGET_LDFLAGS_EXTRA}")
|
||||
|
||||
# Include sub directories here
|
||||
add_subdirectory(lib/ewl1501aa)
|
||||
add_subdirectory(lib/epd-spi)
|
||||
|
||||
# Shared sources, includes and definitions
|
||||
add_compile_definitions(${TARGET_C_DEFINES})
|
||||
|
|
|
@ -59,6 +59,8 @@ void Error_Handler(void);
|
|||
/* Private defines -----------------------------------------------------------*/
|
||||
#define SDMMC1_DET_Pin GPIO_PIN_13
|
||||
#define SDMMC1_DET_GPIO_Port GPIOC
|
||||
#define LED_Pin GPIO_PIN_1
|
||||
#define LED_GPIO_Port GPIOA
|
||||
#define OLED_DC_Pin GPIO_PIN_6
|
||||
#define OLED_DC_GPIO_Port GPIOA
|
||||
#define OLED_RST_Pin GPIO_PIN_4
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ewl1501aa.h"
|
||||
#include "oled_panel_elw1501aa.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
|
@ -375,6 +375,9 @@ static void MX_GPIO_Init(void)
|
|||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_SET);
|
||||
|
||||
|
@ -387,12 +390,12 @@ static void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(SDMMC1_DET_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : OLED_DC_Pin */
|
||||
GPIO_InitStruct.Pin = OLED_DC_Pin;
|
||||
/*Configure GPIO pins : LED_Pin OLED_DC_Pin */
|
||||
GPIO_InitStruct.Pin = LED_Pin|OLED_DC_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(OLED_DC_GPIO_Port, &GPIO_InitStruct);
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : OLED_RST_Pin */
|
||||
GPIO_InitStruct.Pin = OLED_RST_Pin;
|
||||
|
@ -405,14 +408,14 @@ static void MX_GPIO_Init(void)
|
|||
|
||||
/* USER CODE BEGIN 4 */
|
||||
int ewl_impl_init(void);
|
||||
ewl1501aa_ret_t ewl_impl_reset_cb(void *handle);
|
||||
ewl1501aa_ret_t ewl_impl_write_cmd_cb(void *handle, uint8_t *cmd, uint8_t len);
|
||||
ewl1501aa_ret_t ewl_impl_write_data_cb(void *handle, uint8_t *data, uint16_t len);
|
||||
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 ewl1501aa_t s_oled = {
|
||||
static oled_ewl1501aa_t s_oled = {
|
||||
.cb = {
|
||||
.reset_cb = ewl_impl_reset_cb,
|
||||
.write_cmd_cb = ewl_impl_write_cmd_cb,
|
||||
.write_command_cb = ewl_impl_write_cmd_cb,
|
||||
.write_data_cb = ewl_impl_write_data_cb,
|
||||
},
|
||||
.user_data = NULL,
|
||||
|
@ -433,8 +436,20 @@ void StartDefaultTask(void *argument)
|
|||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
ewl_impl_init();
|
||||
ewl1501aa_init(&s_oled);
|
||||
ewl1501aa_power(&s_oled, 1);
|
||||
oled_ewl1501aa_init(&s_oled);
|
||||
oled_ewl1501aa_power(&s_oled, 1);
|
||||
|
||||
memset(s_frame, 0xAA, 8192);
|
||||
epd_coord_t coord = {
|
||||
.x_start = 0,
|
||||
.x_end = 63,
|
||||
.y_start = 0,
|
||||
.y_end = 127,
|
||||
};
|
||||
|
||||
oled_ewl1501aa_upload(&s_oled, &coord, s_frame);
|
||||
|
||||
osDelay(1000);
|
||||
|
||||
if(f_mount(&SDFatFS, SDPath, 1) != FR_OK) {
|
||||
printf("FS mount failed.\r\n");
|
||||
|
@ -453,7 +468,8 @@ void StartDefaultTask(void *argument)
|
|||
if(f_read(&apple_fd, s_frame, 8192, &br) != FR_OK) {
|
||||
printf("Read failed.\r\n");
|
||||
}
|
||||
ewl1501aa_upload(&s_oled, s_frame);
|
||||
oled_ewl1501aa_upload(&s_oled, NULL, s_frame);
|
||||
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
|
||||
uint32_t frame_end = osKernelGetTickCount();
|
||||
if(frame_end - frame_start < 33) {
|
||||
osDelay(33 - (frame_end - frame_start));
|
||||
|
@ -462,7 +478,7 @@ void StartDefaultTask(void *argument)
|
|||
|
||||
dead_loop:
|
||||
osDelay(5000);
|
||||
ewl1501aa_power(&s_oled, 0);
|
||||
oled_ewl1501aa_power(&s_oled, 0);
|
||||
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "cmsis_os.h"
|
||||
#include "ewl1501aa.h"
|
||||
#include "oled_panel_elw1501aa.h"
|
||||
#include "main.h"
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
|
@ -13,7 +13,7 @@ int ewl_impl_init(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
ewl1501aa_ret_t ewl_impl_reset_cb(void *handle) {
|
||||
epd_ret_t ewl_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);
|
||||
|
@ -21,31 +21,31 @@ ewl1501aa_ret_t ewl_impl_reset_cb(void *handle) {
|
|||
HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_SET);
|
||||
osDelay(10);
|
||||
|
||||
return EWL1501AA_OK;
|
||||
return EPD_OK;
|
||||
}
|
||||
|
||||
ewl1501aa_ret_t ewl_impl_write_cmd_cb(void *handle, uint8_t *cmd, uint8_t len) {
|
||||
epd_ret_t ewl_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 EWL1501AA_FAIL;
|
||||
return EPD_FAIL;
|
||||
}
|
||||
|
||||
osSemaphoreAcquire(s_spi_semphr, osWaitForever);
|
||||
|
||||
return EWL1501AA_OK;
|
||||
return EPD_OK;
|
||||
}
|
||||
|
||||
ewl1501aa_ret_t ewl_impl_write_data_cb(void *handle, uint8_t *data, uint16_t len) {
|
||||
epd_ret_t ewl_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) {
|
||||
return EWL1501AA_FAIL;
|
||||
return EPD_FAIL;
|
||||
}
|
||||
|
||||
osSemaphoreAcquire(s_spi_semphr, osWaitForever);
|
||||
|
||||
return EWL1501AA_OK;
|
||||
return EPD_OK;
|
||||
}
|
||||
|
||||
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) {
|
||||
|
|
|
@ -152,26 +152,27 @@ Mcu.Name=STM32H750VBTx
|
|||
Mcu.Package=LQFP100
|
||||
Mcu.Pin0=PC13
|
||||
Mcu.Pin1=PC14-OSC32_IN (OSC32_IN)
|
||||
Mcu.Pin10=PC8
|
||||
Mcu.Pin11=PC9
|
||||
Mcu.Pin12=PA9
|
||||
Mcu.Pin13=PA10
|
||||
Mcu.Pin14=PC10
|
||||
Mcu.Pin15=PC11
|
||||
Mcu.Pin16=PC12
|
||||
Mcu.Pin17=PD2
|
||||
Mcu.Pin18=VP_FATFS_VS_SDIO
|
||||
Mcu.Pin19=VP_FREERTOS_VS_CMSIS_V2
|
||||
Mcu.Pin10=PC4
|
||||
Mcu.Pin11=PC8
|
||||
Mcu.Pin12=PC9
|
||||
Mcu.Pin13=PA9
|
||||
Mcu.Pin14=PA10
|
||||
Mcu.Pin15=PC10
|
||||
Mcu.Pin16=PC11
|
||||
Mcu.Pin17=PC12
|
||||
Mcu.Pin18=PD2
|
||||
Mcu.Pin19=VP_FATFS_VS_SDIO
|
||||
Mcu.Pin2=PC15-OSC32_OUT (OSC32_OUT)
|
||||
Mcu.Pin20=VP_SYS_VS_tim7
|
||||
Mcu.Pin20=VP_FREERTOS_VS_CMSIS_V2
|
||||
Mcu.Pin21=VP_SYS_VS_tim7
|
||||
Mcu.Pin3=PH0-OSC_IN (PH0)
|
||||
Mcu.Pin4=PH1-OSC_OUT (PH1)
|
||||
Mcu.Pin5=PA4
|
||||
Mcu.Pin6=PA5
|
||||
Mcu.Pin7=PA6
|
||||
Mcu.Pin8=PA7
|
||||
Mcu.Pin9=PC4
|
||||
Mcu.PinsNb=21
|
||||
Mcu.Pin5=PA1
|
||||
Mcu.Pin6=PA4
|
||||
Mcu.Pin7=PA5
|
||||
Mcu.Pin8=PA6
|
||||
Mcu.Pin9=PA7
|
||||
Mcu.PinsNb=22
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32H750VBTx
|
||||
|
@ -203,6 +204,10 @@ NVIC.TimeBase=TIM7_IRQn
|
|||
NVIC.TimeBaseIP=TIM7
|
||||
NVIC.USART1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
PA1.GPIOParameters=GPIO_Label
|
||||
PA1.GPIO_Label=LED
|
||||
PA1.Locked=true
|
||||
PA1.Signal=GPIO_Output
|
||||
PA10.Locked=true
|
||||
PA10.Mode=Asynchronous
|
||||
PA10.Signal=USART1_RX
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 3f1f782faa7453fab6bfb81b777266de21cf5973
|
|
@ -1,14 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(ewl1501aa)
|
||||
|
||||
set(EWL_SRCS
|
||||
"src/ewl1501aa.c"
|
||||
)
|
||||
|
||||
set(EWL_INCS
|
||||
"include"
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} ${EWL_SRCS})
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${EWL_INCS})
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef EWL1501AA_H
|
||||
#define EWL1501AA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
EWL1501AA_OK,
|
||||
EWL1501AA_FAIL,
|
||||
} ewl1501aa_ret_t;
|
||||
|
||||
typedef struct {
|
||||
ewl1501aa_ret_t (*reset_cb)(void *handle);
|
||||
ewl1501aa_ret_t (*write_cmd_cb)(void *handle, uint8_t *cmd, uint8_t len);
|
||||
ewl1501aa_ret_t (*write_data_cb)(void *handle, uint8_t *data, uint16_t len);
|
||||
} ewl1501aa_cb_t;
|
||||
|
||||
typedef struct {
|
||||
ewl1501aa_cb_t cb;
|
||||
void *user_data;
|
||||
} ewl1501aa_t;
|
||||
|
||||
ewl1501aa_ret_t ewl1501aa_init(ewl1501aa_t *ewl);
|
||||
ewl1501aa_ret_t ewl1501aa_upload(ewl1501aa_t *ewl, uint8_t *data);
|
||||
ewl1501aa_ret_t ewl1501aa_power(ewl1501aa_t *ewl, uint8_t on);
|
||||
|
||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||
#include "ewl1501aa.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define EWL1501_ERR_CHECK(x) \
|
||||
if (x != EWL1501AA_OK) return EWL1501AA_FAIL
|
||||
|
||||
static uint8_t ewl1501aa_init_param[] = {
|
||||
0x01, 0x81, 0x9C, // Set contrast control
|
||||
0x01, 0xA0, 0x53, // Set segment re-map
|
||||
0x01, 0xA1, 0x00, // Set display start line
|
||||
0x01, 0xA2, 0x00, // Set display offset
|
||||
0x00, 0xA4, // Set normal display mode
|
||||
0x01, 0xA8, 0x7F, // Set MUX ratio
|
||||
0x01, 0xAB, 0x01, // Set enable internal VDD regulator mode
|
||||
0x01, 0xB1, 0x31, // Set phase length of phase 1, phase 2
|
||||
0x01, 0xB3, 0xF1, // Set ratio of dividing frequency & oscillation frequency
|
||||
0x00, 0xB9, // Set gray scale table
|
||||
0x01, 0xBC, 0x07, // Set pre-charge voltage
|
||||
0x01, 0xBE, 0x07, // Set voltage VCOMH
|
||||
0x02, 0x15, 0x00, 0x3F, // Set column address
|
||||
0x02, 0x75, 0x00, 0x7F, // Set row address
|
||||
};
|
||||
|
||||
static ewl1501aa_ret_t ewl1501aa_reset(ewl1501aa_t *ewl) {
|
||||
if (ewl->cb.reset_cb != NULL) {
|
||||
return ewl->cb.reset_cb(ewl->user_data);
|
||||
}
|
||||
|
||||
return EWL1501AA_OK;
|
||||
}
|
||||
|
||||
static ewl1501aa_ret_t ewl1501aa_init_seq(ewl1501aa_t *ewl) {
|
||||
uint16_t seq_ptr = 0;
|
||||
while (seq_ptr < sizeof(ewl1501aa_init_param)) {
|
||||
EWL1501_ERR_CHECK(ewl->cb.write_cmd_cb(ewl->user_data, &ewl1501aa_init_param[seq_ptr + 1],
|
||||
ewl1501aa_init_param[seq_ptr] + 1));
|
||||
seq_ptr += ewl1501aa_init_param[seq_ptr] + 2;
|
||||
}
|
||||
|
||||
return EWL1501AA_OK;
|
||||
}
|
||||
|
||||
ewl1501aa_ret_t ewl1501aa_init(ewl1501aa_t *ewl) {
|
||||
EWL1501_ERR_CHECK(ewl1501aa_reset(ewl));
|
||||
EWL1501_ERR_CHECK(ewl1501aa_init_seq(ewl));
|
||||
|
||||
return EWL1501AA_OK;
|
||||
}
|
||||
|
||||
ewl1501aa_ret_t ewl1501aa_upload(ewl1501aa_t *ewl, uint8_t *data) {
|
||||
EWL1501_ERR_CHECK(ewl->cb.write_data_cb(ewl->user_data, data, 8192));
|
||||
return EWL1501AA_OK;
|
||||
}
|
||||
|
||||
ewl1501aa_ret_t ewl1501aa_power(ewl1501aa_t *ewl, uint8_t on) {
|
||||
uint8_t cmd[2] = { 0xAE, 0x00 };
|
||||
if(on) cmd[0] = 0xAF;
|
||||
EWL1501_ERR_CHECK(ewl->cb.write_cmd_cb(ewl->user_data, cmd, 1));
|
||||
|
||||
return EWL1501AA_OK;
|
||||
}
|
Loading…
Reference in New Issue