#ifndef __BSP_H__ #define __BSP_H__ #if defined (GD32F30X_HD) || defined (GD32F30X_XD) || defined (GD32F30X_CL) #include "gd32f30x.h" #elif defined GD32E10x #include "gd32e10x.h" #endif #include "bsp/gpio.h" #include "bsp/gd32_bkp.h" #include "bsp/gd32_rtc.h" #include "bsp/can.h" #include "bsp/i2c.h" #include "bsp/fmc_flash.h" #include "bsp/can.h" #define ADC_REFERENCE_VOLTAGE 3.30f #define SYSTEM_CLOCK (120000000L) //system clk 120M Hz #define TIM_CLOCK (SYSTEM_CLOCK) /*SystemClock_Config��TIM1��clk��sys PLL �������̶�2����PLLƵ��*/ #define TIM_CLOCK_MHz (120) #define ADC_CLOCK (30000000L) #define ADC_CLOCK_MHz (30) #define NS_PER_TCLK (8) /* (1/120000000 * 1000000000) */ #define NS_2_TCLK(ns) ((ns/NS_PER_TCLK) + 1) //ns תΪpwmʹ�õ��Ǹ�TIM��clk count #define FOC_PWM_FS (30 * 1000) #define FOC_PWM_period (TIM_CLOCK/FOC_PWM_FS) #define FOC_PWM_Half_Period (FOC_PWM_period/2) #define MAX_VBUS (12.f) //12v #define ADC_TRIG_CONV_LATENCY_CYCLES 12.5f #define ADC_SAMPLING_CYCLES 7.5f #define HW_DEAD_TIME_NS 800 #define HW_RISE_TIME_NS 50 #define HW_NOISE_TIME_NS 50 #define TDead NS_2_TCLK(HW_DEAD_TIME_NS/2)/* ����ʱ�� */ #define TRise NS_2_TCLK(HW_RISE_TIME_NS)/* MOS ����ʱ��*/ #define TNoise NS_2_TCLK(HW_NOISE_TIME_NS)/* MOS��������Ŀ�������ʱ�� */ #define TADC ((uint16_t)((ADC_TRIG_CONV_LATENCY_CYCLES + ADC_SAMPLING_CYCLES) * TIM_CLOCK_MHz) / ADC_CLOCK_MHz + 1u)/* ADC ����ʱ�� */ #define START_RAMP_DURATION (100)//ms #define SPEED_SAMPLE_INVAL (100) //ת�Ѳɼ��ļ��,ms #define SPEED_RAMP_DURATION SPEED_SAMPLE_INVAL //�����ٶȵ�б��ʱ�䣬�ٶ�ƽ���������½� #define MAX_VBUS_VOLTAGE 12.0f #define MAX_CURRENT 50.0F #define pwm_timer TIMER0 #define adc_timer TIMER0 #define aux_timer TIMER0 #define USER_ITMER_BRAKE 0 void bsp_init(void); void wdog_reload(void); void system_reboot(void); int wdog_set_timeout(int wdog_time); #endif /* __BSP_H__ */