current.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _PHASE_CURRENT_H__
  2. #define _PHASE_CURRENT_H__
  3. #include "foc/core/foc_type.h"
  4. /* boundary zone definition */
  5. #define REGULAR ((uint8_t)0u)
  6. #define BOUNDARY_1 ((uint8_t)1u) /* Two small, one big */
  7. #define BOUNDARY_2 ((uint8_t)2u) /* Two big, one small */
  8. #define BOUNDARY_3 ((uint8_t)3u) /* Three equal */
  9. #define SAMP_NO 0u
  10. #define SAMP_IA 1u
  11. #define SAMP_IB 2u
  12. #define SAMP_IC 3u
  13. #define SAMP_NIA 4u
  14. #define SAMP_NIB 5u
  15. #define SAMP_NIC 6u
  16. #define SAMP_OLDA 7u
  17. #define SAMP_OLDB 8u
  18. #define SAMP_OLDC 9u
  19. typedef struct current_sample {
  20. s32 adc_offset_a;
  21. s32 adc_offset_b;
  22. s32 adc_offset_c;
  23. s16 adc_ia;
  24. s16 adc_ib;
  25. s16 adc_ic;
  26. u8 sector;
  27. phase_time_t time;
  28. volatile int offset_sample_count;
  29. bool is_calibrating_offset;
  30. }current_samp_t;
  31. void phase_current_init(void);
  32. void phase_current_sample(s16 *ia, s16 *ib, s16 *ic);
  33. bool phase_current_offset(void);
  34. current_samp_t * get_phase_sample_point(u8 sector);
  35. void phase_current_adc_triger(void);
  36. void phase_current_start_cali(void);
  37. #endif /* _PHASE_CURRENT_H__ */