input_capture.h 868 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef INC_INPUT_CAPTURE_H_
  2. #define INC_INPUT_CAPTURE_H_
  3. #define CPU_FCK 64000000
  4. #define DSHOT150_TIM_TRIG CPU_FCK/1000000*6670/2000
  5. #define DSHOT300_TIM_TRIG CPU_FCK/1000000*3330/2000
  6. #define DSHOT600_TIM_TRIG CPU_FCK/1000000*1670/2000
  7. #define DShot_150 0
  8. #define DShot_300 1
  9. #define DShot_600 2
  10. #define DShot_Auto 3
  11. typedef struct
  12. {
  13. uint16_t Value; // 0...47 command, 48...2047 throttle
  14. uint8_t Type;
  15. uint32_t T1[16];
  16. uint32_t T2[16];
  17. uint16_t Dif[16];
  18. uint16_t TDif;
  19. uint8_t Restart_Counter;
  20. } DShotStruct;
  21. void DMA1_Channel1_IRQ (DMA_HandleTypeDef *hdma);
  22. void Dshot_Init(uint8_t type);
  23. void Dshot_DeInit(void);
  24. uint32_t DShot_Get(void);
  25. typedef struct
  26. {
  27. uint32_t Value;
  28. uint32_t OverCaptureCounter;
  29. } PWMInputStruct;
  30. void PWMInput_Init(void);
  31. void PWMInput_DeInit(void);
  32. uint32_t PWMInput_Get(void);
  33. void TIM3_IRQ(void);
  34. #endif