bsp.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __BSP_H__
  2. #define __BSP_H__
  3. #if defined (GD32F30X_HD) || defined (GD32F30X_XD) || defined (GD32F30X_CL)
  4. #include "gd32f30x.h"
  5. #elif defined GD32E10x
  6. #include "gd32e10x.h"
  7. #endif
  8. #include "bsp/gpio.h"
  9. #include "bsp/gd32_bkp.h"
  10. #include "bsp/gd32_rtc.h"
  11. #include "bsp/can.h"
  12. #include "bsp/i2c.h"
  13. #include "bsp/fmc_flash.h"
  14. #include "bsp/can.h"
  15. #define ADC_REFERENCE_VOLTAGE 3.30f
  16. #define SYSTEM_CLOCK (120000000L) //system clk 120M Hz
  17. #define TIM_CLOCK (SYSTEM_CLOCK) /*SystemClock_Config��TIM1��clk��sys PLL �������̶�2����PLLƵ��*/
  18. #define TIM_CLOCK_MHz (120)
  19. #define ADC_CLOCK (30000000L)
  20. #define ADC_CLOCK_MHz (30)
  21. #define NS_PER_TCLK (8) /* (1/120000000 * 1000000000) */
  22. #define NS_2_TCLK(ns) ((ns/NS_PER_TCLK) + 1) //ns תΪpwmʹ�õ��Ǹ�TIM��clk count
  23. #define FOC_PWM_FS (30 * 1000)
  24. #define FOC_PWM_period (TIM_CLOCK/FOC_PWM_FS)
  25. #define FOC_PWM_Half_Period (FOC_PWM_period/2)
  26. #define MAX_VBUS (12.f) //12v
  27. #define ADC_TRIG_CONV_LATENCY_CYCLES 12.5f
  28. #define ADC_SAMPLING_CYCLES 7.5f
  29. #define HW_DEAD_TIME_NS 800
  30. #define HW_RISE_TIME_NS 50
  31. #define HW_NOISE_TIME_NS 50
  32. #define TDead NS_2_TCLK(HW_DEAD_TIME_NS/2)/* ����ʱ�� */
  33. #define TRise NS_2_TCLK(HW_RISE_TIME_NS)/* MOS ����ʱ��*/
  34. #define TNoise NS_2_TCLK(HW_NOISE_TIME_NS)/* MOS��������Ŀ�������ʱ�� */
  35. #define TADC ((uint16_t)((ADC_TRIG_CONV_LATENCY_CYCLES + ADC_SAMPLING_CYCLES) * TIM_CLOCK_MHz) / ADC_CLOCK_MHz + 1u)/* ADC ����ʱ�� */
  36. #define START_RAMP_DURATION (100)//ms
  37. #define SPEED_SAMPLE_INVAL (100) //ת�Ѳɼ��ļ��,ms
  38. #define SPEED_RAMP_DURATION SPEED_SAMPLE_INVAL //�����ٶȵ�б��ʱ�䣬�ٶ�ƽ���������½�
  39. #define MAX_VBUS_VOLTAGE 12.0f
  40. #define MAX_CURRENT 50.0F
  41. #define pwm_timer TIMER0
  42. #define adc_timer TIMER0
  43. #define aux_timer TIMER0
  44. #define USER_ITMER_BRAKE 0
  45. void bsp_init(void);
  46. void wdog_reload(void);
  47. void system_reboot(void);
  48. int wdog_set_timeout(int wdog_time);
  49. #endif /* __BSP_H__ */