Skip to content

Commit 2a74e2d

Browse files
authored
Clean compiling warnings of zephyr samples (#202)
1 parent 63cbe4a commit 2a74e2d

File tree

4 files changed

+46
-44
lines changed

4 files changed

+46
-44
lines changed

samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
* STATIC PROTOTYPES
3232
**********************/
3333
static void xpt2046_corr(int16_t * x, int16_t * y);
34+
#if 0
3435
static void xpt2046_avg(int16_t * x, int16_t * y);
36+
#endif
3537

3638
/**********************
3739
* STATIC VARIABLES
@@ -73,7 +75,6 @@ int last_pen_interrupt_time = 0;
7375
void xpt2046_pen_gpio_callback(struct device *port, struct gpio_callback *cb,
7476
u32_t pins)
7577
{
76-
int i;
7778
cnt++;
7879
if ((k_uptime_get_32() - last_pen_interrupt_time) > 500) {
7980
k_sem_give(&sem_touch_read);
@@ -86,15 +87,15 @@ void xpt2046_pen_gpio_callback(struct device *port, struct gpio_callback *cb,
8687
void disable_pen_interrupt()
8788
{
8889
int ret = 0;
89-
ret = gpio_pin_disable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
90+
ret = gpio_disable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
9091
if (ret != 0) {
91-
printf("gpio_pin_configure GPIO_DIR_IN failed\n");
92+
printf("gpio_pin_configure GPIO_INPUT failed\n");
9293
}
9394
}
9495
void enable_pen_interrupt()
9596
{
9697
int ret = 0;
97-
ret = gpio_pin_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
98+
ret = gpio_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
9899
if (ret != 0) {
99100
printf("gpio_pin_configure failed\n");
100101
}
@@ -152,8 +153,8 @@ void xpt2046_init(void)
152153
return;
153154
}
154155
gpio_pin_configure(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN,
155-
GPIO_DIR_OUT);
156-
gpio_pin_write(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN, 1);
156+
GPIO_OUTPUT);
157+
gpio_pin_set(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN, 1);
157158
xpt2046_cs_ctrl.gpio_pin = XPT2046_CS_GPIO_PIN;
158159
xpt2046_cs_ctrl.delay = 0;
159160
spi_conf_xpt2046.cs = &xpt2046_cs_ctrl;
@@ -169,8 +170,8 @@ void xpt2046_init(void)
169170
}
170171
/* Setup GPIO input */
171172
ret = gpio_pin_configure(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN,
172-
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
173-
| GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE)
173+
(GPIO_INPUT | GPIO_INT_ENABLE | GPIO_INT_EDGE
174+
| GPIO_INT_LOW_0 | GPIO_INT_DEBOUNCE)
174175
);
175176
if (ret) {
176177
printk("Error configuring pin %d!\n", XPT2046_PEN_GPIO_PIN);
@@ -183,9 +184,9 @@ void xpt2046_init(void)
183184
if (ret) {
184185
printk("gpio_add_callback error\n");
185186
}
186-
ret = gpio_pin_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
187+
ret = gpio_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
187188
if (ret) {
188-
printk("gpio_pin_enable_callback error\n");
189+
printk("gpio_enable_callback error\n");
189190
}
190191
#endif
191192

@@ -209,7 +210,6 @@ bool xpt2046_read(lv_indev_data_t * data)
209210
static int16_t last_y = 0;
210211
bool valid = true;
211212
int s32_ret = 0;
212-
uint8_t buf;
213213

214214
int16_t x = 0;
215215
int16_t y = 0;
@@ -293,6 +293,7 @@ static void xpt2046_corr(int16_t * x, int16_t * y)
293293

294294
}
295295

296+
#if 0
296297
static void xpt2046_avg(int16_t * x, int16_t * y)
297298
{
298299
/*Shift out the oldest data*/
@@ -320,6 +321,7 @@ static void xpt2046_avg(int16_t * x, int16_t * y)
320321
(*x) = (int32_t) x_sum / avg_last;
321322
(*y) = (int32_t) y_sum / avg_last;
322323
}
324+
#endif
323325

