Updated LCD driver, added maximum SPI transfer size.
This commit is contained in:
parent
6bcc64d337
commit
4a788dcac1
|
@ -10,6 +10,8 @@ typedef struct {
|
|||
uint32_t speed_hz;
|
||||
} user_spi_driver_t;
|
||||
|
||||
#define SPIDEV_MAX_TRANSFER_SIZE 4096
|
||||
|
||||
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,
|
||||
|
|
|
@ -17,3 +17,4 @@ set(ST7789_LCD_SOURCES
|
|||
)
|
||||
|
||||
add_library(st7789 STATIC ${ST7789_LCD_SOURCES})
|
||||
target_compile_definitions(st7789 PRIVATE "ST7789_PANEL_ZJY_240")
|
|
@ -1 +1 @@
|
|||
Subproject commit c685c2a4a80e047a495c2061d673f1fd191a8edd
|
||||
Subproject commit 2d90485d678d1cf803135df522cd9b35acd3d013
|
|
@ -2,17 +2,18 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/spi/spidev.h>
|
||||
#include <linux/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "drivers/user_config_driver.h"
|
||||
#include "utils/user_log_util.h"
|
||||
|
||||
#include "drivers/user_spi_driver.h"
|
||||
|
||||
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_init(user_spi_driver_t *spi, char *path,
|
||||
uint32_t speed_hz) {
|
||||
USER_LOG(USER_LOG_INFO, "SPI driver init.");
|
||||
|
||||
spi->spidev_fd = open(path, O_RDWR);
|
||||
|
@ -41,11 +42,26 @@ user_spi_ret_t user_spi_driver_xfer(user_spi_driver_t *spi, uint8_t *tx_buf,
|
|||
.len = len,
|
||||
.cs_change = 0,
|
||||
.speed_hz = spi->speed_hz,
|
||||
.bits_per_word = 8
|
||||
.bits_per_word = 8,
|
||||
};
|
||||
if(ioctl(spi->spidev_fd, SPI_IOC_MESSAGE(1), &txn) < 0) {
|
||||
USER_LOG(USER_LOG_ERROR, "SPI transaction error.");
|
||||
return USER_SPI_ERROR;
|
||||
|
||||
while(len > SPIDEV_MAX_TRANSFER_SIZE) {
|
||||
txn.len = SPIDEV_MAX_TRANSFER_SIZE;
|
||||
len -= SPIDEV_MAX_TRANSFER_SIZE;
|
||||
|
||||
if(ioctl(spi->spidev_fd, SPI_IOC_MESSAGE(1), &txn) < 0) {
|
||||
USER_LOG(USER_LOG_ERROR, "SPI transaction error.");
|
||||
return USER_SPI_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if(len > 0) {
|
||||
txn.len = len;
|
||||
|
||||
if(ioctl(spi->spidev_fd, SPI_IOC_MESSAGE(1), &txn) < 0) {
|
||||
USER_LOG(USER_LOG_ERROR, "SPI transaction error.");
|
||||
return USER_SPI_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return USER_SPI_OK;
|
||||
|
|
Loading…
Reference in New Issue