1
WXK
9 天以前 aa14c757b47b2ef43ec8a6ced81fefe1e6594d2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#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"
 
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)
{
    g_com_map[IP_0] =103;
    g_com_map[IP_1] =155;
    g_com_map[IP_2] =76;
    g_com_map[IP_3] =198;
    g_com_map[UDP_PORT] =6666;
    Shell_Init();
    GPS_Init();
    Internet_Init();
    UDPClient_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();
        HIDO_ATLitePoll();
        Internet_Poll();
        GPS_Poll();
        UDPClient_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();
    printf("demo run!\r\n");
    TaskHandle_t xTaskHandle = NULL;
 
    osSemaphoreAttr_t semaphore_attr = {
        .name = "MySemaphore",
        .attr_bits = 0,
        .cb_mem = NULL,
        .cb_size = 0};
 
    // ´´½¨¶þ½øÖÆÐźÅÁ¿£¨³õʼ¼ÆÊýΪ0£¬×î´ó¼ÆÊýΪ1£©
    g_semaphoreHandle = osSemaphoreNew(1, 0, &semaphore_attr);
 
    xTaskCreate(
        app_task,
        "AppTask",
        2048,
        NULL,
        tskIDLE_PRIORITY + 1,
        &xTaskHandle);
}