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 "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_config_t
 Describe DC motor driver with PWM device and motors array. More...
 

Macros

#define CONFIG_MOTOR_DRIVER_MAX   (2)
 Maximum number of motors by motor driver.
 
#define MOTOR_DRIVER_DEV(x)   (x)
 Macro to return motor driver id.
 

Typedefs

typedef unsigned int motor_driver_t
 Default motor driver type definition.
 
typedef void(* motor_driver_cb_t) (const motor_driver_t motor_driver, uint8_t motor_id, int32_t pwm_duty_cycle)
 Motor callback. More...
 

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_driver_mode_brake_t { MOTOR_BRAKE_LOW = 0, MOTOR_BRAKE_HIGH = 1 }
 Describe DC motor driver brake modes. More...
 
enum  motor_direction_t { MOTOR_CW = 0, MOTOR_CCW = 1 }
 Describe DC motor direction states. More...
 

Functions

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