#include "api.h" #include "board_config.h" #include "tbc.h" #include "tbs.h" #include "sys_task.h" #include "TimeTask_Event.h" void PeripheralInit(); void PeripheralStart(); void AppInit() { /* 初始化外设(Api层级配置)并配置调度逻辑 */ PeripheralInit(); // /* 1 电机控制环路初始化 */ // /* 1.1 初始化PU值系统 */ // /* 1.2 初始化参数系统 */ // /* 1.3 算法模块初始化 */ // // McPipelineInit(); // McModulesConfig(); // McPipelineModulesInit(); // McPipelineStaticCoef(); // // /* 2 控制组件初始化 */ // // SysCtrlInit(); // McCtrlInit(); // // /* 状态机初始化 */ // // SysFsmInit(); // CtrlFsmInit(); // McFsmInit(); // // /* 故障处理初始化 */ // // AlmInit(); // // /* 串口调试初始化 */ // // uart_voMonitorInit(); /* 启动外设 */ PeripheralStart(); } void AppLoop() { /* Uart Monitor Service */ // ReadFrame_Poll2(); // uart_voMainDec(); } void PeripheralInit() { /* Gpio配置 */ // iGpio_SetMode(HW_GPIO_HALLA_PIN, ApiGpio_Output); // iGpio_SetMode(HW_GPIO_HALLB_PIN, ApiGpio_Output); // iGpio_SetMode(HW_GPIO_HALLC_PIN, ApiGpio_Output); /* Pwm配置 */ iPwm_BindDeviceInterrupt(0, ApiPwm_CountZeroInt, tbc_voUpIsr); iPwm_BindDeviceInterrupt(0, ApiPwm_CountMaxInt, tbc_voDownIsr); iPwm_EnableDeviceInterrupt(0, ApiPwm_CountZeroInt); iPwm_EnableDeviceInterrupt(0, ApiPwm_CountMaxInt); /* Tbs 定时器配置 */ iTimer_BindInterrupt(HW_TBS_TIMER, tbs_voIsr); iTimer_EnableInterrupt(HW_TBS_TIMER); /* Event1ms 定时器配置 */ iTimer_BindInterrupt(HW_EVENT1MS_TIMER, Event_1ms); iTimer_EnableInterrupt(HW_EVENT1MS_TIMER); /* 1ms 定时器配置 */ // clock = iTimer_GetClock(HW_SYSTICK_TIMER); // iTimer_SetPeriod(HW_SYSTICK_TIMER, clock / 1000 - 1); // iTimer_EnableAutoReload(HW_SYSTICK_TIMER); iTimer_BindInterrupt(HW_SYSTICK_TIMER, SysTask1Ms); iTimer_EnableInterrupt(HW_SYSTICK_TIMER); } void PeripheralStart() { // iPwm_EnableCount(0); // iTimer_Start(HW_TBS_TIMER); // iTimer_Start(HW_SYSTICK_TIMER); }