324326
bool touchscreen_read(lv_indev_data_t * data)
325327
{

samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <sys/byteorder.h>
1919
#include <drivers/spi.h>
2020
#include <string.h>
21+
#include <stdio.h>
2122

2223
struct ili9340_data {
2324
struct device *reset_gpio;
@@ -62,29 +63,29 @@ int ili9340_init()
6263
data->spi_config.cs = NULL;
6364
#endif
6465
data->reset_gpio = device_get_binding(
65-
DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER);
66+
DT_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER);
6667
if (data->reset_gpio == NULL) {
6768
return -EPERM;
6869
}
6970

7071
gpio_pin_configure(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN,
71-
GPIO_DIR_OUT);
72+
GPIO_OUTPUT);
7273

7374
data->command_data_gpio = device_get_binding(
74-
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER);
75+
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER);
7576
if (data->command_data_gpio == NULL) {
7677
return -EPERM;
7778
}
7879

7980
gpio_pin_configure(data->command_data_gpio,
80-
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN, GPIO_DIR_OUT);
81+
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN, GPIO_OUTPUT);
8182

8283
LOG_DBG("Resetting display driver\n");
83-
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
84+
gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
8485
k_sleep(1);
85-
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 0);
86+
gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 0);
8687
k_sleep(1);
87-
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
88+
gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
8889
k_sleep(5);
8990

9091
LOG_DBG("Initializing LCD\n");
@@ -228,19 +229,17 @@ static void ili9340_get_capabilities(const struct device *dev,
228229
void ili9340_transmit(struct ili9340_data *data, u8_t cmd, void *tx_data,
229230
size_t tx_len)
230231
{
231-
int i;
232-
char * buf1 = tx_data;
233232
data = (struct ili9340_data *) &ili9340_data1;
234233
struct spi_buf tx_buf = { .buf = &cmd, .len = 1 };
235234
struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 };
236235

237-
gpio_pin_write(data->command_data_gpio, DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
236+
gpio_pin_set(data->command_data_gpio, DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
238237
ILI9340_CMD_DATA_PIN_COMMAND);
239238
spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
240239
if (tx_data != NULL) {
241240
tx_buf.buf = tx_data;
242241
tx_buf.len = tx_len;
243-
gpio_pin_write(data->command_data_gpio,
242+
gpio_pin_set(data->command_data_gpio,
244243
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
245244
ILI9340_CMD_DATA_PIN_DATA);
246245
spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);

samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
* STATIC PROTOTYPES
3232
**********************/
3333
static void xpt2046_corr(int16_t * x, int16_t * y);
34+
#if 0
3435
static void xpt2046_avg(int16_t * x, int16_t * y);
36+
#endif
3537

3638
/**********************
3739
* STATIC VARIABLES
@@ -73,7 +75,6 @@ int last_pen_interrupt_time = 0;
7375
void xpt2046_pen_gpio_callback(struct device *port, struct gpio_callback *cb,
7476
u32_t pins)
7577
{
76-
int i;
7778
cnt++;
7879
if ((k_uptime_get_32() - last_pen_interrupt_time) > 500) {
7980
k_sem_give(&sem_touch_read);
@@ -86,15 +87,15 @@ void xpt2046_pen_gpio_callback(struct device *port, struct gpio_callback *cb,
8687
void disable_pen_interrupt()
8788
{
8889
int ret = 0;
89-
ret = gpio_pin_disable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
90+
ret = gpio_disable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
9091
if (ret != 0) {
91-
printf("gpio_pin_configure GPIO_DIR_IN failed\n");
92+
printf("gpio_pin_configure GPIO_INPUT failed\n");
9293
}
9394
}
9495
void enable_pen_interrupt()
9596
{
9697
int ret = 0;
97-
ret = gpio_pin_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
98+
ret = gpio_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
9899
if (ret != 0) {
99100
printf("gpio_pin_configure failed\n");
100101
}
@@ -152,8 +153,8 @@ void xpt2046_init(void)
152153
return;
153154
}
154155
gpio_pin_configure(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN,
155-
GPIO_DIR_OUT);
156-
gpio_pin_write(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN, 1);
156+
GPIO_OUTPUT);
157+
gpio_pin_set(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN, 1);
157158
xpt2046_cs_ctrl.gpio_pin = XPT2046_CS_GPIO_PIN;
158159
xpt2046_cs_ctrl.delay = 0;
159160
spi_conf_xpt2046.cs = &xpt2046_cs_ctrl;
@@ -169,8 +170,8 @@ void xpt2046_init(void)
169170
}
170171
/* Setup GPIO input */
171172
ret = gpio_pin_configure(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN,
172-
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
173-
| GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE)
173+
(GPIO_INPUT | GPIO_INT_ENABLE | GPIO_INT_EDGE
174+
| GPIO_INT_LOW_0 | GPIO_INT_DEBOUNCE)
174175
);
175176
if (ret) {
176177
printk("Error configuring pin %d!\n", XPT2046_PEN_GPIO_PIN);
@@ -183,9 +184,9 @@ void xpt2046_init(void)
183184
if (ret) {
184185
printk("gpio_add_callback error\n");
185186
}
186-
ret = gpio_pin_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
187+
ret = gpio_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
187188
if (ret) {
188-
printk("gpio_pin_enable_callback error\n");
189+
printk("gpio_enable_callback error\n");
189190
}
190191
#endif
191192

@@ -209,7 +210,6 @@ bool xpt2046_read(lv_indev_data_t * data)
209210
static int16_t last_y = 0;
210211
bool valid = true;
211212
int s32_ret = 0;
212-
uint8_t buf;
213213

214214
int16_t x = 0;
215215
int16_t y = 0;
@@ -293,6 +293,7 @@ static void xpt2046_corr(int16_t * x, int16_t * y)
293293

294294
}
295295

296+
#if 0
296297
static void xpt2046_avg(int16_t * x, int16_t * y)
297298
{
298299
/*Shift out the oldest data*/
@@ -320,6 +321,7 @@ static void xpt2046_avg(int16_t * x, int16_t * y)
320321
(*x) = (int32_t) x_sum / avg_last;
321322
(*y) = (int32_t) y_sum / avg_last;
322323
}
324+
#endif
323325

324326
bool touchscreen_read(lv_indev_data_t * data)
325327
{

samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <sys/byteorder.h>
1919
#include <drivers/spi.h>
2020
#include <string.h>
21+
#include <stdio.h>
2122

2223
struct ili9340_data {
2324
struct device *reset_gpio;
@@ -68,7 +69,7 @@ int ili9340_init()
6869
}
6970

7071
gpio_pin_configure(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN,
71-
GPIO_DIR_OUT);
72+
GPIO_OUTPUT);
7273

7374
data->command_data_gpio = device_get_binding(
7475
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER);
@@ -77,14 +78,14 @@ int ili9340_init()
7778
}
7879

7980
gpio_pin_configure(data->command_data_gpio,
80-
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN, GPIO_DIR_OUT);
81+
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN, GPIO_OUTPUT);
8182

