You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #pragma once
  2. /**
  3. * @file drv8710.hpp
  4. * @author zhaohe (h_zhaohe@163.com)
  5. * @brief
  6. * @version 0.1
  7. * @date 2023-04-14
  8. *
  9. * @copyright Copyright (c) 2023
  10. *
  11. *
  12. */
  13. #include <stdint.h>
  14. #include "sdk/os/zos.hpp"
  15. #include "sdk\chip\zpwm_generator_muti_channel.hpp"
  16. //
  17. namespace iflytop {
  18. // SUPPORT REG
  19. /**
  20. * @brief Cubemx
  21. *
  22. * 1. ʹһʱIn1óPWM
  23. */
  24. class DRV8710 {
  25. public:
  26. typedef struct {
  27. ZPWMGeneratorMutiChannel::hardware_config_t pwm_cfg;
  28. int32_t in1_chnannel_index;
  29. Pin_t in2;
  30. Pin_t nsleep;
  31. Pin_t nfault;
  32. Pin_t sensePin;
  33. bool shaft;
  34. bool enableTrace;
  35. } config_t;
  36. ZPWMGeneratorMutiChannel m_pwmCtrl;
  37. ZGPIO m_in2;
  38. ZGPIO m_nsleep;
  39. ZGPIO m_nfault;
  40. ZGPIO m_nsensePin;
  41. config_t m_cfg;
  42. // ZGPIO so;
  43. public:
  44. DRV8710(){};
  45. void initialize(config_t* cfg);
  46. void enable(bool varenable);
  47. void moveForward(int32_t duty); // 0->100
  48. void moveBackward(int32_t duty); // 0->100
  49. void move(int32_t duty); // -100->100
  50. bool isFault();
  51. bool getSensePinState() { return m_nsensePin.getState(); }
  52. private:
  53. void set_direcetion(bool direcetion);
  54. };
  55. } // namespace iflytop