app.c 2.4 KB

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