8283
LOG_DBG("Resetting display driver\n");
83-
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
84+
gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
8485
k_sleep(1);
85-
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 0);
86+
gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 0);
8687
k_sleep(1);
87-
gpio_pin_write(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
88+
gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
8889
k_sleep(5);
8990

9091
LOG_DBG("Initializing LCD\n");
@@ -228,30 +229,28 @@ static void ili9340_get_capabilities(const struct device *dev,
228229
void ili9340_transmit(struct ili9340_data *data, u8_t cmd, void *tx_data,
229230
size_t tx_len)
230231
{
231-
int i;
232-
char * buf1 = tx_data;
233232
data = (struct ili9340_data *) &ili9340_data1;
234233
struct spi_buf tx_buf = { .buf = &cmd, .len = 1 };
235234
struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 };
236235

237-
gpio_pin_write(data->command_data_gpio, DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
236+
gpio_pin_set(data->command_data_gpio, DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
238237
ILI9340_CMD_DATA_PIN_COMMAND);
239238
spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
240239
if (tx_data != NULL) {
241240
tx_buf.buf = tx_data;
242241
tx_buf.len = tx_len;
243-
gpio_pin_write(data->command_data_gpio,
242+
gpio_pin_set(data->command_data_gpio,
244243
DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN,
245244
ILI9340_CMD_DATA_PIN_DATA);
246245
spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
247246
}
248247
}
249248

250-
struct display_driver_api ili9340_api1 ={
249+
struct display_driver_api ili9340_api1 = {
251250
.blanking_on = ili9340_display_blanking_on,
252251
.blanking_off = ili9340_display_blanking_off,
253252
.write = ili9340_write,
254-
.read = ili9340_read,
253+
.read = ili9340_read,
255254
.get_framebuffer = ili9340_get_framebuffer,
256255
.set_brightness = ili9340_set_brightness,
257256
.set_contrast = ili9340_set_contrast,

0 commit comments

Comments
 (0)