summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/include
diff options
context:
space:
mode:
Diffstat (limited to 'fw/esp32/components/eos/include')
-rw-r--r--fw/esp32/components/eos/include/app.h15
-rw-r--r--fw/esp32/components/eos/include/cell.h16
-rw-r--r--fw/esp32/components/eos/include/eos.h16
-rw-r--r--fw/esp32/components/eos/include/msgq.h4
-rw-r--r--fw/esp32/components/eos/include/net.h32
-rw-r--r--fw/esp32/components/eos/include/net_priv.h33
-rw-r--r--fw/esp32/components/eos/include/power.h33
-rw-r--r--fw/esp32/components/eos/include/sock.h4
-rw-r--r--fw/esp32/components/eos/include/wifi.h3
9 files changed, 101 insertions, 55 deletions
diff --git a/fw/esp32/components/eos/include/app.h b/fw/esp32/components/eos/include/app.h
index 2033b2b..b6dba99 100644
--- a/fw/esp32/components/eos/include/app.h
+++ b/fw/esp32/components/eos/include/app.h
@@ -1,5 +1,7 @@
#include <stdint.h>
+#include "net.h"
+
/* common */
#define EOS_APP_MTU 1500
#define EOS_APP_SIZE_BUF EOS_APP_MTU
@@ -7,17 +9,18 @@
#define EOS_APP_MTYPE_TUN 1
#define EOS_APP_MAX_MTYPE 8
-#define EOS_APP_MTYPE_FLAG_MASK 0xc0
-
/* esp32 specific */
#define EOS_APP_SIZE_BUFQ 4
#define EOS_APP_SIZE_SNDQ 4
-typedef void (*eos_app_fptr_t) (unsigned char, unsigned char *, uint16_t);
-
void eos_app_init(void);
+void eos_app_run(void);
unsigned char *eos_app_alloc(void);
void eos_app_free(unsigned char *buf);
-int eos_app_send(unsigned char mtype, unsigned char *buffer, uint16_t len);
-void eos_app_set_handler(unsigned char mtype, eos_app_fptr_t handler);
+
+int eos_app_send(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
+
+void eos_app_sleep_req(void);
+void eos_app_wake(void);
+void eos_app_set_handler(unsigned char mtype, eos_net_handler_t handler);
diff --git a/fw/esp32/components/eos/include/cell.h b/fw/esp32/components/eos/include/cell.h
index cb9f49c..c1e7545 100644
--- a/fw/esp32/components/eos/include/cell.h
+++ b/fw/esp32/components/eos/include/cell.h
@@ -27,7 +27,6 @@
#define EOS_CELL_MTYPE_VOICE_END 7
#define EOS_CELL_MTYPE_VOICE_MISS 8
#define EOS_CELL_MTYPE_VOICE_BUSY 9
-#define EOS_CELL_MTYPE_VOICE_ERR 10
#define EOS_CELL_MTYPE_SMS_MSG 1
#define EOS_CELL_MTYPE_SMS_LIST 2
@@ -76,24 +75,26 @@
#define EOS_CELL_UART_SIZE_BUF 1024
void eos_cell_init(void);
+void eos_cell_run(void);
void eos_modem_init(void);
+void eos_modem_run(void);
int eos_modem_atinit(void);
+void eos_modem_reset(void);
void eos_modem_flush(void);
size_t eos_modem_write(void *data, size_t size);
size_t eos_modem_read(void *data, size_t size, uint32_t timeout);
int eos_modem_readln(char *buf, size_t buf_size, uint32_t timeout);
-int eos_modem_resp(char *ok_str, char *err_str, uint32_t timeout);
int eos_modem_present(void);
+int eos_modem_initialized(void);
uint8_t eos_modem_get_mode(void);
size_t eos_modem_get_status(unsigned char *buffer);
int eos_modem_set_mode(uint8_t mode);
int eos_modem_take(uint32_t timeout);
void eos_modem_give(void);
-void eos_modem_sleep(void);
-void eos_modem_deep_sleep(void);
-void eos_modem_wake(uint8_t source, uint8_t mode);
-int eos_modem_reset(void);
+
+void eos_modem_sleep_req(void);
+void eos_modem_wake(void);
void eos_ppp_get_apn(char *apn);
void eos_ppp_set_apn(char *apn);
@@ -105,8 +106,7 @@ int eos_ppp_connect(void);
void eos_ppp_disconnect(void);
void eos_cell_pcm_init(void);
-ssize_t eos_cell_pcm_read(unsigned char *data, size_t size);
-int eos_cell_pcm_push(unsigned char *data, size_t size);
+void eos_cell_pcm_push(unsigned char *data, size_t size);
void eos_cell_pcm_start(void);
void eos_cell_pcm_stop(void);
diff --git a/fw/esp32/components/eos/include/eos.h b/fw/esp32/components/eos/include/eos.h
index bc9dc51..e772637 100644
--- a/fw/esp32/components/eos/include/eos.h
+++ b/fw/esp32/components/eos/include/eos.h
@@ -11,21 +11,21 @@
#define EOS_ERR_NOMEM -100
-#define EOS_TASK_PRIORITY_NET_XCHG 1
-#define EOS_TASK_PRIORITY_APP_XCHG 1
-#define EOS_TASK_PRIORITY_UDP_RCVR 1
+#define EOS_TASK_PRIORITY_NET 1
+#define EOS_TASK_PRIORITY_APP 1
+#define EOS_TASK_PRIORITY_SOCK 1
#define EOS_TASK_PRIORITY_UART 1
#define EOS_TASK_PRIORITY_MODEM 1
-#define EOS_TASK_PRIORITY_I2S 1
+#define EOS_TASK_PRIORITY_PCM 1
#define EOS_TASK_PRIORITY_CELL 1
#define EOS_TASK_PRIORITY_PWR 1
-#define EOS_TASK_SSIZE_NET_XCHG 8192
-#define EOS_TASK_SSIZE_APP_XCHG 8192
-#define EOS_TASK_SSIZE_UDP_RCVR 4096
+#define EOS_TASK_SSIZE_NET 8192
+#define EOS_TASK_SSIZE_APP 8192
+#define EOS_TASK_SSIZE_SOCK 4096
#define EOS_TASK_SSIZE_UART 4096
#define EOS_TASK_SSIZE_MODEM 4096
-#define EOS_TASK_SSIZE_I2S 4096
+#define EOS_TASK_SSIZE_PCM 4096
#define EOS_TASK_SSIZE_CELL 4096
#define EOS_TASK_SSIZE_PWR 4096
diff --git a/fw/esp32/components/eos/include/msgq.h b/fw/esp32/components/eos/include/msgq.h
index bbfe041..b5ae9ac 100644
--- a/fw/esp32/components/eos/include/msgq.h
+++ b/fw/esp32/components/eos/include/msgq.h
@@ -14,9 +14,9 @@ typedef struct EOSMsgQ {
} EOSMsgQ;
void eos_msgq_init(EOSMsgQ *msgq, EOSMsgItem *array, uint8_t size);
+uint8_t eos_msgq_len(EOSMsgQ *msgq);
int eos_msgq_push(EOSMsgQ *msgq, unsigned char type, unsigned char *buffer, uint16_t len);
void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, unsigned char **buffer, uint16_t *len);
-uint8_t eos_msgq_len(EOSMsgQ *msgq);
typedef struct EOSBufQ {
uint8_t idx_r;
@@ -26,6 +26,6 @@ typedef struct EOSBufQ {
} EOSBufQ;
void eos_bufq_init(EOSBufQ *bufq, unsigned char **array, uint8_t size);
+uint8_t eos_bufq_len(EOSBufQ *bufq);
int eos_bufq_push(EOSBufQ *bufq, unsigned char *buffer);
unsigned char *eos_bufq_pop(EOSBufQ *bufq);
-uint8_t eos_bufq_len(EOSBufQ *bufq);
diff --git a/fw/esp32/components/eos/include/net.h b/fw/esp32/components/eos/include/net.h
index 3e9e625..b500e82 100644
--- a/fw/esp32/components/eos/include/net.h
+++ b/fw/esp32/components/eos/include/net.h
@@ -5,32 +5,36 @@
#define EOS_NET_SIZE_BUF EOS_NET_MTU
#define EOS_NET_MTYPE_SOCK 1
-#define EOS_NET_MTYPE_RNG 3
-#define EOS_NET_MTYPE_POWER 4
+#define EOS_NET_MTYPE_WIFI 2
+#define EOS_NET_MTYPE_CELL 3
+#define EOS_NET_MTYPE_APP 4
+#define EOS_NET_MTYPE_RNG 5
-#define EOS_NET_MTYPE_WIFI 5
-#define EOS_NET_MTYPE_CELL 6
-#define EOS_NET_MTYPE_SIP 7
-#define EOS_NET_MTYPE_APP 8
+#define EOS_NET_MAX_MTYPE 5
-#define EOS_NET_MAX_MTYPE 8
+#define EOS_NET_MTYPE_SLEEP 0x10 /* does not have net handler */
#define EOS_NET_MTYPE_FLAG_ONEW 0x40
#define EOS_NET_MTYPE_FLAG_REPL 0x80
-#define EOS_NET_MTYPE_FLAG_MASK 0xc0
+#define EOS_NET_MTYPE_MASK 0x3F /* 0x0F if mtype is handled by evtq */
/* esp32 specific */
#define EOS_NET_SIZE_BUFQ 4
#define EOS_NET_SIZE_SNDQ 4
-typedef void (*eos_net_fptr_t) (unsigned char, unsigned char *, uint16_t);
+typedef void (*eos_net_handler_t) (unsigned char, unsigned char *, uint16_t);
+void eos_net_xchg_task(void *param);
void eos_net_init(void);
+void eos_net_run(void);
unsigned char *eos_net_alloc(void);
void eos_net_free(unsigned char *buf);
-int eos_net_send(unsigned char mtype, unsigned char *buffer, uint16_t len);
-void eos_net_reply(unsigned char mtype, unsigned char *buffer, uint16_t len);
-void eos_net_set_handler(unsigned char mtype, eos_net_fptr_t handler);
-void eos_net_sleep(void);
-void eos_net_wake(uint8_t source, uint8_t mode);
+
+int eos_net_send(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
+void eos_net_reply(unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
+
+void eos_net_sleep_req(void);
+void eos_net_wake(void);
+
+void eos_net_set_handler(unsigned char mtype, eos_net_handler_t handler);
diff --git a/fw/esp32/components/eos/include/net_priv.h b/fw/esp32/components/eos/include/net_priv.h
new file mode 100644
index 0000000..fa1de61
--- /dev/null
+++ b/fw/esp32/components/eos/include/net_priv.h
@@ -0,0 +1,33 @@
+#define NET_DEV_NET EOS_PWR_DEV_NET
+#define NET_DEV_APP EOS_PWR_DEV_APP
+
+typedef struct NETConfig {
+ int sleep;
+ int sleep_req;
+ int present;
+ int gpio_mosi;
+ int gpio_miso;
+ int gpio_sclk;
+ int gpio_cs;
+ int gpio_rts;
+ int gpio_cts;
+ uint32_t dev;
+ spi_host_device_t spi_host;
+ spi_bus_config_t *spi_bus_cfg;
+ spi_slave_interface_config_t *spi_iface_cfg;
+ spi_slave_transaction_t *spi_tr_cfg;
+ TaskHandle_t xchg_task_handle;
+ SemaphoreHandle_t mutex;
+ SemaphoreHandle_t bufq_mutex;
+ SemaphoreHandle_t bufq_semaph;
+ EOSBufQ *buf_q;
+ EOSMsgQ *send_q;
+ eos_net_handler_t msg_handler;
+} NETConfig;
+
+void _eos_net_init_gpio(NETConfig *config);
+unsigned char *_eos_net_alloc(NETConfig *config);
+void _eos_net_free(NETConfig *config, unsigned char *buf);
+int _eos_net_send(NETConfig *config, unsigned char mtype, unsigned char *buffer, uint16_t buf_len);
+void _eos_net_sleep_req(NETConfig *config);
+void _eos_net_wake(NETConfig *config);
diff --git a/fw/esp32/components/eos/include/power.h b/fw/esp32/components/eos/include/power.h
index 2215907..2590b80 100644
--- a/fw/esp32/components/eos/include/power.h
+++ b/fw/esp32/components/eos/include/power.h
@@ -1,22 +1,25 @@
#include <stdint.h>
-#define EOS_PWR_MTYPE_BUTTON 1
+#define EOS_PWR_GPIO_NET 8
+#define EOS_PWR_GPIO_APP 10
+#define EOS_PWR_GPIO_MODEM 16
-#define EOS_PWR_WAKE_RST 0
-#define EOS_PWR_WAKE_BTN 1
-#define EOS_PWR_WAKE_UART 2
-#define EOS_PWR_WAKE_NET 3
-#define EOS_PWR_WAKE_NETQ 4
-#define EOS_PWR_WAKE_UNDEF 5
+#define EOS_PWR_DEV_NONE 0
+#define EOS_PWR_DEV_NET ((uint32_t)1 << EOS_PWR_GPIO_NET)
+#define EOS_PWR_DEV_APP ((uint32_t)1 << EOS_PWR_GPIO_APP)
+#define EOS_PWR_DEV_MODEM ((uint32_t)1 << EOS_PWR_GPIO_MODEM)
+#define EOS_PWR_DEV_ALL (EOS_PWR_DEV_NET | EOS_PWR_DEV_APP | EOS_PWR_DEV_MODEM)
-#define EOS_PWR_SMODE_LIGHT 1
-#define EOS_PWR_SMODE_DEEP 2
+#define EOS_PWR_SMODE_TICKLESS 1
+#define EOS_PWR_SMODE_LIGHT 2
+#define EOS_PWR_SMODE_DEEP 3
void eos_power_init(void);
+void eos_power_run(void);
+void eos_power_sys_sleep(uint8_t mode);
+void eos_power_sys_wake(uint8_t mode) ;
+uint32_t eos_power_wakeup_source(void);
-void eos_power_wait4init(void);
-void eos_power_wait4wake(void);
-uint8_t eos_power_wakeup_cause(void);
-void eos_power_sleep(void);
-void eos_power_wake(uint8_t source);
-void eos_power_net_ready(void); \ No newline at end of file
+void eos_power_sleep_req(uint8_t mode, uint32_t dev);
+void eos_power_sleep_rdy(uint32_t dev);
+void eos_power_wake(uint32_t dev);
diff --git a/fw/esp32/components/eos/include/sock.h b/fw/esp32/components/eos/include/sock.h
index 7e937cb..f2cf0c4 100644
--- a/fw/esp32/components/eos/include/sock.h
+++ b/fw/esp32/components/eos/include/sock.h
@@ -15,4 +15,6 @@ typedef struct EOSNetAddr {
uint16_t port;
} EOSNetAddr;
-void eos_sock_init(void); \ No newline at end of file
+void eos_sock_init(void);
+void eos_sock_run(void);
+void eos_sock_reopen(void); \ No newline at end of file
diff --git a/fw/esp32/components/eos/include/wifi.h b/fw/esp32/components/eos/include/wifi.h
index c1819e7..d080e25 100644
--- a/fw/esp32/components/eos/include/wifi.h
+++ b/fw/esp32/components/eos/include/wifi.h
@@ -13,6 +13,7 @@
#define EOS_WIFI_MAX_SCAN_RECORDS 20
void eos_wifi_init(void);
+void eos_wifi_run(void);
int eos_wifi_scan(void);
int eos_wifi_auth(char *ssid, char *pass);
@@ -21,4 +22,4 @@ int eos_wifi_disconnect(void);
ssize_t eos_wifi_get_status(unsigned char *buffer);
void eos_wifi_send_status(void);
-void eos_wifi_send_scan(void); \ No newline at end of file
+void eos_wifi_send_scan(void);