#include "cmsis_os2.h" #include "FreeRTOS.h" #include "task.h" #include "semphr.h" #include "HIDO_Input.h" #include "HIDO_Timer.h" #include "GPS.h" #include "DBG.h" #include "Internet.h" #include "global_param.h" #include "MCUFlash.h" #include "HIDO_ATLite.h" #include "UDPClient.h" #include "bluetooth.h" #include "TCPClient.h" #include "SBUS.h" #include "pwm_ctrol.h" static osSemaphoreId_t g_semaphoreHandle = NULL; extern uint8_t restart_num; void IdleTask(void) { if(g_com_map[CNT_RESTART]==1) { g_com_map[CNT_RESTART]=0; // printf("%s URTRestart",__debug_info__); HAL_NVIC_SystemReset(); } if(g_com_map[MAP_SIGN_INDEX]!=0x55AA) { // printf("%s URTRestart",__debug_info__); HAL_NVIC_SystemReset(); // SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //����λ�ص�bootloader } } void app_task(void *pvParameters) { Shell_Init(); GPS_Init(); Internet_Init(); UDPClient_Init(); TCPClient_Init(); BT_Init(); SBUS_Init(); while (1) { //HIDO_UINT32 timeout = HIDO_TimerGetNearestTimeout(1000); HIDO_UINT32 timeout = 100; if (xSemaphoreTake(g_semaphoreHandle, timeout / portTICK_PERIOD_MS) == pdTRUE) { } DBG_Poll(); BT_Poll(); SBUS_Poll(); HIDO_ATLitePoll(); Internet_Poll(); GPS_Poll(); UDPClient_Poll(); TCPClient_Poll(); IdleTask(); HIDO_TimerPoll(); } } void app_trigger_from_isr(void) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; if (g_semaphoreHandle != NULL) { BaseType_t result = xSemaphoreGiveFromISR(g_semaphoreHandle, &xHigherPriorityTaskWoken); if (xHigherPriorityTaskWoken == pdTRUE) { portYIELD_FROM_ISR(xHigherPriorityTaskWoken); } } } void app_trigger(void) { if (g_semaphoreHandle != NULL) { xSemaphoreGive(g_semaphoreHandle); } } void app_main(void) { MCUFlash_Init(); parameter_init(); { uint16_t dev_id = g_com_map[DEV_ID]; uint16_t udp_port = g_com_map[UDP_PORT]; uint16_t tcp_port = g_com_map[TCP_PORT]; uint16_t ip0 = g_com_map[IP_0]; uint16_t ip1 = g_com_map[IP_1]; uint16_t ip2 = g_com_map[IP_2]; uint16_t ip3 = g_com_map[IP_3]; uint16_t tip0 = g_com_map[TCP_IP_0]; uint16_t tip1 = g_com_map[TCP_IP_1]; uint16_t tip2 = g_com_map[TCP_IP_2]; uint16_t tip3 = g_com_map[TCP_IP_3]; uint16_t version = g_com_map[VERSION]; HIDO_Debug2("[BOOT] Version: %u\r\n", version); HIDO_Debug2("[BOOT] DeviceID: %u\r\n", dev_id); HIDO_Debug2("[BOOT] UDP Server: %u.%u.%u.%u:%u\r\n", ip0, ip1, ip2, ip3, udp_port); HIDO_Debug2("[BOOT] TCP Server: %u.%u.%u.%u:%u\r\n", tip0, tip1, tip2, tip3, tcp_port); } TaskHandle_t xTaskHandle = NULL; osSemaphoreAttr_t semaphore_attr = { .name = "MySemaphore", .attr_bits = 0, .cb_mem = NULL, .cb_size = 0}; // g_semaphoreHandle = osSemaphoreNew(1, 0, &semaphore_attr); xTaskCreate( app_task, "AppTask", 2048, NULL, tskIDLE_PRIORITY + 1, &xTaskHandle); }