bsp.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __BSP_AT32_H__
  2. #define __BSP_AT32_H__
  3. #if defined AT32F413RCT7
  4. #include "at32f413.h"
  5. #endif
  6. #define BIT(x) ((uint32_t)((uint32_t)0x01U<<(x)))
  7. #define SYSTEM_CLOCK (200000000u) //system clk 200M Hz
  8. #define TIM_CLOCK (SYSTEM_CLOCK) /*SystemClock_Config��TIM1��clk��sys PLL �������̶�2����PLLƵ��*/
  9. #define TIM_CLOCK_MHz (200u)
  10. #define ADC_CLOCK (25000000u)
  11. #define ADC_CLOCK_MHz (30u)
  12. #define NS_PER_TCLK (5u) /* (1/200000000 * 1000000000) */
  13. #define NS_2_TCLK(ns) (((ns)/NS_PER_TCLK) + 1u) //ns תΪpwmʹ�õ��Ǹ�TIM��clk count
  14. #define FOC_PWM_FS (16000u)
  15. #define FOC_PWM_period (TIM_CLOCK/FOC_PWM_FS)
  16. #define FOC_PWM_Half_Period (FOC_PWM_period/2)
  17. #define FOC_CTRL_US (1.0f/(float)FOC_PWM_FS)
  18. #define ADC_TRIG_CONV_LATENCY_CYCLES 12.5f
  19. #define ADC_SAMPLING_CYCLES 13.5f
  20. #if defined (MC100_HW_V1)
  21. #include "bsp/at32/board_mc100_v1.h"
  22. #define CONFIG_BOARD_MCXXX
  23. #define CONFIG_BOARD_NAME "MC100AT"
  24. #define CONFIG_HW_VERSION 2
  25. #elif defined (MC105_HW_V3)
  26. #include "bsp/at32/board_at_mc105_v3.h"
  27. #define CONFIG_BOARD_MCXXX
  28. #define CONFIG_BOARD_NAME "MC105AT"
  29. #define CONFIG_HW_VERSION 3
  30. #endif
  31. #endif /* __BSP_AT32_H__ */