current.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _PHASE_CURRENT_H__
  2. #define _PHASE_CURRENT_H__
  3. #include "math/fix_math.h"
  4. typedef struct _phase_time {
  5. s32 A;
  6. s32 B;
  7. s32 C;
  8. s32 A_next;
  9. s32 B_next;
  10. s32 C_next;
  11. u32 Samp_p1; //单电阻方案两个采样时刻可能不是连续的
  12. u32 Samp_p2;
  13. u8 sampe_phase_1;
  14. u8 sampe_phase_2;
  15. u8 boundary3_flags;
  16. u8 three_shunts_flags;
  17. }phase_time_t; //����pwn��duty cnt
  18. #define IGNORE_NONE 0
  19. #define IGNORE_A 1
  20. #define IGNORE_B 2
  21. #define IGNORE_C 3
  22. #define IGNORE_ALL 4
  23. typedef struct current_sample {
  24. s32 adc_offset_a;
  25. s32 adc_offset_b;
  26. s32 adc_offset_c;
  27. s16 adc_ia;
  28. s16 adc_ib;
  29. s16 adc_ic;
  30. s16 adc_ia_filter;
  31. s16 adc_ib_filter;
  32. s16 adc_ic_filter;
  33. u8 c_phases;
  34. u8 c_ignore_phase;
  35. phase_time_t time;
  36. volatile int sample_count;
  37. volatile bool is_calibrating_offset;
  38. volatile bool is_calibrating_sensor;
  39. float calibrate_current;
  40. float sensor_samples_1;
  41. float sensor_samples_2;
  42. float sensor_k1;
  43. float sensor_k2;
  44. }current_samp_t;
  45. void phase_current_init(void);
  46. void phase_current_get(float *iABC);
  47. bool phase_current_offset(void);
  48. void phase_current_point(void *);
  49. void phase_current_adc_triger(void);
  50. void phase_current_offset_calibrate(void);
  51. void phase_current_calibrate_wait(void);
  52. void phase_current_sensor_start_calibrate(float calibrate_current);
  53. bool phase_current_sensor_do_calibrate(void);
  54. bool phase_curr_offset_check(void);
  55. #endif /* _PHASE_CURRENT_H__ */