#include "app_task.h"
#include "ble_task.h"
#include "can.h"
#include "gpio.h"
#include "i2c1.h"
#include "iap.h"
#include "key.h"
#include "misc.h"
#include "pwm.h"
#include "systick.h"
#include "uart.h"
#include "uart4.h"

#define APP_FLASH_OFFSET 0x8000
#define BOOT_EN          1

int main(void)
{
#if (BOOT_EN == 1)
    NVIC_SetVectorTable(NVIC_VectTab_FLASH, APP_FLASH_OFFSET);
    __set_PRIMASK(0);
#endif

    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    systick_init();
    gpio_init();
    pwm_init(&pwm_timer3_content);
    pwm_mode(&pwm_timer3_content, 0);
    can_init();
    can_network_init();
    usart_config_init(&usart1_context, 115200);
    usart_config_init(&usart3_context, 115200);
    uart4_init();
    BLE_TASK_INIT();
    i2c1_init();
    key_button_init();
    set_firmver();
    iap_flag_release();
    iap_param_init();

    while (1)
    {
        app_task_schdule();
    }

    return 0;
}
