From 9de2090de9f87a837e96b5db0aae0febd8e41ce0 Mon Sep 17 00:00:00 2001 From: mculover666 <2412828003@qq.com> Date: Tue, 1 Mar 2022 15:11:30 +0800 Subject: [PATCH] add support for multi at device --- .../BSP/Src/stm32l4xx_it_module.c | 9 +- .../TencentOS_tiny.uvoptx | 4 +- .../TencentOS_tiny.uvprojx | 13 +- .../BearPi_STM32L31RC.uvoptx | 8 +- .../BearPi_STM32L31RC.uvprojx | 9 +- .../TencentOS_tiny.uvoptx | 2 +- .../TencentOS_tiny.uvprojx | 9 +- .../BearPi_STM32L31RC.uvoptx | 12 +- .../BearPi_STM32L31RC.uvprojx | 9 +- .../BSP/Src/stm32l4xx_it_tf_module.c | 307 ++++++++++++++ .../TencentOS_tiny.uvoptx | 12 +- .../TencentOS_tiny.uvprojx | 21 +- .../demo/stm32l4xx_it_tf_module.c | 307 ++++++++++++++ .../TencentOS_tiny.uvoptx | 82 ++-- .../TencentOS_tiny.uvprojx | 16 +- .../KEIL/hello_world/TencentOS_Tiny.uvoptx | 6 +- .../KEIL/hello_world/TencentOS_Tiny.uvprojx | 11 +- .../wifi_esp8266tc_bh1750/App/stm32wlxx_it.c | 4 +- .../TencentOS_Tiny.uvoptx | 10 +- .../KEIL/TencentOS-Tiny.uvoptx | 2 +- .../mqttclient_iot_explorer/board/mcu_init.c | 13 +- .../KEIL/TencentOS-Tiny.uvprojx | 7 +- .../board/mcu_init.c | 13 +- .../KEIL/TencentOS-Tiny.uvoptx | 12 +- .../tcp_through_module/board/mcu_init.c | 13 +- .../BSP/Src/stm32g0xx_it_module.c | 4 +- .../hello_world/TencentOS_tiny_EVB_G0.uvoptx | 2 +- .../hello_world/TencentOS_tiny_EVB_G0.uvprojx | 11 +- .../TencentOS_tiny_EVB_G0.uvoptx | 6 +- .../TencentOS_tiny_EVB_G0.uvprojx | 13 +- .../TencentOS_tiny_EVB_G0.uvoptx | 2 +- .../TencentOS_tiny_EVB_G0.uvprojx | 11 +- .../demo/stm32g0xx_it_demo.c | 4 +- .../TencentOS_tiny_EVB_G0.uvoptx | 14 +- .../TencentOS_tiny_EVB_G0.uvprojx | 11 +- .../demo/stm32g0xx_it_demo.c | 4 +- .../TencentOS_tiny_EVB_G0.uvprojx | 11 +- .../demo/stm32g0xx_it_demo.c | 4 +- .../TencentOS_tiny_EVB_G0.uvoptx | 12 +- .../TencentOS_tiny_EVB_G0.uvprojx | 11 +- .../BSP/Src/stm32l4xx_it_module.c | 4 +- .../TencentOS_tiny.uvoptx | 30 +- .../TencentOS_tiny.uvprojx | 21 +- .../KEIL/hello_world/TencentOS_tiny.uvoptx | 4 +- .../KEIL/hello_world/TencentOS_tiny.uvprojx | 9 +- .../TencentOS_tiny.uvoptx | 4 +- .../TencentOS_tiny.uvprojx | 9 +- .../TencentOS_tiny.uvoptx | 42 +- .../TencentOS_tiny.uvprojx | 21 +- .../tcp_through_module/TencentOS_tiny.uvoptx | 18 +- .../tcp_through_module/TencentOS_tiny.uvprojx | 16 +- .../TencentOS_tiny.uvoptx | 30 +- .../TencentOS_tiny.uvprojx | 16 +- .../KEIL/test/TencentOS_tiny.uvoptx | 2 +- .../KEIL/test/TencentOS_tiny.uvprojx | 9 +- .../udp_through_module/TencentOS_tiny.uvoptx | 20 +- .../udp_through_module/TencentOS_tiny.uvprojx | 16 +- .../BSP/Src/stm32h7xx_it_at_module.c | 7 +- .../TencentOS_tiny_STM32H750.uvoptx | 2 +- .../TencentOS_tiny_STM32H750.uvprojx | 9 +- devices/ec20_200_600/ec600s.c | 104 ++--- devices/esp8266/esp8266.c | 89 +++-- .../esp8266_tencent_firmware.c | 68 ++-- .../esp8266_tencent_firmware.h | 1 + .../mqttclient_iot_explorer.c | 6 +- net/at/include/tos_at.h | 84 ++-- net/at/src/tos_at.c | 375 +++++++++--------- .../hal/nxp/mimxrt10xx/src/tos_hal_uart.c | 8 +- 68 files changed, 1255 insertions(+), 800 deletions(-) create mode 100644 board/TencentOS_Tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_tf_module.c create mode 100644 board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/demo/stm32l4xx_it_tf_module.c diff --git a/board/BearPi_STM32L431RC/BSP/Src/stm32l4xx_it_module.c b/board/BearPi_STM32L431RC/BSP/Src/stm32l4xx_it_module.c index c50cee4b..ae837942 100644 --- a/board/BearPi_STM32L431RC/BSP/Src/stm32l4xx_it_module.c +++ b/board/BearPi_STM32L431RC/BSP/Src/stm32l4xx_it_module.c @@ -66,7 +66,7 @@ extern UART_HandleTypeDef hlpuart1; extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -299,7 +299,7 @@ void LPUART1_IRQHandler(void) __HAL_UART_CLEAR_IDLEFLAG(&hlpuart1); if (uart_frame_buffer_index != 0) { - tos_at_uart_input_frame(uart_frame_buffer, uart_frame_buffer_index); + tos_at_uart_input_frame(&esp8266_agent, uart_frame_buffer, uart_frame_buffer_index); uart_frame_buffer_index = 0; memset(uart_frame_buffer, 0, sizeof(uart_frame_buffer)); } @@ -314,14 +314,15 @@ void LPUART1_IRQHandler(void) void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { extern uint8_t data; + if (huart->Instance == LPUART1) { HAL_UART_Receive_IT(&hlpuart1, &data, 1); #if AT_INPUT_TYPE_FRAME_EN uart_frame_buffer[uart_frame_buffer_index++] = data; #elif AT_INPUT_SIMULATE_IDLE_EN - tos_at_uart_input_byte_no_notify(data); + tos_at_uart_input_byte_no_notify(&esp8266_agent, data); #else - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_agent, data); #endif /* AT_INPUT_TYPE_FRAME_EN */ } } diff --git a/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx b/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx index 4ad609c8..6a5dc6f4 100644 --- a/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx +++ b/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -1079,7 +1079,7 @@ devices - 1 + 0 0 0 0 diff --git a/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx b/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx index 50927f80..4fa2f920 100644 --- a/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx +++ b/board/BearPi_STM32L431RC/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -339,7 +339,7 @@ USE_HAL_DRIVER,STM32L431xx,WITH_TOS_NET_ADAPTER - ..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L4xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\kernel\core\include;..\..\TOS-CONFIG;..\..\..\..\platform\arch\arm\cortex-m4\keil;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\BSP\Hardware\LCD_ST7789;..\..\BSP\Hardware\BH1750;..\..\..\..\devices\esp8266;..\..\..\..\net\at\include;..\..\..\..\net\sal_module_wrapper;..\..\..\..\kernel\hal\include;..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\include;..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\wrapper\include;..\..\..\..\examples\tencent_os_mqtt;..\..\..\..\components\connectivity\mqttclient\common;..\..\..\..\components\connectivity\mqttclient\common\log;..\..\..\..\components\connectivity\mqttclient\mqtt;..\..\..\..\components\connectivity\mqttclient\mqttclient;..\..\..\..\components\connectivity\mqttclient\network;..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny;..\..\..\..\components\utils\JSON\include + ..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L4xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\kernel\core\include;..\..\TOS-CONFIG;..\..\..\..\platform\arch\arm\cortex-m4\keil;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\BSP\Hardware\LCD_ST7789;..\..\BSP\Hardware\BH1750;..\..\..\..\devices\esp8266;..\..\..\..\net\at\include;..\..\..\..\net\sal_module_wrapper;..\..\..\..\kernel\hal\include;..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\3rdparty\include;..\..\..\..\components\connectivity\Eclipse-Paho-MQTT\wrapper\include;..\..\..\..\examples\tencent_os_mqtt;..\..\..\..\components\connectivity\mqttclient\common;..\..\..\..\components\connectivity\mqttclient\common\log;..\..\..\..\components\connectivity\mqttclient\mqtt;..\..\..\..\components\connectivity\mqttclient\mqttclient;..\..\..\..\components\connectivity\mqttclient\network;..\..\..\..\components\connectivity\mqttclient\platform\TencentOS-tiny;..\..\..\..\components\utils\JSON\include;..\..\..\..\devices\ec20_200_600 @@ -1028,12 +1028,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvoptx b/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvoptx index 0106a3e7..7c5b71e2 100644 --- a/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvoptx +++ b/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvoptx @@ -311,7 +311,7 @@ Application/User - 1 + 0 0 0 0 @@ -1187,7 +1187,7 @@ hal - 1 + 0 0 0 0 @@ -1207,7 +1207,7 @@ at - 1 + 0 0 0 0 @@ -1239,7 +1239,7 @@ device - 1 + 0 0 0 0 diff --git a/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvprojx b/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvprojx index dc80e456..354fd8f0 100644 --- a/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvprojx +++ b/board/BearPi_STM32L431RC/KEIL/tcp_through_module/BearPi_STM32L31RC.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -829,11 +829,6 @@ BearPi_STM32L31RC - - - - - 0 1 diff --git a/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvoptx b/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvoptx index 7c90b858..0e87e2dc 100644 --- a/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvoptx +++ b/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 diff --git a/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvprojx b/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvprojx index 015dae56..b7269876 100644 --- a/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvprojx +++ b/board/BearPi_STM32L431RC/KEIL/tencent_os_mqttclient/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -1019,11 +1019,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvoptx b/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvoptx index bacdbabd..4fe448dd 100644 --- a/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvoptx +++ b/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -311,7 +311,7 @@ Application/User - 1 + 0 0 0 0 @@ -795,7 +795,7 @@ kernel - 1 + 0 0 0 0 @@ -1223,7 +1223,7 @@ hal - 1 + 0 0 0 0 @@ -1243,7 +1243,7 @@ at - 1 + 0 0 0 0 @@ -1275,7 +1275,7 @@ device - 1 + 0 0 0 0 diff --git a/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvprojx b/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvprojx index c64e28fe..3543ea51 100644 --- a/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvprojx +++ b/board/BearPi_STM32L431RC/KEIL/udp_through_module/BearPi_STM32L31RC.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -844,11 +844,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_Tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_tf_module.c b/board/TencentOS_Tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_tf_module.c new file mode 100644 index 00000000..afc66c74 --- /dev/null +++ b/board/TencentOS_Tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_tf_module.c @@ -0,0 +1,307 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32l4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32l4xx_it.h" +#include "tos_k.h" +#include "tos_at.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern UART_HandleTypeDef hlpuart1; +extern UART_HandleTypeDef huart2; +extern UART_HandleTypeDef huart3; +/* USER CODE BEGIN EV */ +extern at_agent_t esp8266_tf_agent; +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Memory management fault. + */ +void MemManage_Handler(void) +{ + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } +} + +/** + * @brief This function handles Prefetch fault, memory access fault. + */ +void BusFault_Handler(void) +{ + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Undefined instruction or illegal state. + */ +void UsageFault_Handler(void) +{ + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } +} + +/** + * @brief This function handles System service call via SWI instruction. + */ +void SVC_Handler(void) +{ + /* USER CODE BEGIN SVCall_IRQn 0 */ + + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ + + /* USER CODE END SVCall_IRQn 1 */ +} + +/** + * @brief This function handles Debug monitor. + */ +void DebugMon_Handler(void) +{ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + + /* USER CODE END DebugMonitor_IRQn 1 */ +} + +/** + * @brief This function handles Pendable request for system service. + */ +__weak void PendSV_Handler(void) +{ + /* USER CODE BEGIN PendSV_IRQn 0 */ + + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ + + /* USER CODE END PendSV_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); + if (tos_knl_is_running()) + { + tos_knl_irq_enter(); + tos_tick_handler(); + tos_knl_irq_leave(); + } + //HAL_SYSTICK_IRQHandler(); + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32L4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32l4xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles EXTI line1 interrupt. + */ +void EXTI1_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI1_IRQn 0 */ + + /* USER CODE END EXTI1_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); + /* USER CODE BEGIN EXTI1_IRQn 1 */ + + /* USER CODE END EXTI1_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line3 interrupt. + */ +void EXTI3_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI3_IRQn 0 */ + + /* USER CODE END EXTI3_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3); + /* USER CODE BEGIN EXTI3_IRQn 1 */ + + /* USER CODE END EXTI3_IRQn 1 */ +} + +/** + * @brief This function handles USART2 global interrupt. + */ +void USART2_IRQHandler(void) +{ + /* USER CODE BEGIN USART2_IRQn 0 */ + + /* USER CODE END USART2_IRQn 0 */ + HAL_UART_IRQHandler(&huart2); + /* USER CODE BEGIN USART2_IRQn 1 */ + + /* USER CODE END USART2_IRQn 1 */ +} + +/** + * @brief This function handles USART3 global interrupt. + */ +void USART3_IRQHandler(void) +{ + /* USER CODE BEGIN USART3_IRQn 0 */ + + /* USER CODE END USART3_IRQn 0 */ + HAL_UART_IRQHandler(&huart3); + /* USER CODE BEGIN USART3_IRQn 1 */ + + /* USER CODE END USART3_IRQn 1 */ +} + +/** + * @brief This function handles LPUART1 global interrupt. + */ +void LPUART1_IRQHandler(void) +{ + /* USER CODE BEGIN LPUART1_IRQn 0 */ + + /* USER CODE END LPUART1_IRQn 0 */ + tos_knl_irq_enter(); + HAL_UART_IRQHandler(&hlpuart1); + tos_knl_irq_leave(); + /* USER CODE BEGIN LPUART1_IRQn 1 */ + + /* USER CODE END LPUART1_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ +void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) +{ + extern uint8_t data; + if (huart->Instance == LPUART1) { + HAL_UART_Receive_IT(&hlpuart1, &data, 1); + tos_at_uart_input_byte(&esp8266_tf_agent, data); + } +} +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvoptx b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvoptx index 0df7bcde..fba66363 100644 --- a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvoptx +++ b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -389,8 +389,8 @@ 0 0 0 - ..\..\BSP\Src\stm32l4xx_it_module.c - stm32l4xx_it_module.c + ..\..\BSP\Src\tim.c + tim.c 0 0 @@ -401,8 +401,8 @@ 0 0 0 - ..\..\BSP\Src\tim.c - tim.c + .\demo\stm32l4xx_it_tf_module.c + stm32l4xx_it_tf_module.c 0 0 @@ -410,7 +410,7 @@ examples - 0 + 1 0 0 0 diff --git a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvprojx b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvprojx index fa17aacf..a798a3cf 100644 --- a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvprojx +++ b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -438,16 +438,16 @@ 1 ..\..\BSP\Src\spi.c - - stm32l4xx_it_module.c - 1 - ..\..\BSP\Src\stm32l4xx_it_module.c - tim.c 1 ..\..\BSP\Src\tim.c + + stm32l4xx_it_tf_module.c + 1 + .\demo\stm32l4xx_it_tf_module.c + @@ -843,12 +843,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/demo/stm32l4xx_it_tf_module.c b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/demo/stm32l4xx_it_tf_module.c new file mode 100644 index 00000000..afc66c74 --- /dev/null +++ b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqtt_iot_explorer_based_tencent_firmware/demo/stm32l4xx_it_tf_module.c @@ -0,0 +1,307 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32l4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32l4xx_it.h" +#include "tos_k.h" +#include "tos_at.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern UART_HandleTypeDef hlpuart1; +extern UART_HandleTypeDef huart2; +extern UART_HandleTypeDef huart3; +/* USER CODE BEGIN EV */ +extern at_agent_t esp8266_tf_agent; +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Memory management fault. + */ +void MemManage_Handler(void) +{ + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } +} + +/** + * @brief This function handles Prefetch fault, memory access fault. + */ +void BusFault_Handler(void) +{ + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Undefined instruction or illegal state. + */ +void UsageFault_Handler(void) +{ + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } +} + +/** + * @brief This function handles System service call via SWI instruction. + */ +void SVC_Handler(void) +{ + /* USER CODE BEGIN SVCall_IRQn 0 */ + + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ + + /* USER CODE END SVCall_IRQn 1 */ +} + +/** + * @brief This function handles Debug monitor. + */ +void DebugMon_Handler(void) +{ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + + /* USER CODE END DebugMonitor_IRQn 1 */ +} + +/** + * @brief This function handles Pendable request for system service. + */ +__weak void PendSV_Handler(void) +{ + /* USER CODE BEGIN PendSV_IRQn 0 */ + + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ + + /* USER CODE END PendSV_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); + if (tos_knl_is_running()) + { + tos_knl_irq_enter(); + tos_tick_handler(); + tos_knl_irq_leave(); + } + //HAL_SYSTICK_IRQHandler(); + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32L4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32l4xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles EXTI line1 interrupt. + */ +void EXTI1_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI1_IRQn 0 */ + + /* USER CODE END EXTI1_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); + /* USER CODE BEGIN EXTI1_IRQn 1 */ + + /* USER CODE END EXTI1_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line3 interrupt. + */ +void EXTI3_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI3_IRQn 0 */ + + /* USER CODE END EXTI3_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3); + /* USER CODE BEGIN EXTI3_IRQn 1 */ + + /* USER CODE END EXTI3_IRQn 1 */ +} + +/** + * @brief This function handles USART2 global interrupt. + */ +void USART2_IRQHandler(void) +{ + /* USER CODE BEGIN USART2_IRQn 0 */ + + /* USER CODE END USART2_IRQn 0 */ + HAL_UART_IRQHandler(&huart2); + /* USER CODE BEGIN USART2_IRQn 1 */ + + /* USER CODE END USART2_IRQn 1 */ +} + +/** + * @brief This function handles USART3 global interrupt. + */ +void USART3_IRQHandler(void) +{ + /* USER CODE BEGIN USART3_IRQn 0 */ + + /* USER CODE END USART3_IRQn 0 */ + HAL_UART_IRQHandler(&huart3); + /* USER CODE BEGIN USART3_IRQn 1 */ + + /* USER CODE END USART3_IRQn 1 */ +} + +/** + * @brief This function handles LPUART1 global interrupt. + */ +void LPUART1_IRQHandler(void) +{ + /* USER CODE BEGIN LPUART1_IRQn 0 */ + + /* USER CODE END LPUART1_IRQn 0 */ + tos_knl_irq_enter(); + HAL_UART_IRQHandler(&hlpuart1); + tos_knl_irq_leave(); + /* USER CODE BEGIN LPUART1_IRQn 1 */ + + /* USER CODE END LPUART1_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ +void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) +{ + extern uint8_t data; + if (huart->Instance == LPUART1) { + HAL_UART_Receive_IT(&hlpuart1, &data, 1); + tos_at_uart_input_byte(&esp8266_tf_agent, data); + } +} +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx index 58a870f3..d8b90216 100644 --- a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx +++ b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -270,7 +270,7 @@ Application/User - 1 + 0 0 0 0 @@ -410,7 +410,7 @@ examples - 0 + 1 0 0 0 @@ -1225,18 +1225,6 @@ 0 0 0 - ..\..\..\..\devices\bc35_28_95\bc35_28_95.c - bc35_28_95.c - 0 - 0 - - - 12 - 75 - 1 - 0 - 0 - 0 ..\..\..\..\devices\esp8266\esp8266.c esp8266.c 0 @@ -1244,7 +1232,7 @@ 12 - 76 + 75 1 0 0 @@ -1264,7 +1252,7 @@ 0 13 - 77 + 76 1 0 0 @@ -1284,7 +1272,7 @@ 0 14 - 78 + 77 1 0 0 @@ -1304,7 +1292,7 @@ 0 15 - 79 + 78 1 0 0 @@ -1316,7 +1304,7 @@ 15 - 80 + 79 1 0 0 @@ -1328,7 +1316,7 @@ 15 - 81 + 80 1 0 0 @@ -1340,7 +1328,7 @@ 15 - 82 + 81 1 0 0 @@ -1352,7 +1340,7 @@ 15 - 83 + 82 1 0 0 @@ -1364,7 +1352,7 @@ 15 - 84 + 83 1 0 0 @@ -1376,7 +1364,7 @@ 15 - 85 + 84 1 0 0 @@ -1388,7 +1376,7 @@ 15 - 86 + 85 1 0 0 @@ -1400,7 +1388,7 @@ 15 - 87 + 86 1 0 0 @@ -1412,7 +1400,7 @@ 15 - 88 + 87 1 0 0 @@ -1432,7 +1420,7 @@ 0 16 - 89 + 88 1 0 0 @@ -1444,7 +1432,7 @@ 16 - 90 + 89 1 0 0 @@ -1456,7 +1444,7 @@ 16 - 91 + 90 1 0 0 @@ -1468,7 +1456,7 @@ 16 - 92 + 91 1 0 0 @@ -1480,7 +1468,7 @@ 16 - 93 + 92 5 0 0 @@ -1500,7 +1488,7 @@ 0 17 - 94 + 93 1 0 0 @@ -1512,7 +1500,7 @@ 17 - 95 + 94 1 0 0 @@ -1524,7 +1512,7 @@ 17 - 96 + 95 5 0 0 @@ -1536,7 +1524,7 @@ 17 - 97 + 96 5 0 0 @@ -1556,7 +1544,7 @@ 0 18 - 98 + 97 1 0 0 @@ -1568,7 +1556,7 @@ 18 - 99 + 98 1 0 0 @@ -1580,7 +1568,7 @@ 18 - 100 + 99 1 0 0 @@ -1600,7 +1588,7 @@ 0 19 - 101 + 100 1 0 0 @@ -1612,7 +1600,7 @@ 19 - 102 + 101 1 0 0 @@ -1624,7 +1612,7 @@ 19 - 103 + 102 1 0 0 @@ -1636,7 +1624,7 @@ 19 - 104 + 103 1 0 0 @@ -1648,7 +1636,7 @@ 19 - 105 + 104 1 0 0 @@ -1668,7 +1656,7 @@ 0 20 - 106 + 105 5 0 0 @@ -1688,7 +1676,7 @@ 0 21 - 107 + 106 1 0 0 diff --git a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx index 82a9c97d..b3f71036 100644 --- a/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx +++ b/board/TencentOS_Tiny_EVB_MX_Plus/KEIL/mqttclient_iot_explorer/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -803,11 +803,6 @@ devices - - bc35_28_95.c - 1 - ..\..\..\..\devices\bc35_28_95\bc35_28_95.c - esp8266.c 1 @@ -1043,12 +1038,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvoptx b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvoptx index b81abd7f..c61ce022 100644 --- a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvoptx +++ b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -277,7 +277,7 @@ Application/User - 1 + 0 0 0 0 @@ -965,7 +965,7 @@ examples - 0 + 1 0 0 0 diff --git a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvprojx b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvprojx index edc90e4f..24feb6ea 100644 --- a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvprojx +++ b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/hello_world/TencentOS_Tiny.uvprojx @@ -10,14 +10,14 @@ TencentOS_Tiny 0x4 ARM-ADS - 6140000::V6.14::ARMCLANG + 6160000::V6.16::ARMCLANG 1 STM32WLE5JCIx STMicroelectronics - Keil.STM32WLxx_DFP.1.0.7 - http://www.keil.com/pack + Keil.STM32WLxx_DFP.1.1.0 + http://www.keil.com/pack/ IRAM(0x20000000,0x10000) IROM(0x08000000,0x40000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -729,11 +729,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/App/stm32wlxx_it.c b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/App/stm32wlxx_it.c index 9b4afc56..71e9f9c3 100644 --- a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/App/stm32wlxx_it.c +++ b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/App/stm32wlxx_it.c @@ -65,7 +65,7 @@ extern UART_HandleTypeDef huart1; extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef hlpuart1; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_tf_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -254,7 +254,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) if (huart->Instance == LPUART1) { HAL_UART_Receive_IT(&hlpuart1, &data, 1); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_tf_agent, data); } } /* USER CODE END 1 */ diff --git a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/TencentOS_Tiny.uvoptx b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/TencentOS_Tiny.uvoptx index a09d6e86..19000a25 100644 --- a/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/TencentOS_Tiny.uvoptx +++ b/board/TencentOS_Tiny_EVB_STM32WL/KEIL/wifi_esp8266tc_bh1750/TencentOS_Tiny.uvoptx @@ -256,7 +256,7 @@ Application/User - 1 + 0 0 0 0 @@ -1116,7 +1116,7 @@ Hardware - 1 + 0 0 0 0 @@ -1156,7 +1156,7 @@ at - 1 + 0 0 0 0 @@ -1188,7 +1188,7 @@ hal - 1 + 0 0 0 0 @@ -1208,7 +1208,7 @@ devices - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/KEIL/TencentOS-Tiny.uvoptx b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/KEIL/TencentOS-Tiny.uvoptx index e91bc57a..7a720a82 100644 --- a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/KEIL/TencentOS-Tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/KEIL/TencentOS-Tiny.uvoptx @@ -413,7 +413,7 @@ source - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/board/mcu_init.c b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/board/mcu_init.c index 8cb6bb70..6c4ce278 100644 --- a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/board/mcu_init.c +++ b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer/board/mcu_init.c @@ -1,6 +1,9 @@ #include "mcu_init.h" #include "tos_at.h" +extern at_agent_t esp8266_agent; +extern at_agent_t ec600s_agent; + void board_init(void) { /* Init board hardware. */ @@ -21,7 +24,8 @@ void SysTick_Handler(void) } /* LPUART2_IRQn interrupt handler */ -void LPUART2_IRQHandler(void) { +void LPUART2_IRQHandler(void) +{ uint8_t data; tos_knl_irq_enter(); @@ -30,14 +34,15 @@ void LPUART2_IRQHandler(void) { if ((kLPUART_RxDataRegFullFlag)&LPUART_GetStatusFlags(LPUART2)) { data = LPUART_ReadByte(LPUART2); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_agent, data); } tos_knl_irq_leave(); } /* LPUART4_IRQn interrupt handler */ -void LPUART4_IRQHandler(void) { +void LPUART4_IRQHandler(void) +{ uint8_t data; tos_knl_irq_enter(); @@ -46,7 +51,7 @@ void LPUART4_IRQHandler(void) { if ((kLPUART_RxDataRegFullFlag)&LPUART_GetStatusFlags(LPUART4)) { data = LPUART_ReadByte(LPUART4); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&ec600s_agent, data); } tos_knl_irq_leave(); diff --git a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/KEIL/TencentOS-Tiny.uvprojx b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/KEIL/TencentOS-Tiny.uvprojx index 49542f13..c0171a23 100644 --- a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/KEIL/TencentOS-Tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/KEIL/TencentOS-Tiny.uvprojx @@ -1231,7 +1231,7 @@ TencentOS-Tiny flexspi_nor_release 0x4 ARM-ADS - 6140000::V6.14::ARMCLANG + 6160000::V6.16::ARMCLANG 1 @@ -2460,11 +2460,6 @@ TencentOS-Tiny - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/board/mcu_init.c b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/board/mcu_init.c index 8cb6bb70..6c4ce278 100644 --- a/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/board/mcu_init.c +++ b/board/TencentOS_tiny_EVB_AIoT/mqttclient_iot_explorer_bh1750/board/mcu_init.c @@ -1,6 +1,9 @@ #include "mcu_init.h" #include "tos_at.h" +extern at_agent_t esp8266_agent; +extern at_agent_t ec600s_agent; + void board_init(void) { /* Init board hardware. */ @@ -21,7 +24,8 @@ void SysTick_Handler(void) } /* LPUART2_IRQn interrupt handler */ -void LPUART2_IRQHandler(void) { +void LPUART2_IRQHandler(void) +{ uint8_t data; tos_knl_irq_enter(); @@ -30,14 +34,15 @@ void LPUART2_IRQHandler(void) { if ((kLPUART_RxDataRegFullFlag)&LPUART_GetStatusFlags(LPUART2)) { data = LPUART_ReadByte(LPUART2); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_agent, data); } tos_knl_irq_leave(); } /* LPUART4_IRQn interrupt handler */ -void LPUART4_IRQHandler(void) { +void LPUART4_IRQHandler(void) +{ uint8_t data; tos_knl_irq_enter(); @@ -46,7 +51,7 @@ void LPUART4_IRQHandler(void) { if ((kLPUART_RxDataRegFullFlag)&LPUART_GetStatusFlags(LPUART4)) { data = LPUART_ReadByte(LPUART4); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&ec600s_agent, data); } tos_knl_irq_leave(); diff --git a/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/KEIL/TencentOS-Tiny.uvoptx b/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/KEIL/TencentOS-Tiny.uvoptx index 42795842..3c6d5434 100644 --- a/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/KEIL/TencentOS-Tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/KEIL/TencentOS-Tiny.uvoptx @@ -413,7 +413,7 @@ source - 1 + 0 0 0 0 @@ -1869,7 +1869,7 @@ config - 1 + 0 0 0 0 @@ -1889,7 +1889,7 @@ hal/uart - 1 + 0 0 0 0 @@ -1909,7 +1909,7 @@ net/at - 1 + 0 0 0 0 @@ -1929,7 +1929,7 @@ net/sal_module_wrapper - 1 + 0 0 0 0 @@ -1949,7 +1949,7 @@ devices - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/board/mcu_init.c b/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/board/mcu_init.c index 8cb6bb70..6c4ce278 100644 --- a/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/board/mcu_init.c +++ b/board/TencentOS_tiny_EVB_AIoT/tcp_through_module/board/mcu_init.c @@ -1,6 +1,9 @@ #include "mcu_init.h" #include "tos_at.h" +extern at_agent_t esp8266_agent; +extern at_agent_t ec600s_agent; + void board_init(void) { /* Init board hardware. */ @@ -21,7 +24,8 @@ void SysTick_Handler(void) } /* LPUART2_IRQn interrupt handler */ -void LPUART2_IRQHandler(void) { +void LPUART2_IRQHandler(void) +{ uint8_t data; tos_knl_irq_enter(); @@ -30,14 +34,15 @@ void LPUART2_IRQHandler(void) { if ((kLPUART_RxDataRegFullFlag)&LPUART_GetStatusFlags(LPUART2)) { data = LPUART_ReadByte(LPUART2); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_agent, data); } tos_knl_irq_leave(); } /* LPUART4_IRQn interrupt handler */ -void LPUART4_IRQHandler(void) { +void LPUART4_IRQHandler(void) +{ uint8_t data; tos_knl_irq_enter(); @@ -46,7 +51,7 @@ void LPUART4_IRQHandler(void) { if ((kLPUART_RxDataRegFullFlag)&LPUART_GetStatusFlags(LPUART4)) { data = LPUART_ReadByte(LPUART4); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&ec600s_agent, data); } tos_knl_irq_leave(); diff --git a/board/TencentOS_tiny_EVB_G0/BSP/Src/stm32g0xx_it_module.c b/board/TencentOS_tiny_EVB_G0/BSP/Src/stm32g0xx_it_module.c index 859c5733..b5c3db44 100644 --- a/board/TencentOS_tiny_EVB_G0/BSP/Src/stm32g0xx_it_module.c +++ b/board/TencentOS_tiny_EVB_G0/BSP/Src/stm32g0xx_it_module.c @@ -63,7 +63,7 @@ extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart4; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_tf_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -201,7 +201,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) if (huart->Instance == USART2) { HAL_UART_Receive_IT(&huart2, &data, 1); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_tf_agent, data); } } /* USER CODE END 1 */ diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvoptx b/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvoptx index 5a398ed6..8f642960 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvoptx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvprojx b/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvprojx index da6c6cf5..9864977a 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvprojx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/hello_world/TencentOS_tiny_EVB_G0.uvprojx @@ -10,14 +10,14 @@ TencentOS_Tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32G070RBTx STMicroelectronics - Keil.STM32G0xx_DFP.1.2.0 - https://www.keil.com/pack/ + Keil.STM32G0xx_DFP.1.4.0 + http://www.keil.com/pack/ IRAM(0x20000000-0x20008FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") @@ -764,11 +764,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx index 0706119e..7fd1dc41 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -1027,7 +1027,7 @@ examples - 0 + 1 0 0 0 @@ -1099,7 +1099,7 @@ devices - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx index dabe9bc9..eea22edb 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx @@ -10,14 +10,14 @@ TencentOS_Tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32G070RBTx STMicroelectronics - Keil.STM32G0xx_DFP.1.2.0 - https://www.keil.com/pack/ + Keil.STM32G0xx_DFP.1.4.0 + http://www.keil.com/pack/ IRAM(0x20000000-0x20008FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") @@ -803,12 +803,7 @@ - <Project Info> - - - - - + TencentOS_tiny_EVB_G0 0 1 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvoptx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvoptx index e9db14af..0d02de29 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvoptx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvoptx @@ -1027,7 +1027,7 @@ examples - 0 + 1 0 0 0 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvprojx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvprojx index f356e240..87baba30 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvprojx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/TencentOS_tiny_EVB_G0.uvprojx @@ -10,14 +10,14 @@ TencentOS_Tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32G070RBTx STMicroelectronics - Keil.STM32G0xx_DFP.1.2.0 - https://www.keil.com/pack/ + Keil.STM32G0xx_DFP.1.4.0 + http://www.keil.com/pack/ IRAM(0x20000000-0x20008FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") @@ -839,11 +839,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_it_demo.c b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_it_demo.c index 36572a00..135b5f57 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_it_demo.c +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_e53_light/demo/stm32g0xx_it_demo.c @@ -64,7 +64,7 @@ extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart4; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_tf_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -203,7 +203,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) if (huart->Instance == USART2) { HAL_UART_Receive_IT(&huart2, &data, 1); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_tf_agent, data); } else if (huart->Instance == USART3) { //HAL_UART_Receive_IT(&huart3, &ch20_msg, 1); } diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvoptx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvoptx index cb0feb13..a91256c5 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvoptx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -223,7 +223,7 @@ Application/User - 1 + 0 0 0 0 @@ -1007,7 +1007,7 @@ tos/config - 1 + 0 0 0 0 @@ -1047,7 +1047,7 @@ hal - 1 + 0 0 0 0 @@ -1067,7 +1067,7 @@ at - 1 + 0 0 0 0 @@ -1099,7 +1099,7 @@ devices - 1 + 0 0 0 0 @@ -1119,7 +1119,7 @@ hardware - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvprojx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvprojx index 382913c2..ab44decd 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvprojx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/TencentOS_tiny_EVB_G0.uvprojx @@ -10,14 +10,14 @@ TencentOS_Tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32G070RBTx STMicroelectronics - Keil.STM32G0xx_DFP.1.2.0 - https://www.keil.com/pack/ + Keil.STM32G0xx_DFP.1.4.0 + http://www.keil.com/pack/ IRAM(0x20000000-0x20008FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") @@ -819,11 +819,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/demo/stm32g0xx_it_demo.c b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/demo/stm32g0xx_it_demo.c index 2f1a8325..0c52fe03 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/demo/stm32g0xx_it_demo.c +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_ch20_oled/demo/stm32g0xx_it_demo.c @@ -64,7 +64,7 @@ extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart4; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_tf_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -203,7 +203,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) if (huart->Instance == USART2) { HAL_UART_Receive_IT(&huart2, &data, 1); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_tf_agent, data); } else if (huart->Instance == USART3) { HAL_UART_Receive_IT(&huart3, &ch20_msg, 1); ch20_parser_input_byte(ch20_msg); diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/TencentOS_tiny_EVB_G0.uvprojx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/TencentOS_tiny_EVB_G0.uvprojx index 6cd7061e..e030da89 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/TencentOS_tiny_EVB_G0.uvprojx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/TencentOS_tiny_EVB_G0.uvprojx @@ -10,14 +10,14 @@ TencentOS_Tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32G070RBTx STMicroelectronics - Keil.STM32G0xx_DFP.1.2.0 - https://www.keil.com/pack/ + Keil.STM32G0xx_DFP.1.4.0 + http://www.keil.com/pack/ IRAM(0x20000000-0x20008FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") @@ -819,11 +819,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/demo/stm32g0xx_it_demo.c b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/demo/stm32g0xx_it_demo.c index 53f8a66a..933ddecc 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/demo/stm32g0xx_it_demo.c +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iot_explorer_tc_pm25/demo/stm32g0xx_it_demo.c @@ -64,7 +64,7 @@ extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart4; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_tf_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -205,7 +205,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) if (huart->Instance == USART2) { HAL_UART_Receive_IT(&huart2, &data, 1); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_tf_agent, data); } else if (huart->Instance == USART3) { HAL_UART_Receive_IT(&huart3, &pm2d5_byte_data, 1); pm2d5_parser_input_byte(pm2d5_byte_data); diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx index 18c14b5d..b3f6df48 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -223,7 +223,7 @@ Application/User - 1 + 0 0 0 0 @@ -1007,7 +1007,7 @@ tos/config - 1 + 0 0 0 0 @@ -1047,7 +1047,7 @@ hal - 1 + 0 0 0 0 @@ -1067,7 +1067,7 @@ at - 1 + 0 0 0 0 @@ -1099,7 +1099,7 @@ devices - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx index fa0d6ecc..a2d8e2ac 100644 --- a/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx +++ b/board/TencentOS_tiny_EVB_G0/KEIL/mqtt_iothub_based_tencent_firmware/TencentOS_tiny_EVB_G0.uvprojx @@ -10,14 +10,14 @@ TencentOS_Tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32G070RBTx STMicroelectronics - Keil.STM32G0xx_DFP.1.2.0 - https://www.keil.com/pack/ + Keil.STM32G0xx_DFP.1.4.0 + http://www.keil.com/pack/ IRAM(0x20000000-0x20008FFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") @@ -804,11 +804,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_module.c b/board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_module.c index 2473e742..02e7e2a5 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_module.c +++ b/board/TencentOS_tiny_EVB_MX_Plus/BSP/Src/stm32l4xx_it_module.c @@ -62,7 +62,7 @@ extern UART_HandleTypeDef hlpuart1; extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart3; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -300,7 +300,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) extern uint8_t data; if (huart->Instance == LPUART1) { HAL_UART_Receive_IT(&hlpuart1, &data, 1); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&esp8266_agent, data); } } /* USER CODE END 1 */ diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvoptx index 5007baa2..40215fb0 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -1206,30 +1206,6 @@ 0 0 - - 12 - 73 - 1 - 0 - 0 - 0 - ..\..\..\..\devices\air724\air724.c - air724.c - 0 - 0 - - - 12 - 74 - 1 - 0 - 0 - 0 - ..\..\..\..\devices\ec20_200_600\ec600s.c - ec600s.c - 0 - 0 - @@ -1240,7 +1216,7 @@ 0 13 - 75 + 73 1 0 0 @@ -1260,7 +1236,7 @@ 0 14 - 76 + 74 1 0 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvprojx index 7c498a13..c7fc201d 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/bin_file_download_through_module/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -798,16 +798,6 @@ 1 ..\..\..\..\devices\esp8266\esp8266.c - - air724.c - 1 - ..\..\..\..\devices\air724\air724.c - - - ec600s.c - 1 - ..\..\..\..\devices\ec20_200_600\ec600s.c - @@ -853,12 +843,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvoptx index 8f2f8a03..14eba946 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -467,7 +467,7 @@ examples - 0 + 1 0 0 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvprojx index 914dbfa1..9a677c1d 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/hello_world/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -794,11 +794,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvoptx index 2da926f1..8aa4b6e2 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -1283,7 +1283,7 @@ ota_download - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvprojx index 8c148be9..785dff0a 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_http/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -924,11 +924,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvoptx index da9d67a4..32e99634 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -302,18 +302,6 @@ 0 0 0 - ..\..\..\BSP\Src\stm32l4xx_it_module.c - stm32l4xx_it_module.c - 0 - 0 - - - 2 - 7 - 1 - 0 - 0 - 0 ..\..\..\BSP\Src\usart.c usart.c 0 @@ -321,7 +309,7 @@ 2 - 8 + 7 1 0 0 @@ -333,7 +321,7 @@ 2 - 9 + 8 1 0 0 @@ -345,7 +333,7 @@ 2 - 10 + 9 1 0 0 @@ -357,7 +345,7 @@ 2 - 11 + 10 1 0 0 @@ -369,7 +357,7 @@ 2 - 12 + 11 1 0 0 @@ -379,6 +367,18 @@ 0 0 + + 2 + 12 + 1 + 0 + 0 + 0 + ..\..\..\BSP\Src\stm32l4xx_it_tf_module.c + stm32l4xx_it_tf_module.c + 0 + 0 + @@ -1223,7 +1223,7 @@ devices - 1 + 0 0 0 0 @@ -1243,7 +1243,7 @@ sal_module_wrapper - 1 + 0 0 0 0 @@ -1283,7 +1283,7 @@ ota_common - 1 + 0 0 0 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvprojx index c855fa72..d4cc8a62 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_application_download_through_qcould_firmware/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -413,11 +413,6 @@ 1 ..\..\..\BSP\Src\stm32l4xx_hal_msp.c - - stm32l4xx_it_module.c - 1 - ..\..\..\BSP\Src\stm32l4xx_it_module.c - usart.c 1 @@ -448,6 +443,11 @@ 1 ..\..\..\BSP\Src\tim.c + + stm32l4xx_it_tf_module.c + 1 + ..\..\..\BSP\Src\stm32l4xx_it_tf_module.c + @@ -908,12 +908,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvoptx index 3a989118..c73da2b2 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -1213,18 +1213,6 @@ 0 0 0 - ..\..\..\..\devices\air724\air724.c - air724.c - 0 - 0 - - - 12 - 74 - 1 - 0 - 0 - 0 ..\..\..\..\devices\ec20_200_600\ec600s.c ec600s.c 0 @@ -1240,7 +1228,7 @@ 0 13 - 75 + 74 1 0 0 @@ -1260,7 +1248,7 @@ 0 14 - 76 + 75 1 0 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvprojx index d1f7aae9..c54ca8d4 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -798,11 +798,6 @@ 1 ..\..\..\..\devices\esp8266\esp8266.c - - air724.c - 1 - ..\..\..\..\devices\air724\air724.c - ec600s.c 1 @@ -853,12 +848,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvoptx index bc782f56..4762dd2d 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -1160,7 +1160,7 @@ devices - 1 + 0 0 0 0 @@ -1171,18 +1171,6 @@ 0 0 0 - ..\..\..\..\devices\air724\air724.c - air724.c - 0 - 0 - - - 12 - 73 - 1 - 0 - 0 - 0 ..\..\..\..\devices\esp8266\esp8266.c esp8266.c 0 @@ -1192,13 +1180,13 @@ sal_module_wrapper - 1 + 0 0 0 0 13 - 74 + 73 1 0 0 @@ -1218,7 +1206,7 @@ 0 14 - 75 + 74 1 0 0 @@ -1232,13 +1220,13 @@ socket_wrapper - 1 + 0 0 0 0 15 - 76 + 75 1 0 0 @@ -1250,7 +1238,7 @@ 15 - 77 + 76 1 0 0 @@ -1262,7 +1250,7 @@ 15 - 78 + 77 1 0 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvprojx index e9cc01a5..401da6af 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/tcp_through_module_based_at_socket/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -793,11 +793,6 @@ devices - - air724.c - 1 - ..\..\..\..\devices\air724\air724.c - esp8266.c 1 @@ -868,12 +863,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvoptx index 75614e44..79be12a8 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvprojx index 7991b2f4..17867e21 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/test/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -874,11 +874,6 @@ <Project Info> - - - - - 0 1 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvoptx index 7b553b5a..4f135247 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvoptx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 @@ -1223,7 +1223,7 @@ devices - 1 + 0 0 0 0 @@ -1239,18 +1239,6 @@ 0 0 - - 12 - 73 - 1 - 0 - 0 - 0 - ..\..\..\..\devices\air724\air724.c - air724.c - 0 - 0 - @@ -1261,7 +1249,7 @@ 0 13 - 74 + 73 1 0 0 @@ -1281,7 +1269,7 @@ 0 14 - 75 + 74 1 0 0 diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvprojx index 521dfbbf..8d2f9f40 100644 --- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvprojx +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/udp_through_module/TencentOS_tiny.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L431RCTx STMicroelectronics - Keil.STM32L4xx_DFP.2.4.0 + Keil.STM32L4xx_DFP.2.6.1 http://www.keil.com/pack/ IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") @@ -798,11 +798,6 @@ 1 ..\..\..\..\devices\esp8266\esp8266.c - - air724.c - 1 - ..\..\..\..\devices\air724\air724.c - @@ -848,12 +843,7 @@ - <Project Info> - - - - - + TencentOS_tiny 0 1 diff --git a/board/TencentOS_tiny_STM32H750/BSP/Src/stm32h7xx_it_at_module.c b/board/TencentOS_tiny_STM32H750/BSP/Src/stm32h7xx_it_at_module.c index d5c28426..10c9a883 100644 --- a/board/TencentOS_tiny_STM32H750/BSP/Src/stm32h7xx_it_at_module.c +++ b/board/TencentOS_tiny_STM32H750/BSP/Src/stm32h7xx_it_at_module.c @@ -64,7 +64,8 @@ extern UART_HandleTypeDef huart5; extern UART_HandleTypeDef huart2; extern UART_HandleTypeDef huart6; /* USER CODE BEGIN EV */ - +extern at_agent_t esp8266_agent; +extern at_agent_t ec600s_agent; /* USER CODE END EV */ /******************************************************************************/ @@ -290,11 +291,11 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) extern uint8_t esp_data; if (huart->Instance == USART6) { HAL_UART_Receive_IT(&huart6, &data, 1); - tos_at_uart_input_byte(data); + tos_at_uart_input_byte(&ec600s_agent, data); } if (huart->Instance == USART2) { HAL_UART_Receive_IT(&huart2, &esp_data, 1); - tos_at_uart_input_byte(esp_data); + tos_at_uart_input_byte(&esp8266_agent, esp_data); } } /* USER CODE END 1 */ diff --git a/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvoptx b/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvoptx index bd112ca2..f5b25841 100644 --- a/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvoptx +++ b/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvoptx @@ -10,7 +10,7 @@ *.s*; *.src; *.a* *.obj; *.o *.lib - *.txt; *.h; *.inc + *.txt; *.h; *.inc; *.md *.plm *.cpp 0 diff --git a/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvprojx b/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvprojx index 5303e1eb..df9c97ee 100644 --- a/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvprojx +++ b/board/TencentOS_tiny_STM32H750/KEIL/mqtt_client_iot_exporer/TencentOS_tiny_STM32H750.uvprojx @@ -10,13 +10,13 @@ TencentOS_tiny_STM32H750 0x4 ARM-ADS - 5060750::V5.06 update 6 (build 750)::.\ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32H750XBHx STMicroelectronics - Keil.STM32H7xx_DFP.2.7.0 + Keil.STM32H7xx_DFP.3.0.0 http://www.keil.com/pack/ IRAM(0x20000000-0x2001FFFF) IRAM2(0x24000000-0x2407FFFF) IROM(0x8000000-0x801FFFF) CLOCK(12000000) FPU3(DFPU) CPUTYPE("Cortex-M7") ELITTLE TZ @@ -1169,11 +1169,6 @@ <Project Info> - - - - - 0 1 diff --git a/devices/ec20_200_600/ec600s.c b/devices/ec20_200_600/ec600s.c index 361db6fe..4b135183 100644 --- a/devices/ec20_200_600/ec600s.c +++ b/devices/ec20_200_600/ec600s.c @@ -31,8 +31,12 @@ typedef struct ip_addr_st { uint8_t seg4; }ip_addr_t; +at_agent_t ec600s_agent; static ip_addr_t domain_parser_addr = {0}; static k_sem_t domain_parser_sem; +static k_stack_t ec600s_at_parse_task_stk[AT_PARSER_TASK_STACK_SIZE]; + +#define AT_AGENT ((at_agent_t *)&ec600s_agent) static int ec600s_check_ready(void) { @@ -41,7 +45,7 @@ static int ec600s_check_ready(void) while (try++ < 10) { tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "AT\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT\r\n"); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -58,7 +62,7 @@ static int ec600s_echo_close(void) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, "ATE0\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "ATE0\r\n"); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -74,7 +78,7 @@ static int ec600s_sim_card_check(void) tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, "AT+CPIN?\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CPIN?\r\n"); if (strstr(echo_buffer, "READY")) { return 0; } @@ -93,7 +97,7 @@ static int ec600s_signal_quality_check(void) tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, "AT+CSQ\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CSQ\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -121,7 +125,7 @@ static int ec600s_gsm_network_check(void) tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, "AT+CREG?\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CREG?\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -149,8 +153,7 @@ static int ec600s_gprs_network_check(void) tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); while (try++ < 10) { - - tos_at_cmd_exec(&echo, 1000, "AT+CGREG?\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CGREG?\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -174,7 +177,7 @@ static int ec600s_close_apn(void) at_echo_t echo; tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 3000, "AT+QIDEACT=1\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 3000, "AT+QIDEACT=1\r\n"); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -187,12 +190,12 @@ static int ec600s_set_apn(void) at_echo_t echo; tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "AT+QICSGP=1,1,\"CMNET\"\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+QICSGP=1,1,\"CMNET\"\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } - tos_at_cmd_exec(&echo, 3000, "AT+QIACT=1\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 3000, "AT+QIACT=1\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -258,7 +261,7 @@ static int ec600s_connect_establish(int id, sal_proto_t proto) char *remote_port = NULL; tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); - tos_at_cmd_exec(&echo, 1000, "AT+QISTATE=1,%d\r\n", id); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+QISTATE=1,%d\r\n", id); if (echo.status != AT_ECHO_STATUS_OK) { printf("query socket %d state fail\r\n", id); return -1; @@ -269,20 +272,20 @@ static int ec600s_connect_establish(int id, sal_proto_t proto) if (query_result_str) { printf("socket %d established on module already\r\n", id); tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "AT+QICLOSE=%d\r\n", id); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+QICLOSE=%d\r\n", id); } memset(except_str, 0, sizeof(except_str)); sprintf(except_str, "+QIOPEN: %d,0", id); - remote_ip = (char*)tos_at_channel_ip_get(id); - remote_port = (char*)tos_at_channel_port_get(id); + remote_ip = (char*)tos_at_channel_ip_get(AT_AGENT, id); + remote_port = (char*)tos_at_channel_port_get(AT_AGENT, id); if (!remote_ip || !remote_port) { return -2; } tos_at_echo_create(&echo, NULL, 0, except_str); - tos_at_cmd_exec_until(&echo, 4000, "AT+QIOPEN=1,%d,\"%s\",\"%s\",%d,0,1\r\n", + tos_at_cmd_exec_until(AT_AGENT, &echo, 4000, "AT+QIOPEN=1,%d,\"%s\",\"%s\",%d,0,1\r\n", id, proto == TOS_SAL_PROTO_UDP ? "UDP" : "TCP", remote_ip, atoi(remote_port)); if (echo.status != AT_ECHO_STATUS_EXPECT) { printf("establish socket %d on module fail\r\n", id); @@ -296,14 +299,14 @@ static int ec600s_connect(const char *ip, const char *port, sal_proto_t proto) { int id; - id = tos_at_channel_alloc(ip, port); + id = tos_at_channel_alloc(AT_AGENT, ip, port); if (id == -1) { printf("at channel alloc fail\r\n"); return -1; } if (ec600s_connect_establish(id, proto) < 0) { - tos_at_channel_free(id); + tos_at_channel_free(AT_AGENT, id); return -2; } @@ -314,14 +317,14 @@ static int ec600s_connect_with_size(const char *ip, const char *port, sal_proto_ { int id; - id = tos_at_channel_alloc_with_size(ip, port, socket_buffer_size); + id = tos_at_channel_alloc_with_size(AT_AGENT, ip, port, socket_buffer_size); if (id == -1) { printf("at channel alloc fail\r\n"); return -1; } if (ec600s_connect_establish(id, proto) < 0) { - tos_at_channel_free(id); + tos_at_channel_free(AT_AGENT, id); return -2; } @@ -330,7 +333,7 @@ static int ec600s_connect_with_size(const char *ip, const char *port, sal_proto_ static int ec600s_recv_timeout(int id, void *buf, size_t len, uint32_t timeout) { - return tos_at_channel_read_timed(id, buf, len, timeout); + return tos_at_channel_read_timed(AT_AGENT, id, buf, len, timeout); } static int ec600s_recv(int id, void *buf, size_t len) @@ -342,38 +345,38 @@ int ec600s_send(int id, const void *buf, size_t len) { at_echo_t echo; - if (!tos_at_channel_is_working(id)) { + if (!tos_at_channel_is_working(AT_AGENT, id)) { return -1; } - if (tos_at_global_lock_pend() != 0) { + if (tos_at_global_lock_pend(AT_AGENT) != 0) { return -1; } tos_at_echo_create(&echo, NULL, 0, ">"); - tos_at_cmd_exec_until(&echo, 1000, "AT+QISEND=%d,%d\r\n", id, len); + tos_at_cmd_exec_until(AT_AGENT, &echo, 1000, "AT+QISEND=%d,%d\r\n", id, len); if (echo.status != AT_ECHO_STATUS_EXPECT) { - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } tos_at_echo_create(&echo, NULL, 0, "SEND OK"); - tos_at_raw_data_send_until(&echo, 10000, (uint8_t *)buf, len); + tos_at_raw_data_send_until(AT_AGENT, &echo, 10000, (uint8_t *)buf, len); if (echo.status != AT_ECHO_STATUS_EXPECT) { - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return len; } int ec600s_recvfrom_timeout(int id, void *buf, size_t len, uint32_t timeout) { - return tos_at_channel_read_timed(id, buf, len, timeout); + return tos_at_channel_read_timed(AT_AGENT, id, buf, len, timeout); } int ec600s_recvfrom(int id, void *buf, size_t len) @@ -385,26 +388,26 @@ int ec600s_sendto(int id, char *ip, char *port, const void *buf, size_t len) { at_echo_t echo; - if (tos_at_global_lock_pend() != 0) { + if (tos_at_global_lock_pend(AT_AGENT) != 0) { return -1; } tos_at_echo_create(&echo, NULL, 0, ">"); - tos_at_cmd_exec_until(&echo, 1000, "AT+QISEND=%d,%d\r\n", id, len); + tos_at_cmd_exec_until(AT_AGENT, &echo, 1000, "AT+QISEND=%d,%d\r\n", id, len); if (echo.status != AT_ECHO_STATUS_EXPECT) { - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } tos_at_echo_create(&echo, NULL, 0, "SEND OK"); - tos_at_raw_data_send(&echo, 1000, (uint8_t *)buf, len); + tos_at_raw_data_send(AT_AGENT, &echo, 1000, (uint8_t *)buf, len); if (echo.status != AT_ECHO_STATUS_EXPECT) { - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return len; } @@ -414,7 +417,7 @@ static void ec600s_transparent_mode_exit(void) at_echo_t echo; tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 500, "+++"); + tos_at_cmd_exec(AT_AGENT, &echo, 500, "+++"); } static int ec600s_close(int id) @@ -424,9 +427,9 @@ static int ec600s_close(int id) ec600s_transparent_mode_exit(); tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "AT+QICLOSE=%d\r\n", id); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+QICLOSE=%d\r\n", id); - tos_at_channel_free(id); + tos_at_channel_free(AT_AGENT, id); return 0; } @@ -439,7 +442,7 @@ static int ec600s_parse_domain(const char *host_name, char *host_ip, size_t host tos_sem_create_max(&domain_parser_sem, 0, 1); tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); - tos_at_cmd_exec(&echo, 2000, "AT+QIDNSGIP=1,\"%s\"\r\n", host_name); + tos_at_cmd_exec(AT_AGENT, &echo, 2000, "AT+QIDNSGIP=1,\"%s\"\r\n", host_name); if (echo.status != AT_ECHO_STATUS_OK) { return -1; @@ -466,7 +469,7 @@ __STATIC__ void ec600s_incoming_data_process(void) */ while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == ',') { @@ -476,7 +479,7 @@ __STATIC__ void ec600s_incoming_data_process(void) } while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } @@ -486,7 +489,7 @@ __STATIC__ void ec600s_incoming_data_process(void) data_len = data_len * 10 + (data - '0'); } - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } @@ -495,11 +498,11 @@ __STATIC__ void ec600s_incoming_data_process(void) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif read_len = MIN(data_len, sizeof(buffer)); - if (tos_at_uart_read(buffer, read_len) != read_len) { + if (tos_at_uart_read(AT_AGENT, buffer, read_len) != read_len) { return; } - if (tos_at_channel_write(channel_id, buffer, read_len) <= 0) { + if (tos_at_channel_write(AT_AGENT, channel_id, buffer, read_len) <= 0) { return; } @@ -519,7 +522,7 @@ __STATIC__ void ec600s_domain_data_process(void) +QIURC: "dnsgip","xxx.xxx.xxx.xxx" */ - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } @@ -530,7 +533,7 @@ __STATIC__ void ec600s_domain_data_process(void) if (data == '\"') { /* start parser domain */ while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == '.') { @@ -539,7 +542,7 @@ __STATIC__ void ec600s_domain_data_process(void) domain_parser_addr.seg1 = domain_parser_addr.seg1 *10 + (data-'0'); } while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == '.') { @@ -548,7 +551,7 @@ __STATIC__ void ec600s_domain_data_process(void) domain_parser_addr.seg2 = domain_parser_addr.seg2 *10 + (data-'0'); } while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == '.') { @@ -557,7 +560,7 @@ __STATIC__ void ec600s_domain_data_process(void) domain_parser_addr.seg3 = domain_parser_addr.seg3 *10 + (data-'0'); } while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == '\"') { @@ -593,7 +596,8 @@ sal_module_t sal_module_ec600s = { int ec600s_sal_init(hal_uart_port_t uart_port) { - if (tos_at_init(uart_port, ec600s_at_event, + if (tos_at_init(AT_AGENT, "ec600s_at", ec600s_at_parse_task_stk, + uart_port, ec600s_at_event, sizeof(ec600s_at_event) / sizeof(ec600s_at_event[0])) != 0) { return -1; } @@ -618,7 +622,7 @@ int ec600s_sal_deinit() tos_sal_module_register_default(); - tos_at_deinit(); + tos_at_deinit(AT_AGENT); return 0; } diff --git a/devices/esp8266/esp8266.c b/devices/esp8266/esp8266.c index 88d1e5d9..13c340e6 100644 --- a/devices/esp8266/esp8266.c +++ b/devices/esp8266/esp8266.c @@ -1,13 +1,17 @@ #include "tos_at.h" #include "esp8266.h" #include "sal_module_wrapper.h" - #include "stdio.h" #include "stdbool.h" #include "ctype.h" #define TOS_CFG_MODULE_SINGLE_LINK_EN 0u +at_agent_t esp8266_agent; +static k_stack_t esp8266_at_parse_task_stk[AT_PARSER_TASK_STACK_SIZE]; + +#define AT_AGENT ((at_agent_t *)&esp8266_agent) + static int esp8266_restore(void) { int try = 0; @@ -15,7 +19,7 @@ static int esp8266_restore(void) tos_at_echo_create(&echo, NULL, 0, "ready"); while (try++ < 10) { - tos_at_cmd_exec_until(&echo, 5000, "AT+RESTORE\r\n"); + tos_at_cmd_exec_until(AT_AGENT, &echo, 5000, "AT+RESTORE\r\n"); if (echo.status == AT_ECHO_STATUS_EXPECT) { return 0; } @@ -28,7 +32,7 @@ static int esp8266_echo_close(void) at_echo_t echo; tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "ATE0\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "ATE0\r\n"); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -57,7 +61,7 @@ static int esp8266_net_mode_set(esp8266_net_mode_t mode) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, cmd); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, cmd); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -72,7 +76,7 @@ static int esp8266_send_mode_set(esp8266_send_mode_t mode) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, "AT+CIPMODE=%d\r\n", mode == ESP8266_SEND_MODE_NORMAL ? 0 : 1); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CIPMODE=%d\r\n", mode == ESP8266_SEND_MODE_NORMAL ? 0 : 1); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -87,7 +91,7 @@ static int esp8266_multilink_set(esp8266_multilink_state_t state) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 500, "AT+CIPMUX=%d\r\n", state == ESP8266_MULTILINK_STATE_ENABLE ? 1 : 0); + tos_at_cmd_exec(AT_AGENT, &echo, 500, "AT+CIPMUX=%d\r\n", state == ESP8266_MULTILINK_STATE_ENABLE ? 1 : 0); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } else if (echo.status == AT_ECHO_STATUS_ERROR) { @@ -104,7 +108,7 @@ int esp8266_join_ap(const char *ssid, const char *pwd) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 15000, "AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, pwd); + tos_at_cmd_exec(AT_AGENT, &echo, 15000, "AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, pwd); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -143,7 +147,7 @@ static int esp8266_connect(const char *ip, const char *port, sal_proto_t proto) int id; at_echo_t echo; - id = tos_at_channel_alloc(ip, port); + id = tos_at_channel_alloc(AT_AGENT, ip, port); if (id == -1) { return -1; } @@ -154,7 +158,7 @@ static int esp8266_connect(const char *ip, const char *port, sal_proto_t proto) "AT+CIPSTART=\"%s\",\"%s\",%s\r\n", proto == TOS_SAL_PROTO_UDP ? "UDP" : "TCP", ip, port); #else - tos_at_cmd_exec(&echo, 10000, + tos_at_cmd_exec(AT_AGENT, &echo, 10000, "AT+CIPSTART=%d,\"%s\",\"%s\",%s\r\n", id, proto == TOS_SAL_PROTO_UDP ? "UDP" : "TCP", ip, port); #endif @@ -162,19 +166,19 @@ static int esp8266_connect(const char *ip, const char *port, sal_proto_t proto) return id; } - tos_at_channel_free(id); + tos_at_channel_free(AT_AGENT, id); return -1; } static int esp8266_recv_timeout(int id, void *buf, size_t len, uint32_t timeout) { - return tos_at_channel_read_timed(id, buf, len, timeout); + return tos_at_channel_read_timed(AT_AGENT, id, buf, len, timeout); } static int esp8266_recv(int id, void *buf, size_t len) { - return tos_at_channel_read(id, buf, len); + return tos_at_channel_read(AT_AGENT, id, buf, len); } static int esp8266_is_link_broken(const char *echo_buffer) @@ -192,11 +196,11 @@ static int esp8266_send(int id, const void *buf, size_t len) at_echo_t echo; char echo_buffer[64]; - if (!tos_at_channel_is_working(id)) { + if (!tos_at_channel_is_working(AT_AGENT, id)) { return -1; } - if (tos_at_global_lock_pend() != 0) { + if (tos_at_global_lock_pend(AT_AGENT) != 0) { return -1; } @@ -205,16 +209,16 @@ static int esp8266_send(int id, const void *buf, size_t len) tos_at_cmd_exec_until(&echo, 5000, "AT+CIPSEND=%d\r\n", len); #else - tos_at_cmd_exec_until(&echo, 5000, + tos_at_cmd_exec_until(AT_AGENT, &echo, 5000, "AT+CIPSEND=%d,%d\r\n", id, len); #endif if (echo.status != AT_ECHO_STATUS_EXPECT) { if (esp8266_is_link_broken((const char *)echo.buffer)) { - tos_at_channel_set_broken(id); + tos_at_channel_set_broken(AT_AGENT, id); } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } @@ -224,17 +228,17 @@ static int esp8266_send(int id, const void *buf, size_t len) ATTENTION: we should wait util "SEND OK" is echoed, otherwise the next time we execute at command, the esp8266 maybe in a "busy s ..." state. */ - tos_at_raw_data_send_until(&echo, 10000, (uint8_t *)buf, len); + tos_at_raw_data_send_until(AT_AGENT, &echo, 10000, (uint8_t *)buf, len); if (echo.status != AT_ECHO_STATUS_EXPECT) { if (esp8266_is_link_broken((const char *)echo.buffer)) { - tos_at_channel_set_broken(id); + tos_at_channel_set_broken(AT_AGENT, id); } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return len; } @@ -243,11 +247,11 @@ static int esp8266_sendto(int id, char *ip, char *port, const void *buf, size_t at_echo_t echo; char echo_buffer[64]; - if (!tos_at_channel_is_working(id)) { + if (!tos_at_channel_is_working(AT_AGENT, id)) { return -1; } - if (tos_at_global_lock_pend() != 0) { + if (tos_at_global_lock_pend(AT_AGENT) != 0) { return -1; } @@ -258,7 +262,7 @@ static int esp8266_sendto(int id, char *ip, char *port, const void *buf, size_t tos_at_cmd_exec_until(&echo, 1000, "AT+CIPSEND=%d,\"%s\",%s\r\n", len, ip, port); #else - tos_at_cmd_exec_until(&echo, 1000, + tos_at_cmd_exec_until(AT_AGENT, &echo, 1000, "AT+CIPSEND=%d,%d,\"%s\",%s\r\n", id, len, ip, port); #endif } else { @@ -266,17 +270,17 @@ static int esp8266_sendto(int id, char *ip, char *port, const void *buf, size_t tos_at_cmd_exec_until(&echo, 1000, "AT+CIPSEND=%d\r\n", len); #else - tos_at_cmd_exec_until(&echo, 1000, + tos_at_cmd_exec_until(AT_AGENT, &echo, 1000, "AT+CIPSEND=%d,%d\r\n", id, len); #endif } if (echo.status != AT_ECHO_STATUS_EXPECT) { if (esp8266_is_link_broken((const char *)echo.buffer)) { - tos_at_channel_set_broken(id); + tos_at_channel_set_broken(AT_AGENT, id); } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } @@ -286,23 +290,23 @@ static int esp8266_sendto(int id, char *ip, char *port, const void *buf, size_t ATTENTION: we should wait util "SEND OK" is echoed, otherwise the next time we execute at command, the esp8266 maybe in a "busy s ..." state. */ - tos_at_raw_data_send_until(&echo, 10000, (uint8_t *)buf, len); + tos_at_raw_data_send_until(AT_AGENT, &echo, 10000, (uint8_t *)buf, len); if (echo.status != AT_ECHO_STATUS_EXPECT) { if (esp8266_is_link_broken((const char *)echo.buffer)) { - tos_at_channel_set_broken(id); + tos_at_channel_set_broken(AT_AGENT, id); } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return -1; } - tos_at_global_lock_post(); + tos_at_global_lock_post(AT_AGENT); return len; } static int esp8266_recvfrom_timeout(int id, void *buf, size_t len, uint32_t timeout) { - return tos_at_channel_read_timed(id, buf, len, timeout); + return tos_at_channel_read_timed(AT_AGENT, id, buf, len, timeout); } static int esp8266_recvfrom(int id, void *buf, size_t len) @@ -317,11 +321,11 @@ static int esp8266_close(int id) tos_at_echo_create(&echo, NULL, 0, NULL); #if TOS_CFG_MODULE_SINGLE_LINK_EN > 0u - tos_at_cmd_exec(&echo, 1000, "AT+CIPCLOSE\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CIPCLOSE\r\n"); #else - tos_at_cmd_exec(&echo, 1000, "AT+CIPCLOSE=%d\r\n", id); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CIPCLOSE=%d\r\n", id); #endif - tos_at_channel_free(id); + tos_at_channel_free(AT_AGENT, id); return 0; } @@ -334,7 +338,7 @@ static int esp8266_parse_domain(const char *host_name, char *host_ip, size_t hos esp8266_reconnect_init(); tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); - tos_at_cmd_exec(&echo, 2000, "AT+CIPDOMAIN=\"%s\"\r\n", host_name); + tos_at_cmd_exec(AT_AGENT, &echo, 2000, "AT+CIPDOMAIN=\"%s\"\r\n", host_name); if (echo.status != AT_ECHO_STATUS_OK) { return -1; @@ -409,7 +413,7 @@ __STATIC__ void esp8266_incoming_data_process(void) */ #if TOS_CFG_MODULE_SINGLE_LINK_EN == 0u while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == ',') { @@ -420,7 +424,7 @@ __STATIC__ void esp8266_incoming_data_process(void) #endif while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == ':') { @@ -434,14 +438,14 @@ __STATIC__ void esp8266_incoming_data_process(void) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif read_len = MIN(data_len, sizeof(buffer)); - if (tos_at_uart_read(buffer, read_len) != read_len) { + if (tos_at_uart_read(AT_AGENT, buffer, read_len) != read_len) { return; } //delay has two reason, wait for the data to be cached and untrigger scheduling tos_stopwatch_delay(200); - if (tos_at_channel_write(channel_id, buffer, read_len) <= 0) { + if (tos_at_channel_write(AT_AGENT, channel_id, buffer, read_len) <= 0) { return; } @@ -469,7 +473,8 @@ sal_module_t sal_module_esp8266 = { int esp8266_sal_init(hal_uart_port_t uart_port) { - if (tos_at_init(uart_port, esp8266_at_event, + if (tos_at_init(AT_AGENT, "esp8266_at", esp8266_at_parse_task_stk, + uart_port, esp8266_at_event, sizeof(esp8266_at_event) / sizeof(esp8266_at_event[0])) != 0) { return -1; } @@ -495,7 +500,7 @@ int esp8266_sal_deinit() tos_sal_module_register_default(); - tos_at_deinit(); + tos_at_deinit(AT_AGENT); return 0; } diff --git a/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.c b/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.c index d356e527..180e7d13 100644 --- a/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.c +++ b/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.c @@ -6,6 +6,11 @@ #include "tencent_firmware_module_wrapper.h" #include "esp8266_tencent_firmware.h" +at_agent_t esp8266_tf_agent; +static k_stack_t esp8266_tf_at_parse_task_stk[AT_PARSER_TASK_STACK_SIZE]; + +#define AT_AGENT ((at_agent_t *)&esp8266_tf_agent) + /* * config dev info to module, do this operate only once in factroy is suggested */ @@ -15,7 +20,7 @@ int esp8266_tencent_firmware_module_info_set(device_info_t *info, tls_mode_t mod tos_at_echo_create(&echo, NULL, 0, "+TCDEVINFOSET:OK"); - tos_at_cmd_exec_until(&echo, 2000, "AT+TCDEVINFOSET=%d,\"%s\",\"%s\",\"%s\"\r\n", + tos_at_cmd_exec_until(AT_AGENT, &echo, 2000, "AT+TCDEVINFOSET=%d,\"%s\",\"%s\",\"%s\"\r\n", mode, info->product_id, info->device_name, info->device_serc); if (echo.status == AT_ECHO_STATUS_EXPECT) { return 0; @@ -31,7 +36,7 @@ int esp8266_tencent_firmware_module_mqtt_conn(mqtt_param_t init_params) tos_at_echo_create(&echo, NULL, 0, "+TCMQTTCONN:OK"); while (try++ < 10) { - tos_at_cmd_exec_until(&echo, 2000, "AT+TCMQTTCONN=%d,%d,%d,%d,%d\r\n", init_params.tls_mode, + tos_at_cmd_exec_until(AT_AGENT, &echo, 2000, "AT+TCMQTTCONN=%d,%d,%d,%d,%d\r\n", init_params.tls_mode, init_params.command_timeout, init_params.keep_alive_interval_ms, init_params.clean_session, init_params.auto_connect_enable); if (echo.status == AT_ECHO_STATUS_EXPECT) { @@ -48,7 +53,7 @@ int esp8266_tencent_firmware_module_mqtt_discon(void) tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "AT+TCMQTTDISCONN\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+TCMQTTDISCONN\r\n"); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -63,13 +68,13 @@ int esp8266_tencent_firmware_module_mqtt_publ(const char *topic, qos_t qos, char strcat(payload, "\r\n"); - tos_at_cmd_exec_until(&echo, 1000, "AT+TCMQTTPUBL=\"%s\",%d,%d\r\n", topic, qos, strlen(payload)-2); + tos_at_cmd_exec_until(AT_AGENT, &echo, 1000, "AT+TCMQTTPUBL=\"%s\",%d,%d\r\n", topic, qos, strlen(payload)-2); if (echo.status != AT_ECHO_STATUS_EXPECT) { return -1; } tos_at_echo_create(&echo, NULL, 0, "+TCMQTTPUBL:OK"); - tos_at_raw_data_send_until(&echo, 1000, (uint8_t *)payload, strlen(payload)); + tos_at_raw_data_send_until(AT_AGENT, &echo, 1000, (uint8_t *)payload, strlen(payload)); if (echo.status != AT_ECHO_STATUS_EXPECT) { return -1; } @@ -84,7 +89,7 @@ int esp8266_tencent_firmware_module_mqtt_pub(const char *topic, qos_t qos, char tos_at_echo_create(&echo, NULL, 0, "+TCMQTTPUB:OK"); - tos_at_cmd_exec_until(&echo, 1000, "AT+TCMQTTPUB=\"%s\",%d,\"%s\"\r\n", topic, qos, payload); + tos_at_cmd_exec_until(AT_AGENT, &echo, 1000, "AT+TCMQTTPUB=\"%s\",%d,\"%s\"\r\n", topic, qos, payload); if (echo.status == AT_ECHO_STATUS_EXPECT) { return 0; } @@ -97,7 +102,7 @@ int esp8266_tencent_firmware_module_mqtt_sub(char *topic, qos_t qos) tos_at_echo_create(&echo, NULL, 0, "+TCMQTTSUB:OK"); - tos_at_cmd_exec_until(&echo, 2000, "AT+TCMQTTSUB=\"%s\",%d\r\n", topic, qos); + tos_at_cmd_exec_until(AT_AGENT, &echo, 2000, "AT+TCMQTTSUB=\"%s\",%d\r\n", topic, qos); if (echo.status == AT_ECHO_STATUS_EXPECT) { return 0; } @@ -110,7 +115,7 @@ int esp8266_tencent_firmware_module_mqtt_unsub(const char *topic) tos_at_echo_create(&echo, NULL, 0, "+TCMQTTUNSUB:OK"); - tos_at_cmd_exec_until(&echo, 2000, "AT+TCMQTTUNSUB=\"%s\"\r\n", topic); + tos_at_cmd_exec_until(AT_AGENT, &echo, 2000, "AT+TCMQTTUNSUB=\"%s\"\r\n", topic); if (echo.status == AT_ECHO_STATUS_EXPECT) { return 0; } @@ -126,7 +131,7 @@ int esp8266_tencent_firmware_module_mqtt_state_get(mqtt_state_t *state) tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), NULL); - tos_at_cmd_exec(&echo, 1000, "AT+TCMQTTSTATE?\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+TCMQTTSTATE?\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -153,7 +158,7 @@ int esp8266_tencent_firmware_module_debug_level_set(int log_level) tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "AT+TCTEMLOG=%d\r\n", log_level); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+TCTEMLOG=%d\r\n", log_level); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -167,7 +172,7 @@ int esp8266_tencent_firmware_join_ap(const char *ssid, const char *pwd) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 30000, "AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, pwd); + tos_at_cmd_exec(AT_AGENT, &echo, 30000, "AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, pwd); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -183,7 +188,7 @@ static int esp8266_tencent_firmware_restore(void) tos_at_echo_create(&echo, NULL, 0, "ready"); while (try++ < 10) { - tos_at_cmd_exec_until(&echo, 5000, "AT+RESTORE\r\n"); + tos_at_cmd_exec_until(AT_AGENT, &echo, 5000, "AT+RESTORE\r\n"); if (echo.status == AT_ECHO_STATUS_EXPECT) { return 0; } @@ -196,7 +201,7 @@ static int esp8266_tencent_firmware_echo_close(void) at_echo_t echo; tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 1000, "ATE0\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "ATE0\r\n"); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -225,7 +230,7 @@ static int esp8266_tencent_firmware_net_mode_set(sal_net_mode_t mode) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, cmd); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, cmd); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -240,7 +245,7 @@ static int esp8266_tencent_firmware_send_mode_set(sal_send_mode_t mode) tos_at_echo_create(&echo, NULL, 0, NULL); while (try++ < 10) { - tos_at_cmd_exec(&echo, 1000, "AT+CIPMODE=%d\r\n", mode == SAL_SEND_MODE_NORMAL ? 0 : 1); + tos_at_cmd_exec(AT_AGENT, &echo, 1000, "AT+CIPMODE=%d\r\n", mode == SAL_SEND_MODE_NORMAL ? 0 : 1); if (echo.status == AT_ECHO_STATUS_OK) { return 0; } @@ -283,7 +288,7 @@ int esp8266_tencent_firmware_ota_set(ota_mode_t mode, char *version) tos_at_echo_create(&echo, NULL, 0, "+TCOTASET:OK"); - tos_at_cmd_exec_until(&echo, 2000, "AT+TCOTASET=%d,\"%s\"\r\n", mode, version); + tos_at_cmd_exec_until(AT_AGENT, &echo, 2000, "AT+TCOTASET=%d,\"%s\"\r\n", mode, version); if (echo.status == AT_ECHO_STATUS_EXPECT) { return 0; } @@ -306,7 +311,7 @@ int esp8266_tencent_firmware_ota_read_fwinfo(ota_fw_info_t *ota_fw_info) tos_at_echo_create(&echo, echo_buffer, sizeof(echo_buffer), "+TCFWINFO:"); - tos_at_cmd_exec_until(&echo, 2000, "AT+TCFWINFO?\r\n"); + tos_at_cmd_exec_until(AT_AGENT, &echo, 2000, "AT+TCFWINFO?\r\n"); if (echo.status == AT_ECHO_STATUS_EXPECT) { sscanf(echo_buffer, "%*[^\"]%*c%[^\"]%*[^,]%*c%[^,]%*[^\"]%*c%[^\"]", ota_fw_info->fw_version, FileSize, ota_fw_info->fw_md5); @@ -341,7 +346,7 @@ static int esp8266_tencent_firmware_ota_read_fwdata(uint8_t *ota_fw_data_buffer, tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 300, "AT+TCREADFWDATA=%d\r\n", read_len); + tos_at_cmd_exec(AT_AGENT, &echo, 300, "AT+TCREADFWDATA=%d\r\n", read_len); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -365,7 +370,7 @@ void esp8266_tencent_firmware_recvpub(void) memset(&mqtt_message, 0, sizeof(mqtt_message)); while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == '"') { @@ -384,7 +389,7 @@ void esp8266_tencent_firmware_recvpub(void) } while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == ',') { @@ -397,7 +402,7 @@ void esp8266_tencent_firmware_recvpub(void) payload_len = sizeof(mqtt_message.payload); } - read_len = tos_at_uart_read((uint8_t*)mqtt_message.payload, payload_len + 2); + read_len = tos_at_uart_read(AT_AGENT, (uint8_t*)mqtt_message.payload, payload_len + 2); if (read_len != payload_len + 2) { return; } @@ -414,7 +419,7 @@ void esp8266_tencent_firmware_recvcmd(void) uint8_t buffer[20]; int read_len = 13; - if (tos_at_uart_read(buffer, read_len) != read_len) { + if (tos_at_uart_read(AT_AGENT, buffer, read_len) != read_len) { return; } @@ -437,7 +442,7 @@ void esp8266_tencent_firmware_recvfwdata(void) static uint8_t buffer[128]; while (1) { - if (tos_at_uart_read(&data, 1) != 1) { + if (tos_at_uart_read(AT_AGENT, &data, 1) != 1) { return; } if (data == ',') { @@ -449,7 +454,7 @@ void esp8266_tencent_firmware_recvfwdata(void) do { #define MIN(a, b) ((a) < (b) ? (a) : (b)) read_len = MIN(data_len, sizeof(buffer)); - if (tos_at_uart_read(buffer, read_len) != read_len) { + if (tos_at_uart_read(AT_AGENT, buffer, read_len) != read_len) { return; } @@ -481,7 +486,7 @@ int esp8266_tencent_firmware_start_smartconfig(void) } tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 2000, "AT+TCSTARTSMART\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 2000, "AT+TCSTARTSMART\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -508,7 +513,7 @@ int esp8266_tencent_firmware_stop_smartconfig(void) tos_at_echo_create(&echo, NULL, 0, NULL); - tos_at_cmd_exec(&echo, 2000, "AT+TCSTOPSMART\r\n"); + tos_at_cmd_exec(AT_AGENT, &echo, 2000, "AT+TCSTOPSMART\r\n"); if (echo.status != AT_ECHO_STATUS_OK) { return -1; } @@ -523,7 +528,7 @@ void esp8266_tencent_firmware_recvscstatus(void) */ static char buffer[40]; - if (tos_at_uart_read((uint8_t*)buffer, sizeof(buffer) - 1) != (sizeof(buffer) - 1)) { + if (tos_at_uart_read(AT_AGENT, (uint8_t*)buffer, sizeof(buffer) - 1) != (sizeof(buffer) - 1)) { return; } @@ -568,7 +573,8 @@ int esp8266_tencent_firmware_sal_init(hal_uart_port_t uart_port) { int ret = -1; - if (tos_at_init(uart_port, esp8266_tencent_firmware_at_event, + if (tos_at_init(AT_AGENT, "esp8266_tf_at", esp8266_tf_at_parse_task_stk, + uart_port, esp8266_tencent_firmware_at_event, sizeof(esp8266_tencent_firmware_at_event) / sizeof(esp8266_tencent_firmware_at_event[0])) != 0) { return -1; @@ -585,3 +591,9 @@ int esp8266_tencent_firmware_sal_init(hal_uart_port_t uart_port) return 0; } +int esp8266_tencent_firmware_sal_deinit() +{ + tos_at_deinit(AT_AGENT); + + return 0; +} diff --git a/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.h b/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.h index 4a5b3408..b717b04a 100644 --- a/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.h +++ b/devices/esp8266_tencent_firmware/esp8266_tencent_firmware.h @@ -32,6 +32,7 @@ typedef enum sal_send_mode { } sal_send_mode_t; int esp8266_tencent_firmware_sal_init(hal_uart_port_t uart_port); +int esp8266_tencent_firmware_sal_deinit(void); int esp8266_tencent_firmware_join_ap(const char *ssid, const char *pwd); #endif /* __ESP8266_TENCENT_FIRMWARE_H__ */ diff --git a/examples/mqttclient_iot_explorer/mqttclient_iot_explorer.c b/examples/mqttclient_iot_explorer/mqttclient_iot_explorer.c index 271a6d6e..5ba7988c 100644 --- a/examples/mqttclient_iot_explorer/mqttclient_iot_explorer.c +++ b/examples/mqttclient_iot_explorer/mqttclient_iot_explorer.c @@ -5,13 +5,11 @@ #include "sal_module_wrapper.h" #define USE_ESP8266 - //#define USE_EC600S #if defined(USE_ESP8266) #include "esp8266.h" - -#elif defined(USE_EC200S) +#elif defined(USE_EC600S) #include "ec600s.h" #endif @@ -101,7 +99,7 @@ void mqttclient_task(void) #endif -#ifdef USE_EC200S +#ifdef USE_EC600S ec600s_sal_init(HAL_UART_PORT_2); #endif diff --git a/net/at/include/tos_at.h b/net/at/include/tos_at.h index 6d085ec7..f3c3f3b1 100644 --- a/net/at/include/tos_at.h +++ b/net/at/include/tos_at.h @@ -165,14 +165,13 @@ typedef struct at_agent_st { uint8_t *uart_rx_fifo_buffer; } at_agent_t; -#define AT_AGENT ((at_agent_t *)(&at_agent)) - /** * @brief Write data to a channel. * Write data to a channel with certain id. * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * @param[in] buffer data buffer to write. * @param[in] buffer_len length of the buffer. @@ -181,7 +180,7 @@ typedef struct at_agent_st { * @retval -1 write failed(error). * @retval none -1 the number of bytes written. */ -__API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_len); +__API__ int tos_at_channel_write(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len); /** * @brief Read data from a channel. @@ -189,6 +188,7 @@ __API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_ * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * @param[out] buffer buffer to hold the data read. * @param[in] buffer_len length of the buffer. @@ -198,7 +198,7 @@ __API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_ * @retval -1 read failed(error). * @retval none -1 the number of bytes read. */ -__API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t buffer_len, uint32_t timeout); +__API__ int tos_at_channel_read_timed(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len, uint32_t timeout); /** * @brief Read data from a channel. @@ -206,6 +206,7 @@ __API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t bu * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * @param[out] buffer buffer to hold the data read. * @param[in] buffer_len length of the buffer. @@ -214,7 +215,7 @@ __API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t bu * @retval -1 read failed(error). * @retval none -1 the number of bytes read. */ -__API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_len); +__API__ int tos_at_channel_read(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len); /** * @brief Allocate a channel. @@ -222,6 +223,7 @@ __API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_l * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * @param[in] ip remote ip of the channel. * @param[in] port remote port of the channel. @@ -230,7 +232,7 @@ __API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_l * @retval -1 allocate failed(error). * @retval none -1 the id of the channel. */ -__API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char *port); +__API__ int tos_at_channel_alloc_id(at_agent_t *at_agent, int channel_id, const char *ip, const char *port); /** * @brief Allocate a channel. @@ -238,6 +240,7 @@ __API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char * * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] ip remote ip of the channel. * @param[in] port remote port of the channel. * @@ -245,7 +248,7 @@ __API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char * * @retval -1 allocate failed(error). * @retval none -1 the id of the channel. */ -__API__ int tos_at_channel_alloc(const char *ip, const char *port); +__API__ int tos_at_channel_alloc(at_agent_t *at_agent, const char *ip, const char *port); /** * @brief Allocate a channel. @@ -253,6 +256,7 @@ __API__ int tos_at_channel_alloc(const char *ip, const char *port); * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * @param[in] ip remote ip of the channel. * @param[in] port remote port of the channel. @@ -262,7 +266,7 @@ __API__ int tos_at_channel_alloc(const char *ip, const char *port); * @retval -1 allocate failed(error). * @retval none -1 the id of the channel. */ -__API__ int tos_at_channel_alloc_with_size(const char *ip, const char *port, size_t socket_buffer_size); +__API__ int tos_at_channel_alloc_with_size(at_agent_t *at_agent, const char *ip, const char *port, size_t socket_buffer_size); /** * @brief Free a channel. @@ -270,43 +274,47 @@ __API__ int tos_at_channel_alloc_with_size(const char *ip, const char *port, siz * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * * @return errcode * @retval -1 free failed(error). * @retval 0 free successfully. */ -__API__ int tos_at_channel_free(int channel_id); +__API__ int tos_at_channel_free(at_agent_t *at_agent, int channel_id); /** * @brief Set channel broken. * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * * @return errcode * @retval -1 set failed(error). * @retval 0 set successfully. */ -__API__ int tos_at_channel_set_broken(int channel_id); +__API__ int tos_at_channel_set_broken(at_agent_t *at_agent, int channel_id); /** * @brief Judge whether channel is working. * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * * @return at channel status(type of at_channel_status_t) */ -__API__ int tos_at_channel_is_working(int channel_id); +__API__ int tos_at_channel_is_working(at_agent_t *at_agent, int channel_id); /** * @brief Initialize the at framework. * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] uart_port port number of the uart thougth which the module connect to the MCU. * @param[in] event_table the listened event table. * @param[in] event_table_size the size of the listened event table. @@ -315,17 +323,19 @@ __API__ int tos_at_channel_is_working(int channel_id); * @retval -1 initialize failed(error). * @retval 0 initialize successfully. */ -__API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size_t event_table_size); +__API__ int tos_at_init(at_agent_t *at_agent, char *task_name, k_stack_t *stk, hal_uart_port_t uart_port, at_event_t *event_table, size_t event_table_size); /** * @brief De-initialize the at framework. * + * @param[in] at_agent pointer to the at agent struct. + * * @attention None * * @return None */ -__API__ void tos_at_deinit(void); +__API__ void tos_at_deinit(at_agent_t *at_agent); /** * @brief Create a echo struct. @@ -364,6 +374,7 @@ __API__ int tos_at_echo_fuzzy_matching_create(at_echo_t *echo, char *buffer, siz * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] echo pointer to the echo struct. * @param[in] timeout command wait timeout . * @param[in] cmd at command. @@ -372,7 +383,7 @@ __API__ int tos_at_echo_fuzzy_matching_create(at_echo_t *echo, char *buffer, siz * @retval -1 execute failed(error). * @retval 0 execute successfully. */ -__API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, ...); +__API__ int tos_at_cmd_exec(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const char *cmd, ...); /** * @brief Execute an at command. @@ -380,6 +391,7 @@ __API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] echo pointer to the echo struct. * @param[in] timeout command wait timeout . * @param[in] cmd at command. @@ -388,13 +400,14 @@ __API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, * @retval -1 execute failed(error). * @retval 0 execute successfully. */ -__API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char *cmd, ...); +__API__ int tos_at_cmd_exec_until(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const char *cmd, ...); /** * @brief Send raw data througth uart. * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] echo pointer to the echo struct. * @param[in] timeout command wait timeout . * @param[in] buf data to send. @@ -404,7 +417,7 @@ __API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char * @retval -1 execute failed(error). * @retval 0 execute successfully. */ -__API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size); +__API__ int tos_at_raw_data_send(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size); /** * @brief Send raw data througth uart. @@ -412,6 +425,7 @@ __API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_ * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] echo pointer to the echo struct. * @param[in] timeout command wait timeout . * @param[in] buf data to send. @@ -421,7 +435,7 @@ __API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_ * @retval -1 execute failed(error). * @retval 0 execute successfully. */ -__API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size); +__API__ int tos_at_raw_data_send_until(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size); #if AT_INPUT_TYPE_FRAME_EN /** @@ -430,12 +444,13 @@ __API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const * * @attention None * - * @param[in] pdata pointer of the uart received data. - * @param[in] len length of the uart received data. + * @param[in] at_agent pointer to the at agent struct. + * @param[in] pdata pointer of the uart received data. + * @param[in] len length of the uart received data. * * @return None */ -__API__ void tos_at_uart_input_frame(uint8_t *pdata, uint16_t len); +__API__ void tos_at_uart_input_frame(at_agent_t *at_agent, uint8_t *pdata, uint16_t len); #elif AT_INPUT_SIMULATE_IDLE_EN /** @@ -444,11 +459,12 @@ __API__ void tos_at_uart_input_frame(uint8_t *pdata, uint16_t len); * * @attention No notification is given after writing. * + * @param[in] at_agent pointer to the at agent struct. * @param[in] data uart received data. * * @return None */ -__API__ void tos_at_uart_input_byte_no_notify(uint8_t data); +__API__ void tos_at_uart_input_byte_no_notify(at_agent_t *at_agent, uint8_t data); #else /** * @brief Write byte to the at uart. @@ -456,11 +472,12 @@ __API__ void tos_at_uart_input_byte_no_notify(uint8_t data); * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] data uart received data. * * @return None */ -__API__ void tos_at_uart_input_byte(uint8_t data); +__API__ void tos_at_uart_input_byte(at_agent_t *at_agent, uint8_t data); #endif /** * @brief A global lock provided by at framework. @@ -468,13 +485,13 @@ __API__ void tos_at_uart_input_byte(uint8_t data); * * @attention None * - * @param None. + * @param[in] at_agent pointer to the at agent struct. * * @return errcode * @retval -1 pend failed(error). * @retval 0 pend successfully. */ -__API__ int tos_at_global_lock_pend(void); +__API__ int tos_at_global_lock_pend(at_agent_t *at_agent); /** * @brief A global lock provided by at framework. @@ -482,13 +499,13 @@ __API__ int tos_at_global_lock_pend(void); * * @attention None * - * @param None. + * @param[in] at_agent pointer to the at agent struct. * * @return errcode * @retval -1 post failed(error). * @retval 0 post successfully. */ -__API__ int tos_at_global_lock_post(void); +__API__ int tos_at_global_lock_post(at_agent_t *at_agent); /** * @brief Read data from the uart. @@ -496,12 +513,13 @@ __API__ int tos_at_global_lock_post(void); * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[out] buffer buffer to hold the data read from the uart. * @param[in] buffer_len length of the buffer. * * @return length of the data read from the uart. */ -__API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len); +__API__ int tos_at_uart_read(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len); /** * @brief Read data from the uart. @@ -509,12 +527,13 @@ __API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len); * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[out] buffer buffer to hold the data read from the uart. * @param[in] buffer_len length of the buffer. * * @return length of the data read from the uart. */ -__API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len); +__API__ int tos_at_uart_readline(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len); /** * @brief Read data from the uart. @@ -522,12 +541,13 @@ __API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len); * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[out] buffer buffer to hold the data read from the uart. * @param[in] buffer_len length of the buffer. * * @return length of the data read from the uart. */ -__API__ int tos_at_uart_drain(uint8_t *buffer, size_t buffer_len); +__API__ int tos_at_uart_drain(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len); /** * @brief Get the remote ip of a channel. @@ -535,11 +555,12 @@ __API__ int tos_at_uart_drain(uint8_t *buffer, size_t buffer_len); * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * * @return remote ip of the channel. */ -__API__ const char *tos_at_channel_ip_get(int channel_id); +__API__ const char *tos_at_channel_ip_get(at_agent_t *at_agent, int channel_id); /** * @brief Get the remote port of a channel. @@ -547,11 +568,12 @@ __API__ const char *tos_at_channel_ip_get(int channel_id); * * @attention None * + * @param[in] at_agent pointer to the at agent struct. * @param[in] channel_id id of the channel. * * @return remote port of the channel. */ -__API__ const char *tos_at_channel_port_get(int channel_id); +__API__ const char *tos_at_channel_port_get(at_agent_t *at_agent, int channel_id); #endif /* _TOS_AT_H_ */ diff --git a/net/at/src/tos_at.c b/net/at/src/tos_at.c index de0aeecd..0e4e19e6 100644 --- a/net/at/src/tos_at.c +++ b/net/at/src/tos_at.c @@ -26,65 +26,61 @@ Note: #include "tos_at.h" -__STATIC__ at_agent_t at_agent; - -__STATIC__ k_stack_t at_parser_task_stack[AT_PARSER_TASK_STACK_SIZE]; - -__API__ int tos_at_global_lock_pend(void) +__API__ int tos_at_global_lock_pend(at_agent_t *at_agent) { - if (tos_mutex_pend(&AT_AGENT->global_lock) != K_ERR_NONE) { + if (tos_mutex_pend(&at_agent->global_lock) != K_ERR_NONE) { return -1; } return 0; } -__API__ int tos_at_global_lock_post(void) +__API__ int tos_at_global_lock_post(at_agent_t *at_agent) { - if (tos_mutex_post(&AT_AGENT->global_lock) != K_ERR_NONE) { + if (tos_mutex_post(&at_agent->global_lock) != K_ERR_NONE) { return -1; } return 0; } -__STATIC__ int at_uart_getchar_from_fifo(uint8_t *data) +__STATIC__ int at_uart_getchar_from_fifo(at_agent_t *at_agent, uint8_t *data) { TOS_CPU_CPSR_ALLOC(); k_err_t err; TOS_CPU_INT_DISABLE(); - err = tos_chr_fifo_pop(&AT_AGENT->uart_rx_fifo, data); + err = tos_chr_fifo_pop(&at_agent->uart_rx_fifo, data); TOS_CPU_INT_ENABLE(); return err; } -__STATIC__ int at_uart_getchar(uint8_t *data, k_tick_t timeout) +__STATIC__ int at_uart_getchar(at_agent_t *at_agent, uint8_t *data, k_tick_t timeout) { #if AT_INPUT_TYPE_FRAME_EN at_frame_len_mail_t frame_len_mail; size_t mail_size; - if (AT_AGENT->fifo_available_len == 0) { - if (tos_mail_q_pend(&AT_AGENT->uart_rx_frame_mail, &frame_len_mail, &mail_size, timeout) != K_ERR_NONE) { + if (at_agent->fifo_available_len == 0) { + if (tos_mail_q_pend(&at_agent->uart_rx_frame_mail, &frame_len_mail, &mail_size, timeout) != K_ERR_NONE) { return -1; } - AT_AGENT->fifo_available_len = frame_len_mail.frame_len; + at_agent->fifo_available_len = frame_len_mail.frame_len; } - if (at_uart_getchar_from_fifo(data) != K_ERR_NONE) { + if (at_uart_getchar_from_fifo(at_agent, data) != K_ERR_NONE) { return -1; } - AT_AGENT->fifo_available_len -= 1; + at_agent->fifo_available_len -= 1; return 0; #elif AT_INPUT_SIMULATE_IDLE_EN - if (tos_chr_fifo_is_empty(&AT_AGENT->uart_rx_fifo)) { - if (tos_sem_pend(&AT_AGENT->uart_rx_sem, timeout) != K_ERR_NONE) { + if (tos_chr_fifo_is_empty(&at_agent->uart_rx_fifo)) { + if (tos_sem_pend(&at_agent->uart_rx_sem, timeout) != K_ERR_NONE) { return -1; } } - if (at_uart_getchar_from_fifo(data) != K_ERR_NONE) { + if (at_uart_getchar_from_fifo(at_agent, data) != K_ERR_NONE) { return -1; } @@ -93,7 +89,7 @@ __STATIC__ int at_uart_getchar(uint8_t *data, k_tick_t timeout) #else tos_stopwatch_delay(1); - if (tos_sem_pend(&AT_AGENT->uart_rx_sem, timeout) != K_ERR_NONE) { + if (tos_sem_pend(&at_agent->uart_rx_sem, timeout) != K_ERR_NONE) { return -1; } @@ -103,28 +99,28 @@ __STATIC__ int at_uart_getchar(uint8_t *data, k_tick_t timeout) so it is more effective to use critical sections. */ -// if (tos_mutex_pend(&AT_AGENT->uart_rx_lock) != K_ERR_NONE) { +// if (tos_mutex_pend(&at_agent->uart_rx_lock) != K_ERR_NONE) { // return -1; // } - if (at_uart_getchar_from_fifo(data) != K_ERR_NONE) { + if (at_uart_getchar_from_fifo(at_agent, data) != K_ERR_NONE) { return -1; } -// tos_mutex_post(&AT_AGENT->uart_rx_lock); +// tos_mutex_post(&at_agent->uart_rx_lock); return 0; #endif /* AT_INPUT_TYPE_FRAME_EN */ } -__STATIC__ at_event_t *at_event_do_get(char *buffer, size_t buffer_len) +__STATIC__ at_event_t *at_event_do_get(at_agent_t *at_agent, char *buffer, size_t buffer_len) { int i = 0; at_event_t *event_table = K_NULL, *event = K_NULL; size_t event_table_size = 0, event_len; - event_table = AT_AGENT->event_table; - event_table_size = AT_AGENT->event_table_size; + event_table = at_agent->event_table; + event_table_size = at_agent->event_table_size; for (i = 0; i < event_table_size; ++i) { event = &event_table[i]; @@ -142,27 +138,27 @@ __STATIC__ at_event_t *at_event_do_get(char *buffer, size_t buffer_len) return K_NULL; } -__STATIC__ at_event_t *at_get_event(void) +__STATIC__ at_event_t *at_get_event(at_agent_t *at_agent) { char *buffer; size_t buffer_len; at_cache_t *at_cache = K_NULL; - at_cache = &AT_AGENT->recv_cache; + at_cache = &at_agent->recv_cache; buffer = (char *)at_cache->buffer; buffer_len = at_cache->recv_len; - return at_event_do_get(buffer, buffer_len); + return at_event_do_get(at_agent, buffer, buffer_len); } -__API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len) +__API__ int tos_at_uart_read(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len) { uint8_t data; size_t read_len = 0; while (K_TRUE) { - if (at_uart_getchar(&data, TOS_TIME_FOREVER) != 0) { + if (at_uart_getchar(at_agent, &data, TOS_TIME_FOREVER) != 0) { return read_len; } @@ -174,13 +170,13 @@ __API__ int tos_at_uart_read(uint8_t *buffer, size_t buffer_len) } } -__API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len) +__API__ int tos_at_uart_readline(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len) { uint8_t data; size_t read_len = 0; while (K_TRUE) { - if (at_uart_getchar(&data, TOS_TIME_FOREVER) != 0) { + if (at_uart_getchar(at_agent, &data, TOS_TIME_FOREVER) != 0) { return read_len; } @@ -194,13 +190,13 @@ __API__ int tos_at_uart_readline(uint8_t *buffer, size_t buffer_len) } } -__API__ int tos_at_uart_drain(uint8_t *buffer, size_t buffer_len) +__API__ int tos_at_uart_drain(at_agent_t *at_agent, uint8_t *buffer, size_t buffer_len) { uint8_t data; size_t read_len = 0; while (K_TRUE) { - if (at_uart_getchar(&data, TOS_TIME_NOWAIT) != 0) { + if (at_uart_getchar(at_agent, &data, TOS_TIME_NOWAIT) != 0) { return read_len; } @@ -212,20 +208,20 @@ __API__ int tos_at_uart_drain(uint8_t *buffer, size_t buffer_len) } } -__STATIC__ int at_is_echo_expect(void) +__STATIC__ int at_is_echo_expect(at_agent_t *at_agent) { char *recv_buffer, *expect; size_t recv_buffer_len, expect_len; at_echo_t *at_echo = K_NULL; at_cache_t *at_cache = K_NULL; - at_echo = AT_AGENT->echo; + at_echo = at_agent->echo; if (!at_echo || !at_echo->echo_expect) { return 0; } - at_cache = &AT_AGENT->recv_cache; + at_cache = &at_agent->recv_cache; recv_buffer = (char *)at_cache->buffer; recv_buffer_len = at_cache->recv_len; @@ -251,19 +247,19 @@ __STATIC__ int at_is_echo_expect(void) return 0; } -__STATIC__ at_parse_status_t at_uart_line_parse(void) +__STATIC__ at_parse_status_t at_uart_line_parse(at_agent_t *at_agent) { size_t curr_len = 0; uint8_t data, last_data = 0; at_cache_t *recv_cache = K_NULL; - recv_cache = &AT_AGENT->recv_cache; + recv_cache = &at_agent->recv_cache; recv_cache->recv_len = 0; memset(recv_cache->buffer, 0, recv_cache->buffer_size); while (K_TRUE) { - if (at_uart_getchar(&data, TOS_TIME_FOREVER) != 0) { + if (at_uart_getchar(at_agent, &data, TOS_TIME_FOREVER) != 0) { continue; } @@ -279,11 +275,11 @@ __STATIC__ at_parse_status_t at_uart_line_parse(void) return AT_PARSE_STATUS_OVERFLOW; } - if (at_get_event() != K_NULL) { + if (at_get_event(at_agent) != K_NULL) { return AT_PARSE_STATUS_EVENT; } - if (at_is_echo_expect()) { + if (at_is_echo_expect(at_agent)) { return AT_PARSE_STATUS_EXPECT; } @@ -343,11 +339,13 @@ __STATIC__ void at_parser(void *arg) at_cache_t *recv_cache = K_NULL; at_parse_status_t at_parse_status; - recv_cache = &AT_AGENT->recv_cache; + at_agent_t *at_agent = (at_agent_t *)arg; + + recv_cache = &at_agent->recv_cache; while (K_TRUE) { - at_parse_status = at_uart_line_parse(); + at_parse_status = at_uart_line_parse(at_agent); AT_LOG("at line parser end!(%d)\r\n", at_parse_status); @@ -359,14 +357,14 @@ __STATIC__ void at_parser(void *arg) } if (at_parse_status == AT_PARSE_STATUS_EVENT) { - at_event = at_get_event(); + at_event = at_get_event(at_agent); if (at_event && at_event->event_callback) { at_event->event_callback(); } continue; } - at_echo = AT_AGENT->echo; + at_echo = at_agent->echo; if (!at_echo) { continue; } @@ -399,13 +397,13 @@ __STATIC__ void at_parser(void *arg) } } -__STATIC__ int at_uart_send(const uint8_t *buf, size_t size, uint32_t timeout) +__STATIC__ int at_uart_send(at_agent_t *at_agent, const uint8_t *buf, size_t size, uint32_t timeout) { int ret; - tos_mutex_pend(&AT_AGENT->uart_tx_lock); - ret = tos_hal_uart_write(&AT_AGENT->uart, buf, size, timeout); - tos_mutex_post(&AT_AGENT->uart_tx_lock); + tos_mutex_pend(&at_agent->uart_tx_lock); + ret = tos_hal_uart_write(&at_agent->uart, buf, size, timeout); + tos_mutex_post(&at_agent->uart_tx_lock); return ret; } @@ -459,30 +457,30 @@ __STATIC_INLINE__ void at_echo_flush(at_echo_t *echo) echo->__w_idx = 0; } -__STATIC_INLINE__ void at_echo_attach(at_echo_t *echo) +__STATIC_INLINE__ void at_echo_attach(at_agent_t *at_agent, at_echo_t *echo) { at_echo_flush(echo); - AT_AGENT->echo = echo; + at_agent->echo = echo; } -__API__ int tos_at_raw_data_send(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size) +__API__ int tos_at_raw_data_send(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size) { int ret = 0; if (echo) { - at_echo_attach(echo); + at_echo_attach(at_agent, echo); } - ret = at_uart_send(buf, size, 0xFFFF); + ret = at_uart_send(at_agent, buf, size, 0xFFFF); tos_task_delay(tos_millisec2tick(timeout)); - AT_AGENT->echo = K_NULL; + at_agent->echo = K_NULL; return ret; } -__API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size) +__API__ int tos_at_raw_data_send_until(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const uint8_t *buf, size_t size) { int ret = 0; @@ -494,9 +492,9 @@ __API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const return -1; } echo->__is_expecting = K_TRUE; - at_echo_attach(echo); + at_echo_attach(at_agent, echo); - ret = at_uart_send(buf, size, 0xFFFF); + ret = at_uart_send(at_agent, buf, size, 0xFFFF); if (tos_sem_pend(&echo->__expect_notify, tos_millisec2tick(timeout)) != K_ERR_NONE) { ret = -1; @@ -504,31 +502,31 @@ __API__ int tos_at_raw_data_send_until(at_echo_t *echo, uint32_t timeout, const tos_sem_destroy(&echo->__expect_notify); - AT_AGENT->echo = K_NULL; + at_agent->echo = K_NULL; return ret; } -__STATIC__ int at_cmd_do_exec(const char *format, va_list args) +__STATIC__ int at_cmd_do_exec(at_agent_t *at_agent, const char *format, va_list args) { size_t cmd_len = 0; - if (tos_mutex_pend(&AT_AGENT->cmd_buf_lock) != K_ERR_NONE) { + if (tos_mutex_pend(&at_agent->cmd_buf_lock) != K_ERR_NONE) { return -1; } - cmd_len = vsnprintf(AT_AGENT->cmd_buf, AT_CMD_BUFFER_SIZE, format, args); + cmd_len = vsnprintf(at_agent->cmd_buf, AT_CMD_BUFFER_SIZE, format, args); - tos_kprintln("AT CMD:\n%s\n", AT_AGENT->cmd_buf); + tos_kprintln("AT CMD:\n%s\n", at_agent->cmd_buf); - at_uart_send((uint8_t *)AT_AGENT->cmd_buf, cmd_len, 0xFFFF); + at_uart_send(at_agent, (uint8_t *)at_agent->cmd_buf, cmd_len, 0xFFFF); - tos_mutex_post(&AT_AGENT->cmd_buf_lock); + tos_mutex_post(&at_agent->cmd_buf_lock); return 0; } -__API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, ...) +__API__ int tos_at_cmd_exec(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const char *cmd, ...) { int ret = 0; va_list args; @@ -541,14 +539,14 @@ __API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, return -1; } - at_echo_attach(echo); + at_echo_attach(at_agent, echo); va_start(args, cmd); - ret = at_cmd_do_exec(cmd, args); + ret = at_cmd_do_exec(at_agent, cmd, args); va_end(args); if (ret != 0) { - AT_AGENT->echo = K_NULL; + at_agent->echo = K_NULL; return -1; } @@ -558,12 +556,12 @@ __API__ int tos_at_cmd_exec(at_echo_t *echo, uint32_t timeout, const char *cmd, tos_sem_destroy(&echo->__status_set_notify); - AT_AGENT->echo = K_NULL; + at_agent->echo = K_NULL; return ret; } -__API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char *cmd, ...) +__API__ int tos_at_cmd_exec_until(at_agent_t *at_agent, at_echo_t *echo, uint32_t timeout, const char *cmd, ...) { int ret = 0; va_list args; @@ -576,14 +574,14 @@ __API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char return -1; } echo->__is_expecting = K_TRUE; - at_echo_attach(echo); + at_echo_attach(at_agent, echo); va_start(args, cmd); - ret = at_cmd_do_exec(cmd, args); + ret = at_cmd_do_exec(at_agent, cmd, args); va_end(args); if (ret != 0) { - AT_AGENT->echo = K_NULL; + at_agent->echo = K_NULL; return -1; } @@ -593,42 +591,42 @@ __API__ int tos_at_cmd_exec_until(at_echo_t *echo, uint32_t timeout, const char tos_sem_destroy(&echo->__expect_notify); - AT_AGENT->echo = K_NULL; + at_agent->echo = K_NULL; return ret; } -__STATIC__ int at_recv_cache_init(void) +__STATIC__ int at_recv_cache_init(at_agent_t *at_agent) { uint8_t *buffer = K_NULL; buffer = tos_mmheap_alloc(AT_RECV_CACHE_SIZE); if (!buffer) { - AT_AGENT->recv_cache.buffer = K_NULL; + at_agent->recv_cache.buffer = K_NULL; return - 1; } - AT_AGENT->recv_cache.buffer = buffer; - AT_AGENT->recv_cache.buffer_size = AT_RECV_CACHE_SIZE; - AT_AGENT->recv_cache.recv_len = 0; + at_agent->recv_cache.buffer = buffer; + at_agent->recv_cache.buffer_size = AT_RECV_CACHE_SIZE; + at_agent->recv_cache.recv_len = 0; return 0; } -__STATIC__ void at_recv_cache_deinit(void) +__STATIC__ void at_recv_cache_deinit(at_agent_t *at_agent) { uint8_t *buffer = K_NULL; - buffer = AT_AGENT->recv_cache.buffer; + buffer = at_agent->recv_cache.buffer; if (buffer) { tos_mmheap_free(buffer); } - AT_AGENT->recv_cache.buffer = K_NULL; - AT_AGENT->recv_cache.buffer_size = 0; - AT_AGENT->recv_cache.recv_len = 0; + at_agent->recv_cache.buffer = K_NULL; + at_agent->recv_cache.buffer_size = 0; + at_agent->recv_cache.recv_len = 0; } -__STATIC__ at_data_channel_t *at_channel_get(int channel_id, int is_alloc) +__STATIC__ at_data_channel_t *at_channel_get(at_agent_t *at_agent, int channel_id, int is_alloc) { /* if is_alloc is K_TRUE, means we are allocating a channel with certain id, @@ -642,7 +640,7 @@ __STATIC__ at_data_channel_t *at_channel_get(int channel_id, int is_alloc) return K_NULL; } - data_channel = &AT_AGENT->data_channel[channel_id]; + data_channel = &at_agent->data_channel[channel_id]; if (is_alloc && data_channel->is_free) { return data_channel; @@ -655,13 +653,13 @@ __STATIC__ at_data_channel_t *at_channel_get(int channel_id, int is_alloc) return K_NULL; } -__API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_len) +__API__ int tos_at_channel_read(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len) { int read_len; size_t total_read_len = 0; at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); if (!data_channel || data_channel->status == AT_CHANNEL_STATUS_BROKEN) { return -1; } @@ -684,14 +682,14 @@ __API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_l } } -__API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t buffer_len, uint32_t timeout) +__API__ int tos_at_channel_read_timed(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len, uint32_t timeout) { int read_len = 0; size_t total_read_len = 0; k_tick_t remain_tick; at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); if (!data_channel || data_channel->status == AT_CHANNEL_STATUS_BROKEN) { return -1; } @@ -729,12 +727,12 @@ __API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t bu return total_read_len; } -__API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_len) +__API__ int tos_at_channel_write(at_agent_t *at_agent, int channel_id, uint8_t *buffer, size_t buffer_len) { int ret; at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); if (!data_channel) { return -1; } @@ -788,12 +786,12 @@ errout: return -1; } -__API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char *port) +__API__ int tos_at_channel_alloc_id(at_agent_t *at_agent, int channel_id, const char *ip, const char *port) { at_data_channel_t *data_channel = K_NULL; size_t socket_buffer_size = 0; - data_channel = at_channel_get(channel_id, K_TRUE); + data_channel = at_channel_get(at_agent, channel_id, K_TRUE); if (!data_channel) { return -1; } @@ -806,14 +804,14 @@ __API__ int tos_at_channel_alloc_id(int channel_id, const char *ip, const char * return channel_id; } -__API__ int tos_at_channel_alloc(const char *ip, const char *port) +__API__ int tos_at_channel_alloc(at_agent_t *at_agent, const char *ip, const char *port) { int id = 0; at_data_channel_t *data_channel = K_NULL; size_t socket_buffer_size = 0; for (id = 0; id < AT_DATA_CHANNEL_NUM; ++id) { - data_channel = &AT_AGENT->data_channel[id]; + data_channel = &at_agent->data_channel[id]; if (data_channel->is_free) { break; } @@ -831,13 +829,13 @@ __API__ int tos_at_channel_alloc(const char *ip, const char *port) return id; } -__API__ int tos_at_channel_alloc_with_size(const char *ip, const char *port, size_t socket_buffer_size) +__API__ int tos_at_channel_alloc_with_size(at_agent_t *at_agent, const char *ip, const char *port, size_t socket_buffer_size) { int id = 0; at_data_channel_t *data_channel = K_NULL; for (id = 0; id < AT_DATA_CHANNEL_NUM; ++id) { - data_channel = &AT_AGENT->data_channel[id]; + data_channel = &at_agent->data_channel[id]; if (data_channel->is_free) { break; } @@ -854,11 +852,11 @@ __API__ int tos_at_channel_alloc_with_size(const char *ip, const char *port, siz return id; } -__API__ int tos_at_channel_free(int channel_id) +__API__ int tos_at_channel_free(at_agent_t *at_agent, int channel_id) { at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); if (!data_channel) { return -1; } @@ -880,11 +878,11 @@ __API__ int tos_at_channel_free(int channel_id) return 0; } -__API__ int tos_at_channel_set_broken(int channel_id) +__API__ int tos_at_channel_set_broken(at_agent_t *at_agent, int channel_id) { at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); if (!data_channel) { return -1; } @@ -893,39 +891,39 @@ __API__ int tos_at_channel_set_broken(int channel_id) return 0; } -__API__ int tos_at_channel_is_working(int channel_id) +__API__ int tos_at_channel_is_working(at_agent_t *at_agent, int channel_id) { at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); return data_channel && data_channel->status == AT_CHANNEL_STATUS_WORKING; } -__STATIC__ void at_channel_init(void) +__STATIC__ void at_channel_init(at_agent_t *at_agent) { int i = 0; for (i = 0; i < AT_DATA_CHANNEL_NUM; ++i) { - memset(&AT_AGENT->data_channel[i], 0, sizeof(at_data_channel_t)); - AT_AGENT->data_channel[i].is_free = K_TRUE; - AT_AGENT->data_channel[i].status = AT_CHANNEL_STATUS_HANGING; + memset(&at_agent->data_channel[i], 0, sizeof(at_data_channel_t)); + at_agent->data_channel[i].is_free = K_TRUE; + at_agent->data_channel[i].status = AT_CHANNEL_STATUS_HANGING; } } -__STATIC__ void at_channel_deinit(void) +__STATIC__ void at_channel_deinit(at_agent_t *at_agent) { int i = 0; for (i = 0; i < AT_DATA_CHANNEL_NUM; ++i) { - tos_at_channel_free(i); + tos_at_channel_free(at_agent, i); } } -__API__ const char *tos_at_channel_ip_get(int channel_id) +__API__ const char *tos_at_channel_ip_get(at_agent_t *at_agent, int channel_id) { at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); if (!data_channel) { return K_NULL; } @@ -933,11 +931,11 @@ __API__ const char *tos_at_channel_ip_get(int channel_id) return data_channel->remote_ip; } -__API__ const char *tos_at_channel_port_get(int channel_id) +__API__ const char *tos_at_channel_port_get(at_agent_t *at_agent, int channel_id) { at_data_channel_t *data_channel = K_NULL; - data_channel = at_channel_get(channel_id, K_FALSE); + data_channel = at_channel_get(at_agent, channel_id, K_FALSE); if (!data_channel) { return K_NULL; } @@ -945,54 +943,55 @@ __API__ const char *tos_at_channel_port_get(int channel_id) return data_channel->remote_port; } -__STATIC__ void at_event_table_set(at_event_t *event_table, size_t event_table_size) +__STATIC__ void at_event_table_set(at_agent_t *at_agent, at_event_t *event_table, size_t event_table_size) { - AT_AGENT->event_table = event_table; - AT_AGENT->event_table_size = event_table_size; + at_agent->event_table = event_table; + at_agent->event_table_size = event_table_size; } #if AT_INPUT_SIMULATE_IDLE_EN -__STATIC__ void tos_at_uart_input_notify() +__STATIC__ void tos_at_uart_input_notify(at_agent_t *at_agent) { - tos_sem_post(&AT_AGENT->uart_rx_sem); + tos_sem_post(&at_agent->uart_rx_sem); } __STATIC__ void idle_check_timer_callback(void *args) { - tos_at_uart_input_notify(); + at_agent_t *at_agent = (at_agent_t *)args; + tos_at_uart_input_notify(at_agent); } #endif /* #if AT_INPUT_SIMULATE_IDLE_EN */ -__API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size_t event_table_size) +__API__ int tos_at_init(at_agent_t *at_agent, char *task_name, k_stack_t *stk, hal_uart_port_t uart_port, at_event_t *event_table, size_t event_table_size) { void *buffer = K_NULL; - memset(AT_AGENT, 0, sizeof(at_agent_t)); + memset(at_agent, 0, sizeof(at_agent_t)); - at_event_table_set(event_table, event_table_size); + at_event_table_set(at_agent, event_table, event_table_size); - at_channel_init(); + at_channel_init(at_agent); buffer = tos_mmheap_alloc(AT_UART_RX_FIFO_BUFFER_SIZE); if (!buffer) { return -1; } - AT_AGENT->uart_rx_fifo_buffer = (uint8_t *)buffer; - tos_chr_fifo_create(&AT_AGENT->uart_rx_fifo, buffer, AT_UART_RX_FIFO_BUFFER_SIZE); + at_agent->uart_rx_fifo_buffer = (uint8_t *)buffer; + tos_chr_fifo_create(&at_agent->uart_rx_fifo, buffer, AT_UART_RX_FIFO_BUFFER_SIZE); buffer = tos_mmheap_alloc(AT_CMD_BUFFER_SIZE); if (!buffer) { goto errout0; } - AT_AGENT->cmd_buf = (char *)buffer; + at_agent->cmd_buf = (char *)buffer; - if (tos_mutex_create(&AT_AGENT->cmd_buf_lock) != K_ERR_NONE) { + if (tos_mutex_create(&at_agent->cmd_buf_lock) != K_ERR_NONE) { goto errout1; } - if (at_recv_cache_init() != 0) { + if (at_recv_cache_init(at_agent) != 0) { goto errout2; } @@ -1002,164 +1001,164 @@ __API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size goto errout3; } - AT_AGENT->uart_rx_frame_mail_buffer = (uint8_t *)buffer; + at_agent->uart_rx_frame_mail_buffer = (uint8_t *)buffer; - if (tos_mail_q_create(&AT_AGENT->uart_rx_frame_mail, buffer, AT_FRAME_LEN_MAIL_MAX, sizeof(at_frame_len_mail_t)) != K_ERR_NONE) { + if (tos_mail_q_create(&at_agent->uart_rx_frame_mail, buffer, AT_FRAME_LEN_MAIL_MAX, sizeof(at_frame_len_mail_t)) != K_ERR_NONE) { goto errout4; } #else - if (tos_sem_create(&AT_AGENT->uart_rx_sem, (k_sem_cnt_t)0u) != K_ERR_NONE) { + if (tos_sem_create(&at_agent->uart_rx_sem, (k_sem_cnt_t)0u) != K_ERR_NONE) { goto errout3; } #endif /* AT_INPUT_TYPE_FRAME_EN */ -// if (tos_mutex_create(&AT_AGENT->uart_rx_lock) != K_ERR_NONE) { +// if (tos_mutex_create(&at_agent->uart_rx_lock) != K_ERR_NONE) { // goto errout5; // } - if (tos_mutex_create(&AT_AGENT->uart_tx_lock) != K_ERR_NONE) { + if (tos_mutex_create(&at_agent->uart_tx_lock) != K_ERR_NONE) { goto errout6; } - if (tos_mutex_create(&AT_AGENT->global_lock) != K_ERR_NONE) { + if (tos_mutex_create(&at_agent->global_lock) != K_ERR_NONE) { goto errout7; } #if AT_INPUT_SIMULATE_IDLE_EN - if (tos_timer_create(&AT_AGENT->idle_check_timer, SIMULATE_IDLE_DEFAULT_TIME, - 0, idle_check_timer_callback, NULL, TOS_OPT_TIMER_ONESHOT) != K_ERR_NONE) { + if (tos_timer_create(&at_agent->idle_check_timer, SIMULATE_IDLE_DEFAULT_TIME, + 0, idle_check_timer_callback, at_agent, TOS_OPT_TIMER_ONESHOT) != K_ERR_NONE) { goto errout8; } #endif /* AT_INPUT_SIMULATE_IDLE_EN */ - if (tos_hal_uart_init(&AT_AGENT->uart, uart_port) != 0) { + if (tos_hal_uart_init(&at_agent->uart, uart_port) != 0) { goto errout9; } - if (tos_task_create(&AT_AGENT->parser, "at_parser", at_parser, - K_NULL, AT_PARSER_TASK_PRIO, at_parser_task_stack, + if (tos_task_create(&at_agent->parser, task_name, at_parser, + at_agent, AT_PARSER_TASK_PRIO, stk, AT_PARSER_TASK_STACK_SIZE, 0) != K_ERR_NONE) { goto errout10; } return 0; errout10: - tos_hal_uart_deinit(&AT_AGENT->uart); + tos_hal_uart_deinit(&at_agent->uart); errout9: #if AT_INPUT_SIMULATE_IDLE_EN - tos_timer_destroy(&AT_AGENT->idle_check_timer); + tos_timer_destroy(&at_agent->idle_check_timer); errout8: #endif /* AT_INPUT_SIMULATE_IDLE_EN */ - tos_mutex_destroy(&AT_AGENT->global_lock); + tos_mutex_destroy(&at_agent->global_lock); errout7: - tos_mutex_destroy(&AT_AGENT->uart_tx_lock); + tos_mutex_destroy(&at_agent->uart_tx_lock); errout6: -// tos_mutex_destroy(&AT_AGENT->uart_rx_lock); +// tos_mutex_destroy(&at_agent->uart_rx_lock); //errout5: #if AT_INPUT_TYPE_FRAME_EN - tos_mail_q_destroy(&AT_AGENT->uart_rx_frame_mail); + tos_mail_q_destroy(&at_agent->uart_rx_frame_mail); #else - tos_sem_destroy(&AT_AGENT->uart_rx_sem); + tos_sem_destroy(&at_agent->uart_rx_sem); #endif /* AT_INPUT_TYPE_FRAME_EN */ #if AT_INPUT_TYPE_FRAME_EN errout4: - tos_mmheap_free(AT_AGENT->uart_rx_frame_mail_buffer); - AT_AGENT->uart_rx_frame_mail_buffer = K_NULL; + tos_mmheap_free(at_agent->uart_rx_frame_mail_buffer); + at_agent->uart_rx_frame_mail_buffer = K_NULL; #endif /* AT_INPUT_TYPE_FRAME_EN */ errout3: - at_recv_cache_deinit(); + at_recv_cache_deinit(at_agent); errout2: - tos_mutex_destroy(&AT_AGENT->cmd_buf_lock); + tos_mutex_destroy(&at_agent->cmd_buf_lock); errout1: - tos_mmheap_free(AT_AGENT->cmd_buf); - AT_AGENT->cmd_buf = K_NULL; + tos_mmheap_free(at_agent->cmd_buf); + at_agent->cmd_buf = K_NULL; errout0: - tos_mmheap_free(AT_AGENT->uart_rx_fifo_buffer); - AT_AGENT->uart_rx_fifo_buffer = K_NULL; - tos_chr_fifo_destroy(&AT_AGENT->uart_rx_fifo); + tos_mmheap_free(at_agent->uart_rx_fifo_buffer); + at_agent->uart_rx_fifo_buffer = K_NULL; + tos_chr_fifo_destroy(&at_agent->uart_rx_fifo); return -1; } -__API__ void tos_at_deinit(void) +__API__ void tos_at_deinit(at_agent_t *at_agent) { - tos_task_destroy(&AT_AGENT->parser); + tos_task_destroy(&at_agent->parser); - tos_hal_uart_deinit(&AT_AGENT->uart); + tos_hal_uart_deinit(&at_agent->uart); - tos_mutex_destroy(&AT_AGENT->global_lock); + tos_mutex_destroy(&at_agent->global_lock); - tos_mutex_destroy(&AT_AGENT->uart_tx_lock); + tos_mutex_destroy(&at_agent->uart_tx_lock); - //tos_mutex_destroy(&AT_AGENT->uart_tx_lock); + //tos_mutex_destroy(&at_agent->uart_tx_lock); #if AT_INPUT_SIMULATE_IDLE_EN - tos_timer_destroy(&AT_AGENT->idle_check_timer); + tos_timer_destroy(&at_agent->idle_check_timer); #endif /* AT_INPUT_SIMULATE_IDLE_EN */ #if AT_INPUT_TYPE_FRAME_EN - tos_mail_q_destroy(&AT_AGENT->uart_rx_frame_mail); - tos_mmheap_free(AT_AGENT->uart_rx_frame_mail_buffer); - AT_AGENT->uart_rx_frame_mail_buffer = K_NULL; + tos_mail_q_destroy(&at_agent->uart_rx_frame_mail); + tos_mmheap_free(at_agent->uart_rx_frame_mail_buffer); + at_agent->uart_rx_frame_mail_buffer = K_NULL; #else - tos_sem_destroy(&AT_AGENT->uart_rx_sem); + tos_sem_destroy(&at_agent->uart_rx_sem); #endif /* AT_INPUT_TYPE_FRAME_EN */ - at_recv_cache_deinit(); + at_recv_cache_deinit(at_agent); - tos_mutex_destroy(&AT_AGENT->cmd_buf_lock); + tos_mutex_destroy(&at_agent->cmd_buf_lock); - tos_mmheap_free(AT_AGENT->cmd_buf); - AT_AGENT->cmd_buf = K_NULL; + tos_mmheap_free(at_agent->cmd_buf); + at_agent->cmd_buf = K_NULL; - tos_mmheap_free(AT_AGENT->uart_rx_fifo_buffer); - AT_AGENT->uart_rx_fifo_buffer = K_NULL; + tos_mmheap_free(at_agent->uart_rx_fifo_buffer); + at_agent->uart_rx_fifo_buffer = K_NULL; - tos_chr_fifo_destroy(&AT_AGENT->uart_rx_fifo); + tos_chr_fifo_destroy(&at_agent->uart_rx_fifo); - at_channel_deinit(); + at_channel_deinit(at_agent); } /* To completely decouple the uart intterupt and at agent, we need a more powerful hal(driver framework), that would be a huge work, we place it in future plans. */ #if AT_INPUT_TYPE_FRAME_EN -__API__ void tos_at_uart_input_frame(uint8_t *pdata, uint16_t len) +__API__ void tos_at_uart_input_frame(at_agent_t *at_agent, uint8_t *pdata, uint16_t len) { int ret; at_frame_len_mail_t at_frame_len_mail; - ret = tos_chr_fifo_push_stream(&AT_AGENT->uart_rx_fifo, pdata, len); + ret = tos_chr_fifo_push_stream(&at_agent->uart_rx_fifo, pdata, len); if (ret != len) { return; } at_frame_len_mail.frame_len = len; - tos_mail_q_post(&AT_AGENT->uart_rx_frame_mail, &at_frame_len_mail, sizeof(at_frame_len_mail_t)); + tos_mail_q_post(&at_agent->uart_rx_frame_mail, &at_frame_len_mail, sizeof(at_frame_len_mail_t)); } #elif AT_INPUT_SIMULATE_IDLE_EN -__API__ void tos_at_uart_input_byte_no_notify(uint8_t data) +__API__ void tos_at_uart_input_byte_no_notify(at_agent_t *at_agent, uint8_t data) { - tos_timer_stop(&AT_AGENT->idle_check_timer); - tos_chr_fifo_push(&AT_AGENT->uart_rx_fifo, data); - tos_timer_start(&AT_AGENT->idle_check_timer); + tos_timer_stop(&at_agent->idle_check_timer); + tos_chr_fifo_push(&at_agent->uart_rx_fifo, data); + tos_timer_start(&at_agent->idle_check_timer); } #else -__API__ void tos_at_uart_input_byte(uint8_t data) +__API__ void tos_at_uart_input_byte(at_agent_t *at_agent, uint8_t data) { - if (tos_chr_fifo_push(&AT_AGENT->uart_rx_fifo, data) == K_ERR_NONE) { - tos_sem_post(&AT_AGENT->uart_rx_sem); + if (tos_chr_fifo_push(&at_agent->uart_rx_fifo, data) == K_ERR_NONE) { + tos_sem_post(&at_agent->uart_rx_sem); } } diff --git a/platform/hal/nxp/mimxrt10xx/src/tos_hal_uart.c b/platform/hal/nxp/mimxrt10xx/src/tos_hal_uart.c index 63e9094e..be9962da 100644 --- a/platform/hal/nxp/mimxrt10xx/src/tos_hal_uart.c +++ b/platform/hal/nxp/mimxrt10xx/src/tos_hal_uart.c @@ -29,7 +29,7 @@ __API__ int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port) return -1; } - /* Enable RX interrupt. */ + /* Enable RX interrupt. */ LPUART_EnableInterrupts(LPUART1, kLPUART_RxDataRegFullInterruptEnable); EnableIRQ(LPUART1_IRQn); } else if (port == HAL_UART_PORT_2) { @@ -44,7 +44,7 @@ __API__ int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port) return -1; } - /* Enable RX interrupt. */ + /* Enable RX interrupt. */ LPUART_EnableInterrupts(LPUART2, kLPUART_RxDataRegFullInterruptEnable); EnableIRQ(LPUART2_IRQn); } else if (port == HAL_UART_PORT_3) { @@ -59,7 +59,7 @@ __API__ int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port) return -1; } - /* Enable RX interrupt. */ + /* Enable RX interrupt. */ LPUART_EnableInterrupts(LPUART3, kLPUART_RxDataRegFullInterruptEnable); EnableIRQ(LPUART3_IRQn); } else if (port == HAL_UART_PORT_4) { @@ -74,7 +74,7 @@ __API__ int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port) return -1; } - /* Enable RX interrupt. */ + /* Enable RX interrupt. */ LPUART_EnableInterrupts(LPUART4, kLPUART_RxDataRegFullInterruptEnable); EnableIRQ(LPUART4_IRQn); }