board_config.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**
  2. * @file board_config.h
  3. * @author Xiao Lifan (xiaolf6@midea.com)
  4. * @brief 硬件相关参数配置
  5. * @version 0.1
  6. * @date 2023-05-06
  7. *
  8. * @copyright Copyright (c) 2023
  9. *
  10. */
  11. /* ========================================================================== */
  12. /* ================================= 采样范围配置 ================================= */
  13. /* ========================================================================== */
  14. #define HW_VBUS_MEASMAX_V 6419 /**< Vdc measure max 424.6(0.1V) */
  15. #define HW_VAC_MEASMAX_V 4950 /**< Vac measure max 495.0(0.1V) */
  16. #define HW_VPHASE_MEASMAX_V 4290 /**< Terminal Voltage measure max 429.0(0.1V) */
  17. #define HW_I_MEASMAX_A 825 /**< Current measure max(peak2peak) (0.01A) */
  18. /* ========================================================================== */
  19. /* ================================= 硬件参数配置 ================================= */
  20. /* ========================================================================== */
  21. /* ---------------------------------- 系统RAM --------------------------------- */
  22. #define HW_RAM_START_ADDRESS 0x20000000UL
  23. #define HW_RAM_END_ADDRESS 0x20017fffUL
  24. /* ---------------------------------- MCU Frequency ---------------------------------- */
  25. #define HW_CLK_CORE_KHZ 72000
  26. #define HW_CLK_AHB_KHZ 72000
  27. #define HW_CLK_APB1_KHZ 36000
  28. #define HW_CLK_APB2_KHZ 72000
  29. #define HW_CLK_TIM0_KHZ 72000
  30. #define HW_CLK_PWM_KHZ 72000
  31. #define HW_CLK_ADC_KHZ 36000
  32. /* ---------------------------------- 系统时钟 ---------------------------------- */
  33. #define HW_MCU_CLOCK_HZ 72000000UL
  34. #define HW_CORECLK_KHZ HW_CLK_CORE_KHZ // Internal Clock
  35. #define HW_AHBCLK_KHZ HW_CLK_AHB_KHZ // AHB Clock
  36. #define HW_APB1CLK_KHZ HW_CLK_APB1_KHZ // APB1 Clock
  37. #define HW_APB2CLK_KHZ HW_CLK_APB2_KHZ // APB2 Clock
  38. #define HW_TIM0CLK_KHZ HW_CLK_TIM0_KHZ // TIM0 Clock
  39. #define HW_TIM1CLK_KHZ HW_CLK_TIM0_KHZ / 100
  40. #define HW_TIM2CLK_KHZ HW_CLK_TIM0_KHZ
  41. #define HW_TIM5CLK_KHZ HW_CLK_TIM0_KHZ / 2
  42. /* --------------------------------- 电力系统参数 --------------------------------- */
  43. #define HW_UAC_FREQ_HZ 50
  44. /* --------------------------------- PWM频率配置 -------------------------------- */
  45. #define HW_TIM_CLOCK_HZ 72000000UL
  46. #define HW_TIM_CLOCK_MHZ (HW_TIM_CLOCK_HZ / 1000000UL)
  47. #define HW_INIT_FPWM_HZ 16000
  48. #define HW_INIT_FTBC_TICK 2
  49. #define HW_INIT_FTBS_TICK 4
  50. #define HW_INIT_FTBC_HZ (HW_INIT_FPWM_HZ / HW_INIT_FTBC_TICK)
  51. #define HW_INIT_FTBS_HZ (HW_INIT_FPWM_HZ / HW_INIT_FTBS_TICK)
  52. #define HW_INIT_PWM_PERIOD (HW_TIM_CLOCK_HZ / HW_INIT_FPWM_HZ)
  53. #define HW_INIT_HPWM_PERIOD (HW_INIT_PWM_PERIOD >> 1)
  54. #define HW_INIT_HHPWM_PERIOD (HW_INIT_PWM_PERIOD >> 2)
  55. #define HW_INIT_HHHPWM_PERIOD (HW_INIT_PWM_PERIOD >> 3)
  56. /* --------------------------------- PWM死区参数 -------------------------------- */
  57. #define HW_DEADBAND_TIME HW_TIM_CLOCK_MHZ /**< 死区时间,单位: 时钟Tick */
  58. /* --------------------------------- PWM特殊参数 -------------------------------- */
  59. #define HW_PWM_MODE_SWITCH_PRE_COUNT (120) /**< PWM模式切换中断提前值 */
  60. /* ---------------------------------- adc参数 --------------------------------- */
  61. #define HW_SAMPLE_BEFORE_UPDATE_CNTS 100 /**< 采样相对于PWM顶底点提前的周期数,单位: 时钟Tick */
  62. /* ---------------------------------- 充电继电器 --------------------------------- */
  63. #define HW_RLY_VOL_V 1600 /**< 母线充电限值电压,单位: 0.1V */
  64. #define HW_RLY_VOL_MS 1000 /**< 母线充时间,单位: MS */
  65. #define HW_RLYON_OVER_MS 200
  66. /* ---------------------------------- 输入捕获 ---------------------------------- */
  67. #define HW_CAP_TIM_HZ 40
  68. /* ---------------------------------- EEPROM参数 ---------------------------------- */
  69. #define HW_I2C_EE_PAGESIZE_BYTE 16
  70. #define HW_I2C_EE_ADDR_BLOCK1 0xA0
  71. #define HW_I2C_EE_ADDR_BLOCK2 0xA2
  72. #define HW_I2C_EE_ADDR_BLOCK3 0xA4
  73. #define HW_I2C_EE_ADDR_BLOCK4 0xA6
  74. /* ========================================================================== */
  75. /* ================================ API接口序号定义 =============================== */
  76. /* ========================================================================== */
  77. /* Api Device Index Definations */
  78. #define HW_TBC_HALF_UPDATE_TIMER 0
  79. #define HW_TBS_TIMER 1
  80. #define HW_EVENT1MS_TIMER 2
  81. #define HW_SYSTICK_TIMER 3
  82. /* ADC Sample mode*/
  83. #define SINGLE_RESISITANCE 0 // Sample using single resistance
  84. #define MOS_RESISITANCE 1 // Sample using Rdson
  85. #define COMBIN_MOSSING 2
  86. #define DOUBLE_RESISITANCE 3 // Sample using double resistance
  87. #define HW_BIKESPD_CAD_CAP 0
  88. #define HW_MOTOR_HALL_CAP 1
  89. /* ADC0 injected group: API ADC1 */
  90. #define HW_ADC_IA_CH 0
  91. #define HW_ADC_IB_CH 1
  92. #define HW_ADC_IC_CH 2
  93. /* ADC1 injected group: API ADC2 */
  94. #define HW_ADC_IDC_CH 0
  95. /* ADC0 regular group: API ADC0 */
  96. #define HW_ADC_IBUSAVG_CH 0
  97. #define HW_ADC_MOTTEMP_CH 1
  98. #define HW_ADC_UDC_CH 2
  99. #define HW_ADC_TORQ_CH 3
  100. #define HW_ADC_PCBTEMP_CH 4
  101. #define HW_ADC_THRO_CH 5
  102. #define HW_ADC_U12V_CH 6
  103. #define HW_ADC_U6V_CH 7
  104. /* GPIO*/
  105. #define HW_GPIO_POWERSTATE_PIN 0 /**< GPIOC PIN12 */
  106. #define HW_GPIO_POWERLOCK_PIN 1 /**< GPIOB PIN4 */
  107. #define HW_GPIO_BLIG_EN_PIN 2 /**< GPIOB PIN5 */
  108. #define HW_GPIO_BLIG_6V_12V_EN_PIN 3 /**< GPIOB PIN7 */
  109. #define HW_GPIO_FLIG_EN_PIN 4 /**< GPIOB PIN3 */
  110. #define HW_GPIO_FLIG_6V_12V_EN_PIN 5 /**< GPIOB PIN6 */
  111. #define HW_GPIO_BRAKE_PIN 6 /**< GPIOD PIN2 */
  112. #define HW_GPIO_UARTTX_PIN 7 /**< GPIOC PIN10 */
  113. #define HW_GPIO_UARTRX_PIN 8 /**< GPIOC PIN11 */
  114. #define HW_GPIO_CANTX_PIN 9 /**< GPIOB PIN9 */
  115. #define HW_GPIO_CANRX_PIN 10 /**< GPIOB PIN8 */
  116. #define HW_GPIO_CANSTB_PIN 11 /**< GPIOA PIN12 */
  117. #define HW_GPIO_CADENCE_PIN 12 /**< GPIOB PIN10 */
  118. #define HW_GPIO_HALLA_PIN 13 /**< GPIOC PIN6, HALLA、B、C的序号必须是连续的,且A的序号最小 */
  119. #define HW_GPIO_HALLB_PIN (HW_GPIO_HALLA_PIN + 1) /**< GPIOC PIN7 */
  120. #define HW_GPIO_HALLC_PIN (HW_GPIO_HALLA_PIN + 2) /**< GPIOC PIN8 */
  121. #define HW_GPIO_MOTTEMP_PIN 16 /**< GPIOB PIN11 */
  122. #define HW_GPIO_LED_PIN 17 /**< GPIOC PIN13 */
  123. #define HW_GPIO_BIKESPD_PIN 18 /**< GPIOB PIN11 */