123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- /**
- * @file board_config.h
- * @author Xiao Lifan (xiaolf6@midea.com)
- * @brief 硬件相关参数配置
- * @version 0.1
- * @date 2023-05-06
- *
- * @copyright Copyright (c) 2023
- *
- */
- /* ========================================================================== */
- /* ================================= 采样范围配置 ================================= */
- /* ========================================================================== */
- #define HW_VBUS_MEASMAX_V 6419 /**< Vdc measure max 424.6(0.1V) */
- #define HW_VAC_MEASMAX_V 4950 /**< Vac measure max 495.0(0.1V) */
- #define HW_VPHASE_MEASMAX_V 4290 /**< Terminal Voltage measure max 429.0(0.1V) */
- #define HW_I_MEASMAX_A 825 /**< Current measure max(peak2peak) (0.01A) */
- /* ========================================================================== */
- /* ================================= 硬件参数配置 ================================= */
- /* ========================================================================== */
- /* ---------------------------------- 系统RAM --------------------------------- */
- #define HW_RAM_START_ADDRESS 0x20000000UL
- #define HW_RAM_END_ADDRESS 0x20017fffUL
- /* ---------------------------------- MCU Frequency ---------------------------------- */
- #define HW_CLK_CORE_KHZ 72000
- #define HW_CLK_AHB_KHZ 72000
- #define HW_CLK_APB1_KHZ 36000
- #define HW_CLK_APB2_KHZ 72000
- #define HW_CLK_TIM0_KHZ 72000
- #define HW_CLK_PWM_KHZ 72000
- #define HW_CLK_ADC_KHZ 36000
- /* ---------------------------------- 系统时钟 ---------------------------------- */
- #define HW_MCU_CLOCK_HZ 72000000UL
- #define HW_CORECLK_KHZ HW_CLK_CORE_KHZ // Internal Clock
- #define HW_AHBCLK_KHZ HW_CLK_AHB_KHZ // AHB Clock
- #define HW_APB1CLK_KHZ HW_CLK_APB1_KHZ // APB1 Clock
- #define HW_APB2CLK_KHZ HW_CLK_APB2_KHZ // APB2 Clock
- #define HW_TIM0CLK_KHZ HW_CLK_TIM0_KHZ // TIM0 Clock
- #define HW_TIM1CLK_KHZ HW_CLK_TIM0_KHZ / 100
- #define HW_TIM2CLK_KHZ HW_CLK_TIM0_KHZ
- #define HW_TIM5CLK_KHZ HW_CLK_TIM0_KHZ / 2
- /* --------------------------------- 电力系统参数 --------------------------------- */
- #define HW_UAC_FREQ_HZ 50
- /* --------------------------------- PWM频率配置 -------------------------------- */
- #define HW_TIM_CLOCK_HZ 72000000UL
- #define HW_TIM_CLOCK_MHZ (HW_TIM_CLOCK_HZ / 1000000UL)
- #define HW_INIT_FPWM_HZ 16000
- #define HW_INIT_FTBC_TICK 2
- #define HW_INIT_FTBS_TICK 4
- #define HW_INIT_FTBC_HZ (HW_INIT_FPWM_HZ / HW_INIT_FTBC_TICK)
- #define HW_INIT_FTBS_HZ (HW_INIT_FPWM_HZ / HW_INIT_FTBS_TICK)
- #define HW_INIT_PWM_PERIOD (HW_TIM_CLOCK_HZ / HW_INIT_FPWM_HZ)
- #define HW_INIT_HPWM_PERIOD (HW_INIT_PWM_PERIOD >> 1)
- #define HW_INIT_HHPWM_PERIOD (HW_INIT_PWM_PERIOD >> 2)
- #define HW_INIT_HHHPWM_PERIOD (HW_INIT_PWM_PERIOD >> 3)
- /* --------------------------------- PWM死区参数 -------------------------------- */
- #define HW_DEADBAND_TIME HW_TIM_CLOCK_MHZ /**< 死区时间,单位: 时钟Tick */
- /* --------------------------------- PWM特殊参数 -------------------------------- */
- #define HW_PWM_MODE_SWITCH_PRE_COUNT (120) /**< PWM模式切换中断提前值 */
- /* ---------------------------------- adc参数 --------------------------------- */
- #define HW_SAMPLE_BEFORE_UPDATE_CNTS 100 /**< 采样相对于PWM顶底点提前的周期数,单位: 时钟Tick */
- /* ---------------------------------- 充电继电器 --------------------------------- */
- #define HW_RLY_VOL_V 1600 /**< 母线充电限值电压,单位: 0.1V */
- #define HW_RLY_VOL_MS 1000 /**< 母线充时间,单位: MS */
- #define HW_RLYON_OVER_MS 200
- /* ---------------------------------- 输入捕获 ---------------------------------- */
- #define HW_CAP_TIM_HZ 40
- /* ---------------------------------- EEPROM参数 ---------------------------------- */
- #define HW_I2C_EE_PAGESIZE_BYTE 16
- #define HW_I2C_EE_ADDR_BLOCK1 0xA0
- #define HW_I2C_EE_ADDR_BLOCK2 0xA2
- #define HW_I2C_EE_ADDR_BLOCK3 0xA4
- #define HW_I2C_EE_ADDR_BLOCK4 0xA6
- /* ========================================================================== */
- /* ================================ API接口序号定义 =============================== */
- /* ========================================================================== */
- /* Api Device Index Definations */
- #define HW_TBC_HALF_UPDATE_TIMER 0
- #define HW_TBS_TIMER 1
- #define HW_EVENT1MS_TIMER 2
- #define HW_SYSTICK_TIMER 3
- /* ADC Sample mode*/
- #define SINGLE_RESISITANCE 0 // Sample using single resistance
- #define MOS_RESISITANCE 1 // Sample using Rdson
- #define COMBIN_MOSSING 2
- #define DOUBLE_RESISITANCE 3 // Sample using double resistance
- #define HW_BIKESPD_CAD_CAP 0
- #define HW_MOTOR_HALL_CAP 1
- /* ADC0 injected group: API ADC1 */
- #define HW_ADC_IA_CH 0
- #define HW_ADC_IB_CH 1
- #define HW_ADC_IC_CH 2
- /* ADC1 injected group: API ADC2 */
- #define HW_ADC_IDC_CH 0
- /* ADC0 regular group: API ADC0 */
- #define HW_ADC_IBUSAVG_CH 0
- #define HW_ADC_MOTTEMP_CH 1
- #define HW_ADC_UDC_CH 2
- #define HW_ADC_TORQ_CH 3
- #define HW_ADC_PCBTEMP_CH 4
- #define HW_ADC_THRO_CH 5
- #define HW_ADC_U12V_CH 6
- #define HW_ADC_U6V_CH 7
- /* GPIO*/
- #define HW_GPIO_POWERSTATE_PIN 0 /**< GPIOC PIN12 */
- #define HW_GPIO_POWERLOCK_PIN 1 /**< GPIOB PIN4 */
- #define HW_GPIO_BLIG_EN_PIN 2 /**< GPIOB PIN5 */
- #define HW_GPIO_BLIG_6V_12V_EN_PIN 3 /**< GPIOB PIN7 */
- #define HW_GPIO_FLIG_EN_PIN 4 /**< GPIOB PIN3 */
- #define HW_GPIO_FLIG_6V_12V_EN_PIN 5 /**< GPIOB PIN6 */
- #define HW_GPIO_BRAKE_PIN 6 /**< GPIOD PIN2 */
- #define HW_GPIO_UARTTX_PIN 7 /**< GPIOC PIN10 */
- #define HW_GPIO_UARTRX_PIN 8 /**< GPIOC PIN11 */
- #define HW_GPIO_CANTX_PIN 9 /**< GPIOB PIN9 */
- #define HW_GPIO_CANRX_PIN 10 /**< GPIOB PIN8 */
- #define HW_GPIO_CANSTB_PIN 11 /**< GPIOA PIN12 */
- #define HW_GPIO_CADENCE_PIN 12 /**< GPIOB PIN10 */
- #define HW_GPIO_HALLA_PIN 13 /**< GPIOC PIN6, HALLA、B、C的序号必须是连续的,且A的序号最小 */
- #define HW_GPIO_HALLB_PIN (HW_GPIO_HALLA_PIN + 1) /**< GPIOC PIN7 */
- #define HW_GPIO_HALLC_PIN (HW_GPIO_HALLA_PIN + 2) /**< GPIOC PIN8 */
- #define HW_GPIO_MOTTEMP_PIN 16 /**< GPIOB PIN11 */
- #define HW_GPIO_LED_PIN 17 /**< GPIOC PIN13 */
- #define HW_GPIO_BIKESPD_PIN 18 /**< GPIOB PIN11 */
|