upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | _md_context |
Functions | |
md_context | md_init (int bus, uint8_t address) |
void | md_close (md_context dev) |
bool | md_write_packet (const md_context dev, MD_REG_T reg, uint8_t data1, uint8_t data2) |
bool | md_set_motor_speeds (const md_context dev, uint8_t speedA, uint8_t speedB) |
bool | md_set_pwm_frequency_prescale (const md_context dev, uint8_t freq) |
bool | md_set_motor_directions (const md_context dev, MD_DC_DIRECTION_T dirA, MD_DC_DIRECTION_T dirB) |
bool | md_enable_stepper (const md_context dev, MD_STEP_DIRECTION_T dir, uint8_t speed) |
bool | md_disable_stepper (const md_context dev) |
bool | md_set_stepper_steps (const md_context dev, unsigned int steps) |
void | md_config_stepper (const md_context dev, unsigned int stepsPerRev, MD_STEP_MODE_T mode) |
Typedefs | |
typedef struct _md_context * | md_context |
md_context md_init | ( | int | bus, |
uint8_t | address | ||
) |
MD initializer.
bus | I2C bus to use |
address | I2C address to use |
void md_close | ( | md_context | dev | ) |
MD close.
dev | Device context. |
bool md_write_packet | ( | const md_context | dev, |
MD_REG_T | reg, | ||
uint8_t | data1, | ||
uint8_t | data2 | ||
) |
Composes and writes a 3-byte packet to the controller
dev | Device context. |
reg | Register location |
data1 | First byte of data |
data2 | Second byte of data |
bool md_set_motor_speeds | ( | const md_context | dev, |
uint8_t | speedA, | ||
uint8_t | speedB | ||
) |
To control DC motors, sets the speed of motors A & B. Valid values are 0-255.
dev | Device context. |
speedA | Speed of motor A |
speedB | Speed of motor B |
bool md_set_pwm_frequency_prescale | ( | const md_context | dev, |
uint8_t | freq | ||
) |
To control DC motors, sets the PWM frequency prescale factor. Note: this register is not ducumented other than to say the default value is 0x03. Presumably, this is the timer prescale factor used on the ATMega MCU timer driving the PWM.
dev | Device context. |
freq | PWM prescale frequency; default should be 0x03 |
bool md_set_motor_directions | ( | const md_context | dev, |
MD_DC_DIRECTION_T | dirA, | ||
MD_DC_DIRECTION_T | dirB | ||
) |
To control DC motors, sets the directions of motors A & B
dev | Device context. |
dirA | Direction for motor A, MD_DIR_CW or MD_DIR_CCW |
dirB | Direction for motor B, MD_DIR_CW or MD_DIR_CCW |
bool md_enable_stepper | ( | const md_context | dev, |
MD_STEP_DIRECTION_T | dir, | ||
uint8_t | speed | ||
) |
To control a stepper motor, sets its direction and speed, and then starts operation. For Mode2, this method will return immediately. For Mode1 (the default) this method returns when the number of steps specified by md_set_stepper_steps() has completed.
dev | Device context. |
dir | Direction, MD_STEP_DIR_CW or MD_STEP_DIR_CCW |
speed | Motor speed. Valid range is 1-255. For Mode 1 (default), this specifies the speed in RPM's. For Mode 2, speed is multiplied by 4ms by the board, so higher numbers will mean a slower speed. |
bool md_disable_stepper | ( | const md_context | dev | ) |
To control a stepper motor, stops the stepper motor.
dev | Device context. |
bool md_set_stepper_steps | ( | const md_context | dev, |
unsigned int | steps | ||
) |
To control a stepper motor, specifies the number of steps to execute. For Mode2, valid values are between 1-255, 255 means continuous rotation.
For Mode1 (the default) steps can be any positive integer.
dev | Device context. |
steps | Number of steps to execute. 255 (only in Mode2) means continuous rotation. |
void md_config_stepper | ( | const md_context | dev, |
unsigned int | stepsPerRev, | ||
MD_STEP_MODE_T | mode | ||
) |
Configure the initial Stepper parameters. This should be called before any other stepper method.
dev | Device context. |
stepsPerRev | The number of steps required to complete one full revolution. |
mode | The stepper operating mode. MD_STEP_MODE1 is more flexible, and is handled directly by this driver. MD_STEP_MODE2 is handled completely by the MCU on board the motor driver, but is much more restrictive and requires updated firmware. We generally recommend MODE1. |
typedef struct _md_context * md_context |
Device context