Loading...
Searching...
No Matches
motor_driver.h File Reference

High-level driver for DC motors. More...

Detailed Description

High-level driver for DC motors.

Author
Gilles DOFFE g.dof.nosp@m.fe@g.nosp@m.mail..nosp@m.com

Definition in file motor_driver.h.

#include <stdbool.h>
#include "periph/pwm.h"
#include "periph/gpio.h"
+ Include dependency graph for motor_driver.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  motor_t
 Describe DC motor with PWM channel and GPIOs. More...
 
struct  motor_driver_params_t
 Describe DC motor driver with PWM device and motors array. More...
 
struct  _motor_driver_t
 Motor driver. More...
 

Macros

#define CONFIG_MOTOR_DRIVER_MAX   (2)
 Maximum number of motors by motor driver.
 

Typedefs

typedef struct _motor_driver_t motor_driver_t
 Motor driver.
 
typedef void(* motor_set_post_cb_t) (const motor_driver_t *motor_driver, uint8_t motor_id, int32_t pwm_duty_cycle)
 Motor callback.
 
typedef void(* motor_set_cb_t) (const motor_t *motor, motor_direction_t direction)
 Motor set callback.
 
typedef void(* motor_brake_cb_t) (const motor_t *motor, bool brake)
 Motor brake callback.
 

Enumerations

enum  motor_driver_mode_t { MOTOR_DRIVER_2_DIRS = 0 , MOTOR_DRIVER_1_DIR = 1 , MOTOR_DRIVER_1_DIR_BRAKE = 2 }
 Describe DC motor driver modes. More...
 
enum  motor_direction_t { MOTOR_CW = 0 , MOTOR_CCW = 1 }
 Describe DC motor direction states. More...
 

Functions

int motor_driver_init (motor_driver_t *motor_driver, const motor_driver_params_t *params)
 Initialize DC motor driver board.
 
int motor_set (const motor_driver_t *motor_driver, uint8_t motor_id, int32_t pwm_duty_cycle)
 Set motor speed and direction.
 
int motor_brake (const motor_driver_t *motor_driver, uint8_t motor_id)
 Brake the motor of a given motor driver.
 
void motor_enable (const motor_driver_t *motor_driver, uint8_t motor_id)
 Enable a motor of a given motor driver.
 
void motor_disable (const motor_driver_t *motor_driver, uint8_t motor_id)
 Disable a motor of a given motor driver.