summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--code/esp32/components/eos/cell_modem.c8
-rw-r--r--code/esp32/components/eos/cell_pcm.c16
-rw-r--r--code/esp32/components/eos/i2c.c1
-rw-r--r--code/esp32/components/eos/include/eos.h17
-rw-r--r--code/esp32/components/eos/include/net.h4
-rw-r--r--code/esp32/components/eos/msgq.c2
-rw-r--r--code/esp32/components/eos/net.c8
-rw-r--r--code/esp32/components/eos/sock.c7
-rwxr-xr-xcode/esp32/components/eos/wifi.c1
-rw-r--r--code/esp32/main/app_main.c4
10 files changed, 44 insertions, 24 deletions
diff --git a/code/esp32/components/eos/cell_modem.c b/code/esp32/components/eos/cell_modem.c
index 26748a1..2534eb1 100644
--- a/code/esp32/components/eos/cell_modem.c
+++ b/code/esp32/components/eos/cell_modem.c
@@ -30,6 +30,8 @@
static QueueHandle_t uart_queue;
// static uint8_t *uart_data[UART_BUF_SIZE];
+static const char *TAG = "EOS MODEM";
+
static void uart_event_task(void *pvParameters) {
char mode = 0;
uart_event_t event;
@@ -58,6 +60,7 @@ static void uart_event_task(void *pvParameters) {
default:
break;
}
+ break;
case UART_EVENT_MAX:
/* Mode change
@@ -113,9 +116,10 @@ void eos_modem_init(void) {
gpio_set_level(UART_GPIO_DTR, 1);
// Create a task to handle uart event from ISR
- xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, EOS_IRQ_PRIORITY_UART, NULL);
+ xTaskCreate(uart_event_task, "uart_event", EOS_TASK_SSIZE_UART, NULL, EOS_TASK_PRIORITY_UART, NULL);
eos_net_set_handler(EOS_NET_MTYPE_CELL, modem_handler);
+ ESP_LOGI(TAG, "INIT");
}
ssize_t eos_modem_write(void *data, size_t size) {
@@ -126,5 +130,5 @@ void eos_modem_set_mode(char mode) {
uart_event_t evt;
evt.type = UART_EVENT_MAX; /* my type */
evt.size = mode;
- xQueueSend(&uart_queue, (void *)&evt, portMAX_DELAY);
+ xQueueSend(uart_queue, (void *)&evt, portMAX_DELAY);
}
diff --git a/code/esp32/components/eos/cell_pcm.c b/code/esp32/components/eos/cell_pcm.c
index 0c9dfc9..961a322 100644
--- a/code/esp32/components/eos/cell_pcm.c
+++ b/code/esp32/components/eos/cell_pcm.c
@@ -5,6 +5,7 @@
#include <freertos/task.h>
#include <freertos/queue.h>
#include <driver/i2s.h>
+#include <driver/gpio.h>
#include <esp_log.h>
#include "eos.h"
@@ -22,6 +23,8 @@ static i2s_dev_t* I2S[I2S_NUM_MAX] = {&I2S0, &I2S1};
static QueueHandle_t i2s_queue;
+static const char *TAG = "EOS PCM";
+
static void i2s_event_task(void *pvParameters) {
size_t size_out;
i2s_event_t event;
@@ -54,7 +57,7 @@ static void i2s_event_task(void *pvParameters) {
i2s_write(I2S_NUM_0, (const void *)data, BUF_SIZE, &size_out, 1000 / portTICK_RATE_MS);
break;
case I2S_EVENT_DMA_ERROR:
- printf("*** I2S DMA ERROR ***");
+ ESP_LOGE(TAG, "*** I2S DMA ERROR ***");
break;
default:
break;
@@ -108,15 +111,18 @@ void eos_pcm_init(void) {
.data_out_num = PCM_GPIO_DOUT
};
i2s_driver_install(I2S_NUM_0, &i2s_config, 10, &i2s_queue); //install and start i2s driver
- i2s_set_pin(I2S_NUM_0, &pin_config);
i2s_stop(I2S_NUM_0);
+ i2s_set_pin(I2S_NUM_0, &pin_config);
+ gpio_matrix_in(pin_config.ws_io_num, I2S0I_WS_IN_IDX, 1);
+ gpio_matrix_in(pin_config.bck_io_num, I2S0I_BCK_IN_IDX, 1);
I2S[I2S_NUM_0]->conf.tx_mono = 1;
I2S[I2S_NUM_0]->conf.rx_mono = 1;
- i2s_start(I2S_NUM_0);
// Create a task to handle i2s event from ISR
- xTaskCreate(i2s_event_task, "i2s_event_task", 2048, NULL, EOS_IRQ_PRIORITY_I2S, NULL);
- // xTaskCreate(i2s_write_task, "i2s_write_task", 2048, NULL, EOS_IRQ_PRIORITY_I2S, NULL);
+ xTaskCreate(i2s_event_task, "i2s_event", EOS_TASK_SSIZE_I2S, NULL, EOS_TASK_PRIORITY_I2S, NULL);
+ // xTaskCreate(i2s_write_task, "i2s_write_task", EOS_TASK_SSIZE_I2S, NULL, EOS_TASK_PRIORITY_I2S, NULL);
+ ESP_LOGI(TAG, "INIT");
+ i2s_start(I2S_NUM_0);
}
ssize_t eos_pcm_write(void *data, size_t size) {
diff --git a/code/esp32/components/eos/i2c.c b/code/esp32/components/eos/i2c.c
index 1182431..38ad6ba 100644
--- a/code/esp32/components/eos/i2c.c
+++ b/code/esp32/components/eos/i2c.c
@@ -32,6 +32,7 @@ void eos_i2c_init(void) {
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
i2c_param_config(I2C_MASTER_NUM, &conf);
i2c_driver_install(I2C_MASTER_NUM, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
+ ESP_LOGI(TAG, "INIT");
}
/**
diff --git a/code/esp32/components/eos/include/eos.h b/code/esp32/components/eos/include/eos.h
index a21985a..e9a67d4 100644
--- a/code/esp32/components/eos/include/eos.h
+++ b/code/esp32/components/eos/include/eos.h
@@ -1,9 +1,16 @@
#define EOS_OK 0
#define EOS_ERR -1
-#define EOS_ERR_Q_FULL -10
+#define EOS_ERR_FULL -10
+#define EOS_ERR_EMPTY -11
+
+#define EOS_TASK_PRIORITY_UART 1
+#define EOS_TASK_PRIORITY_I2S 1
+#define EOS_TASK_PRIORITY_NET_XCHG 1
+#define EOS_TASK_PRIORITY_UDP_RCVR 1
+
+#define EOS_TASK_SSIZE_UART 4096
+#define EOS_TASK_SSIZE_I2S 4096
+#define EOS_TASK_SSIZE_NET_XCHG 4096
+#define EOS_TASK_SSIZE_UDP_RCVR 4096
-#define EOS_IRQ_PRIORITY_UART 1
-#define EOS_IRQ_PRIORITY_I2S 1
-#define EOS_IRQ_PRIORITY_NET_XCHG 1
-#define EOS_IRQ_PRIORITY_UDP_RCVR 1
diff --git a/code/esp32/components/eos/include/net.h b/code/esp32/components/eos/include/net.h
index d6f3f34..abf2893 100644
--- a/code/esp32/components/eos/include/net.h
+++ b/code/esp32/components/eos/include/net.h
@@ -13,8 +13,8 @@
#define EOS_NET_MTYPE_FLAG_ONEW 0x10
#define EOS_NET_SIZE_BUF 1500
-#define EOS_NET_SIZE_BUFQ 8
-#define EOS_NET_SIZE_SNDQ 16
+#define EOS_NET_SIZE_BUFQ 4
+#define EOS_NET_SIZE_SNDQ 4
#define EOS_NET_FLAG_BFREE 0x1
#define EOS_NET_FLAG_BCOPY 0x2
diff --git a/code/esp32/components/eos/msgq.c b/code/esp32/components/eos/msgq.c
index 6fda261..30fb0ad 100644
--- a/code/esp32/components/eos/msgq.c
+++ b/code/esp32/components/eos/msgq.c
@@ -13,7 +13,7 @@ void eos_msgq_init(EOSMsgQ *msgq, EOSMsgItem *array, uint8_t size) {
}
int eos_msgq_push(EOSMsgQ *msgq, unsigned char type, unsigned char *buffer, uint16_t len, uint8_t flags) {
- if ((uint8_t)(msgq->idx_w - msgq->idx_r) == msgq->size) return EOS_ERR_Q_FULL;
+ if ((uint8_t)(msgq->idx_w - msgq->idx_r) == msgq->size) return EOS_ERR_FULL;
uint8_t idx = EOS_MSGQ_IDX_MASK(msgq->idx_w, msgq->size);
msgq->array[idx].type = type;
diff --git a/code/esp32/components/eos/net.c b/code/esp32/components/eos/net.c
index 3c7877d..be4d0f1 100644
--- a/code/esp32/components/eos/net.c
+++ b/code/esp32/components/eos/net.c
@@ -37,7 +37,6 @@ typedef struct EOSNetBufQ {
} EOSNetBufQ;
static EOSNetBufQ net_buf_q;
-static unsigned char net_bufq_array[EOS_NET_SIZE_BUFQ][EOS_NET_SIZE_BUF];
static EOSMsgQ net_send_q;
static EOSMsgItem net_sndq_array[EOS_NET_SIZE_SNDQ];
@@ -59,7 +58,7 @@ static void net_bufq_init(void) {
net_buf_q.idx_r = 0;
net_buf_q.idx_w = EOS_NET_SIZE_BUFQ;
for (i=0; i<EOS_NET_SIZE_BUFQ; i++) {
- net_buf_q.array[i] = net_bufq_array[i];
+ net_buf_q.array[i] = malloc(EOS_NET_SIZE_BUF);
}
}
@@ -72,7 +71,7 @@ static unsigned char *net_bufq_pop(void) {
return net_buf_q.array[NET_BUFQ_IDX_MASK(net_buf_q.idx_r++)];
}
-static void exchange(void *pvParameters) {
+static void net_xchg_task(void *pvParameters) {
int repeat = 0;
unsigned char mtype = 0;
unsigned char *buffer;
@@ -195,7 +194,8 @@ void eos_net_init(void) {
semaph = xSemaphoreCreateCounting(EOS_NET_SIZE_BUFQ, EOS_NET_SIZE_BUFQ);
mutex = xSemaphoreCreateBinary();
xSemaphoreGive(mutex);
- xTaskCreate(&exchange, "net_xchg", 2048, NULL, EOS_IRQ_PRIORITY_NET_XCHG, NULL);
+ xTaskCreate(&net_xchg_task, "net_xchg", EOS_TASK_SSIZE_NET_XCHG, NULL, EOS_TASK_PRIORITY_NET_XCHG, NULL);
+ ESP_LOGI(TAG, "INIT");
}
unsigned char *eos_net_alloc(void) {
diff --git a/code/esp32/components/eos/sock.c b/code/esp32/components/eos/sock.c
index ee3c6a3..8994b62 100644
--- a/code/esp32/components/eos/sock.c
+++ b/code/esp32/components/eos/sock.c
@@ -78,7 +78,7 @@ static ssize_t t_recvfrom(int sock, void *msg, size_t msg_size, EOSNetAddr *addr
return recvlen;
}
-static void sock_receiver(void *pvParameters) {
+static void udp_rcvr_task(void *pvParameters) {
EOSNetAddr addr;
uint8_t esock = (uint8_t)pvParameters;
int sock = _socks[esock-1];
@@ -136,8 +136,8 @@ static void sock_handler(unsigned char type, unsigned char *buffer, uint16_t siz
}
xSemaphoreGive(mutex);
}
- // xTaskCreatePinnedToCore(&sock_receiver, "sock_receiver", 2048, NULL, EOS_IRQ_PRIORITY_UDP_RCVR, NULL, 1);
- xTaskCreate(&sock_receiver, "sock_receiver", 2048, (void *)esock, EOS_IRQ_PRIORITY_UDP_RCVR, NULL);
+ // xTaskCreatePinnedToCore(&sock_receiver, "sock_receiver", EOS_TASK_SSIZE_UDP_RCVR, (void *)esock, EOS_TASK_PRIORITY_UDP_RCVR, NULL, 1);
+ xTaskCreate(&udp_rcvr_task, "udp_rcvr", EOS_TASK_SSIZE_UDP_RCVR, (void *)esock, EOS_TASK_PRIORITY_UDP_RCVR, NULL);
rbuf = eos_net_alloc();
rbuf[0] = EOS_SOCK_MTYPE_OPEN_DGRAM;
rbuf[1] = esock;
@@ -159,4 +159,5 @@ void eos_sock_init(void) {
mutex = xSemaphoreCreateBinary();
xSemaphoreGive(mutex);
eos_net_set_handler(EOS_NET_MTYPE_SOCK, sock_handler);
+ ESP_LOGI(TAG, "INIT");
} \ No newline at end of file
diff --git a/code/esp32/components/eos/wifi.c b/code/esp32/components/eos/wifi.c
index 29cd983..09b0b39 100755
--- a/code/esp32/components/eos/wifi.c
+++ b/code/esp32/components/eos/wifi.c
@@ -88,6 +88,7 @@ void eos_wifi_init(void) {
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
eos_net_set_handler(EOS_NET_MTYPE_WIFI, wifi_handler);
+ ESP_LOGI(TAG, "INIT");
}
void eos_wifi_connect(char *ssid, char *pass) {
diff --git a/code/esp32/main/app_main.c b/code/esp32/main/app_main.c
index 705e46f..314a313 100644
--- a/code/esp32/main/app_main.c
+++ b/code/esp32/main/app_main.c
@@ -8,9 +8,9 @@
// Main application
void app_main() {
eos_i2c_init();
- eos_modem_init();
- eos_pcm_init();
eos_net_init();
+ eos_pcm_init();
+ eos_modem_init();
eos_wifi_init();
eos_sock_init();
eos_bq25895_set_ilim();