bsp.c 632 B

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