From 33d5e2cffd685f269b5e56a42961e42203054354 Mon Sep 17 00:00:00 2001 From: Francisco Llobet Date: Mon, 15 Jan 2024 22:06:58 +0100 Subject: [PATCH] updating cc3100 driver logic --- csrc/board/src/board_CC3100.c | 11 +++++++---- csrc/config/FreeRTOSConfig.h | 2 +- csrc/src/network.c | 18 +++++++++--------- src/config.zig | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/csrc/board/src/board_CC3100.c b/csrc/board/src/board_CC3100.c index eff1e25..1c74817 100644 --- a/csrc/board/src/board_CC3100.c +++ b/csrc/board/src/board_CC3100.c @@ -237,11 +237,14 @@ int CC3100_IfRead(Fd_t Fd, uint8_t *pBuff, int Len) ecode = SPIDRV_MReceive(&cc3100_usart, pBuff, Len, recieve_callback); if (ECODE_EMDRV_SPIDRV_OK == ecode) { - (void) xQueueReceive(rx_semaphore, &transfer_status, portMAX_DELAY); - if (ECODE_EMDRV_SPIDRV_OK == transfer_status.transferStatus) + if(pdTRUE == xQueueReceive(rx_semaphore, &transfer_status, 2*1000)) // Added rx timeout { - retVal = transfer_status.itemsTransferred; - } else + if (ECODE_EMDRV_SPIDRV_OK == transfer_status.transferStatus) + { + retVal = transfer_status.itemsTransferred; + } + } + else { retVal = -1; } diff --git a/csrc/config/FreeRTOSConfig.h b/csrc/config/FreeRTOSConfig.h index 4f8e3ca..a7bd38a 100644 --- a/csrc/config/FreeRTOSConfig.h +++ b/csrc/config/FreeRTOSConfig.h @@ -134,7 +134,7 @@ extern "C" { #define configCPU_CLOCK_HZ (( unsigned long )48000000 ) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE (( unsigned short ) 160) -#define configTOTAL_HEAP_SIZE (( size_t )(61 * 1024 )) +#define configTOTAL_HEAP_SIZE (( size_t )(59 * 1024 )) #define configMAX_TASK_NAME_LEN ( 10 ) #define configUSE_TRACE_FACILITY ( 0 ) #define configUSE_16_BIT_TICKS ( 0 ) diff --git a/csrc/src/network.c b/csrc/src/network.c index ae37594..5530043 100644 --- a/csrc/src/network.c +++ b/csrc/src/network.c @@ -235,7 +235,7 @@ static void select_task(void *param) fd_set write_fd_set; uint32_t notification_counter = 0; - struct timeout_msg_s timeout_msg; + struct timeout_msg_s timeout_msg = {0}; BaseType_t ret = pdFALSE; while (1) @@ -303,14 +303,14 @@ static void select_task(void *param) { // Start second cycle // The select function is called with a timeout of 20 ms - const struct timeval tv = - {.tv_sec = 0, .tv_usec = 20000}; // Here we have the select cycle time + struct timeval tv = {.tv_sec = 0, .tv_usec = 50000}; // Here we have the select cycle time + int result = 0; - (void)xSemaphoreTake(rx_tx_mutex, portMAX_DELAY); - - int result = sl_Select(FD_SETSIZE, read_set_ptr, write_fd_set_ptr, NULL, (struct SlTimeval_t *)&tv); - - (void)xSemaphoreGive(rx_tx_mutex); + if(pdTRUE == xSemaphoreTake(rx_tx_mutex, portMAX_DELAY)) + { + result = sl_Select(FD_SETSIZE, read_set_ptr, write_fd_set_ptr, NULL, (struct SlTimeval_t *)&tv); + (void)xSemaphoreGive(rx_tx_mutex); + } if (result > 0) { @@ -350,7 +350,7 @@ static void select_task(void *param) } else { - // printf("select %d\r\n", uxTaskGetStackHighWaterMark(network_monitor_task_handle)); + // printf("select %d\r\n", uxTaskGetStackHighWaterMark(network_monitor_task_handle)); // Wait for notifications (void)xTaskGenericNotifyWait(0, 0, UINT32_MAX, ¬ification_counter, portMAX_DELAY); diff --git a/src/config.zig b/src/config.zig index 18706e0..f74a4c6 100644 --- a/src/config.zig +++ b/src/config.zig @@ -45,7 +45,7 @@ pub const rtos_stack_depth_lwm2m: u16 = if (enable_lwm2m) 2000 else min_task_sta // MQTT pub const rtos_prio_mqtt = @intFromEnum(task_priorities.rtos_prio_normal); -pub const rtos_stack_depth_mqtt: u16 = if (enable_mqtt) 1400 else min_task_stack_depth; +pub const rtos_stack_depth_mqtt: u16 = if (enable_mqtt) 1450 else min_task_stack_depth; // HTTP pub const rtos_prio_http = @intFromEnum(task_priorities.rtos_prio_normal);