#include #include #include #include #include #include #include #include #include #include #include #include #include "eos.h" #include "msgq.h" #include "power.h" #include "app.h" #include "net_priv.h" #define SPI_GPIO_CTS 9 #define SPI_GPIO_RTS 47 #define SPI_GPIO_MOSI 11 #define SPI_GPIO_MISO 13 #define SPI_GPIO_SCLK 12 #define SPI_GPIO_CS 10 #define SPI_SIZE_BUF (EOS_APP_SIZE_BUF + 4) #define SPI_SIZE_HDR 3 #define SPI_HOST SPI2_HOST static EOSBufQ app_buf_q; static unsigned char *app_bufq_array[EOS_APP_SIZE_BUFQ]; static EOSMsgQ app_send_q; static EOSMsgItem app_sndq_array[EOS_APP_SIZE_SNDQ]; static NETConfig app_config; static eos_net_handler_t app_handler[EOS_APP_MAX_MTYPE]; static spi_bus_config_t app_spi_bus_cfg; static spi_slave_interface_config_t app_spi_iface_cfg; static spi_slave_transaction_t app_spi_tr_cfg; static const char *TAG = "EOS APP"; static void bad_handler(unsigned char mtype, unsigned char *buffer, uint16_t len) { ESP_LOGE(TAG, "bad handler: 0x%.2X len: %d", mtype, len); } static void app_msg_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len) { uint8_t idx; idx = mtype & EOS_NET_MTYPE_MASK; if (idx && (idx <= EOS_APP_MAX_MTYPE) && (buf_len <= EOS_APP_MTU)) { app_handler[idx - 1](mtype, buffer, buf_len); } else { bad_handler(mtype, buffer, buf_len); } } void eos_app_init(void) { SemaphoreHandle_t mutex; SemaphoreHandle_t bufq_mutex; SemaphoreHandle_t bufq_semaph; int i; eos_msgq_init(&app_send_q, app_sndq_array, EOS_APP_SIZE_SNDQ); eos_bufq_init(&app_buf_q, app_bufq_array, EOS_APP_SIZE_BUFQ); for (i=0; i