current.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef _PHASE_CURRENT_H__
  2. #define _PHASE_CURRENT_H__
  3. #include "math/fix_math.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 _phase_time {
  20. s32 A;
  21. s32 B;
  22. s32 C;
  23. s32 A_next;
  24. s32 B_next;
  25. s32 C_next;
  26. u32 Samp_p1; //单电阻方案两个采样时刻可能不是连续的
  27. u32 Samp_p2;
  28. u8 sampe_phase_1;
  29. u8 sampe_phase_2;
  30. u8 boundary3_flags;
  31. u8 three_shunts_flags;
  32. }phase_time_t; //����pwn��duty cnt
  33. typedef struct current_sample {
  34. s32 adc_offset_a;
  35. s32 adc_offset_b;
  36. s32 adc_offset_c;
  37. s16 adc_ia;
  38. s16 adc_ib;
  39. s16 adc_ic;
  40. u8 sector;
  41. phase_time_t time;
  42. volatile int offset_sample_count;
  43. bool is_calibrating_offset;
  44. }current_samp_t;
  45. void phase_current_init(void);
  46. void phase_current_get(s16 *iABC);
  47. bool phase_current_offset(void);
  48. void phase_current_point(void *);
  49. void phase_current_adc_triger(void);
  50. void phase_current_start_cali(void);
  51. #endif /* _PHASE_CURRENT_H__ */