app.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "api.h"
  2. #include "board_config.h"
  3. #include "tbc.h"
  4. #include "tbs.h"
  5. #include "sys_task.h"
  6. #include "TimeTask_Event.h"
  7. void PeripheralInit();
  8. void PeripheralStart();
  9. void AppInit()
  10. {
  11. /* 初始化外设(Api层级配置)并配置调度逻辑 */
  12. PeripheralInit();
  13. // /* 1 电机控制环路初始化 */
  14. // /* 1.1 初始化PU值系统 */
  15. // /* 1.2 初始化参数系统 */
  16. // /* 1.3 算法模块初始化 */
  17. //
  18. // McPipelineInit();
  19. // McModulesConfig();
  20. // McPipelineModulesInit();
  21. // McPipelineStaticCoef();
  22. //
  23. // /* 2 控制组件初始化 */
  24. //
  25. // SysCtrlInit();
  26. // McCtrlInit();
  27. //
  28. // /* 状态机初始化 */
  29. //
  30. // SysFsmInit();
  31. // CtrlFsmInit();
  32. // McFsmInit();
  33. //
  34. // /* 故障处理初始化 */
  35. //
  36. // AlmInit();
  37. //
  38. // /* 串口调试初始化 */
  39. //
  40. // uart_voMonitorInit();
  41. /* 启动外设 */
  42. PeripheralStart();
  43. }
  44. void AppLoop()
  45. {
  46. /* Uart Monitor Service */
  47. // ReadFrame_Poll2();
  48. // uart_voMainDec();
  49. }
  50. void PeripheralInit()
  51. {
  52. /* Gpio配置 */
  53. // iGpio_SetMode(HW_GPIO_HALLA_PIN, ApiGpio_Output);
  54. // iGpio_SetMode(HW_GPIO_HALLB_PIN, ApiGpio_Output);
  55. // iGpio_SetMode(HW_GPIO_HALLC_PIN, ApiGpio_Output);
  56. /* Pwm配置 */
  57. iPwm_BindDeviceInterrupt(0, ApiPwm_CountZeroInt, tbc_voUpIsr);
  58. iPwm_BindDeviceInterrupt(0, ApiPwm_CountMaxInt, tbc_voDownIsr);
  59. iPwm_EnableDeviceInterrupt(0, ApiPwm_CountZeroInt);
  60. iPwm_EnableDeviceInterrupt(0, ApiPwm_CountMaxInt);
  61. /* Tbs 定时器配置 */
  62. iTimer_BindInterrupt(HW_TBS_TIMER, tbs_voIsr);
  63. iTimer_EnableInterrupt(HW_TBS_TIMER);
  64. /* Event1ms 定时器配置 */
  65. iTimer_BindInterrupt(HW_EVENT1MS_TIMER, Event_1ms);
  66. iTimer_EnableInterrupt(HW_EVENT1MS_TIMER);
  67. /* 1ms 定时器配置 */
  68. // clock = iTimer_GetClock(HW_SYSTICK_TIMER);
  69. // iTimer_SetPeriod(HW_SYSTICK_TIMER, clock / 1000 - 1);
  70. // iTimer_EnableAutoReload(HW_SYSTICK_TIMER);
  71. iTimer_BindInterrupt(HW_SYSTICK_TIMER, SysTask1Ms);
  72. iTimer_EnableInterrupt(HW_SYSTICK_TIMER);
  73. }
  74. void PeripheralStart()
  75. {
  76. // iPwm_EnableCount(0);
  77. // iTimer_Start(HW_TBS_TIMER);
  78. // iTimer_Start(HW_SYSTICK_TIMER);
  79. }