/**
|
* @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 (;;)
|
{
|
}
|
}
|