Apply clang format for samples files (#833)
Apply clang format for c source files under samples folder
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file XPT2046.c
|
||||
*/
|
||||
*/
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
@ -30,7 +30,8 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void xpt2046_corr(int16_t * x, int16_t * y);
|
||||
static void
|
||||
xpt2046_corr(int16_t *x, int16_t *y);
|
||||
#if 0
|
||||
static void xpt2046_avg(int16_t * x, int16_t * y);
|
||||
#endif
|
||||
@ -63,18 +64,20 @@ lv_indev_data_t touch_point;
|
||||
lv_indev_data_t last_touch_point;
|
||||
|
||||
#define TOUCH_READ_THREAD_STACK_SIZE 4096
|
||||
static K_THREAD_STACK_DEFINE(touch_read_thread_stack, TOUCH_READ_THREAD_STACK_SIZE);
|
||||
static K_THREAD_STACK_DEFINE(touch_read_thread_stack,
|
||||
TOUCH_READ_THREAD_STACK_SIZE);
|
||||
static struct k_thread touch_thread_data;
|
||||
static struct k_sem sem_touch_read;
|
||||
|
||||
K_MUTEX_DEFINE( spi_display_touch_mutex);
|
||||
K_MUTEX_DEFINE(spi_display_touch_mutex);
|
||||
|
||||
int cnt = 0;
|
||||
int touch_read_times = 0;
|
||||
int last_pen_interrupt_time = 0;
|
||||
|
||||
void xpt2046_pen_gpio_callback(struct device *port, struct gpio_callback *cb,
|
||||
uint32_t pins)
|
||||
void
|
||||
xpt2046_pen_gpio_callback(struct device *port, struct gpio_callback *cb,
|
||||
uint32_t pins)
|
||||
{
|
||||
cnt++;
|
||||
if ((k_uptime_get_32() - last_pen_interrupt_time) > 500) {
|
||||
@ -82,10 +85,10 @@ void xpt2046_pen_gpio_callback(struct device *port, struct gpio_callback *cb,
|
||||
touch_read_times++;
|
||||
last_pen_interrupt_time = k_uptime_get_32();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void disable_pen_interrupt()
|
||||
void
|
||||
disable_pen_interrupt()
|
||||
{
|
||||
int ret = 0;
|
||||
ret = gpio_disable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
|
||||
@ -93,7 +96,8 @@ void disable_pen_interrupt()
|
||||
printf("gpio_pin_configure GPIO_INPUT failed\n");
|
||||
}
|
||||
}
|
||||
void enable_pen_interrupt()
|
||||
void
|
||||
enable_pen_interrupt()
|
||||
{
|
||||
int ret = 0;
|
||||
ret = gpio_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
|
||||
@ -102,7 +106,8 @@ void enable_pen_interrupt()
|
||||
}
|
||||
}
|
||||
|
||||
void touch_screen_read_thread()
|
||||
void
|
||||
touch_screen_read_thread()
|
||||
{
|
||||
int i;
|
||||
bool ret = false;
|
||||
@ -119,12 +124,11 @@ void touch_screen_read_thread()
|
||||
ret = xpt2046_read(&touch_point);
|
||||
if (ret) {
|
||||
if ((abs(last_touch_point.point.x - touch_point.point.x) < 4)
|
||||
&& (abs(last_touch_point.point.y - touch_point.point.y)
|
||||
< 4)) {
|
||||
&& (abs(last_touch_point.point.y - touch_point.point.y)
|
||||
< 4)) {
|
||||
break;
|
||||
}
|
||||
last_touch_point = touch_point;
|
||||
|
||||
}
|
||||
}
|
||||
enable_pen_interrupt();
|
||||
@ -132,7 +136,8 @@ void touch_screen_read_thread()
|
||||
}
|
||||
}
|
||||
|
||||
void xpt2046_init(void)
|
||||
void
|
||||
xpt2046_init(void)
|
||||
{
|
||||
int ret;
|
||||
input_dev = device_get_binding(XPT2046_SPI_DEVICE_NAME);
|
||||
@ -141,7 +146,7 @@ void xpt2046_init(void)
|
||||
printf("device not found. Aborting test.");
|
||||
return;
|
||||
}
|
||||
memset((void *) &touch_point, 0, sizeof(lv_indev_data_t));
|
||||
memset((void *)&touch_point, 0, sizeof(lv_indev_data_t));
|
||||
|
||||
spi_conf_xpt2046.frequency = XPT2046_SPI_MAX_FREQUENCY;
|
||||
spi_conf_xpt2046.operation = SPI_OP_MODE_MASTER | SPI_WORD_SET(8);
|
||||
@ -172,8 +177,7 @@ void xpt2046_init(void)
|
||||
/* Setup GPIO input */
|
||||
ret = gpio_pin_configure(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN,
|
||||
(GPIO_INPUT | GPIO_INT_ENABLE | GPIO_INT_EDGE
|
||||
| GPIO_INT_LOW_0 | GPIO_INT_DEBOUNCE)
|
||||
);
|
||||
| GPIO_INT_LOW_0 | GPIO_INT_DEBOUNCE));
|
||||
if (ret) {
|
||||
printk("Error configuring pin %d!\n", XPT2046_PEN_GPIO_PIN);
|
||||
}
|
||||
@ -195,8 +199,7 @@ void xpt2046_init(void)
|
||||
|
||||
k_thread_create(&touch_thread_data, touch_read_thread_stack,
|
||||
TOUCH_READ_THREAD_STACK_SIZE, touch_screen_read_thread,
|
||||
NULL, NULL, NULL, 5,
|
||||
0, K_NO_WAIT);
|
||||
NULL, NULL, NULL, 5, 0, K_NO_WAIT);
|
||||
printf("xpt2046_init ok \n");
|
||||
}
|
||||
|
||||
@ -205,7 +208,8 @@ void xpt2046_init(void)
|
||||
* @param data store the read data here
|
||||
* @return false: because no ore data to be read
|
||||
*/
|
||||
bool xpt2046_read(lv_indev_data_t * data)
|
||||
bool
|
||||
xpt2046_read(lv_indev_data_t *data)
|
||||
{
|
||||
static int16_t last_x = 0;
|
||||
static int16_t last_y = 0;
|
||||
@ -259,7 +263,8 @@ bool xpt2046_read(lv_indev_data_t * data)
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
static void xpt2046_corr(int16_t * x, int16_t * y)
|
||||
static void
|
||||
xpt2046_corr(int16_t *x, int16_t *y)
|
||||
{
|
||||
#if XPT2046_XY_SWAP != 0
|
||||
int16_t swap_tmp;
|
||||
@ -279,10 +284,10 @@ static void xpt2046_corr(int16_t * x, int16_t * y)
|
||||
(*y) = 0;
|
||||
|
||||
(*x) = (uint32_t)((uint32_t)(*x) * XPT2046_HOR_RES)
|
||||
/ (XPT2046_X_MAX - XPT2046_X_MIN);
|
||||
/ (XPT2046_X_MAX - XPT2046_X_MIN);
|
||||
|
||||
(*y) = (uint32_t)((uint32_t)(*y) * XPT2046_VER_RES)
|
||||
/ (XPT2046_Y_MAX - XPT2046_Y_MIN);
|
||||
/ (XPT2046_Y_MAX - XPT2046_Y_MIN);
|
||||
|
||||
#if XPT2046_X_INV != 0
|
||||
(*x) = XPT2046_HOR_RES - (*x);
|
||||
@ -291,7 +296,6 @@ static void xpt2046_corr(int16_t * x, int16_t * y)
|
||||
#if XPT2046_Y_INV != 0
|
||||
(*y) = XPT2046_VER_RES - (*y);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -324,7 +328,8 @@ static void xpt2046_avg(int16_t * x, int16_t * y)
|
||||
}
|
||||
#endif
|
||||
|
||||
bool touchscreen_read(lv_indev_data_t * data)
|
||||
bool
|
||||
touchscreen_read(lv_indev_data_t *data)
|
||||
{
|
||||
/*Store the collected data*/
|
||||
data->point.x = last_touch_point.point.x;
|
||||
|
||||
@ -8,18 +8,17 @@
|
||||
|
||||
#define USE_XPT2046 1
|
||||
|
||||
#define XPT2046_HOR_RES 320
|
||||
#define XPT2046_VER_RES 240
|
||||
#define XPT2046_X_MIN 200
|
||||
#define XPT2046_Y_MIN 200
|
||||
#define XPT2046_X_MAX 3800
|
||||
#define XPT2046_Y_MAX 3800
|
||||
#define XPT2046_AVG 4
|
||||
#define XPT2046_INV 0
|
||||
|
||||
# define XPT2046_HOR_RES 320
|
||||
# define XPT2046_VER_RES 240
|
||||
# define XPT2046_X_MIN 200
|
||||
# define XPT2046_Y_MIN 200
|
||||
# define XPT2046_X_MAX 3800
|
||||
# define XPT2046_Y_MAX 3800
|
||||
# define XPT2046_AVG 4
|
||||
# define XPT2046_INV 0
|
||||
|
||||
#define CMD_X_READ 0b10010000
|
||||
#define CMD_Y_READ 0b11010000
|
||||
#define CMD_X_READ 0b10010000
|
||||
#define CMD_Y_READ 0b11010000
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -37,9 +36,7 @@ extern "C" {
|
||||
#include "device.h"
|
||||
#include "drivers/gpio.h"
|
||||
#if 1
|
||||
enum {
|
||||
LV_INDEV_STATE_REL = 0, LV_INDEV_STATE_PR
|
||||
};
|
||||
enum { LV_INDEV_STATE_REL = 0, LV_INDEV_STATE_PR };
|
||||
typedef uint8_t lv_indev_state_t;
|
||||
typedef int16_t lv_coord_t;
|
||||
typedef struct {
|
||||
@ -49,12 +46,14 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/
|
||||
lv_point_t
|
||||
point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/
|
||||
uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/
|
||||
uint32_t btn; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/
|
||||
int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/
|
||||
int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the
|
||||
previous read*/
|
||||
};
|
||||
void *user_data; /*'lv_indev_drv_t.priv' for this driver*/
|
||||
void *user_data; /*'lv_indev_drv_t.priv' for this driver*/
|
||||
lv_indev_state_t state; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/
|
||||
} lv_indev_data_t;
|
||||
#endif
|
||||
@ -70,8 +69,10 @@ typedef struct {
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void xpt2046_init(void);
|
||||
bool xpt2046_read(lv_indev_data_t * data);
|
||||
void
|
||||
xpt2046_init(void);
|
||||
bool
|
||||
xpt2046_read(lv_indev_data_t *data);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@ -143,8 +143,8 @@ typedef int (*display_blanking_off_api)(const struct device *dev);
|
||||
* @brief Callback API for writing data to the display
|
||||
* See display_write() for argument description
|
||||
*/
|
||||
typedef int (*display_write_api)(const struct device *dev,
|
||||
const uint16_t x, const uint16_t y,
|
||||
typedef int (*display_write_api)(const struct device *dev, const uint16_t x,
|
||||
const uint16_t y,
|
||||
const struct display_buffer_descriptor *desc,
|
||||
const void *buf);
|
||||
|
||||
@ -153,8 +153,8 @@ typedef int (*display_write_api)(const struct device *dev,
|
||||
* @brief Callback API for reading data from the display
|
||||
* See display_read() for argument description
|
||||
*/
|
||||
typedef int (*display_read_api)(const struct device *dev,
|
||||
const uint16_t x, const uint16_t y,
|
||||
typedef int (*display_read_api)(const struct device *dev, const uint16_t x,
|
||||
const uint16_t y,
|
||||
const struct display_buffer_descriptor *desc,
|
||||
void *buf);
|
||||
|
||||
@ -186,24 +186,24 @@ typedef int (*display_set_contrast_api)(const struct device *dev,
|
||||
* @brief Callback API to get display capabilities
|
||||
* See display_get_capabilities() for argument description
|
||||
*/
|
||||
typedef void (*display_get_capabilities_api)(const struct device *dev,
|
||||
struct display_capabilities * capabilities);
|
||||
typedef void (*display_get_capabilities_api)(
|
||||
const struct device *dev, struct display_capabilities *capabilities);
|
||||
|
||||
/**
|
||||
* @typedef display_set_pixel_format_api
|
||||
* @brief Callback API to set pixel format used by the display
|
||||
* See display_set_pixel_format() for argument description
|
||||
*/
|
||||
typedef int (*display_set_pixel_format_api)(const struct device *dev,
|
||||
const enum display_pixel_format pixel_format);
|
||||
typedef int (*display_set_pixel_format_api)(
|
||||
const struct device *dev, const enum display_pixel_format pixel_format);
|
||||
|
||||
/**
|
||||
* @typedef display_set_orientation_api
|
||||
* @brief Callback API to set orientation used by the display
|
||||
* See display_set_orientation() for argument description
|
||||
*/
|
||||
typedef int (*display_set_orientation_api)(const struct device *dev,
|
||||
const enum display_orientation orientation);
|
||||
typedef int (*display_set_orientation_api)(
|
||||
const struct device *dev, const enum display_orientation orientation);
|
||||
|
||||
/**
|
||||
* @brief Display driver API
|
||||
@ -363,7 +363,7 @@ display_set_contrast(const struct device *dev, uint8_t contrast)
|
||||
*/
|
||||
static inline void
|
||||
display_get_capabilities(const struct device *dev,
|
||||
struct display_capabilities * capabilities)
|
||||
struct display_capabilities *capabilities)
|
||||
{
|
||||
struct display_driver_api *api = &ili9340_api1;
|
||||
//(struct display_driver_api *)dev->driver_api;
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
//#define LOG_LEVEL CONFIG_DISPLAY_LOG_LEVEL
|
||||
//#include <logging/log.h>
|
||||
//LOG_MODULE_REGISTER(display_ili9340);
|
||||
// LOG_MODULE_REGISTER(display_ili9340);
|
||||
#define LOG_ERR printf
|
||||
#define LOG_DBG printf
|
||||
#define LOG_WRN printf
|
||||
@ -39,7 +39,7 @@ static void
|
||||
ili9340_exit_sleep(struct ili9340_data *data)
|
||||
{
|
||||
ili9340_transmit(data, ILI9340_CMD_EXIT_SLEEP, NULL, 0);
|
||||
//k_sleep(Z_TIMEOUT_MS(120));
|
||||
// k_sleep(Z_TIMEOUT_MS(120));
|
||||
}
|
||||
|
||||
int
|
||||
@ -53,20 +53,22 @@ ili9340_init()
|
||||
return -EPERM;
|
||||
}
|
||||
data->spi_config.frequency = DT_ILITEK_ILI9340_0_SPI_MAX_FREQUENCY;
|
||||
data->spi_config.operation = SPI_OP_MODE_MASTER | SPI_WORD_SET(8); //SPI_OP_MODE_MASTER | SPI_WORD_SET(8);
|
||||
data->spi_config.operation =
|
||||
SPI_OP_MODE_MASTER
|
||||
| SPI_WORD_SET(8); // SPI_OP_MODE_MASTER | SPI_WORD_SET(8);
|
||||
data->spi_config.slave = DT_ILITEK_ILI9340_0_BASE_ADDRESS;
|
||||
|
||||
#ifdef DT_ILITEK_ILI9340_0_CS_GPIO_CONTROLLER
|
||||
data->cs_ctrl.gpio_dev =
|
||||
device_get_binding(DT_ILITEK_ILI9340_0_CS_GPIO_CONTROLLER);
|
||||
device_get_binding(DT_ILITEK_ILI9340_0_CS_GPIO_CONTROLLER);
|
||||
data->cs_ctrl.gpio_pin = DT_ILITEK_ILI9340_0_CS_GPIO_PIN;
|
||||
data->cs_ctrl.delay = 0;
|
||||
data->spi_config.cs = &(data->cs_ctrl);
|
||||
#else
|
||||
data->spi_config.cs = NULL;
|
||||
#endif
|
||||
data->reset_gpio = device_get_binding(
|
||||
DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER);
|
||||
data->reset_gpio =
|
||||
device_get_binding(DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER);
|
||||
if (data->reset_gpio == NULL) {
|
||||
return -EPERM;
|
||||
}
|
||||
@ -74,8 +76,8 @@ ili9340_init()
|
||||
gpio_pin_configure(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN,
|
||||
GPIO_OUTPUT);
|
||||
|
||||
data->command_data_gpio = device_get_binding(
|
||||
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER);
|
||||
data->command_data_gpio =
|
||||
device_get_binding(DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER);
|
||||
if (data->command_data_gpio == NULL) {
|
||||
return -EPERM;
|
||||
}
|
||||
@ -101,9 +103,8 @@ ili9340_init()
|
||||
}
|
||||
|
||||
static void
|
||||
ili9340_set_mem_area(struct ili9340_data *data,
|
||||
const uint16_t x, const uint16_t y,
|
||||
const uint16_t w, const uint16_t h)
|
||||
ili9340_set_mem_area(struct ili9340_data *data, const uint16_t x,
|
||||
const uint16_t y, const uint16_t w, const uint16_t h)
|
||||
{
|
||||
uint16_t spi_data[2];
|
||||
|
||||
@ -120,8 +121,8 @@ static int
|
||||
ili9340_write(const struct device *dev, const uint16_t x, const uint16_t y,
|
||||
const struct display_buffer_descriptor *desc, const void *buf)
|
||||
{
|
||||
struct ili9340_data *data = (struct ili9340_data *) &ili9340_data1;
|
||||
const uint8_t *write_data_start = (uint8_t *) buf;
|
||||
struct ili9340_data *data = (struct ili9340_data *)&ili9340_data1;
|
||||
const uint8_t *write_data_start = (uint8_t *)buf;
|
||||
struct spi_buf tx_buf;
|
||||
struct spi_buf_set tx_bufs;
|
||||
uint16_t write_cnt;
|
||||
@ -136,11 +137,12 @@ ili9340_write(const struct device *dev, const uint16_t x, const uint16_t y,
|
||||
if (desc->pitch > desc->width) {
|
||||
write_h = 1U;
|
||||
nbr_of_writes = desc->height;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
write_h = desc->height;
|
||||
nbr_of_writes = 1U;
|
||||
}
|
||||
ili9340_transmit(data, ILI9340_CMD_MEM_WRITE, (void *) write_data_start,
|
||||
ili9340_transmit(data, ILI9340_CMD_MEM_WRITE, (void *)write_data_start,
|
||||
3 * desc->width * write_h);
|
||||
|
||||
tx_bufs.buffers = &tx_buf;
|
||||
@ -148,7 +150,7 @@ ili9340_write(const struct device *dev, const uint16_t x, const uint16_t y,
|
||||
|
||||
write_data_start += (3 * desc->pitch);
|
||||
for (write_cnt = 1U; write_cnt < nbr_of_writes; ++write_cnt) {
|
||||
tx_buf.buf = (void *) write_data_start;
|
||||
tx_buf.buf = (void *)write_data_start;
|
||||
tx_buf.len = 3 * desc->width * write_h;
|
||||
spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
|
||||
write_data_start += (3 * desc->pitch);
|
||||
@ -241,22 +243,23 @@ ili9340_get_capabilities(const struct device *dev,
|
||||
}
|
||||
|
||||
void
|
||||
ili9340_transmit(struct ili9340_data *data, uint8_t cmd,
|
||||
void *tx_data, size_t tx_len)
|
||||
ili9340_transmit(struct ili9340_data *data, uint8_t cmd, void *tx_data,
|
||||
size_t tx_len)
|
||||
{
|
||||
struct spi_buf tx_buf = { .buf = &cmd, .len = 1 };
|
||||
struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 };
|
||||
|
||||
data = (struct ili9340_data *) &ili9340_data1;
|
||||
gpio_pin_set(data->command_data_gpio, DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_COMMAND);
|
||||
data = (struct ili9340_data *)&ili9340_data1;
|
||||
gpio_pin_set(data->command_data_gpio,
|
||||
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_COMMAND);
|
||||
spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
|
||||
if (tx_data != NULL) {
|
||||
tx_buf.buf = tx_data;
|
||||
tx_buf.len = tx_len;
|
||||
gpio_pin_set(data->command_data_gpio,
|
||||
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_DATA);
|
||||
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
|
||||
ILI9340_CMD_DATA_PIN_DATA);
|
||||
spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,15 +52,17 @@ struct ili9340_data;
|
||||
* @param tx_len Number of bytes in tx_data buffer
|
||||
*
|
||||
*/
|
||||
void ili9340_transmit(struct ili9340_data *data, uint8_t cmd,
|
||||
void *tx_data, size_t tx_len);
|
||||
void
|
||||
ili9340_transmit(struct ili9340_data *data, uint8_t cmd, void *tx_data,
|
||||
size_t tx_len);
|
||||
|
||||
/**
|
||||
* Perform LCD specific initialization
|
||||
*
|
||||
* @param data Device data structure
|
||||
*/
|
||||
void ili9340_lcd_init(struct ili9340_data *data);
|
||||
void
|
||||
ili9340_lcd_init(struct ili9340_data *data);
|
||||
|
||||
#define DT_ILITEK_ILI9340_0_LABEL "DISPLAY"
|
||||
#define CONFIG_DISPLAY_LOG_LEVEL 0
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
|
||||
#include "display_ili9340.h"
|
||||
|
||||
void ili9340_lcd_init(struct ili9340_data *data)
|
||||
void
|
||||
ili9340_lcd_init(struct ili9340_data *data)
|
||||
{
|
||||
uint8_t tx_data[15];
|
||||
|
||||
@ -24,11 +25,11 @@ void ili9340_lcd_init(struct ili9340_data *data)
|
||||
ili9340_transmit(data, ILI9340_CMD_VCOM_CTRL_2, tx_data, 1);
|
||||
|
||||
tx_data[0] =
|
||||
ILI9340_DATA_MEM_ACCESS_CTRL_MV | ILI9340_DATA_MEM_ACCESS_CTRL_BGR;
|
||||
ILI9340_DATA_MEM_ACCESS_CTRL_MV | ILI9340_DATA_MEM_ACCESS_CTRL_BGR;
|
||||
ili9340_transmit(data, ILI9340_CMD_MEM_ACCESS_CTRL, tx_data, 1);
|
||||
|
||||
tx_data[0] = ILI9340_DATA_PIXEL_FORMAT_MCU_18_BIT |
|
||||
ILI9340_DATA_PIXEL_FORMAT_RGB_18_BIT;
|
||||
tx_data[0] = ILI9340_DATA_PIXEL_FORMAT_MCU_18_BIT
|
||||
| ILI9340_DATA_PIXEL_FORMAT_RGB_18_BIT;
|
||||
ili9340_transmit(data, ILI9340_CMD_PIXEL_FORMAT_SET, tx_data, 1);
|
||||
|
||||
tx_data[0] = 0x00;
|
||||
|
||||
@ -12,10 +12,11 @@
|
||||
#define MONITOR_HOR_RES 320
|
||||
#define MONITOR_VER_RES 240
|
||||
#ifndef MONITOR_ZOOM
|
||||
#define MONITOR_ZOOM 1
|
||||
#define MONITOR_ZOOM 1
|
||||
#endif
|
||||
|
||||
extern int ili9340_init();
|
||||
extern int
|
||||
ili9340_init();
|
||||
|
||||
static int lcd_initialized = 0;
|
||||
|
||||
@ -32,15 +33,14 @@ display_init(void)
|
||||
}
|
||||
|
||||
void
|
||||
display_flush(wasm_exec_env_t exec_env,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t *color)
|
||||
display_flush(wasm_exec_env_t exec_env, int32_t x1, int32_t y1, int32_t x2,
|
||||
int32_t y2, lv_color_t *color)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
struct display_buffer_descriptor desc;
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(module_inst,
|
||||
color, sizeof(lv_color_t)))
|
||||
if (!wasm_runtime_validate_native_addr(module_inst, color,
|
||||
sizeof(lv_color_t)))
|
||||
return;
|
||||
|
||||
uint16_t w = x2 - x1 + 1;
|
||||
@ -56,27 +56,23 @@ display_flush(wasm_exec_env_t exec_env,
|
||||
}
|
||||
|
||||
void
|
||||
display_fill(wasm_exec_env_t exec_env,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t *color)
|
||||
{
|
||||
}
|
||||
display_fill(wasm_exec_env_t exec_env, int32_t x1, int32_t y1, int32_t x2,
|
||||
int32_t y2, lv_color_t *color)
|
||||
{}
|
||||
|
||||
void
|
||||
display_map(wasm_exec_env_t exec_env,
|
||||
int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color)
|
||||
{
|
||||
}
|
||||
display_map(wasm_exec_env_t exec_env, int32_t x1, int32_t y1, int32_t x2,
|
||||
int32_t y2, const lv_color_t *color)
|
||||
{}
|
||||
|
||||
bool
|
||||
display_input_read(wasm_exec_env_t exec_env, void *data)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
lv_indev_data_t *lv_data = (lv_indev_data_t*)data;
|
||||
lv_indev_data_t *lv_data = (lv_indev_data_t *)data;
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(module_inst,
|
||||
lv_data, sizeof(lv_indev_data_t)))
|
||||
if (!wasm_runtime_validate_native_addr(module_inst, lv_data,
|
||||
sizeof(lv_indev_data_t)))
|
||||
return false;
|
||||
|
||||
return touchscreen_read(lv_data);
|
||||
@ -84,19 +80,17 @@ display_input_read(wasm_exec_env_t exec_env, void *data)
|
||||
|
||||
void
|
||||
display_deinit(wasm_exec_env_t exec_env)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void
|
||||
display_vdb_write(wasm_exec_env_t exec_env,
|
||||
void *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t *color, lv_opa_t opa)
|
||||
display_vdb_write(wasm_exec_env_t exec_env, void *buf, lv_coord_t buf_w,
|
||||
lv_coord_t x, lv_coord_t y, lv_color_t *color, lv_opa_t opa)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint8_t *buf_xy = (uint8_t*)buf + 3 * x + 3 * y * buf_w;
|
||||
uint8_t *buf_xy = (uint8_t *)buf + 3 * x + 3 * y * buf_w;
|
||||
|
||||
if (!wasm_runtime_validate_native_addr(module_inst,
|
||||
color, sizeof(lv_color_t)))
|
||||
if (!wasm_runtime_validate_native_addr(module_inst, color,
|
||||
sizeof(lv_color_t)))
|
||||
return;
|
||||
|
||||
*buf_xy = color->red;
|
||||
@ -109,4 +103,3 @@ time_get_ms(wasm_exec_env_t exec_env)
|
||||
{
|
||||
return k_uptime_get_32();
|
||||
}
|
||||
|
||||
|
||||
@ -20,15 +20,17 @@
|
||||
#include <drivers/uart.h>
|
||||
#include <device.h>
|
||||
|
||||
|
||||
extern void init_sensor_framework();
|
||||
extern void exit_sensor_framework();
|
||||
extern int aee_host_msg_callback(void *msg, uint32_t msg_len);
|
||||
extern void
|
||||
init_sensor_framework();
|
||||
extern void
|
||||
exit_sensor_framework();
|
||||
extern int
|
||||
aee_host_msg_callback(void *msg, uint32_t msg_len);
|
||||
|
||||
int uart_char_cnt = 0;
|
||||
|
||||
static void uart_irq_callback(const struct device *dev,
|
||||
void *user_data)
|
||||
static void
|
||||
uart_irq_callback(const struct device *dev, void *user_data)
|
||||
{
|
||||
unsigned char ch;
|
||||
|
||||
@ -41,7 +43,8 @@ static void uart_irq_callback(const struct device *dev,
|
||||
|
||||
const struct device *uart_dev = NULL;
|
||||
|
||||
static bool host_init()
|
||||
static bool
|
||||
host_init()
|
||||
{
|
||||
uart_dev = device_get_binding(HOST_DEVICE_COMM_UART_NAME);
|
||||
if (!uart_dev) {
|
||||
@ -53,7 +56,8 @@ static bool host_init()
|
||||
return true;
|
||||
}
|
||||
|
||||
int host_send(void * ctx, const char *buf, int size)
|
||||
int
|
||||
host_send(void *ctx, const char *buf, int size)
|
||||
{
|
||||
if (!uart_dev)
|
||||
return 0;
|
||||
@ -64,15 +68,17 @@ int host_send(void * ctx, const char *buf, int size)
|
||||
return size;
|
||||
}
|
||||
|
||||
void host_destroy()
|
||||
{
|
||||
}
|
||||
void
|
||||
host_destroy()
|
||||
{}
|
||||
|
||||
/* clang-format off */
|
||||
host_interface interface = {
|
||||
.init = host_init,
|
||||
.send = host_send,
|
||||
.destroy = host_destroy
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
timer_ctx_t timer_ctx;
|
||||
|
||||
@ -87,7 +93,8 @@ static NativeSymbol native_symbols[] = {
|
||||
EXPORT_WASM_API_WITH_SIG(time_get_ms, "()i")
|
||||
};
|
||||
|
||||
int iwasm_main()
|
||||
int
|
||||
iwasm_main()
|
||||
{
|
||||
RuntimeInitArgs init_args;
|
||||
|
||||
|
||||
@ -10,15 +10,17 @@
|
||||
#include "bh_log.h"
|
||||
#include "wasm_export.h"
|
||||
|
||||
extern void display_init(void);
|
||||
extern int iwasm_main();
|
||||
extern void
|
||||
display_init(void);
|
||||
extern int
|
||||
iwasm_main();
|
||||
|
||||
void main(void)
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
display_init();
|
||||
iwasm_main();
|
||||
for(;;){
|
||||
for (;;) {
|
||||
k_sleep(Z_TIMEOUT_MS(1000));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,21 +6,21 @@
|
||||
#define __PIN_CONFIG_JLF_H__
|
||||
|
||||
#define DT_ILITEK_ILI9340_0_BUS_NAME "SPI_2"
|
||||
#define DT_ILITEK_ILI9340_0_SPI_MAX_FREQUENCY 10*1000
|
||||
#define DT_ILITEK_ILI9340_0_SPI_MAX_FREQUENCY 10 * 1000
|
||||
|
||||
#define DT_ILITEK_ILI9340_0_BASE_ADDRESS 1
|
||||
#define DT_ILITEK_ILI9340_0_BASE_ADDRESS 1
|
||||
#define DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER "GPIO_0"
|
||||
#define DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN 5
|
||||
#define DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER "GPIO_0"
|
||||
#define DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN 4
|
||||
|
||||
#define XPT2046_SPI_DEVICE_NAME "SPI_2"
|
||||
#define XPT2046_SPI_MAX_FREQUENCY 10*1000
|
||||
#define XPT2046_SPI_MAX_FREQUENCY 10 * 1000
|
||||
#define XPT2046_CS_GPIO_CONTROLLER "GPIO_0"
|
||||
#define XPT2046_CS_GPIO_PIN 6
|
||||
#define XPT2046_CS_GPIO_PIN 6
|
||||
|
||||
#define XPT2046_PEN_GPIO_CONTROLLER "GPIO_0"
|
||||
#define XPT2046_PEN_GPIO_PIN 7
|
||||
#define XPT2046_PEN_GPIO_PIN 7
|
||||
|
||||
#define HOST_DEVICE_COMM_UART_NAME "UART_1"
|
||||
#endif /* __PIN_CONFIG_JLF_H__ */
|
||||
|
||||
@ -6,24 +6,24 @@
|
||||
#define __PIN_CONFIG_STM32_H__
|
||||
|
||||
#define DT_ILITEK_ILI9340_0_BUS_NAME "SPI_1"
|
||||
#define DT_ILITEK_ILI9340_0_SPI_MAX_FREQUENCY 24*1000*1000
|
||||
#define DT_ILITEK_ILI9340_0_SPI_MAX_FREQUENCY 24 * 1000 * 1000
|
||||
|
||||
#define DT_ILITEK_ILI9340_0_BASE_ADDRESS 1
|
||||
#define DT_ILITEK_ILI9340_0_BASE_ADDRESS 1
|
||||
#define DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER "GPIOC"
|
||||
#define DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN 12
|
||||
#define DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN 12
|
||||
#define DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER "GPIOC"
|
||||
#define DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN 11
|
||||
|
||||
#define DT_ILITEK_ILI9340_0_CS_GPIO_CONTROLLER "GPIOC"
|
||||
#define DT_ILITEK_ILI9340_0_CS_GPIO_PIN 10
|
||||
#define DT_ILITEK_ILI9340_0_CS_GPIO_CONTROLLER "GPIOC"
|
||||
#define DT_ILITEK_ILI9340_0_CS_GPIO_PIN 10
|
||||
|
||||
#define XPT2046_SPI_DEVICE_NAME "SPI_1"
|
||||
#define XPT2046_SPI_MAX_FREQUENCY 12*1000*1000
|
||||
#define XPT2046_SPI_MAX_FREQUENCY 12 * 1000 * 1000
|
||||
#define XPT2046_CS_GPIO_CONTROLLER "GPIOD"
|
||||
#define XPT2046_CS_GPIO_PIN 0
|
||||
#define XPT2046_CS_GPIO_PIN 0
|
||||
|
||||
#define XPT2046_PEN_GPIO_CONTROLLER "GPIOD"
|
||||
#define XPT2046_PEN_GPIO_PIN 1
|
||||
#define XPT2046_PEN_GPIO_PIN 1
|
||||
|
||||
#define HOST_DEVICE_COMM_UART_NAME "UART_6"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user