tao_z
2022-06-01 0ff91e66071237834a1501c78648729c8c32f67a
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
/**
 * @file main.c
 * @author Ethan.Tao (tzj0429@163.com)
 * @brief
 * @version 0.1
 * @date 2022-05-15
 *
 * @copyright Copyright (c) 2022 Äþ²¨ÕýÀÊÆû³µÁ㲿¼þÓÐÏÞ¹«Ë¾
 *
 */
 
#include "xl6600.h"
#include "xl_gpio.h"
#include "xl_ics.h"
#include "xl_sim.h"
#include "system_XL6600.h"
#include <stdio.h>
#include "os_task.h"
#include "os_clock.h"
#include <Hal_GPIO.h>
 
#include "Hal_can.h"
#include "Hal_crc.h"
#include "uds.h"
#include "did.h"
#include "light.h"
#include "fbl_def.h"
#include "fbl_ap.h"
#include "NVM.h"
#include "flash_interface.h"
#include "xl_crc.h"
// define bootloader mode
uint8_t fblMode;
 
static void fbl_init(void)
{
    Hal_GPIOInit();
    Hal_CANConfig();
    Hal_CrcInit(); // CRC FOR FLASH
    UDS_Init();
 
    NVM_Init();
    light_init();
    did_init();
}
/**
 * @brief  main
 */
int32_t main(void)
{
    OS_TASK_MSG task_queue[5] = {0};
    InitOSTaskQueue(task_queue, 5);
    SystemSetFEE(16000000, ICS_FLLFACTOR_1280, ICS_RDIV_2or64, ICS_RDIV2_5); // 16000000/32 /5 *1920 =64MHz
    Ostick_config();
    if (FblChkFblProgramRequestFlag() == true)
    {
        fbl_init();
        SetFblMode(START_FROM_APPL);
        UDS_SwitchtoProgrammingSession();
        UDS_ResponseEntryProgrammingSession();
    }
    else
    {
        SetFblMode(START_FROM_RESET);
        if (ApplFblIsValidApp() == true)
        {
            // disable timer and interrupt
            AP_StartApp();
        }
        else
        {
            /*app is invalid ,so request*/
            fbl_init();
            SetFblMode(APPL_CORRUPT);
        }
    }
 
    OSTaskCreate(UDS_Task_1ms, 1, 1, NULL);
    OSTaskCreate(UDS_Task_10ms, 10, 9, NULL);
    OSTaskCreate(light_task, 50, 49, NULL);
 
    OSSchedule(&OS_GetTick);
    for (;;)
    {
    }
}