bsp.c 730 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "bsp/bsp.h"
  2. #include "foc/foc_api.h"
  3. void system_init(void){
  4. HAL_Init();
  5. SystemClock_Config();
  6. HAL_GPIO_init();
  7. HAL_NVIC_Init();
  8. HAL_PWM_Init();
  9. HAL_ADC1_Init();
  10. HAL_EXIT_Enable();
  11. serial_init();
  12. TIM4_Init();
  13. }
  14. void system_reboot(void){
  15. }
  16. int get_hall_stat(int samples) {
  17. samples = 1 + 2 * samples;
  18. int h1 = 0, h2 = 0, h3 = 0;
  19. int tres = samples / 2;
  20. while (samples--) {
  21. h1 += READ_HALL1();
  22. h2 += READ_HALL2();
  23. h3 += READ_HALL3();
  24. }
  25. return (h1 > tres) | ((h2 > tres) << 1) | ((h3 > tres) << 2);
  26. }
  27. void normal_task_enable(bool enable) {
  28. TIM4_Enable_IRQ(enable);
  29. }
  30. void wdog_reload(void){
  31. #if CONFIG_DEBUG == 0
  32. #endif
  33. }
  34. void wdog_enable(void)
  35. {
  36. #if CONFIG_DEBUG == 0
  37. #endif
  38. }