#pragma once /** * @file drv8710.hpp * @author zhaohe (h_zhaohe@163.com) * @brief * @version 0.1 * @date 2023-04-14 * * @copyright Copyright (c) 2023 * * */ #include #include "sdk/os/zos.hpp" #include "sdk\chip\zpwm_generator_muti_channel.hpp" // namespace iflytop { // SUPPORT REG /** * @brief Cubemx配置 * * 1. 使能一个定时器,将In1引脚配置成PWM引脚 */ class DRV8710 { public: typedef struct { ZPWMGeneratorMutiChannel::hardware_config_t pwm_cfg; int32_t in1_chnannel_index; Pin_t in2; Pin_t nsleep; Pin_t nfault; bool shaft; bool enableTrace; } config_t; ZPWMGeneratorMutiChannel m_pwmCtrl; ZGPIO m_in2; ZGPIO m_nsleep; ZGPIO m_nfault; config_t m_cfg; // ZGPIO so; public: DRV8710(){}; void initialize(config_t* cfg); void enable(bool varenable); void moveForward(int32_t duty); // 0->100 void moveBackward(int32_t duty); // 0->100 void move(int32_t duty); // -100->100 bool isFault(); private: void set_direcetion(bool direcetion); }; } // namespace iflytop