diff options
author | Uros Majstorovic <majstor@majstor.org> | 2022-09-04 18:39:21 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2022-09-04 18:39:21 +0200 |
commit | d894eb01e9c979d0eb51f9495a7cf7281c213302 (patch) | |
tree | 9849af7b4c62cc22e61ff7e51c0169674d073986 /fw/fe310 | |
parent | fc98d3809e0db36d634f290417b9152f87f83e3e (diff) |
removed old test
Diffstat (limited to 'fw/fe310')
-rw-r--r-- | fw/fe310/eos/board.h | 33 | ||||
-rw-r--r-- | fw/fe310/test/Makefile | 32 | ||||
-rw-r--r-- | fw/fe310/test/app/Makefile | 15 | ||||
-rw-r--r-- | fw/fe310/test/app/app_root.c | 86 | ||||
-rw-r--r-- | fw/fe310/test/app/app_root.h | 12 | ||||
-rw-r--r-- | fw/fe310/test/app/app_status.c | 74 | ||||
-rw-r--r-- | fw/fe310/test/app/app_status.h | 5 | ||||
-rw-r--r-- | fw/fe310/test/cam.c | 163 | ||||
-rw-r--r-- | fw/fe310/test/cam.h | 2 | ||||
-rw-r--r-- | fw/fe310/test/cell_dev.c | 31 | ||||
-rw-r--r-- | fw/fe310/test/cell_dev.h | 1 | ||||
-rw-r--r-- | fw/fe310/test/cell_pdp.c | 105 | ||||
-rw-r--r-- | fw/fe310/test/cell_pdp.h | 4 | ||||
-rw-r--r-- | fw/fe310/test/fs.c | 127 | ||||
-rw-r--r-- | fw/fe310/test/fs.h | 3 | ||||
-rw-r--r-- | fw/fe310/test/main.c | 107 | ||||
-rw-r--r-- | fw/fe310/test/mem.c | 24 | ||||
-rw-r--r-- | fw/fe310/test/modem.c | 166 | ||||
-rw-r--r-- | fw/fe310/test/modem.h | 2 | ||||
-rw-r--r-- | fw/fe310/test/phone.c | 119 | ||||
-rw-r--r-- | fw/fe310/test/phone.h | 9 | ||||
-rw-r--r-- | fw/fe310/test/test.c | 63 | ||||
-rw-r--r-- | fw/fe310/test/test.h | 2 | ||||
-rw-r--r-- | fw/fe310/test/wifi.c | 91 | ||||
-rw-r--r-- | fw/fe310/test/wifi.h | 4 |
25 files changed, 8 insertions, 1272 deletions
diff --git a/fw/fe310/eos/board.h b/fw/fe310/eos/board.h index 3891c61..ad79a17 100644 --- a/fw/fe310/eos/board.h +++ b/fw/fe310/eos/board.h @@ -13,42 +13,25 @@ #define SPI_CSPIN_SDC 0 #define SPI_CSPIN_CAM -1 -#define SPI_CSPIN_LCD 11 +#define SPI_CSPIN_LCD 21 -#define SPI_IOF_MASK ((1 << IOF_SPI1_SCK) | (1 << IOF_SPI1_MOSI) | (1 << IOF_SPI1_MISO) | (1 << IOF_SPI1_SS0) | (1 << IOF_SPI1_SS2) | (1 << IOF_SPI1_SS3)) +// SS2 used as I2S_PIN_INT +// #define SPI_IOF_MASK ((1 << IOF_SPI1_SCK) | (1 << IOF_SPI1_MOSI) | (1 << IOF_SPI1_MISO) | (1 << IOF_SPI1_SS0) | (1 << IOF_SPI1_SS2) | (1 << IOF_SPI1_SS3)) +#define SPI_IOF_MASK ((1 << IOF_SPI1_SCK) | (1 << IOF_SPI1_MOSI) | (1 << IOF_SPI1_MISO) | (1 << IOF_SPI1_SS0) | (1 << IOF_SPI1_SS3)) #define NET_PIN_RTS 20 #define NET_PIN_CTS 22 #define EVE_PIN_INTR 1 -//#define EVE_PIN_INTR 23 #define I2S_PIN_CK 1 /* PWM 0.1 */ -#define I2S_PIN_CK_SW 21 /* PWM 1.2 */ -#define I2S_PIN_CK_SR 18 +#define I2S_PIN_SR_CK 18 +#define I2S_PIN_SR_SEL 11 /* PWM 2.1 */ #define I2S_PIN_WS_MIC 19 /* PWM 1.1 */ -#define I2S_PIN_WS_SPK 11 /* PWM 2.1 */ +#define I2S_PIN_WS_SPK 21 /* PWM 1.2 */ #define I2S_PIN_SD_IN 17 #define I2S_PIN_SD_OUT 16 -//#define I2S_PIN_SD_IN 13 -//#define I2S_PIN_SD_OUT 12 +#define I2S_PIN_INT 9 -#define I2S_IRQ_WS_ID (INT_PWM2_BASE + 0) -#define I2S_IRQ_SD_ID (INT_PWM2_BASE + 3) - -#define I2S_CTRL_ADDR_CK PWM0_CTRL_ADDR -#define I2S_CTRL_ADDR_WS_MIC PWM1_CTRL_ADDR -#define I2S_CTRL_ADDR_WS_SPK PWM2_CTRL_ADDR - -#define I2S_IDLE_CYCLES 1 - -//#define CTP_PIN_INT 1 #define CTP_PIN_INT 23 #define CTP_PIN_RST 19 - -#define EVE_GPIO_DIR 0xf - -#define EVE_GPIO_CAM 0 -#define EVE_GPIO_LCD_EN 1 -#define EVE_GPIO_GAIN 2 -#define EVE_GPIO_HAPT 3 diff --git a/fw/fe310/test/Makefile b/fw/fe310/test/Makefile deleted file mode 100644 index 5608a49..0000000 --- a/fw/fe310/test/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -include ../common.mk -DEPS = main.o mem.o cell_dev.o phone.o modem.o cam.o fs.o test.o - -lib_eos = eve eos eos-soc eos-dev eos-net eos-ext eos-bsp -lib_ecp = - -# DEPS += ecp.o ecp_init.o audio.o -# lib_ecp += ecp ecpcr ecptr ecptm ecpdir ecpvconn - -CFLAGS += -I$(bsp_dir)/include -I$(bsp_dir)/drivers -I$(ext_dir)/crypto -I$(ext_dir)/fsfat -I$(ecp_dir)/src -I$(ecp_dir)/src/platform/fe310 -I.. -LDFLAGS = app/*.o $(CFLAGS) -L.. -L$(ecp_dir)/build-fe310 -Wl,--gc-sections -nostartfiles -nostdlib -Wl,--start-group -lc -lm -lgcc $(addprefix -l,$(lib_eos)) $(addprefix -l,$(lib_ecp)) -Wl,--end-group -T../bsp/default.lds -TARGET = phone - - -all: $(TARGET) - -app_: - (cd app && $(MAKE)) || exit; - -%.o: %.c - $(CC) $(CFLAGS) -c $< - -$(TARGET): app_ $(DEPS) - $(CC) $(DEPS) $(LDFLAGS) -o $@ - -clean: - (cd app && $(MAKE) clean) || exit; - rm -f *.o *.a $(TARGET) - -upload: $(TARGET) - ../bsp/upload --elf ./$(TARGET) --openocd $(RISCV_OPENOCD_HOME)/bin/openocd --gdb $(RISCV_HOME)/bin/riscv64-unknown-elf-gdb --openocd-config ../bsp/openocd.cfg - diff --git a/fw/fe310/test/app/Makefile b/fw/fe310/test/app/Makefile deleted file mode 100644 index fe0ba21..0000000 --- a/fw/fe310/test/app/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -include ../../common.mk - -obj = app_root.o app_status.o - - -%.o: %.c %.h - $(CC) $(CFLAGS) -c $< - -%.o: %.S - $(CC) $(CFLAGS) -c $< - -all: $(obj) - -clean: - rm -f *.o diff --git a/fw/fe310/test/app/app_root.c b/fw/fe310/test/app/app_root.c deleted file mode 100644 index 18ca284..0000000 --- a/fw/fe310/test/app/app_root.c +++ /dev/null @@ -1,86 +0,0 @@ -#include <stdlib.h> - -#include <dev/net.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app_status.h" -#include "app_root.h" - -#define KBD_X 0 -#define KBD_Y 629 -#define KBD_W 480 -#define KBD_H 225 - -static EVEKbd kbd; -static EVEFont font; -static EVEWindowRoot win_root; -static EVEWindowKbd win_kbd; -static EVEWindow win_status; -static EVEWindow win_main; -static EVEView view_status; -static EVEViewStack view_stack; - -EVEWindowRoot *app_root(void) { - return &win_root; -} - -void app_root_refresh(void) { - eve_spi_start(); - eve_window_root_draw(app_root()); - eve_spi_stop(); -} - -void app_root_init(eve_view_constructor_t home_page, int b) { - EVERect g; - - eve_spi_start(); - - if (b >= 0) eve_brightness(b); - - eve_font_init(&font, APP_FONT_HANDLE); - - g.x = 0; - g.y = 0; - g.w = APP_SCREEN_W; - g.h = APP_SCREEN_H; - eve_window_init_root(&win_root, &g, "root", &font); - - g.x = KBD_X; - g.y = KBD_Y; - g.w = KBD_W; - g.h = KBD_H; - eve_kbd_init(&kbd, &g, win_root.mem_next, &win_root.mem_next); - eve_window_init_kbd(&win_kbd, &g, &win_root, "kbd", &kbd); - - g.x = 0; - g.y = 0; - g.w = APP_SCREEN_W; - g.h = APP_STATUS_H; - eve_window_init(&win_status, &g, (EVEWindow *)&win_root, "status"); - eve_view_init(&view_status, &win_status, app_status_draw, app_status_touch, NULL, NULL); - - g.x = 0; - g.y = APP_STATUS_H; - g.w = APP_SCREEN_W; - g.h = APP_SCREEN_H - APP_STATUS_H; - eve_window_init(&win_main, &g, (EVEWindow *)&win_root, "main"); - - eve_view_stack_init(&view_stack); - eve_view_create(&win_main, &view_stack, home_page); - - eve_window_append(&win_status); - eve_window_append(&win_main); - - eve_window_root_draw(&win_root); - - eve_spi_stop(); - - eos_net_acquire_for_evt(EOS_EVT_EVE | EVE_ETYPE_INTR, 1); -} diff --git a/fw/fe310/test/app/app_root.h b/fw/fe310/test/app/app_root.h deleted file mode 100644 index 35f889f..0000000 --- a/fw/fe310/test/app/app_root.h +++ /dev/null @@ -1,12 +0,0 @@ -#include <stdint.h> - -#define APP_SCREEN_W 480 -#define APP_SCREEN_H 854 -#define APP_STATUS_H 60 - -#define APP_FONT_HANDLE 31 - -EVEWindowRoot *app_root(void); -void app_root_refresh(void); - -void app_root_init(eve_view_constructor_t home_page, int b); diff --git a/fw/fe310/test/app/app_status.c b/fw/fe310/test/app/app_status.c deleted file mode 100644 index bbe906d..0000000 --- a/fw/fe310/test/app/app_status.c +++ /dev/null @@ -1,74 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <dev/net.h> -#include <net/cell.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app_root.h" -#include "app_status.h" - -#include "../phone.h" - -static char status_msg[128]; - -int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { - unsigned char state = 0; - int8_t touch_idx; - - // state = app_phone_state_get(); - touch_idx = eve_touch_get_idx(touch); - if (touch_idx != 0) return 0; - - evt = eve_touch_evt(touch, evt, tag0, view->tag, 2); - if (touch && (evt & EVE_TOUCH_ETYPE_POINT_UP)) { - if ((state == VOICE_STATE_RING) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT)) { - unsigned char *buf = eos_net_alloc(); - - buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_ANSWER; - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, 1, 0); - status_msg[0] = '\0'; - } - if ((state != VOICE_STATE_IDLE) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_RIGHT)) { - unsigned char *buf = eos_net_alloc(); - - buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_HANGUP; - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, 1, 0); - status_msg[0] = '\0'; - } - return 1; - } - return 0; -} - -uint8_t app_status_draw(EVEView *view, uint8_t tag0) { - uint8_t tag_opt = EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY; - - tag0 = eve_view_clear(view, tag0, tag_opt); - - if (tag0 != EVE_NOTAG) { - eve_touch_set_opt(tag0, eve_touch_get_opt(tag0) | tag_opt); - eve_cmd_dl(TAG(tag0)); - tag0++; - } - - eve_cmd(CMD_TEXT, "hhhhs", 0, 0, 31, 0, status_msg); - - return tag0; -} - -void app_status_msg_set(char *msg, int refresh) { - strcpy(status_msg, msg); - - if (refresh) app_root_refresh(); -} diff --git a/fw/fe310/test/app/app_status.h b/fw/fe310/test/app/app_status.h deleted file mode 100644 index 262d29c..0000000 --- a/fw/fe310/test/app/app_status.h +++ /dev/null @@ -1,5 +0,0 @@ -#include <stdint.h> - -int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0); -uint8_t app_status_draw(EVEView *view, uint8_t tag0); -void app_status_msg_set(char *msg, int refresh); diff --git a/fw/fe310/test/cam.c b/fw/fe310/test/cam.c deleted file mode 100644 index 7e84cdf..0000000 --- a/fw/fe310/test/cam.c +++ /dev/null @@ -1,163 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <board.h> -#include <soc/i2c.h> - -#include <dev/cam.h> -#include <dev/ov2640.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app/app_root.h" - -#include "cam.h" - -#include <stdio.h> - -static int cam_init = 0; -static int cam_capture = 0; - -#define CHUNK_SIZE 512 - -#define CAM_W 640 -#define CAM_H 480 - -static void transfer_chunk(uint8_t *fbuf, size_t size, int first, int last, uint32_t addr) { - int rv; - - eos_cam_fbuf_read(fbuf, size, first); - if (last) { - eos_cam_fbuf_done(); - eos_cam_capture(); - } - - eos_spi_select(EOS_SPI_DEV_EVE); - eve_cmd_burst_start(); - if (first) eve_cmd(CMD_LOADIMAGE, "ww+", addr, EVE_OPT_NODL); - eve_cmd_write(fbuf, size); - if (last) eve_cmd_end(); - eve_cmd_burst_end(); - rv = eve_cmd_exec(last); - if (rv) printf("CMD EXEC ERR\n"); - if (!last) eos_spi_select(EOS_SPI_DEV_CAM); -} - -static void transfer_img(uint32_t addr) { - int i; - uint32_t fb_size; - uint32_t fb_div; - uint32_t fb_mod; - uint8_t fbuf[CHUNK_SIZE]; - - cam_capture = 1; - fb_size = eos_cam_fbuf_size(); - - fb_div = fb_size / CHUNK_SIZE; - fb_mod = fb_size % CHUNK_SIZE; - for (i=0; i<fb_div; i++) { - transfer_chunk(fbuf, CHUNK_SIZE, i == 0, (fb_mod == 0) && (i + 1 == fb_div), addr); - } - if (fb_mod) { - transfer_chunk(fbuf, fb_mod, fb_size < CHUNK_SIZE, 1, addr); - } - printf("CAPTURE DONE. ADDR:%x SIZE:%d\n", addr, fb_size); -} - -static void user_handler(unsigned char type, unsigned char *buffer, uint16_t size) { - eos_spi_select(EOS_SPI_DEV_CAM); - if (eos_cam_capture_done()) { - EVEWindowRoot *root = app_root(); - uint32_t addr = root->mem_next; - - transfer_img(addr); - eve_window_root_draw(root); - } - eos_spi_deselect(); - eos_evtq_push(EOS_EVT_USER, NULL, 0); -} - -static void image_draw(EVEFreeWidget *widget) { - EVEWindowRoot *root = widget->w.page->v.window->root; - uint32_t addr = root->mem_next; - - if (cam_capture) { - // eve_freew_tag(widget); - eve_cmd_dl(TAG_MASK(0)); - eve_cmd_dl(BEGIN(EVE_BITMAPS)); - // eve_cmd_dl(BITMAP_HANDLE(15)); - eve_cmd_dl(BITMAP_SOURCE(addr)); - eve_cmd_dl(BITMAP_LAYOUT(EVE_RGB565, CAM_W * 2, CAM_H)); - eve_cmd_dl(BITMAP_LAYOUT_H(CAM_W * 2, CAM_H)); - eve_cmd_dl(BITMAP_SIZE(EVE_NEAREST, EVE_BORDER, EVE_BORDER, CAM_H, CAM_W)); - eve_cmd_dl(BITMAP_SIZE_H(CAM_H, CAM_W)); - eve_cmd(CMD_LOADIDENTITY, ""); - eve_cmd(CMD_TRANSLATE, "ww", CAM_H * 65536, 0); - eve_cmd(CMD_ROTATE, "w", 90 * 65536 / 360); - eve_cmd(CMD_SETMATRIX, ""); - eve_cmd_dl(VERTEX2F(0, 0)); - eve_cmd_dl(TAG_MASK(1)); - } -} - -static int image_touch(EVEFreeWidget *widget, EVETouch *touch, uint16_t evt) { - return 0; -} - -void fbuf_print(uint8_t *fbuf, size_t size) { - int i; - - for (i=0; i<size; i++) { - if (i % 128 == 0) printf("\n"); - printf("%.2x", fbuf[i]); - } -} - -void app_cam(EVEWindow *window, EVEViewStack *stack) { - EVEFormSpec spec[] = { - { - .widget.type = EVE_WIDGET_TYPE_FREE, - .widget.g.h = CAM_W, - .widget.tspec.free.draw = image_draw, - .widget.tspec.free.touch = image_touch, - }, - }; - EVEForm *form = eve_form_create(window, stack, spec, 1, NULL, NULL, app_cam_close); - int rv = EOS_OK; - - eve_gpio_set(EVE_GPIO_CAM, 1); - eos_time_sleep(100); - - eos_i2c_speed(100000); - rv = eos_ov2640_init(); - if (!rv) rv = eos_ov2640_set_pixfmt(PIXFORMAT_JPEG); - if (!rv) rv = eos_ov2640_set_framesize(FRAMESIZE_VGA); - eos_i2c_speed(EOS_I2C_SPEED); - - if (!rv) { - printf("CAM INIT\n"); - } else { - printf("CAM INIT ERR:%d\n", rv); - } - eos_evtq_set_handler(EOS_EVT_USER, user_handler); - eos_evtq_push(EOS_EVT_USER, NULL, 0); - eos_spi_select(EOS_SPI_DEV_CAM); - eos_cam_capture(); - eos_spi_select(EOS_SPI_DEV_EVE); -} - -void app_cam_close(EVEForm *form) { - eve_form_destroy(form); - eve_gpio_set(EVE_GPIO_CAM, 0); - eos_evtq_get(EOS_EVT_USER, NULL, NULL); - eos_evtq_set_handler(EOS_EVT_USER, NULL); -} diff --git a/fw/fe310/test/cam.h b/fw/fe310/test/cam.h deleted file mode 100644 index fdf07b8..0000000 --- a/fw/fe310/test/cam.h +++ /dev/null @@ -1,2 +0,0 @@ -void app_cam(EVEWindow *window, EVEViewStack *stack); -void app_cam_close(EVEForm *form); diff --git a/fw/fe310/test/cell_dev.c b/fw/fe310/test/cell_dev.c deleted file mode 100644 index 9598bc4..0000000 --- a/fw/fe310/test/cell_dev.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <dev/net.h> -#include <net/cell.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> -#include <eve/screen/window.h> - -#include "app/app_root.h" -#include "app/app_status.h" - -#include "cell_dev.h" - -static void cell_dev_handler(unsigned char type, unsigned char *buffer, uint16_t len) { - switch (type) { - case EOS_CELL_MTYPE_READY: - app_status_msg_set("Modem ready", 1); - break; - } - eos_net_free(buffer, 0); -} - -void app_cell_dev_init(void) { - eos_cell_set_handler(EOS_CELL_MTYPE_DEV, cell_dev_handler); -} diff --git a/fw/fe310/test/cell_dev.h b/fw/fe310/test/cell_dev.h deleted file mode 100644 index 19b7717..0000000 --- a/fw/fe310/test/cell_dev.h +++ /dev/null @@ -1 +0,0 @@ -void app_cell_dev_init(void);
\ No newline at end of file diff --git a/fw/fe310/test/cell_pdp.c b/fw/fe310/test/cell_pdp.c deleted file mode 100644 index e67ddb2..0000000 --- a/fw/fe310/test/cell_pdp.c +++ /dev/null @@ -1,105 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <dev/net.h> -#include <net/cell.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app/app_root.h" -#include "app/app_status.h" - -#include "cell_pdp.h" - -static void cell_pdp_connect(char *apn, char *user, char *pass) { - unsigned char *buffer, *p; - - buffer = eos_net_alloc(); - buffer[0] = EOS_CELL_MTYPE_PDP | EOS_CELL_MTYPE_PDP_CONFIG; - p = buffer + 1; - strcpy(p, user); - p += strlen(user) + 1; - strcpy(p, user); - p += strlen(user) + 1; - strcpy(p, pass); - p += strlen(pass) + 1; - eos_net_send(EOS_NET_MTYPE_CELL, buffer, p - buffer); - - buffer[0] = EOS_CELL_MTYPE_PDP | EOS_CELL_MTYPE_PDP_CONNECT; - eos_net_send_async(EOS_NET_MTYPE_CELL, buffer, 1, 0); -} - -static void cell_pdp_disconnect(void) { - unsigned char *buffer = eos_net_alloc(); - buffer[0] = EOS_CELL_MTYPE_PDP | EOS_CELL_MTYPE_PDP_DISCONNECT; - eos_net_send_async(EOS_NET_MTYPE_CELL, buffer, 1, 0); -} - -static void cell_pdp_handler(unsigned char type, unsigned char *buffer, uint16_t size) { - switch (type) { - case EOS_CELL_MTYPE_PDP_CONNECT: - app_status_msg_set("Cell data connected", 1); - break; - - case EOS_CELL_MTYPE_PDP_DISCONNECT: - app_status_msg_set("Cell data disconnected", 1); - break; - - default: - break; - } - eos_net_free(buffer, 0); -} - -void app_cell_pdp(EVEWindow *window, EVEViewStack *stack) { - EVEFormSpec spec[] = { - { - .label.g.w = APP_SCREEN_W / 3, - .label.title = "APN:", - - .widget.type = EVE_WIDGET_TYPE_STR, - .widget.tspec.str.str_size = 128, - }, - { - .label.g.w = APP_SCREEN_W / 3, - .label.title = "User:", - - .widget.type = EVE_WIDGET_TYPE_STR, - .widget.tspec.str.str_size = 128, - }, - { - .label.g.w = APP_SCREEN_W / 3, - .label.title = "Pass:", - - .widget.type = EVE_WIDGET_TYPE_STR, - .widget.tspec.str.str_size = 128, - }, - }; - - EVEForm *form = eve_form_create(window, stack, spec, 3, NULL, app_cell_pdp_action, app_cell_pdp_close); -} - -void app_cell_pdp_action(EVEForm *form) { - EVEStrWidget *apn = (EVEStrWidget *)eve_page_widget(&form->p, 0); - EVEStrWidget *user = (EVEStrWidget *)eve_page_widget(&form->p, 1); - EVEStrWidget *pass = (EVEStrWidget *)eve_page_widget(&form->p, 2); - - cell_pdp_connect(apn->str, user->str, pass->str); -} - -void app_cell_pdp_close(EVEForm *form) { - eve_form_destroy(form); -} - -void app_cell_pdp_init(void) { - eos_cell_set_handler(EOS_CELL_MTYPE_PDP, cell_pdp_handler); -} diff --git a/fw/fe310/test/cell_pdp.h b/fw/fe310/test/cell_pdp.h deleted file mode 100644 index 3c28176..0000000 --- a/fw/fe310/test/cell_pdp.h +++ /dev/null @@ -1,4 +0,0 @@ -void app_cell_pdp(EVEWindow *window, EVEViewStack *stack); -void app_cell_pdp_action(EVEForm *form); -void app_cell_pdp_close(EVEForm *form); -void app_cell_pdp_init(void);
\ No newline at end of file diff --git a/fw/fe310/test/fs.c b/fw/fe310/test/fs.c deleted file mode 100644 index 0b3d4dc..0000000 --- a/fw/fe310/test/fs.c +++ /dev/null @@ -1,127 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <dev/sdc_crypto.h> -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include <aes/aes.h> -#include <ff.h> - -#include "fs.h" - -FATFS fs; - -#define TEXT_SIZE 128 -#define TEXT_FN "test.txt" -#define KEY "passwordpassword" - -PARTITION VolToPart[FF_VOLUMES] = { - {0, 1} /* "0:" ==> 1st partition on the pd#0 */ -}; - -static EOSSDCCrypto sdcc; -static AESCtx ctx_crypt; -static AESCtx ctx_essiv; - -void app_fs(EVEWindow *window, EVEViewStack *stack) { - EVEFormSpec spec[] = { - { - .label.title = "Text", - .widget.type = EVE_WIDGET_TYPE_STR, - .widget.tspec.str.str_size = TEXT_SIZE, - }, - }; - EVEForm *form = eve_form_create(window, stack, spec, 1, NULL, NULL, app_fs_close); - EVEStrWidget *text = (EVEStrWidget *)eve_page_widget(&form->p, 0); - FIL f; - FRESULT rv; - - eos_spi_select(EOS_SPI_DEV_SDC); - rv = f_open(&f, TEXT_FN, FA_READ); - printf("f_open:%d\n", rv); - if (!rv) { - UINT r; - - rv = f_read(&f, text->str, TEXT_SIZE-1, &r); - printf("f_read:%d\n", rv); - if (rv != FR_OK) r = 0; - text->str[r] = '\0'; - f_close(&f); - } - eos_spi_select(EOS_SPI_DEV_EVE); - eve_strw_update(text); -} - -void app_fs_close(EVEForm *form) { - EVEStrWidget *text = (EVEStrWidget *)eve_page_widget(&form->p, 0); - FIL f; - FRESULT rv; - - eos_spi_select(EOS_SPI_DEV_SDC); - rv = f_open(&f, TEXT_FN, FA_WRITE | FA_CREATE_ALWAYS); - printf("f_open:%d\n", rv); - if (!rv) { - UINT w; - - rv = f_write(&f, text->str, strlen(text->str), &w); - printf("f_write:%d\n", rv); - f_close(&f); - } - eos_spi_select(EOS_SPI_DEV_EVE); - eve_form_destroy(form); -} - -void app_fs_init(void) { - FRESULT rv; - - eos_sdcc_init(&sdcc, KEY, &ctx_crypt, (eve_sdcc_init_t)aes_init, (eve_sdcc_crypt_t)aes_cbc_encrypt, (eve_sdcc_crypt_t)aes_cbc_decrypt, &ctx_essiv, (eve_sdcc_init_t)aes_init, (eve_sdcc_essiv_t)aes_ecb_encrypt); - eos_spi_select(EOS_SPI_DEV_SDC); - rv = f_mount(&fs, "", 1); - printf("f_mount:%d\n", rv); - if (rv == FR_NO_FILESYSTEM) { - uint8_t w[FF_MAX_SS]; - LBA_t plist[] = {100, 0}; - - rv = f_fdisk(0, plist, w); - printf("f_fdisk:%d\n", rv); - rv = f_mkfs("0:", 0, w, sizeof(w)); - printf("f_mkfs:%d\n", rv); - rv = f_mount(&fs, "", 1); - printf("f_mount:%d\n", rv); - } - - if (rv == FR_OK) { - FIL f; - UINT w; - char *msg = "PERA JE CAR!"; - - rv = f_open(&f, TEXT_FN, FA_READ); - printf("f_open:%d\n", rv); - if (!rv) { - UINT r; - char _msg[TEXT_SIZE]; - - memset(_msg, 0, sizeof(_msg)); - rv = f_read(&f, _msg, sizeof(_msg), &r); - printf("f_read:%d %u %s\n", rv, r, _msg); - f_close(&f); - } else { - rv = f_open(&f, TEXT_FN, FA_WRITE | FA_CREATE_ALWAYS); - printf("f_open:%d\n", rv); - rv = f_write(&f, msg, strlen(msg), &w); - printf("f_write:%d\n", rv); - } - f_close(&f); - - } - eos_spi_deselect(); -}
\ No newline at end of file diff --git a/fw/fe310/test/fs.h b/fw/fe310/test/fs.h deleted file mode 100644 index c525c5b..0000000 --- a/fw/fe310/test/fs.h +++ /dev/null @@ -1,3 +0,0 @@ -void app_fs(EVEWindow *window, EVEViewStack *stack); -void app_fs_close(EVEForm *form); -void app_fs_init(void); diff --git a/fw/fe310/test/main.c b/fw/fe310/test/main.c deleted file mode 100644 index f292ecf..0000000 --- a/fw/fe310/test/main.c +++ /dev/null @@ -1,107 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <prci_driver.h> - -#include <eos.h> -#include <soc/timer.h> -#include <soc/pwr.h> -#include <dev/eve.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app/app_root.h" - -#include "cell_dev.h" -#include "cell_pdp.h" -#include "phone.h" -#include "modem.h" -#include "wifi.h" -#include "cam.h" -#include "fs.h" -#include "test.h" - -static const uint32_t touch_matrix[6] = {0xf7ac,0x440,0x3e704,0xfffff718,0x108a3,0xfff76d42}; - -void app_home_page(EVEWindow *window, EVEViewStack *stack) { - EVEFormSpec spec[] = { - /* - { - .widget.type = EVE_WIDGET_TYPE_PAGE, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.page.title = "Phone", - .widget.tspec.page.constructor = app_phone - }, - { - .widget.type = EVE_WIDGET_TYPE_PAGE, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.page.title = "WiFi", - .widget.tspec.page.constructor = app_wifi - }, - { - .widget.type = EVE_WIDGET_TYPE_PAGE, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.page.title = "Cellular data", - .widget.tspec.page.constructor = app_cell_pdp - }, - { - .widget.type = EVE_WIDGET_TYPE_PAGE, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.page.title = "Modem", - .widget.tspec.page.constructor = app_modem - }, - { - .widget.type = EVE_WIDGET_TYPE_PAGE, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.page.title = "Camera", - .widget.tspec.page.constructor = app_cam - }, - { - .widget.type = EVE_WIDGET_TYPE_PAGE, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.page.title = "File system", - .widget.tspec.page.constructor = app_fs - }, - */ - { - .widget.type = EVE_WIDGET_TYPE_PAGE, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.page.title = "Test", - .widget.tspec.page.constructor = app_test - }, - }; - - EVEForm *form = eve_form_create(window, stack, spec, 1, NULL, NULL, NULL); -} - -void print_mem(void); - -int main() { - eos_init(); - // eos_run_once(); - eos_eve_set_touch_matrix(touch_matrix); - - printf("FREQ:%lu\n", PRCI_get_cpu_freq()); - printf("\nREADY.\n"); - - app_root_init(app_home_page, 0x20); - /* - app_phone_init(); - app_wifi_init(); - app_cell_dev_init(); - app_cell_pdp_init(); - app_fs_init(); - */ - // audio_start(); - // app_ecp_init(); - - eos_evtq_loop(); -} diff --git a/fw/fe310/test/mem.c b/fw/fe310/test/mem.c deleted file mode 100644 index a8c9546..0000000 --- a/fw/fe310/test/mem.c +++ /dev/null @@ -1,24 +0,0 @@ -#include <stdio.h> - -extern char metal_segment_itim_target_start; -extern char metal_segment_itim_target_end; - -extern char metal_segment_data_target_start; -extern char metal_segment_data_target_end; - -extern char metal_segment_bss_target_start; -extern char metal_segment_bss_target_end; - -extern char metal_segment_heap_target_start; -extern char metal_segment_heap_target_end; - -extern char metal_segment_stack_begin; -extern char metal_segment_stack_end; - -void print_mem(void) { - printf("ITIM: %p - %p\n", &metal_segment_itim_target_start, &metal_segment_itim_target_end); - printf("DATA: %p - %p\n", &metal_segment_data_target_start, &metal_segment_data_target_end); - printf("BSS: %p - %p\n", &metal_segment_bss_target_start, &metal_segment_bss_target_end); - printf("HEAP: %p - %p\n", &metal_segment_heap_target_start, &metal_segment_heap_target_end); - printf("STACK: %p - %p\n", &metal_segment_stack_begin, &metal_segment_stack_end); -} diff --git a/fw/fe310/test/modem.c b/fw/fe310/test/modem.c deleted file mode 100644 index 0921be9..0000000 --- a/fw/fe310/test/modem.c +++ /dev/null @@ -1,166 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <soc/uart.h> -#include <dev/net.h> -#include <net/cell.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_text.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app/app_root.h" - -#include "modem.h" - -typedef struct { - uint32_t mem; - EVEViewStack *stack; - eos_evt_handler_t cell_dev_handler; - EVEText text; -} VParam; - -static void key_down(void *p, int c) { - EVEView *view = p; - EVEText *text = &((VParam *)view->param)->text; - unsigned char *buf; - int i = 2; - - if (c == 0x11) { - app_modem_close(view); - return; - } - buf = eos_net_alloc(); - buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_UART_DATA; - if (c == '\n') { - buf[1] = '\r'; - buf[2] = '\n'; - i++; - } else { - buf[1] = c; - } - - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, i, 0); - eve_text_scroll0(text); -} - -static void handle_uart(unsigned char type) { - int i = 0; - int c = 0; - unsigned char *buf = NULL; - - c = eos_uart_getc(0); - if (c == EOS_ERR_EMPTY) return; - - buf = eos_net_alloc(); - buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_UART_DATA; - buf[1] = c; - i = 2; - while ((c = eos_uart_getc(0)) != EOS_ERR_EMPTY) { - buf[i] = c; - i++; - if (i == EOS_NET_MTU) break; - } - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, i, 0); - eos_uart_rxwm_set(0); -} - -static void handle_cell_msg(unsigned char type, unsigned char *buffer, uint16_t len) { - EVEWindowRoot *root = app_root(); - EVEWindow *window = eve_window_search(&root->w, "main"); - VParam *param = window->view->param; - - if (type == EOS_CELL_MTYPE_UART_DATA) { - EVEText *text = ¶m->text; - int i; - - eve_spi_start(); - for (i=1; i<len; i++) { - if (buffer[i] != '\r') eve_text_putc(text, buffer[i]); - } - if (text->dirty) { - text->dirty = 0; - eve_window_root_draw(root); - } - eve_spi_stop(); - eos_net_free(buffer, 0); - } else { - param->cell_dev_handler(type, buffer, len); - } -} - -static uint8_t modem_draw(EVEView *view, uint8_t tag0) { - VParam *param = view->param; - EVEText *text = ¶m->text; - - tag0 = eve_view_clear(view, tag0, 0); - return eve_text_draw(text, tag0); -} - -static int modem_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { - VParam *param = view->param; - EVEText *text = ¶m->text; - - return eve_text_touch(text, touch, evt, tag0); -} - -void app_modem(EVEWindow *window, EVEViewStack *stack) { - unsigned char *buf; - EVEWindowRoot *root = window->root; - EVEKbd *kbd = eve_window_kbd(window); - EVERect g = {0, 60, 480, 512}; - EVEView *view; - VParam *param; - - view = eve_malloc(sizeof(EVEView)); - param = eve_malloc(sizeof(VParam)); - param->mem = root->mem_next; - param->stack = stack; - param->cell_dev_handler = eos_cell_get_handler(EOS_CELL_MTYPE_DEV); - eve_text_init(¶m->text, &g, 30, 16, 200, root->mem_next, &root->mem_next); - eve_view_init(view, window, modem_draw, modem_touch, NULL, param); - - eve_kbd_set_handler(kbd, key_down, view); - eve_window_kbd_attach(window); - - eos_uart_set_handler(EOS_UART_ETYPE_RX, handle_uart); - eos_cell_set_handler(EOS_CELL_MTYPE_DEV, handle_cell_msg); - eos_net_acquire_for_evt(EOS_EVT_UART | EOS_UART_ETYPE_RX, 1); - - buf = eos_net_alloc(); - buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_UART_TAKE; - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, 1, 0); - eos_uart_rxwm_set(0); -} - -void app_modem_close(EVEView *view) { - unsigned char *buf = eos_net_alloc(); - VParam *param = view->param; - EVEWindow *window = view->window; - EVEWindowRoot *root = window->root; - EVEKbd *kbd = eve_window_kbd(window); - EVEViewStack *stack = param->stack; - - buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_RESET; - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, 1, 0); - eos_uart_rxwm_clear(); - eos_uart_set_handler(EOS_UART_ETYPE_RX, NULL); - eos_cell_set_handler(EOS_CELL_MTYPE_DEV, param->cell_dev_handler); - eos_net_acquire_for_evt(EOS_EVT_UART | EOS_UART_ETYPE_RX, 0); - - root->mem_next = param->mem; - eve_window_kbd_detach(window); - eve_kbd_set_handler(kbd, NULL, NULL); - - eve_free(param); - eve_free(view); - eve_view_destroy(window, stack); -} diff --git a/fw/fe310/test/modem.h b/fw/fe310/test/modem.h deleted file mode 100644 index 3a6bc35..0000000 --- a/fw/fe310/test/modem.h +++ /dev/null @@ -1,2 +0,0 @@ -void app_modem(EVEWindow *window, EVEViewStack *stack); -void app_modem_close(EVEView *view); diff --git a/fw/fe310/test/phone.c b/fw/fe310/test/phone.c deleted file mode 100644 index 06b24fd..0000000 --- a/fw/fe310/test/phone.c +++ /dev/null @@ -1,119 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <soc/i2s.h> -#include <dev/net.h> -#include <net/cell.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app/app_root.h" -#include "app/app_status.h" - -#include "phone.h" - -#define ABUF_SIZE 128 -#define MIC_WM 64 - -static uint8_t mic_arr[ABUF_SIZE]; -static uint8_t spk_arr[ABUF_SIZE]; - -#define VOICE_STATE_IDLE 0 -#define VOICE_STATE_DIAL 1 -#define VOICE_STATE_RING 2 -#define VOICE_STATE_CIP 3 - -static unsigned char voice_state = 0; - -static void handle_mic(unsigned char type) { - uint16_t size; - unsigned char *buf = eos_net_alloc(); - - buf[0] = EOS_CELL_MTYPE_VOICE_PCM; - size = eos_i2s_mic_read(buf + 1, MIC_WM); - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, size + 1, 0); -} - -static void cell_voice_handler(unsigned char type, unsigned char *buffer, uint16_t len) { - char msg[128]; - - msg[0] = 0; - switch (type) { - case EOS_CELL_MTYPE_VOICE_RING: - voice_state = VOICE_STATE_RING; - sprintf(msg, "RING:%s", buffer+1); - break; - - case EOS_CELL_MTYPE_VOICE_MISS: - voice_state = VOICE_STATE_IDLE; - break; - - case EOS_CELL_MTYPE_VOICE_BEGIN: - printf("VOICE BEGIN\n"); - voice_state = VOICE_STATE_CIP; - eos_i2s_mic_init(mic_arr, ABUF_SIZE); - eos_i2s_mic_set_wm(MIC_WM); - eos_i2s_mic_set_handler(handle_mic); - eos_i2s_spk_init(spk_arr, ABUF_SIZE); - eos_i2s_start(8000, EOS_I2S_FMT_PCM16); - break; - - case EOS_CELL_MTYPE_VOICE_END: - voice_state = VOICE_STATE_IDLE; - eos_i2s_stop(); - break; - - case EOS_CELL_MTYPE_VOICE_PCM: - if (voice_state == VOICE_STATE_CIP) { - eos_i2s_spk_write(buffer+1, len-1); - } - break; - } - app_status_msg_set(msg, 1); - eos_net_free(buffer, 0); -} - -void app_phone(EVEWindow *window, EVEViewStack *stack) { - EVEFormSpec spec[] = { - { - .label.title = "Phone:", - - .widget.type = EVE_WIDGET_TYPE_STR, - .widget.tspec.str.str_size = 128, - }, - }; - - EVEForm *form = eve_form_create(window, stack, spec, 1, NULL, app_phone_action, NULL); -} - -void app_phone_action(EVEForm *form) { - char msg[128]; - EVEStrWidget *w = (EVEStrWidget *)eve_page_widget(&form->p, 0); - unsigned char *buf = eos_net_alloc(); - - buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_DIAL; - strcpy(buf + 1, w->str); - eos_net_send_async(EOS_NET_MTYPE_CELL, buf, 1 + strlen(w->str), 0); - - voice_state = VOICE_STATE_DIAL; - sprintf(msg, "DIAL:%s", w->str); - app_status_msg_set(msg, 0); -} - -void app_phone_init(void) { - eos_cell_set_handler(EOS_CELL_MTYPE_VOICE, cell_voice_handler); - eos_net_acquire_for_evt(EOS_EVT_I2S | EOS_I2S_ETYPE_MIC, 1); -} - -unsigned char app_phone_state_get(void) { - return voice_state; -} diff --git a/fw/fe310/test/phone.h b/fw/fe310/test/phone.h deleted file mode 100644 index f346a38..0000000 --- a/fw/fe310/test/phone.h +++ /dev/null @@ -1,9 +0,0 @@ -#define VOICE_STATE_IDLE 0 -#define VOICE_STATE_DIAL 1 -#define VOICE_STATE_RING 2 -#define VOICE_STATE_CIP 3 - -void app_phone(EVEWindow *window, EVEViewStack *stack); -void app_phone_action(EVEForm *form); -void app_phone_init(void); -unsigned char app_phone_state_get(void); diff --git a/fw/fe310/test/test.c b/fw/fe310/test/test.c deleted file mode 100644 index fc080d2..0000000 --- a/fw/fe310/test/test.c +++ /dev/null @@ -1,63 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> - -#include <soc/i2c.h> -#include <dev/bq25895.h> -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app/app_root.h" - -#include "test.h" - -static int reg_read(uint8_t reg, uint8_t *data) { - return eos_i2c_read8(BQ25895_ADDR, reg, data, 1); -} - -static int reg_write(uint8_t reg, uint8_t data) { - return eos_i2c_write8(BQ25895_ADDR, reg, &data, 1); -} - -int app_test_uievt(EVEForm *form, uint16_t evt, void *param) { - uint8_t data = 0; - int rv, ret = 0, i; - - switch (evt) { - case EVE_UIEVT_GEST_TOUCH: - printf("PAGE TOUCH\n"); - printf("BQ25895:\n"); - for (i=0; i<0x15; i++) { - rv = reg_read(i, &data); - if (!rv) printf("REG%02x: %02x\n", i, data); - } - break; - - default: - ret = eve_form_uievt(form, evt, param); - break; - } - return ret; -} - -void app_test(EVEWindow *window, EVEViewStack *stack) { - EVEFormSpec spec[] = { - { - .widget.type = EVE_WIDGET_TYPE_SPACER, - .widget.g.h = 1, - }, - }; - EVEForm *form = eve_form_create(window, stack, spec, 1, app_test_uievt, NULL, app_test_close); -} - -void app_test_close(EVEForm *form) { - eve_form_destroy(form); -} diff --git a/fw/fe310/test/test.h b/fw/fe310/test/test.h deleted file mode 100644 index daf1f1a..0000000 --- a/fw/fe310/test/test.h +++ /dev/null @@ -1,2 +0,0 @@ -void app_test(EVEWindow *window, EVEViewStack *stack); -void app_test_close(EVEForm *form); diff --git a/fw/fe310/test/wifi.c b/fw/fe310/test/wifi.c deleted file mode 100644 index 92be3db..0000000 --- a/fw/fe310/test/wifi.c +++ /dev/null @@ -1,91 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -#include <eos.h> -#include <dev/net.h> -#include <net/wifi.h> - -#include <eve/eve.h> -#include <eve/eve_kbd.h> -#include <eve/eve_font.h> - -#include <eve/screen/window.h> -#include <eve/screen/page.h> -#include <eve/screen/form.h> - -#include "app/app_root.h" -#include "app/app_status.h" - -#include "wifi.h" - -static void wifi_scan_handler(unsigned char type, unsigned char *buffer, uint16_t size) { - EVEWindowRoot *root = app_root(); - EVEWindow *window = eve_window_search(&root->w, "main"); - EVEForm *form = (EVEForm *)window->view; - EVESelectWidget *select = (EVESelectWidget *)eve_page_widget(&form->p, 0); - - eve_selectw_set_option(select, buffer + 1, size - 1); - eos_net_free(buffer, 0); - - app_root_refresh(); -} - -static void wifi_connect_handler(unsigned char type, unsigned char *buffer, uint16_t size) { - app_status_msg_set("WiFi connected", 1); - eos_net_free(buffer, 0); -} - -static void wifi_disconnect_handler(unsigned char type, unsigned char *buffer, uint16_t size) { - app_status_msg_set("WiFi disconnected", 1); - eos_net_free(buffer, 0); -} - -void app_wifi(EVEWindow *window, EVEViewStack *stack) { - EVEFormSpec spec[] = { - { - .label.g.w = APP_SCREEN_W, - .label.title = "Select network:", - - .widget.type = EVE_WIDGET_TYPE_SELECT, - .widget.g.w = APP_SCREEN_W, - .widget.tspec.select.option_size = 1500, - }, - { - .widget.type = EVE_WIDGET_TYPE_SPACER, - .widget.g.w = APP_SCREEN_W, - .widget.g.h = 50, - }, - { - .label.title = "Password:", - - .widget.type = EVE_WIDGET_TYPE_STR, - .widget.tspec.str.str_size = 128, - }, - }; - - EVEForm *form = eve_form_create(window, stack, spec, 3, NULL, app_wifi_action, app_wifi_close); - eos_wifi_scan(NULL); -} - -void app_wifi_action(EVEForm *form) { - EVESelectWidget *sel = (EVESelectWidget *)eve_page_widget(&form->p, 0); - EVEStrWidget *str = (EVEStrWidget *)eve_page_widget(&form->p, 2); - char *ssid = eve_selectw_option_selected(sel); - - if (ssid) { - eos_wifi_auth(ssid, str->str, NULL); - eos_wifi_connect(NULL); - } -} - -void app_wifi_close(EVEForm *form) { - eve_form_destroy(form); -} - -void app_wifi_init(void) { - eos_wifi_set_handler(EOS_WIFI_MTYPE_SCAN, wifi_scan_handler); - eos_wifi_set_handler(EOS_WIFI_MTYPE_CONNECT, wifi_connect_handler); - eos_wifi_set_handler(EOS_WIFI_MTYPE_DISCONNECT, wifi_disconnect_handler); -} diff --git a/fw/fe310/test/wifi.h b/fw/fe310/test/wifi.h deleted file mode 100644 index 5adaebd..0000000 --- a/fw/fe310/test/wifi.h +++ /dev/null @@ -1,4 +0,0 @@ -void app_wifi(EVEWindow *window, EVEViewStack *stack); -void app_wifi_action(EVEForm *form); -void app_wifi_close(EVEForm *form); -void app_wifi_init(void);
\ No newline at end of file |