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.
 
 

66 lines
1.0 KiB

#pragma once
/**
* @file drv8710.hpp
* @author zhaohe (h_zhaohe@163.com)
* @brief
* @version 0.1
* @date 2023-04-14
*
* @copyright Copyright (c) 2023
*
*
*/
#include <stdint.h>
#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 {
TIM_HandleTypeDef* tim;
int32_t in1_chnannel_index;
Pin_t in2;
Pin_t nsleep;
Pin_t nfault;
bool shaft;
} 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