tb6612fng.h 1.08 KB
#ifndef TB6612FNG_H
#define TB6612FNG_H

#include "periph/pwm.h"
#include "periph/gpio.h"
#include "xtimer.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    pwm_t device;           /**< the PWM device driving the motor */
    int channel;            /**< the channel the motor is connected to */
    gpio_t in1;
    gpio_t in2;
    gpio_t stby;    
} motor_t;

int motor_init(motor_t *dev, pwm_t pwm, int pwm_channel, gpio_t in1, gpio_t in2, gpio_t stby);
void motor_drive(const motor_t *dev, uint16_t speed, int direction);
void motor_fw(const motor_t *dev, uint16_t speed);
void motor_rev(const motor_t *dev, uint16_t speed);
void motor_brake(const motor_t *dev1, motor_t *dev2);
void motor_forward(const motor_t *dev1, const motor_t *dev2, uint16_t speed);
void motor_back(const motor_t *dev1, const motor_t *dev2, uint16_t speed);
void motor_left(const motor_t *dev1, const motor_t *dev2, uint16_t speed);
void motor_right(const motor_t *dev1,const motor_t *dev2, uint16_t speed);

void motor_stby(const motor_t *dev);



#ifdef __cplusplus
}
#endif

#endif /* TB6612FNG_H */
/** @} */