summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src')
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h96
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c347
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c544
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c11
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c97
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE202
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c345
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h87
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h9
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h418
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c284
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h70
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c80
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c105
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c131
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c26
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h26
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h30
18 files changed, 2908 insertions, 0 deletions
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h
new file mode 100644
index 000000000..273d0ad03
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h
@@ -0,0 +1,96 @@
+#ifndef DISPLAY_INDEV_H_
+#define DISPLAY_INDEV_H_
+#include <stdio.h>
+#include <stdbool.h>
+#include <inttypes.h>
+#include "bh_platform.h"
+#include "wasm_export.h"
+
+#define USE_MOUSE 1
+typedef union {
+ struct {
+ uint8_t blue;
+ uint8_t green;
+ uint8_t red;
+ uint8_t alpha;
+ };
+ uint32_t full;
+} lv_color32_t;
+
+typedef lv_color32_t lv_color_t;
+typedef uint8_t lv_indev_state_t;
+typedef int16_t lv_coord_t;
+typedef uint8_t lv_opa_t;
+typedef struct {
+ lv_coord_t x;
+ lv_coord_t y;
+} lv_point_t;
+
+typedef struct {
+ union {
+ 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*/
+ };
+ 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;
+
+enum { LV_INDEV_STATE_REL = 0, LV_INDEV_STATE_PR };
+enum {
+ LV_OPA_TRANSP = 0,
+ LV_OPA_0 = 0,
+ LV_OPA_10 = 25,
+ LV_OPA_20 = 51,
+ LV_OPA_30 = 76,
+ LV_OPA_40 = 102,
+ LV_OPA_50 = 127,
+ LV_OPA_60 = 153,
+ LV_OPA_70 = 178,
+ LV_OPA_80 = 204,
+ LV_OPA_90 = 229,
+ LV_OPA_100 = 255,
+ LV_OPA_COVER = 255,
+};
+
+extern void
+xpt2046_init(void);
+
+extern bool
+touchscreen_read(lv_indev_data_t *data);
+
+extern bool
+mouse_read(lv_indev_data_t *data);
+
+extern void
+display_init(void);
+
+extern void
+display_deinit(wasm_exec_env_t exec_env);
+
+extern int
+time_get_ms(wasm_exec_env_t exec_env);
+
+extern 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);
+
+extern 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);
+
+extern 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);
+
+extern bool
+display_input_read(wasm_exec_env_t exec_env, void *data);
+
+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);
+
+#endif
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c
new file mode 100644
index 000000000..2b3b00067
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c
@@ -0,0 +1,347 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include "display_indev.h"
+#include "SDL2/SDL.h"
+#include "sys/time.h"
+#include "wasm_export.h"
+#include "app_manager_export.h"
+
+#define MONITOR_HOR_RES 320
+#define MONITOR_VER_RES 240
+#ifndef MONITOR_ZOOM
+#define MONITOR_ZOOM 1
+#endif
+#define SDL_REFR_PERIOD 50
+void
+monitor_sdl_init(void);
+void
+monitor_sdl_refr_core(void);
+void
+monitor_sdl_clean_up(void);
+
+static uint32_t tft_fb[MONITOR_HOR_RES * MONITOR_VER_RES];
+
+int
+time_get_ms(wasm_exec_env_t exec_env)
+{
+ static struct timeval tv;
+ gettimeofday(&tv, NULL);
+ long long time_in_mill = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000;
+
+ return (int)time_in_mill;
+}
+
+SDL_Window *window;
+SDL_Renderer *renderer;
+SDL_Texture *texture;
+static volatile bool sdl_inited = false;
+static volatile bool sdl_refr_qry = false;
+static volatile bool sdl_quit_qry = false;
+
+void
+monitor_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
+ const lv_color_t *color)
+{
+ /*Return if the area is out the screen*/
+ if (x2 < 0 || y2 < 0 || x1 > MONITOR_HOR_RES - 1
+ || y1 > MONITOR_VER_RES - 1) {
+ return;
+ }
+
+ int32_t y;
+ uint32_t w = x2 - x1 + 1;
+
+ for (y = y1; y <= y2; y++) {
+ memcpy(&tft_fb[y * MONITOR_HOR_RES + x1], color,
+ w * sizeof(lv_color_t));
+
+ color += w;
+ }
+ sdl_refr_qry = true;
+
+ /*IMPORTANT! It must be called to tell the system the flush is ready*/
+}
+
+/**
+ * Fill out the marked area with a color
+ * @param x1 left coordinate
+ * @param y1 top coordinate
+ * @param x2 right coordinate
+ * @param y2 bottom coordinate
+ * @param color fill color
+ */
+void
+monitor_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color)
+{
+ /*Return if the area is out the screen*/
+ if (x2 < 0)
+ return;
+ if (y2 < 0)
+ return;
+ if (x1 > MONITOR_HOR_RES - 1)
+ return;
+ if (y1 > MONITOR_VER_RES - 1)
+ return;
+
+ /*Truncate the area to the screen*/
+ int32_t act_x1 = x1 < 0 ? 0 : x1;
+ int32_t act_y1 = y1 < 0 ? 0 : y1;
+ int32_t act_x2 = x2 > MONITOR_HOR_RES - 1 ? MONITOR_HOR_RES - 1 : x2;
+ int32_t act_y2 = y2 > MONITOR_VER_RES - 1 ? MONITOR_VER_RES - 1 : y2;
+
+ int32_t x;
+ int32_t y;
+ uint32_t color32 = color->full; // lv_color_to32(color);
+
+ for (x = act_x1; x <= act_x2; x++) {
+ for (y = act_y1; y <= act_y2; y++) {
+ tft_fb[y * MONITOR_HOR_RES + x] = color32;
+ }
+ }
+
+ sdl_refr_qry = true;
+}
+
+/**
+ * Put a color map to the marked area
+ * @param x1 left coordinate
+ * @param y1 top coordinate
+ * @param x2 right coordinate
+ * @param y2 bottom coordinate
+ * @param color an array of colors
+ */
+void
+monitor_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
+ const lv_color_t *color)
+{
+ /*Return if the area is out the screen*/
+ if (x2 < 0)
+ return;
+ if (y2 < 0)
+ return;
+ if (x1 > MONITOR_HOR_RES - 1)
+ return;
+ if (y1 > MONITOR_VER_RES - 1)
+ return;
+
+ /*Truncate the area to the screen*/
+ int32_t act_x1 = x1 < 0 ? 0 : x1;
+ int32_t act_y1 = y1 < 0 ? 0 : y1;
+ int32_t act_x2 = x2 > MONITOR_HOR_RES - 1 ? MONITOR_HOR_RES - 1 : x2;
+ int32_t act_y2 = y2 > MONITOR_VER_RES - 1 ? MONITOR_VER_RES - 1 : y2;
+
+ int32_t x;
+ int32_t y;
+
+ for (y = act_y1; y <= act_y2; y++) {
+ for (x = act_x1; x <= act_x2; x++) {
+ tft_fb[y * MONITOR_HOR_RES + x] =
+ color->full; // lv_color_to32(*color);
+ color++;
+ }
+
+ color += x2 - act_x2;
+ }
+
+ sdl_refr_qry = true;
+}
+
+void
+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)
+{
+ wasm_module_inst_t module_inst = get_module_inst(exec_env);
+
+ if (!wasm_runtime_validate_native_addr(module_inst, color,
+ sizeof(lv_color_t)))
+ return;
+
+ monitor_flush(x1, y1, x2, y2, color);
+}
+
+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)
+{
+ monitor_fill(x1, y1, x2, y2, 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)
+{
+ monitor_map(x1, y1, x2, y2, color);
+}
+
+typedef struct display_input_data {
+ lv_point_t point;
+ uint32 user_data_offset;
+ uint8 state;
+} display_input_data;
+
+bool
+display_input_read(wasm_exec_env_t exec_env, void *input_data_app)
+{
+ wasm_module_inst_t module_inst = get_module_inst(exec_env);
+ display_input_data *data_app = (display_input_data *)input_data_app;
+ bool ret;
+
+ if (!wasm_runtime_validate_native_addr(module_inst, data_app,
+ sizeof(display_input_data)))
+ return false;
+
+ lv_indev_data_t data = { 0 };
+
+ ret = mouse_read(&data);
+
+ data_app->point = data.point;
+ data_app->user_data_offset =
+ wasm_runtime_addr_native_to_app(module_inst, data.user_data);
+ data_app->state = data.state;
+
+ return ret;
+}
+
+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)
+{
+ wasm_module_inst_t module_inst = get_module_inst(exec_env);
+ unsigned char *buf_xy = (unsigned char *)buf + 4 * x + 4 * y * buf_w;
+
+ if (!wasm_runtime_validate_native_addr(module_inst, color,
+ sizeof(lv_color_t)))
+ return;
+
+ *(lv_color_t *)buf_xy = *color;
+}
+
+int
+monitor_sdl_refr_thread(void *param)
+{
+ (void)param;
+
+ /*If not OSX initialize SDL in the Thread*/
+ monitor_sdl_init();
+ /*Run until quit event not arrives*/
+ while (sdl_quit_qry == false) {
+ /*Refresh handling*/
+ monitor_sdl_refr_core();
+ }
+
+ monitor_sdl_clean_up();
+ exit(0);
+
+ return 0;
+}
+extern void
+mouse_handler(SDL_Event *event);
+void
+monitor_sdl_refr_core(void)
+{
+ if (sdl_refr_qry != false) {
+ sdl_refr_qry = false;
+
+ SDL_UpdateTexture(texture, NULL, tft_fb,
+ MONITOR_HOR_RES * sizeof(uint32_t));
+ SDL_RenderClear(renderer);
+ /*Update the renderer with the texture containing the rendered image*/
+ SDL_RenderCopy(renderer, texture, NULL, NULL);
+ SDL_RenderPresent(renderer);
+ }
+
+ SDL_Event event;
+ while (SDL_PollEvent(&event)) {
+
+ mouse_handler(&event);
+
+ if ((&event)->type == SDL_WINDOWEVENT) {
+ switch ((&event)->window.event) {
+#if SDL_VERSION_ATLEAST(2, 0, 5)
+ case SDL_WINDOWEVENT_TAKE_FOCUS:
+#endif
+ case SDL_WINDOWEVENT_EXPOSED:
+
+ SDL_UpdateTexture(texture, NULL, tft_fb,
+ MONITOR_HOR_RES * sizeof(uint32_t));
+ SDL_RenderClear(renderer);
+ SDL_RenderCopy(renderer, texture, NULL, NULL);
+ SDL_RenderPresent(renderer);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /*Sleep some time*/
+ SDL_Delay(SDL_REFR_PERIOD);
+}
+int
+quit_filter(void *userdata, SDL_Event *event)
+{
+ (void)userdata;
+
+ if (event->type == SDL_QUIT) {
+ sdl_quit_qry = true;
+ }
+
+ return 1;
+}
+
+void
+monitor_sdl_clean_up(void)
+{
+ SDL_DestroyTexture(texture);
+ SDL_DestroyRenderer(renderer);
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+}
+
+void
+monitor_sdl_init(void)
+{
+ /*Initialize the SDL*/
+ SDL_Init(SDL_INIT_VIDEO);
+
+ SDL_SetEventFilter(quit_filter, NULL);
+
+ window = SDL_CreateWindow(
+ "TFT Simulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+ MONITOR_HOR_RES * MONITOR_ZOOM, MONITOR_VER_RES * MONITOR_ZOOM,
+ 0); /*last param. SDL_WINDOW_BORDERLESS to hide borders*/
+
+ renderer = SDL_CreateRenderer(window, -1, 0);
+ texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
+ SDL_TEXTUREACCESS_STATIC, MONITOR_HOR_RES,
+ MONITOR_VER_RES);
+ SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+
+ /*Initialize the frame buffer to gray (77 is an empirical value) */
+ memset(tft_fb, 0x44, MONITOR_HOR_RES * MONITOR_VER_RES * sizeof(uint32_t));
+ SDL_UpdateTexture(texture, NULL, tft_fb,
+ MONITOR_HOR_RES * sizeof(uint32_t));
+ sdl_refr_qry = true;
+ sdl_inited = true;
+}
+
+void
+display_SDL_init()
+{
+ SDL_CreateThread(monitor_sdl_refr_thread, "sdl_refr", NULL);
+ while (sdl_inited == false)
+ ; /*Wait until 'sdl_refr' initializes the SDL*/
+}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c
new file mode 100644
index 000000000..e2253bb5e
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c
@@ -0,0 +1,544 @@
+
+#ifndef CONNECTION_UART
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#else
+#include <termios.h>
+#endif
+
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <unistd.h>
+#include <strings.h>
+
+#include "runtime_lib.h"
+#include "runtime_timer.h"
+#include "native_interface.h"
+#include "app_manager_export.h"
+#include "bh_platform.h"
+#include "bi-inc/attr_container.h"
+#include "module_wasm_app.h"
+#include "wasm_export.h"
+#include "sensor_native_api.h"
+#include "connection_native_api.h"
+#include "display_indev.h"
+
+#define MAX 2048
+
+#ifndef CONNECTION_UART
+#define SA struct sockaddr
+static char *host_address = "127.0.0.1";
+static int port = 8888;
+#else
+static char *uart_device = "/dev/ttyS2";
+static int baudrate = B115200;
+#endif
+
+extern bool
+init_sensor_framework();
+extern void
+exit_sensor_framework();
+extern void
+exit_connection_framework();
+extern int
+aee_host_msg_callback(void *msg, uint32_t msg_len);
+extern bool
+init_connection_framework();
+
+#ifndef CONNECTION_UART
+int listenfd = -1;
+int sockfd = -1;
+static pthread_mutex_t sock_lock = PTHREAD_MUTEX_INITIALIZER;
+#else
+int uartfd = -1;
+#endif
+
+#ifndef CONNECTION_UART
+static bool server_mode = false;
+
+// Function designed for chat between client and server.
+void *
+func(void *arg)
+{
+ char buff[MAX];
+ int n;
+ struct sockaddr_in servaddr;
+
+ while (1) {
+ if (sockfd != -1)
+ close(sockfd);
+ // socket create and verification
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sockfd == -1) {
+ printf("socket creation failed...\n");
+ return NULL;
+ }
+ else
+ printf("Socket successfully created..\n");
+ bzero(&servaddr, sizeof(servaddr));
+ // assign IP, PORT
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_addr.s_addr = inet_addr(host_address);
+ servaddr.sin_port = htons(port);
+
+ // connect the client socket to server socket
+ if (connect(sockfd, (SA *)&servaddr, sizeof(servaddr)) != 0) {
+ printf("connection with the server failed...\n");
+ sleep(10);
+ continue;
+ }
+ else {
+ printf("connected to the server..\n");
+ }
+
+ // infinite loop for chat
+ for (;;) {
+ bzero(buff, MAX);
+
+ // read the message from client and copy it in buffer
+ n = read(sockfd, buff, sizeof(buff));
+ // print buffer which contains the client contents
+ // fprintf(stderr, "recieved %d bytes from host: %s", n, buff);
+
+ // socket disconnected
+ if (n <= 0)
+ break;
+
+ aee_host_msg_callback(buff, n);
+ }
+ }
+
+ // After chatting close the socket
+ close(sockfd);
+}
+
+static bool
+host_init()
+{
+ return true;
+}
+
+int
+host_send(void *ctx, const char *buf, int size)
+{
+ int ret;
+
+ if (pthread_mutex_trylock(&sock_lock) == 0) {
+ if (sockfd == -1) {
+ pthread_mutex_unlock(&sock_lock);
+ return 0;
+ }
+
+ ret = write(sockfd, buf, size);
+
+ pthread_mutex_unlock(&sock_lock);
+ return ret;
+ }
+
+ return -1;
+}
+
+void
+host_destroy()
+{
+ if (server_mode)
+ close(listenfd);
+
+ pthread_mutex_lock(&sock_lock);
+ close(sockfd);
+ pthread_mutex_unlock(&sock_lock);
+}
+
+host_interface interface = { .init = host_init,
+ .send = host_send,
+ .destroy = host_destroy };
+
+void *
+func_server_mode(void *arg)
+{
+ int clilent;
+ struct sockaddr_in serv_addr, cli_addr;
+ int n;
+ char buff[MAX];
+ struct sigaction sa;
+
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGPIPE, &sa, 0);
+
+ /* First call to socket() function */
+ listenfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ if (listenfd < 0) {
+ perror("ERROR opening socket");
+ exit(1);
+ }
+
+ /* Initialize socket structure */
+ bzero((char *)&serv_addr, sizeof(serv_addr));
+
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_addr.s_addr = INADDR_ANY;
+ serv_addr.sin_port = htons(port);
+
+ /* Now bind the host address using bind() call.*/
+ if (bind(listenfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
+ perror("ERROR on binding");
+ exit(1);
+ }
+
+ listen(listenfd, 5);
+ clilent = sizeof(cli_addr);
+
+ while (1) {
+ pthread_mutex_lock(&sock_lock);
+
+ sockfd = accept(listenfd, (struct sockaddr *)&cli_addr, &clilent);
+
+ pthread_mutex_unlock(&sock_lock);
+
+ if (sockfd < 0) {
+ perror("ERROR on accept");
+ exit(1);
+ }
+
+ printf("connection established!\n");
+
+ for (;;) {
+ bzero(buff, MAX);
+
+ // read the message from client and copy it in buffer
+ n = read(sockfd, buff, sizeof(buff));
+
+ // socket disconnected
+ if (n <= 0) {
+ pthread_mutex_lock(&sock_lock);
+ close(sockfd);
+ sockfd = -1;
+ pthread_mutex_unlock(&sock_lock);
+
+ sleep(2);
+ break;
+ }
+
+ aee_host_msg_callback(buff, n);
+ }
+ }
+}
+
+#else
+static int
+parse_baudrate(int baud)
+{
+ switch (baud) {
+ case 9600:
+ return B9600;
+ case 19200:
+ return B19200;
+ case 38400:
+ return B38400;
+ case 57600:
+ return B57600;
+ case 115200:
+ return B115200;
+ case 230400:
+ return B230400;
+ case 460800:
+ return B460800;
+ case 500000:
+ return B500000;
+ case 576000:
+ return B576000;
+ case 921600:
+ return B921600;
+ case 1000000:
+ return B1000000;
+ case 1152000:
+ return B1152000;
+ case 1500000:
+ return B1500000;
+ case 2000000:
+ return B2000000;
+ case 2500000:
+ return B2500000;
+ case 3000000:
+ return B3000000;
+ case 3500000:
+ return B3500000;
+ case 4000000:
+ return B4000000;
+ default:
+ return -1;
+ }
+}
+static bool
+uart_init(const char *device, int baudrate, int *fd)
+{
+ int uart_fd;
+ struct termios uart_term;
+
+ uart_fd = open(device, O_RDWR | O_NOCTTY);
+
+ if (uart_fd <= 0)
+ return false;
+
+ memset(&uart_term, 0, sizeof(uart_term));
+ uart_term.c_cflag = baudrate | CS8 | CLOCAL | CREAD;
+ uart_term.c_iflag = IGNPAR;
+ uart_term.c_oflag = 0;
+
+ /* set noncanonical mode */
+ uart_term.c_lflag = 0;
+ uart_term.c_cc[VTIME] = 30;
+ uart_term.c_cc[VMIN] = 1;
+ tcflush(uart_fd, TCIFLUSH);
+
+ if (tcsetattr(uart_fd, TCSANOW, &uart_term) != 0) {
+ close(uart_fd);
+ return false;
+ }
+
+ *fd = uart_fd;
+
+ return true;
+}
+
+static void *
+func_uart_mode(void *arg)
+{
+ int n;
+ char buff[MAX];
+
+ if (!uart_init(uart_device, baudrate, &uartfd)) {
+ printf("open uart fail! %s\n", uart_device);
+ return NULL;
+ }
+
+ for (;;) {
+ bzero(buff, MAX);
+
+ n = read(uartfd, buff, sizeof(buff));
+
+ if (n <= 0) {
+ close(uartfd);
+ uartfd = -1;
+ break;
+ }
+
+ aee_host_msg_callback(buff, n);
+ }
+
+ return NULL;
+}
+
+static int
+uart_send(void *ctx, const char *buf, int size)
+{
+ int ret;
+
+ ret = write(uartfd, buf, size);
+
+ return ret;
+}
+
+static void
+uart_destroy()
+{
+ close(uartfd);
+}
+
+static host_interface interface = { .send = uart_send,
+ .destroy = uart_destroy };
+
+#endif
+
+#ifdef __x86_64__
+static char global_heap_buf[400 * 1024] = { 0 };
+#else
+static char global_heap_buf[270 * 1024] = { 0 };
+#endif
+
+/* clang-format off */
+static void showUsage()
+{
+#ifndef CONNECTION_UART
+ printf("Usage:\n");
+ printf("\nWork as TCP server mode:\n");
+ printf("\tvgl_wasm_runtime -s|--server_mode -p|--port <Port>\n");
+ printf("where\n");
+ printf("\t<Port> represents the port that would be listened on and the default is 8888\n");
+ printf("\nWork as TCP client mode:\n");
+ printf("\tvgl_wasm_runtime -a|--host_address <Host Address> -p|--port <Port>\n");
+ printf("where\n");
+ printf("\t<Host Address> represents the network address of host and the default is 127.0.0.1\n");
+ printf("\t<Port> represents the listen port of host and the default is 8888\n");
+#else
+ printf("Usage:\n");
+ printf("\tvgl_wasm_runtime -u <Uart Device> -b <Baudrate>\n\n");
+ printf("where\n");
+ printf("\t<Uart Device> represents the UART device name and the default is /dev/ttyS2\n");
+ printf("\t<Baudrate> represents the UART device baudrate and the default is 115200\n");
+#endif
+ printf("\nNote:\n");
+ printf("\tUse -w|--wasi_root to specify the root dir (default to '.') of WASI wasm modules. \n");
+}
+/* clang-format on */
+
+static bool
+parse_args(int argc, char *argv[])
+{
+ int c;
+
+ while (1) {
+ int optIndex = 0;
+ static struct option longOpts[] = {
+#ifndef CONNECTION_UART
+ { "server_mode", no_argument, NULL, 's' },
+ { "host_address", required_argument, NULL, 'a' },
+ { "port", required_argument, NULL, 'p' },
+#else
+ { "uart", required_argument, NULL, 'u' },
+ { "baudrate", required_argument, NULL, 'b' },
+#endif
+#if WASM_ENABLE_LIBC_WASI != 0
+ { "wasi_root", required_argument, NULL, 'w' },
+#endif
+ { "help", required_argument, NULL, 'h' },
+ { 0, 0, 0, 0 }
+ };
+
+ c = getopt_long(argc, argv, "sa:p:u:b:w:h", longOpts, &optIndex);
+ if (c == -1)
+ break;
+
+ switch (c) {
+#ifndef CONNECTION_UART
+ case 's':
+ server_mode = true;
+ break;
+ case 'a':
+ host_address = optarg;
+ printf("host address: %s\n", host_address);
+ break;
+ case 'p':
+ port = atoi(optarg);
+ printf("port: %d\n", port);
+ break;
+#else
+ case 'u':
+ uart_device = optarg;
+ printf("uart device: %s\n", uart_device);
+ break;
+ case 'b':
+ baudrate = parse_baudrate(atoi(optarg));
+ printf("uart baudrate: %s\n", optarg);
+ break;
+#endif
+#if WASM_ENABLE_LIBC_WASI != 0
+ case 'w':
+ if (!wasm_set_wasi_root_dir(optarg)) {
+ printf("Fail to set wasi root dir: %s\n", optarg);
+ return false;
+ }
+ break;
+#endif
+ case 'h':
+ showUsage();
+ return false;
+ default:
+ showUsage();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static NativeSymbol native_symbols[] = {
+ EXPORT_WASM_API_WITH_SIG(display_input_read, "(*)i"),
+ EXPORT_WASM_API_WITH_SIG(display_flush, "(iiii*)"),
+ EXPORT_WASM_API_WITH_SIG(display_fill, "(iiii*)"),
+ EXPORT_WASM_API_WITH_SIG(display_vdb_write, "(*iii*i)"),
+ EXPORT_WASM_API_WITH_SIG(display_map, "(iiii*)"),
+ EXPORT_WASM_API_WITH_SIG(time_get_ms, "()i")
+};
+
+// Driver function
+int
+iwasm_main(int argc, char *argv[])
+{
+ RuntimeInitArgs init_args;
+ korp_tid tid;
+ uint32 n_native_symbols;
+
+ if (!parse_args(argc, argv))
+ return -1;
+
+ memset(&init_args, 0, sizeof(RuntimeInitArgs));
+
+ init_args.mem_alloc_type = Alloc_With_Pool;
+ init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;
+ init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);
+
+ init_args.native_module_name = "env";
+ init_args.n_native_symbols = sizeof(native_symbols) / sizeof(NativeSymbol);
+ init_args.native_symbols = native_symbols;
+
+ /* initialize runtime environment */
+ if (!wasm_runtime_full_init(&init_args)) {
+ printf("Init runtime environment failed.\n");
+ return -1;
+ }
+
+ if (!init_connection_framework()) {
+ goto fail1;
+ }
+
+ extern void display_SDL_init();
+ display_SDL_init();
+
+ if (!init_sensor_framework()) {
+ goto fail2;
+ }
+
+ /* timer manager */
+ if (!init_wasm_timer()) {
+ goto fail3;
+ }
+
+#ifndef CONNECTION_UART
+ if (server_mode)
+ os_thread_create(&tid, func_server_mode, NULL,
+ BH_APPLET_PRESERVED_STACK_SIZE);
+ else
+ os_thread_create(&tid, func, NULL, BH_APPLET_PRESERVED_STACK_SIZE);
+#else
+ os_thread_create(&tid, func_uart_mode, NULL,
+ BH_APPLET_PRESERVED_STACK_SIZE);
+#endif
+
+ app_manager_startup(&interface);
+
+ exit_wasm_timer();
+
+fail3:
+ exit_sensor_framework();
+
+fail2:
+ exit_connection_framework();
+
+fail1:
+ wasm_runtime_destroy();
+
+ return -1;
+}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c
new file mode 100644
index 000000000..63e24f11d
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+extern int
+iwasm_main(int argc, char *argv[]);
+int
+main(int argc, char *argv[])
+{
+ return iwasm_main(argc, argv);
+}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c
new file mode 100644
index 000000000..45eb8cfe5
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c
@@ -0,0 +1,97 @@
+/**
+ * @file mouse.c
+ *
+ */
+
+/*********************
+ * INCLUDES
+ *********************/
+#include "display_indev.h"
+#include "SDL2/SDL.h"
+#if USE_MOUSE != 0
+
+/*********************
+ * DEFINES
+ *********************/
+#ifndef MONITOR_ZOOM
+#define MONITOR_ZOOM 1
+#endif
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+static bool left_button_down = false;
+static int16_t last_x = 0;
+static int16_t last_y = 0;
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL FUNCTIONS
+ **********************/
+
+/**
+ * Initialize the mouse
+ */
+void
+mouse_init(void)
+{}
+
+/**
+ * Get the current position and state of the mouse
+ * @param data store the mouse data here
+ * @return false: because the points are not buffered, so no more data to be
+ * read
+ */
+bool
+mouse_read(lv_indev_data_t *data)
+{
+ /*Store the collected data*/
+ data->point.x = last_x;
+ data->point.y = last_y;
+ data->state = left_button_down ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
+
+ return false;
+}
+
+/**
+ * It will be called from the main SDL thread
+ */
+void
+mouse_handler(SDL_Event *event)
+{
+ switch (event->type) {
+ case SDL_MOUSEBUTTONUP:
+ if (event->button.button == SDL_BUTTON_LEFT)
+ left_button_down = false;
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ if (event->button.button == SDL_BUTTON_LEFT) {
+ left_button_down = true;
+ last_x = event->motion.x / MONITOR_ZOOM;
+ last_y = event->motion.y / MONITOR_ZOOM;
+ }
+ break;
+ case SDL_MOUSEMOTION:
+ last_x = event->motion.x / MONITOR_ZOOM;
+ last_y = event->motion.y / MONITOR_ZOOM;
+
+ break;
+ }
+}
+
+/**********************
+ * STATIC FUNCTIONS
+ **********************/
+
+#endif
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE
new file mode 100644
index 000000000..8f71f43fe
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE
@@ -0,0 +1,202 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c
new file mode 100644
index 000000000..d59b6c9b7
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c
@@ -0,0 +1,345 @@
+/**
+ * @file XPT2046.c
+ */
+/*********************
+ * INCLUDES
+ *********************/
+#include "XPT2046.h"
+#include "board_config.h"
+#include "stdio.h"
+#include <string.h>
+#include "drivers/spi.h"
+
+#include "zephyr.h"
+#include "kernel.h"
+
+#if USE_XPT2046
+
+#include <stddef.h>
+
+#define abs(x) ((x) < 0 ? -(x) : (x))
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+static void
+xpt2046_corr(int16_t *x, int16_t *y);
+#if 0
+static void xpt2046_avg(int16_t * x, int16_t * y);
+#endif
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+int16_t avg_buf_x[XPT2046_AVG];
+int16_t avg_buf_y[XPT2046_AVG];
+uint8_t avg_last;
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL FUNCTIONS
+ **********************/
+
+/**
+ * Initialize the XPT2046
+ */
+struct device *input_dev;
+
+struct spi_config spi_conf_xpt2046;
+struct spi_cs_control xpt2046_cs_ctrl;
+struct device *xpt2046_pen_gpio_dev;
+static struct gpio_callback gpio_cb;
+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 struct k_thread touch_thread_data;
+static struct k_sem sem_touch_read;
+
+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)
+{
+ cnt++;
+ if ((k_uptime_get_32() - last_pen_interrupt_time) > 500) {
+ k_sem_give(&sem_touch_read);
+ touch_read_times++;
+ last_pen_interrupt_time = k_uptime_get_32();
+ }
+}
+
+void
+disable_pen_interrupt()
+{
+ int ret = 0;
+ ret = gpio_disable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
+ if (ret != 0) {
+ printf("gpio_pin_configure GPIO_INPUT failed\n");
+ }
+}
+void
+enable_pen_interrupt()
+{
+ int ret = 0;
+ ret = gpio_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
+ if (ret != 0) {
+ printf("gpio_pin_configure failed\n");
+ }
+}
+
+void
+touch_screen_read_thread()
+{
+ int i;
+ bool ret = false;
+
+ for (;;) {
+ k_sem_take(&sem_touch_read, K_FOREVER);
+ memset(&last_touch_point, 0, sizeof(lv_indev_data_t));
+ memset(&touch_point, 0, sizeof(lv_indev_data_t));
+ memset(avg_buf_x, 0, sizeof(avg_buf_x));
+ memset(avg_buf_y, 0, sizeof(avg_buf_y));
+ k_mutex_lock(&spi_display_touch_mutex, K_FOREVER);
+ disable_pen_interrupt();
+ for (i = 0; i < 100; i++) {
+ 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)) {
+ break;
+ }
+ last_touch_point = touch_point;
+ }
+ }
+ enable_pen_interrupt();
+ k_mutex_unlock(&spi_display_touch_mutex);
+ }
+}
+
+void
+xpt2046_init(void)
+{
+ int ret;
+ input_dev = device_get_binding(XPT2046_SPI_DEVICE_NAME);
+
+ if (input_dev == NULL) {
+ printf("device not found. Aborting test.");
+ return;
+ }
+ 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);
+ spi_conf_xpt2046.slave = 0;
+ spi_conf_xpt2046.cs = NULL;
+#ifdef XPT2046_CS_GPIO_CONTROLLER
+ xpt2046_cs_ctrl.gpio_dev = device_get_binding(XPT2046_CS_GPIO_CONTROLLER);
+ if (xpt2046_cs_ctrl.gpio_dev == NULL) {
+ printk("Cannot find %s!\n", XPT2046_CS_GPIO_CONTROLLER);
+ return;
+ }
+ gpio_pin_configure(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN,
+ GPIO_OUTPUT);
+ gpio_pin_set(xpt2046_cs_ctrl.gpio_dev, XPT2046_CS_GPIO_PIN, 1);
+ xpt2046_cs_ctrl.gpio_pin = XPT2046_CS_GPIO_PIN;
+ xpt2046_cs_ctrl.delay = 0;
+ spi_conf_xpt2046.cs = &xpt2046_cs_ctrl;
+
+#endif
+
+#ifdef XPT2046_PEN_GPIO_CONTROLLER
+
+ xpt2046_pen_gpio_dev = device_get_binding(XPT2046_PEN_GPIO_CONTROLLER);
+ if (!xpt2046_pen_gpio_dev) {
+ printk("Cannot find %s!\n", XPT2046_PEN_GPIO_CONTROLLER);
+ return;
+ }
+ /* 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));
+ if (ret) {
+ printk("Error configuring pin %d!\n", XPT2046_PEN_GPIO_PIN);
+ }
+
+ gpio_init_callback(&gpio_cb, xpt2046_pen_gpio_callback,
+ BIT(XPT2046_PEN_GPIO_PIN));
+
+ ret = gpio_add_callback(xpt2046_pen_gpio_dev, &gpio_cb);
+ if (ret) {
+ printk("gpio_add_callback error\n");
+ }
+ ret = gpio_enable_callback(xpt2046_pen_gpio_dev, XPT2046_PEN_GPIO_PIN);
+ if (ret) {
+ printk("gpio_enable_callback error\n");
+ }
+#endif
+
+ k_sem_init(&sem_touch_read, 0, 1);
+
+ 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);
+ printf("xpt2046_init ok \n");
+}
+
+/**
+ * Get the current position and state of the touchpad
+ * @param data store the read data here
+ * @return false: because no ore data to be read
+ */
+bool
+xpt2046_read(lv_indev_data_t *data)
+{
+ static int16_t last_x = 0;
+ static int16_t last_y = 0;
+ bool valid = true;
+ int s32_ret = 0;
+
+ int16_t x = 0;
+ int16_t y = 0;
+
+ char tx1[16] = { 0 };
+ char rx1[16] = { 0 };
+
+ struct spi_buf tx_buf = { .buf = &tx1, .len = 3 };
+ struct spi_buf_set tx_bufs = { .buffers = &tx_buf, .count = 1 };
+ struct spi_buf rx_buf = { .buf = &rx1, .len = 3 };
+ struct spi_buf_set rx_bufs = { .buffers = &rx_buf, .count = 1 };
+
+ tx1[0] = CMD_X_READ;
+ s32_ret = spi_transceive(input_dev, &spi_conf_xpt2046, &tx_bufs, &rx_bufs);
+ if (s32_ret != 0) {
+ printf("spi_transceive return failed:%d\n", s32_ret);
+ }
+ x = rx1[1] << 8;
+ x += rx1[2];
+
+ tx1[0] = CMD_Y_READ;
+ s32_ret = spi_transceive(input_dev, &spi_conf_xpt2046, &tx_bufs, &rx_bufs);
+ if (s32_ret != 0) {
+ printf("spi_transceive return failed:%d\n", s32_ret);
+ }
+ y = rx1[1] << 8;
+ y += rx1[2];
+ x = x >> 3;
+ y = y >> 3;
+
+ xpt2046_corr(&x, &y);
+ if (y <= 0 || (x > 320)) {
+ valid = false;
+ }
+
+ last_x = x;
+ last_y = y;
+
+ data->point.x = x;
+ data->point.y = y;
+ data->state = valid == false ? LV_INDEV_STATE_REL : LV_INDEV_STATE_PR;
+
+ return valid;
+}
+
+/**********************
+ * STATIC FUNCTIONS
+ **********************/
+static void
+xpt2046_corr(int16_t *x, int16_t *y)
+{
+#if XPT2046_XY_SWAP != 0
+ int16_t swap_tmp;
+ swap_tmp = *x;
+ *x = *y;
+ *y = swap_tmp;
+#endif
+
+ if ((*x) > XPT2046_X_MIN)
+ (*x) -= XPT2046_X_MIN;
+ else
+ (*x) = 0;
+
+ if ((*y) > XPT2046_Y_MIN)
+ (*y) -= XPT2046_Y_MIN;
+ else
+ (*y) = 0;
+
+ (*x) = (uint32_t)((uint32_t)(*x) * XPT2046_HOR_RES)
+ / (XPT2046_X_MAX - XPT2046_X_MIN);
+
+ (*y) = (uint32_t)((uint32_t)(*y) * XPT2046_VER_RES)
+ / (XPT2046_Y_MAX - XPT2046_Y_MIN);
+
+#if XPT2046_X_INV != 0
+ (*x) = XPT2046_HOR_RES - (*x);
+#endif
+
+#if XPT2046_Y_INV != 0
+ (*y) = XPT2046_VER_RES - (*y);
+#endif
+}
+
+#if 0
+static void xpt2046_avg(int16_t * x, int16_t * y)
+{
+ /*Shift out the oldest data*/
+ uint8_t i;
+ for (i = XPT2046_AVG - 1; i > 0; i--) {
+ avg_buf_x[i] = avg_buf_x[i - 1];
+ avg_buf_y[i] = avg_buf_y[i - 1];
+ }
+
+ /*Insert the new point*/
+ avg_buf_x[0] = *x;
+ avg_buf_y[0] = *y;
+ if (avg_last < XPT2046_AVG)
+ avg_last++;
+
+ /*Sum the x and y coordinates*/
+ int32_t x_sum = 0;
+ int32_t y_sum = 0;
+ for (i = 0; i < avg_last; i++) {
+ x_sum += avg_buf_x[i];
+ y_sum += avg_buf_y[i];
+ }
+
+ /*Normalize the sums*/
+ (*x) = (int32_t) x_sum / avg_last;
+ (*y) = (int32_t) y_sum / avg_last;
+}
+#endif
+
+bool
+touchscreen_read(lv_indev_data_t *data)
+{
+ /*Store the collected data*/
+ data->point.x = last_touch_point.point.x;
+ data->point.y = last_touch_point.point.y;
+ data->state = last_touch_point.state;
+
+ if (last_touch_point.state == LV_INDEV_STATE_PR) {
+ last_touch_point.state = LV_INDEV_STATE_REL;
+ }
+ return false;
+}
+
+#endif
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h
new file mode 100644
index 000000000..3cd3a571d
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h
@@ -0,0 +1,87 @@
+/**
+ * @file XPT2046.h
+ *
+ */
+
+#ifndef XPT2046_H
+#define XPT2046_H
+
+#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 CMD_X_READ 0b10010000
+#define CMD_Y_READ 0b11010000
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*********************
+ * INCLUDES
+ *********************/
+
+#if USE_XPT2046
+#include <autoconf.h>
+#include <stdint.h>
+#include <stdbool.h>
+//#include "lvgl/lv_hal/lv_hal_indev.h"
+#include "device.h"
+#include "drivers/gpio.h"
+#if 1
+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 {
+ lv_coord_t x;
+ lv_coord_t y;
+} lv_point_t;
+
+typedef struct {
+ union {
+ 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*/
+ };
+ 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
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * GLOBAL PROTOTYPES
+ **********************/
+void
+xpt2046_init(void);
+bool
+xpt2046_read(lv_indev_data_t *data);
+
+/**********************
+ * MACROS
+ **********************/
+
+#endif /* USE_XPT2046 */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* XPT2046_H */
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h
new file mode 100644
index 000000000..d7ea279a9
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+#ifndef __BOARD_CONFIG_H__
+#define __BOARD_CONFIG_H__
+#include "pin_config_stm32.h"
+
+#endif /* __BOARD_CONFIG_H__ */
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h
new file mode 100644
index 000000000..c6657a40a
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h
@@ -0,0 +1,418 @@
+/*
+ * Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/**
+ * @file
+ * @brief Public API for display drivers and applications
+ */
+
+#ifndef ZEPHYR_INCLUDE_DISPLAY_H_
+#define ZEPHYR_INCLUDE_DISPLAY_H_
+
+/**
+ * @brief Display Interface
+ * @defgroup display_interface Display Interface
+ * @ingroup display_interfaces
+ * @{
+ */
+
+#include <device.h>
+#include <stddef.h>
+#include <zephyr/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum display_pixel_format {
+ PIXEL_FORMAT_RGB_888 = BIT(0),
+ PIXEL_FORMAT_MONO01 = BIT(1), /* 0=Black 1=White */
+ PIXEL_FORMAT_MONO10 = BIT(2), /* 1=Black 0=White */
+ PIXEL_FORMAT_ARGB_8888 = BIT(3),
+ PIXEL_FORMAT_RGB_565 = BIT(4),
+};
+
+enum display_screen_info {
+ /**
+ * If selected, one octet represents 8 pixels ordered vertically,
+ * otherwise ordered horizontally.
+ */
+ SCREEN_INFO_MONO_VTILED = BIT(0),
+ /**
+ * If selected, the MSB represents the first pixel,
+ * otherwise MSB represents the last pixel.
+ */
+ SCREEN_INFO_MONO_MSB_FIRST = BIT(1),
+ /**
+ * Electrophoretic Display.
+ */
+ SCREEN_INFO_EPD = BIT(2),
+ /**
+ * Screen has two alternating ram buffers
+ */
+ SCREEN_INFO_DOUBLE_BUFFER = BIT(3),
+};
+
+/**
+ * @enum display_orientation
+ * @brief Enumeration with possible display orientation
+ *
+ */
+enum display_orientation {
+ DISPLAY_ORIENTATION_NORMAL,
+ DISPLAY_ORIENTATION_ROTATED_90,
+ DISPLAY_ORIENTATION_ROTATED_180,
+ DISPLAY_ORIENTATION_ROTATED_270,
+};
+
+/**
+ * @struct display_capabilities
+ * @brief Structure holding display capabilities
+ *
+ * @var u16_t display_capabilities::x_resolution
+ * Display resolution in the X direction
+ *
+ * @var u16_t display_capabilities::y_resolution
+ * Display resolution in the Y direction
+ *
+ * @var u32_t display_capabilities::supported_pixel_formats
+ * Bitwise or of pixel formats supported by the display
+ *
+ * @var u32_t display_capabilities::screen_info
+ * Information about display panel
+ *
+ * @var enum display_pixel_format display_capabilities::current_pixel_format
+ * Currently active pixel format for the display
+ *
+ * @var enum display_orientation display_capabilities::current_orientation
+ * Current display orientation
+ *
+ */
+struct display_capabilities {
+ uint16_t x_resolution;
+ uint16_t y_resolution;
+ uint32_t supported_pixel_formats;
+ uint32_t screen_info;
+ enum display_pixel_format current_pixel_format;
+ enum display_orientation current_orientation;
+};
+
+/**
+ * @struct display_buffer_descriptor
+ * @brief Structure to describe display data buffer layout
+ *
+ * @var u32_t display_buffer_descriptor::buf_size
+ * Data buffer size in bytes
+ *
+ * @var u16_t display_buffer_descriptor::width
+ * Data buffer row width in pixels
+ *
+ * @var u16_t display_buffer_descriptor::height
+ * Data buffer column height in pixels
+ *
+ * @var u16_t display_buffer_descriptor::pitch
+ * Number of pixels between consecutive rows in the data buffer
+ *
+ */
+struct display_buffer_descriptor {
+ uint32_t buf_size;
+ uint16_t width;
+ uint16_t height;
+ uint16_t pitch;
+};
+
+/**
+ * @typedef display_blanking_on_api
+ * @brief Callback API to turn on display blanking
+ * See display_blanking_on() for argument description
+ */
+typedef int (*display_blanking_on_api)(const struct device *dev);
+
+/**
+ * @typedef display_blanking_off_api
+ * @brief Callback API to turn off display blanking
+ * See display_blanking_off() for argument description
+ */
+typedef int (*display_blanking_off_api)(const struct device *dev);
+
+/**
+ * @typedef display_write_api
+ * @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,
+ const struct display_buffer_descriptor *desc,
+ const void *buf);
+
+/**
+ * @typedef display_read_api
+ * @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,
+ const struct display_buffer_descriptor *desc,
+ void *buf);
+
+/**
+ * @typedef display_get_framebuffer_api
+ * @brief Callback API to get framebuffer pointer
+ * See display_get_framebuffer() for argument description
+ */
+typedef void *(*display_get_framebuffer_api)(const struct device *dev);
+
+/**
+ * @typedef display_set_brightness_api
+ * @brief Callback API to set display brightness
+ * See display_set_brightness() for argument description
+ */
+typedef int (*display_set_brightness_api)(const struct device *dev,
+ const uint8_t brightness);
+
+/**
+ * @typedef display_set_contrast_api
+ * @brief Callback API to set display contrast
+ * See display_set_contrast() for argument description
+ */
+typedef int (*display_set_contrast_api)(const struct device *dev,
+ const uint8_t contrast);
+
+/**
+ * @typedef display_get_capabilities_api
+ * @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 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 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);
+
+/**
+ * @brief Display driver API
+ * API which a display driver should expose
+ */
+struct display_driver_api {
+ display_blanking_on_api blanking_on;
+ display_blanking_off_api blanking_off;
+ display_write_api write;
+ display_read_api read;
+ display_get_framebuffer_api get_framebuffer;
+ display_set_brightness_api set_brightness;
+ display_set_contrast_api set_contrast;
+ display_get_capabilities_api get_capabilities;
+ display_set_pixel_format_api set_pixel_format;
+ display_set_orientation_api set_orientation;
+};
+extern struct ili9340_data ili9340_data1;
+extern struct display_driver_api ili9340_api1;
+/**
+ * @brief Write data to display
+ *
+ * @param dev Pointer to device structure
+ * @param x x Coordinate of the upper left corner where to write the buffer
+ * @param y y Coordinate of the upper left corner where to write the buffer
+ * @param desc Pointer to a structure describing the buffer layout
+ * @param buf Pointer to buffer array
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_write(const struct device *dev, const uint16_t x, const uint16_t y,
+ const struct display_buffer_descriptor *desc, const void *buf)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->write(dev, x, y, desc, buf);
+}
+
+/**
+ * @brief Read data from display
+ *
+ * @param dev Pointer to device structure
+ * @param x x Coordinate of the upper left corner where to read from
+ * @param y y Coordinate of the upper left corner where to read from
+ * @param desc Pointer to a structure describing the buffer layout
+ * @param buf Pointer to buffer array
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_read(const struct device *dev, const uint16_t x, const uint16_t y,
+ const struct display_buffer_descriptor *desc, void *buf)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->read(dev, x, y, desc, buf);
+}
+
+/**
+ * @brief Get pointer to framebuffer for direct access
+ *
+ * @param dev Pointer to device structure
+ *
+ * @retval Pointer to frame buffer or NULL if direct framebuffer access
+ * is not supported
+ *
+ */
+static inline void *
+display_get_framebuffer(const struct device *dev)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->get_framebuffer(dev);
+}
+
+/**
+ * @brief Turn display blanking on
+ *
+ * @param dev Pointer to device structure
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_blanking_on(const struct device *dev)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->blanking_on(dev);
+}
+
+/**
+ * @brief Turn display blanking off
+ *
+ * @param dev Pointer to device structure
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_blanking_off(const struct device *dev)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->blanking_off(dev);
+}
+
+/**
+ * @brief Set the brightness of the display
+ *
+ * Set the brightness of the display in steps of 1/256, where 255 is full
+ * brightness and 0 is minimal.
+ *
+ * @param dev Pointer to device structure
+ * @param brightness Brightness in steps of 1/256
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_set_brightness(const struct device *dev, uint8_t brightness)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->set_brightness(dev, brightness);
+}
+
+/**
+ * @brief Set the contrast of the display
+ *
+ * Set the contrast of the display in steps of 1/256, where 255 is maximum
+ * difference and 0 is minimal.
+ *
+ * @param dev Pointer to device structure
+ * @param contrast Contrast in steps of 1/256
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_set_contrast(const struct device *dev, uint8_t contrast)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->set_contrast(dev, contrast);
+}
+
+/**
+ * @brief Get display capabilities
+ *
+ * @param dev Pointer to device structure
+ * @param capabilities Pointer to capabilities structure to populate
+ */
+static inline void
+display_get_capabilities(const struct device *dev,
+ struct display_capabilities *capabilities)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ api->get_capabilities(dev, capabilities);
+}
+
+/**
+ * @brief Set pixel format used by the display
+ *
+ * @param dev Pointer to device structure
+ * @param pixel_format Pixel format to be used by display
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_set_pixel_format(const struct device *dev,
+ const enum display_pixel_format pixel_format)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->set_pixel_format(dev, pixel_format);
+}
+
+/**
+ * @brief Set display orientation
+ *
+ * @param dev Pointer to device structure
+ * @param orientation Orientation to be used by display
+ *
+ * @retval 0 on success else negative errno code.
+ */
+static inline int
+display_set_orientation(const struct device *dev,
+ const enum display_orientation orientation)
+{
+ struct display_driver_api *api = &ili9340_api1;
+ //(struct display_driver_api *)dev->driver_api;
+
+ return api->set_orientation(dev, orientation);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+ * @}
+ */
+
+#endif /* ZEPHYR_INCLUDE_DISPLAY_H_*/
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c
new file mode 100644
index 000000000..e5b0d771a
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "display_ili9340.h"
+#include <display.h>
+
+//#define LOG_LEVEL CONFIG_DISPLAY_LOG_LEVEL
+//#include <logging/log.h>
+// LOG_MODULE_REGISTER(display_ili9340);
+#define LOG_ERR printf
+#define LOG_DBG printf
+#define LOG_WRN printf
+
+#include <drivers/gpio.h>
+#include <sys/byteorder.h>
+#include <drivers/spi.h>
+#include <string.h>
+#include <stdio.h>
+
+struct ili9340_data {
+ struct device *reset_gpio;
+ struct device *command_data_gpio;
+ struct device *spi_dev;
+ struct spi_config spi_config;
+#ifdef DT_ILITEK_ILI9340_0_CS_GPIO_CONTROLLER
+ struct spi_cs_control cs_ctrl;
+#endif
+};
+
+struct ili9340_data ili9340_data1;
+
+#define ILI9340_CMD_DATA_PIN_COMMAND 0
+#define ILI9340_CMD_DATA_PIN_DATA 1
+
+static void
+ili9340_exit_sleep(struct ili9340_data *data)
+{
+ ili9340_transmit(data, ILI9340_CMD_EXIT_SLEEP, NULL, 0);
+ // k_sleep(Z_TIMEOUT_MS(120));
+}
+
+int
+ili9340_init()
+{
+ struct ili9340_data *data = &ili9340_data1;
+
+ printf("Initializing display driver\n");
+ data->spi_dev = device_get_binding(DT_ILITEK_ILI9340_0_BUS_NAME);
+ if (data->spi_dev == NULL) {
+ 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.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);
+ 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);
+ if (data->reset_gpio == NULL) {
+ return -EPERM;
+ }
+
+ 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);
+ if (data->command_data_gpio == NULL) {
+ return -EPERM;
+ }
+
+ gpio_pin_configure(data->command_data_gpio,
+ DT_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN, GPIO_OUTPUT);
+
+ LOG_DBG("Resetting display driver\n");
+ gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
+ k_sleep(Z_TIMEOUT_MS(1));
+ gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 0);
+ k_sleep(Z_TIMEOUT_MS(1));
+ gpio_pin_set(data->reset_gpio, DT_ILITEK_ILI9340_0_RESET_GPIOS_PIN, 1);
+ k_sleep(Z_TIMEOUT_MS(5));
+
+ LOG_DBG("Initializing LCD\n");
+ ili9340_lcd_init(data);
+
+ LOG_DBG("Exiting sleep mode\n");
+ ili9340_exit_sleep(data);
+
+ return 0;
+}
+
+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)
+{
+ uint16_t spi_data[2];
+
+ spi_data[0] = sys_cpu_to_be16(x);
+ spi_data[1] = sys_cpu_to_be16(x + w - 1);
+ ili9340_transmit(data, ILI9340_CMD_COLUMN_ADDR, &spi_data[0], 4);
+
+ spi_data[0] = sys_cpu_to_be16(y);
+ spi_data[1] = sys_cpu_to_be16(y + h - 1);
+ ili9340_transmit(data, ILI9340_CMD_PAGE_ADDR, &spi_data[0], 4);
+}
+
+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 spi_buf tx_buf;
+ struct spi_buf_set tx_bufs;
+ uint16_t write_cnt;
+ uint16_t nbr_of_writes;
+ uint16_t write_h;
+
+ __ASSERT(desc->width <= desc->pitch, "Pitch is smaller then width");
+ __ASSERT((3 * desc->pitch * desc->height) <= desc->buf_size,
+ "Input buffer to small");
+ ili9340_set_mem_area(data, x, y, desc->width, desc->height);
+
+ if (desc->pitch > desc->width) {
+ write_h = 1U;
+ nbr_of_writes = desc->height;
+ }
+ else {
+ write_h = desc->height;
+ nbr_of_writes = 1U;
+ }
+ ili9340_transmit(data, ILI9340_CMD_MEM_WRITE, (void *)write_data_start,
+ 3 * desc->width * write_h);
+
+ tx_bufs.buffers = &tx_buf;
+ tx_bufs.count = 1;
+
+ 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.len = 3 * desc->width * write_h;
+ spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
+ write_data_start += (3 * desc->pitch);
+ }
+
+ return 0;
+}
+
+static int
+ili9340_read(const struct device *dev, const uint16_t x, const uint16_t y,
+ const struct display_buffer_descriptor *desc, void *buf)
+{
+ LOG_ERR("Reading not supported\n");
+ return -ENOTSUP;
+}
+
+static void *
+ili9340_get_framebuffer(const struct device *dev)
+{
+ LOG_ERR("Direct framebuffer access not supported\n");
+ return NULL;
+}
+
+static int
+ili9340_display_blanking_off(const struct device *dev)
+{
+ struct ili9340_data *data = (struct ili9340_data *)dev->driver_data;
+
+ LOG_DBG("Turning display blanking off\n");
+ ili9340_transmit(data, ILI9340_CMD_DISPLAY_ON, NULL, 0);
+ return 0;
+}
+
+static int
+ili9340_display_blanking_on(const struct device *dev)
+{
+ struct ili9340_data *data = (struct ili9340_data *)dev->driver_data;
+
+ LOG_DBG("Turning display blanking on\n");
+ ili9340_transmit(data, ILI9340_CMD_DISPLAY_OFF, NULL, 0);
+ return 0;
+}
+
+static int
+ili9340_set_brightness(const struct device *dev, const uint8_t brightness)
+{
+ LOG_WRN("Set brightness not implemented\n");
+ return -ENOTSUP;
+}
+
+static int
+ili9340_set_contrast(const struct device *dev, const uint8_t contrast)
+{
+ LOG_ERR("Set contrast not supported\n");
+ return -ENOTSUP;
+}
+
+static int
+ili9340_set_pixel_format(const struct device *dev,
+ const enum display_pixel_format pixel_format)
+{
+ if (pixel_format == PIXEL_FORMAT_RGB_888) {
+ return 0;
+ }
+ LOG_ERR("Pixel format change not implemented\n");
+ return -ENOTSUP;
+}
+
+static int
+ili9340_set_orientation(const struct device *dev,
+ const enum display_orientation orientation)
+{
+ if (orientation == DISPLAY_ORIENTATION_NORMAL) {
+ return 0;
+ }
+ LOG_ERR("Changing display orientation not implemented\n");
+ return -ENOTSUP;
+}
+
+static void
+ili9340_get_capabilities(const struct device *dev,
+ struct display_capabilities *capabilities)
+{
+ memset(capabilities, 0, sizeof(struct display_capabilities));
+ capabilities->x_resolution = 320;
+ capabilities->y_resolution = 240;
+ capabilities->supported_pixel_formats = PIXEL_FORMAT_RGB_888;
+ capabilities->current_pixel_format = PIXEL_FORMAT_RGB_888;
+ capabilities->current_orientation = DISPLAY_ORIENTATION_NORMAL;
+}
+
+void
+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);
+ 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);
+ spi_transceive(data->spi_dev, &data->spi_config, &tx_bufs, NULL);
+ }
+}
+
+struct display_driver_api ili9340_api1 = {
+ .blanking_on = ili9340_display_blanking_on,
+ .blanking_off = ili9340_display_blanking_off,
+ .write = ili9340_write,
+ .read = ili9340_read,
+ .get_framebuffer = ili9340_get_framebuffer,
+ .set_brightness = ili9340_set_brightness,
+ .set_contrast = ili9340_set_contrast,
+ .get_capabilities = ili9340_get_capabilities,
+ .set_pixel_format = ili9340_set_pixel_format,
+ .set_orientation = ili9340_set_orientation
+};
+
+/*
+DEVICE_AND_API_INIT(ili9340, DT_ILITEK_ILI9340_0_LABEL, &ili9340_init,
+ &ili9340_data, NULL, APPLICATION,
+ CONFIG_APPLICATION_INIT_PRIORITY, &ili9340_api);
+*/
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h
new file mode 100644
index 000000000..4eb11e2d1
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+#ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_
+#define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_
+#include "board_config.h"
+#include <autoconf.h>
+#include <zephyr.h>
+
+#define ILI9340_CMD_ENTER_SLEEP 0x10
+#define ILI9340_CMD_EXIT_SLEEP 0x11
+#define ILI9340_CMD_GAMMA_SET 0x26
+#define ILI9340_CMD_DISPLAY_OFF 0x28
+#define ILI9340_CMD_DISPLAY_ON 0x29
+#define ILI9340_CMD_COLUMN_ADDR 0x2a
+#define ILI9340_CMD_PAGE_ADDR 0x2b
+#define ILI9340_CMD_MEM_WRITE 0x2c
+#define ILI9340_CMD_MEM_ACCESS_CTRL 0x36
+#define ILI9340_CMD_PIXEL_FORMAT_SET 0x3A
+#define ILI9340_CMD_FRAME_CTRL_NORMAL_MODE 0xB1
+#define ILI9340_CMD_DISPLAY_FUNCTION_CTRL 0xB6
+#define ILI9340_CMD_POWER_CTRL_1 0xC0
+#define ILI9340_CMD_POWER_CTRL_2 0xC1
+#define ILI9340_CMD_VCOM_CTRL_1 0xC5
+#define ILI9340_CMD_VCOM_CTRL_2 0xC7
+#define ILI9340_CMD_POSITVE_GAMMA_CORRECTION 0xE0
+#define ILI9340_CMD_NEGATIVE_GAMMA_CORRECTION 0xE1
+
+#define ILI9340_DATA_MEM_ACCESS_CTRL_MY 0x80
+#define ILI9340_DATA_MEM_ACCESS_CTRL_MX 0x40
+#define ILI9340_DATA_MEM_ACCESS_CTRL_MV 0x20
+#define ILI9340_DATA_MEM_ACCESS_CTRL_ML 0x10
+#define ILI9340_DATA_MEM_ACCESS_CTRL_BGR 0x08
+#define ILI9340_DATA_MEM_ACCESS_CTRL_MH 0x04
+
+#define ILI9340_DATA_PIXEL_FORMAT_RGB_18_BIT 0x60
+#define ILI9340_DATA_PIXEL_FORMAT_RGB_16_BIT 0x50
+#define ILI9340_DATA_PIXEL_FORMAT_MCU_18_BIT 0x06
+#define ILI9340_DATA_PIXEL_FORMAT_MCU_16_BIT 0x05
+
+struct ili9340_data;
+
+/**
+ * Send data to ILI9340 display controller
+ *
+ * @param data Device data structure
+ * @param cmd Command to send to display controller
+ * @param tx_data Data to transmit to the display controller
+ * In case no data should be transmitted pass a NULL pointer
+ * @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);
+
+/**
+ * Perform LCD specific initialization
+ *
+ * @param data Device data structure
+ */
+void
+ili9340_lcd_init(struct ili9340_data *data);
+
+#define DT_ILITEK_ILI9340_0_LABEL "DISPLAY"
+#define CONFIG_DISPLAY_LOG_LEVEL 0
+
+#endif /* ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ */
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c
new file mode 100644
index 000000000..65aa618b5
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017 Jan Van Winkel <jan.van_winkel@dxplore.eu>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "display_ili9340.h"
+
+void
+ili9340_lcd_init(struct ili9340_data *data)
+{
+ uint8_t tx_data[15];
+
+ tx_data[0] = 0x23;
+ ili9340_transmit(data, ILI9340_CMD_POWER_CTRL_1, tx_data, 1);
+
+ tx_data[0] = 0x10;
+ ili9340_transmit(data, ILI9340_CMD_POWER_CTRL_2, tx_data, 1);
+
+ tx_data[0] = 0x3e;
+ tx_data[1] = 0x28;
+ ili9340_transmit(data, ILI9340_CMD_VCOM_CTRL_1, tx_data, 2);
+
+ tx_data[0] = 0x86;
+ 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_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;
+ ili9340_transmit(data, ILI9340_CMD_PIXEL_FORMAT_SET, tx_data, 1);
+
+ tx_data[0] = 0x00;
+ tx_data[1] = 0x18;
+ ili9340_transmit(data, ILI9340_CMD_FRAME_CTRL_NORMAL_MODE, tx_data, 2);
+
+ tx_data[0] = 0x08;
+ tx_data[1] = 0x82;
+ tx_data[2] = 0x27;
+ ili9340_transmit(data, ILI9340_CMD_DISPLAY_FUNCTION_CTRL, tx_data, 3);
+
+ tx_data[0] = 0x01;
+ ili9340_transmit(data, ILI9340_CMD_GAMMA_SET, tx_data, 1);
+
+ tx_data[0] = 0x0F;
+ tx_data[1] = 0x31;
+ tx_data[2] = 0x2B;
+ tx_data[3] = 0x0C;
+ tx_data[4] = 0x0E;
+ tx_data[5] = 0x08;
+ tx_data[6] = 0x4E;
+ tx_data[7] = 0xF1;
+ tx_data[8] = 0x37;
+ tx_data[9] = 0x07;
+ tx_data[10] = 0x10;
+ tx_data[11] = 0x03;
+ tx_data[12] = 0x0E;
+ tx_data[13] = 0x09;
+ tx_data[14] = 0x00;
+ ili9340_transmit(data, ILI9340_CMD_POSITVE_GAMMA_CORRECTION, tx_data, 15);
+
+ tx_data[0] = 0x00;
+ tx_data[1] = 0x0E;
+ tx_data[2] = 0x14;
+ tx_data[3] = 0x03;
+ tx_data[4] = 0x11;
+ tx_data[5] = 0x07;
+ tx_data[6] = 0x31;
+ tx_data[7] = 0xC1;
+ tx_data[8] = 0x48;
+ tx_data[9] = 0x08;
+ tx_data[10] = 0x0F;
+ tx_data[11] = 0x0C;
+ tx_data[12] = 0x31;
+ tx_data[13] = 0x36;
+ tx_data[14] = 0x0F;
+ ili9340_transmit(data, ILI9340_CMD_NEGATIVE_GAMMA_CORRECTION, tx_data, 15);
+}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c
new file mode 100644
index 000000000..b2f9f8e52
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+#include <stdio.h>
+#include <stdbool.h>
+#include "display_indev.h"
+#include "display.h"
+#include "wasm_export.h"
+#include "app_manager_export.h"
+
+#define MONITOR_HOR_RES 320
+#define MONITOR_VER_RES 240
+#ifndef MONITOR_ZOOM
+#define MONITOR_ZOOM 1
+#endif
+
+extern int
+ili9340_init();
+
+static int lcd_initialized = 0;
+
+void
+display_init(void)
+{
+ if (lcd_initialized != 0) {
+ return;
+ }
+ lcd_initialized = 1;
+ xpt2046_init();
+ ili9340_init();
+ display_blanking_off(NULL);
+}
+
+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)
+{
+ 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)))
+ return;
+
+ uint16_t w = x2 - x1 + 1;
+ uint16_t h = y2 - y1 + 1;
+
+ desc.buf_size = 3 * w * h;
+ desc.width = w;
+ desc.pitch = w;
+ desc.height = h;
+ display_write(NULL, x1, y1, &desc, (void *)color);
+
+ /*lv_flush_ready();*/
+}
+
+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)
+{}
+
+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)
+{}
+
+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;
+
+ if (!wasm_runtime_validate_native_addr(module_inst, lv_data,
+ sizeof(lv_indev_data_t)))
+ return false;
+
+ return touchscreen_read(lv_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)
+{
+ wasm_module_inst_t module_inst = get_module_inst(exec_env);
+ 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)))
+ return;
+
+ *buf_xy = color->red;
+ *(buf_xy + 1) = color->green;
+ *(buf_xy + 2) = color->blue;
+}
+
+int
+time_get_ms(wasm_exec_env_t exec_env)
+{
+ return k_uptime_get_32();
+}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c
new file mode 100644
index 000000000..dceb5786b
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+#include "bh_platform.h"
+#include "runtime_lib.h"
+#include "native_interface.h"
+#include "app_manager_export.h"
+#include "board_config.h"
+#include "bh_platform.h"
+#include "runtime_sensor.h"
+#include "bi-inc/attr_container.h"
+#include "module_wasm_app.h"
+#include "wasm_export.h"
+#include "sensor_native_api.h"
+#include "connection_native_api.h"
+#include "display_indev.h"
+
+#include <zephyr.h>
+#include <drivers/uart.h>
+#include <device.h>
+
+extern bool
+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)
+{
+ unsigned char ch;
+
+ while (uart_poll_in(dev, &ch) == 0) {
+ uart_char_cnt++;
+ aee_host_msg_callback(&ch, 1);
+ }
+ (void)user_data;
+}
+
+const struct device *uart_dev = NULL;
+
+static bool
+host_init()
+{
+ uart_dev = device_get_binding(HOST_DEVICE_COMM_UART_NAME);
+ if (!uart_dev) {
+ printf("UART: Device driver not found.\n");
+ return false;
+ }
+ uart_irq_rx_enable(uart_dev);
+ uart_irq_callback_set(uart_dev, uart_irq_callback);
+ return true;
+}
+
+int
+host_send(void *ctx, const char *buf, int size)
+{
+ if (!uart_dev)
+ return 0;
+
+ for (int i = 0; i < size; i++)
+ uart_poll_out(uart_dev, buf[i]);
+
+ return size;
+}
+
+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;
+
+static char global_heap_buf[350 * 1024] = { 0 };
+
+static NativeSymbol native_symbols[] = {
+ EXPORT_WASM_API_WITH_SIG(display_input_read, "(*)i"),
+ EXPORT_WASM_API_WITH_SIG(display_flush, "(iiii*)"),
+ EXPORT_WASM_API_WITH_SIG(display_fill, "(iiii*)"),
+ EXPORT_WASM_API_WITH_SIG(display_vdb_write, "(*iii*i)"),
+ EXPORT_WASM_API_WITH_SIG(display_map, "(iiii*)"),
+ EXPORT_WASM_API_WITH_SIG(time_get_ms, "()i")
+};
+
+int
+iwasm_main()
+{
+ RuntimeInitArgs init_args;
+
+ host_init();
+
+ memset(&init_args, 0, sizeof(RuntimeInitArgs));
+
+ init_args.mem_alloc_type = Alloc_With_Pool;
+ init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;
+ init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);
+
+ init_args.native_module_name = "env";
+ init_args.n_native_symbols = sizeof(native_symbols) / sizeof(NativeSymbol);
+ init_args.native_symbols = native_symbols;
+
+ /* initialize runtime environment */
+ if (!wasm_runtime_full_init(&init_args)) {
+ printf("Init runtime environment failed.\n");
+ return -1;
+ }
+
+ display_init();
+
+ /* timer manager */
+ if (!init_wasm_timer()) {
+ goto fail;
+ }
+
+ app_manager_startup(&interface);
+
+fail:
+ wasm_runtime_destroy();
+ return -1;
+}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c
new file mode 100644
index 000000000..c331306ed
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "bh_platform.h"
+#include "bh_assert.h"
+#include "bh_log.h"
+#include "wasm_export.h"
+
+extern void
+display_init(void);
+extern int
+iwasm_main();
+
+void
+main(void)
+{
+ display_init();
+ iwasm_main();
+ for (;;) {
+ k_sleep(Z_TIMEOUT_MS(1000));
+ }
+}
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h
new file mode 100644
index 000000000..bb20ecbb8
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+#ifndef __PIN_CONFIG_JLF_H__
+#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_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_CS_GPIO_CONTROLLER "GPIO_0"
+#define XPT2046_CS_GPIO_PIN 6
+
+#define XPT2046_PEN_GPIO_CONTROLLER "GPIO_0"
+#define XPT2046_PEN_GPIO_PIN 7
+
+#define HOST_DEVICE_COMM_UART_NAME "UART_1"
+#endif /* __PIN_CONFIG_JLF_H__ */
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h
new file mode 100644
index 000000000..523ce2308
--- /dev/null
+++ b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+#ifndef __PIN_CONFIG_STM32_H__
+#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_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_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 XPT2046_SPI_DEVICE_NAME "SPI_1"
+#define XPT2046_SPI_MAX_FREQUENCY 12 * 1000 * 1000
+#define XPT2046_CS_GPIO_CONTROLLER "GPIOD"
+#define XPT2046_CS_GPIO_PIN 0
+
+#define XPT2046_PEN_GPIO_CONTROLLER "GPIOD"
+#define XPT2046_PEN_GPIO_PIN 1
+
+#define HOST_DEVICE_COMM_UART_NAME "UART_6"
+
+#endif /* __PIN_CONFIG_STM32_H__ */