Fixed SPI driver, updated LCD driver.
This commit is contained in:
parent
4a788dcac1
commit
8600d20915
|
@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.10)
|
|||
|
||||
project(SystemAgent)
|
||||
|
||||
set(ST7789_LCD_DEFINES "ST7789_PANEL_ZJY_240")
|
||||
set(LVGL_DEFINES "LV_CONF_INCLUDE_SIMPLE")
|
||||
|
||||
set(C_SOURCES
|
||||
"src/main.c"
|
||||
"src/drivers/user_gpio_driver.c"
|
||||
|
@ -14,11 +17,14 @@ set(C_SOURCES
|
|||
|
||||
set(C_INCLUDES
|
||||
"lib/LittleVGL"
|
||||
"lib/st7789_lcd"
|
||||
"include"
|
||||
)
|
||||
|
||||
set(C_DEFINES
|
||||
"_GNU_SOURCE"
|
||||
${ST7789_LCD_DEFINES}
|
||||
${LVGL_DEFINES}
|
||||
)
|
||||
|
||||
set(C_LIBRARIES
|
||||
|
|
|
@ -22,7 +22,7 @@ which runs on Linux.
|
|||
|
||||
- [x] LittleVGL
|
||||
- [ ] mosquitto
|
||||
- [ ] libgpiod
|
||||
- [x] libgpiod
|
||||
- [ ] libconfig
|
||||
- [ ] libpthread
|
||||
- [ ] libiio
|
||||
|
|
|
@ -15,6 +15,6 @@ typedef struct {
|
|||
user_spi_ret_t user_spi_driver_init(user_spi_driver_t *spi, char *path, uint32_t speed_hz);
|
||||
user_spi_ret_t user_spi_driver_deinit(user_spi_driver_t *spi);
|
||||
user_spi_ret_t user_spi_driver_xfer(user_spi_driver_t *spi, uint8_t *tx_buf,
|
||||
uint8_t rx_buf, uint32_t len);
|
||||
uint8_t *rx_buf, uint32_t len);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,7 +9,7 @@ set(LVGL_INCLUDES
|
|||
|
||||
add_library(lvgl STATIC ${LVGL_SOURCES})
|
||||
target_include_directories(lvgl PRIVATE ${LVGL_INCLUDES})
|
||||
target_compile_definitions(lvgl PRIVATE "LV_CONF_INCLUDE_SIMPLE")
|
||||
target_compile_definitions(lvgl PRIVATE ${LVGL_DEFINES})
|
||||
|
||||
|
||||
set(ST7789_LCD_SOURCES
|
||||
|
@ -17,4 +17,4 @@ set(ST7789_LCD_SOURCES
|
|||
)
|
||||
|
||||
add_library(st7789 STATIC ${ST7789_LCD_SOURCES})
|
||||
target_compile_definitions(st7789 PRIVATE "ST7789_PANEL_ZJY_240")
|
||||
target_compile_definitions(st7789 PRIVATE ${ST7789_LCD_DEFINES})
|
|
@ -1 +1 @@
|
|||
Subproject commit 2d90485d678d1cf803135df522cd9b35acd3d013
|
||||
Subproject commit b4261874cfa472c4d947d73bd1a3629ec9f4a4d5
|
|
@ -36,9 +36,10 @@ user_spi_ret_t user_spi_driver_deinit(user_spi_driver_t *spi) {
|
|||
}
|
||||
|
||||
user_spi_ret_t user_spi_driver_xfer(user_spi_driver_t *spi, uint8_t *tx_buf,
|
||||
uint8_t rx_buf, uint32_t len) {
|
||||
uint8_t *rx_buf, uint32_t len) {
|
||||
struct spi_ioc_transfer txn = {
|
||||
.tx_buf = (unsigned long)tx_buf,
|
||||
.rx_buf = (unsigned long)rx_buf,
|
||||
.len = len,
|
||||
.cs_change = 0,
|
||||
.speed_hz = spi->speed_hz,
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
#include "lvgl.h"
|
||||
|
||||
#include "st7789_lcd.h"
|
||||
|
||||
#include "drivers/user_gpio_driver.h"
|
||||
#include "drivers/user_spi_driver.h"
|
||||
|
||||
extern user_spi_driver_t g_spi;
|
||||
|
||||
st7789_ret_t _user_lvgl_impl_lcd_write_cmd(void *handle, uint8_t *cmd,
|
||||
uint8_t len);
|
||||
st7789_ret_t _user_lvgl_impl_lcd_write_data(void *handle, uint8_t *data,
|
||||
uint32_t len);
|
||||
st7789_ret_t _user_lvgl_impl_lcd_reset(void *handle);
|
||||
|
||||
st7789_lcd_t g_lcd = {
|
||||
.cb =
|
||||
{
|
||||
.write_cmd_cb = _user_lvgl_impl_lcd_write_cmd,
|
||||
.write_data_cb = _user_lvgl_impl_lcd_write_data,
|
||||
.reset_cb = _user_lvgl_impl_lcd_reset,
|
||||
},
|
||||
.config =
|
||||
{
|
||||
.direction = ST7789_DIR_0,
|
||||
.pix_fmt = ST7789_RGB888,
|
||||
},
|
||||
};
|
||||
|
||||
void user_lvgl_impl_init(void) {}
|
||||
|
||||
st7789_ret_t _user_lvgl_impl_lcd_write_cmd(void *handle, uint8_t *cmd,
|
||||
uint8_t len) {
|
||||
// TODO: Change CS and DC here
|
||||
if(user_spi_driver_xfer(&g_spi, cmd, NULL, len) != USER_SPI_OK) {
|
||||
return ST7789_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
st7789_ret_t _user_lvgl_impl_lcd_write_data(void *handle, uint8_t *data,
|
||||
uint32_t len) {
|
||||
// TODO: Change CS and DC here
|
||||
if(user_spi_driver_xfer(&g_spi, data, NULL, len) != USER_SPI_OK) {
|
||||
return ST7789_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
st7789_ret_t _user_lvgl_impl_lcd_reset(void *handle) {
|
||||
// Implement reset here.
|
||||
}
|
Loading…
Reference in New Issue