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.

68 lines
1.1 KiB

2 years ago
  1. #pragma once
  2. /**
  3. * @file tmp117.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. * 1. ο:https://github.com/rkiyak/TMP117.git
  13. * 2. ͬĿ¼оƬdatasheet
  14. */
  15. #include <stdint.h>
  16. #include "sdk/os/zos.hpp"
  17. #include "sdk\chip\zpwm_generator_muti_channel.hpp"
  18. //
  19. namespace iflytop {
  20. // SUPPORT REG
  21. /**
  22. * @brief Cubemx
  23. *
  24. * 1. ʹһʱIn1óPWM
  25. */
  26. class DRV8710 {
  27. public:
  28. typedef struct {
  29. TIM_HandleTypeDef* tim;
  30. int32_t in1_chnannel_index;
  31. Pin_t in2;
  32. Pin_t nsleep;
  33. Pin_t nfault;
  34. bool shaft;
  35. } hardware_cfg_t;
  36. ZPWMGeneratorMutiChannel m_pwmCtrl;
  37. ZGPIO m_in2;
  38. ZGPIO m_nsleep;
  39. ZGPIO m_nfault;
  40. hardware_cfg_t m_cfg;
  41. // ZGPIO so;
  42. public:
  43. DRV8710(){};
  44. void initialize(hardware_cfg_t* cfg);
  45. void enable(bool varenable);
  46. void moveForward(int32_t duty); // 0->100
  47. void moveBackward(int32_t duty); // 0->100
  48. void move(int32_t duty); // -100->100
  49. bool isFault();
  50. private:
  51. void set_direcetion(bool direcetion);
  52. };
  53. } // namespace iflytop