AP1017 library for the Rev.E hardware with expanded capabilities.
Fork of AP1017 by
Diff: AP1017.h
- Revision:
- 2:8a644b1066c4
- Parent:
- 1:4d4c77589134
- Child:
- 3:f8e70f639ed0
--- a/AP1017.h Mon Apr 17 19:08:36 2017 +0000 +++ b/AP1017.h Mon Apr 17 19:17:25 2017 +0000 @@ -10,34 +10,24 @@ /** * This is a device driver for the AP1017 with pulse width modulation. - * - * @note AP1017 is a 12V Single Channel H-Bridge Motor Driver IC manufactured by AKM. - * - * Example: - * @code - * #include "mbed.h" - * #include "AP1017.h" - * - * int main() { - * AP1017 motorA; - * - * } - * @endcode */ class AP1017 { public: - /** Default constructor creates motors with PWM initial duty cycle of 0%. - * Motor EN pin connected to D2, INA connected to D0, INB connected to D1. - */ + /** + * Default constructor creates motors with PWM initial duty cycle of 0%. + * Motor EN pin connected to D2, INA connected to D0, INB connected to D1. + */ AP1017(void); - /** Disables PWM for the motors. + /** + * Disables PWM for the motors. */ ~AP1017(void); - /** Return status enumeration for debugging. + /** + * Return status enumeration for debugging. */ typedef enum { SUCCESS = 0x00, /**< Successful termination */ @@ -49,7 +39,8 @@ ERROR_MOTORON = 0x06 /**< Direction switched while motor on */ } Status; - /** Motor directions. + /** + * Motor directions. */ typedef enum { DIRECTION_CW = 0x00, /**< Clockwise motor rotation */ @@ -62,62 +53,80 @@ float getDutyCycle(void); Rotation getDirection(void); - /** Sets the direction to clockwise, counterclockwise, brake or coast. - * Changing between clockwise and counterclockwise may only be performed - * when motor is off. + /** + * Sets the direction to clockwise, counterclockwise, brake or coast. + * Changing between clockwise and counterclockwise may only be performed + * when motor is off. * - * @param dir Rotation type: DIRECTION_CW, DIRECTION_CCW, DIRECTION_COAST, + * @param dir Rotation type: DIRECTION_CW, DIRECTION_CCW, DIRECTION_COAST, * or DIRECTION_BRAKE - * @return Returns successful termination, ERROR_MOTORON for invalid + * @return Returns successful termination, ERROR_MOTORON for invalid * direction switching, or ERROR_DIRECTION for invalid direction. */ Status setDirection(char dir); - /** Sets the duty cycle in percentage. Also sets the pulse width in - * microseconds by calculation using current value of the period. + /** + * Sets the duty cycle in percentage. Also sets the pulse width in + * microseconds by calculation using current value of the period. * - * @param dc Duty cycle as a proportion (0.0 to 1.0). - * @return Returns successful termination or dutyc cyle error. + * @param dc Duty cycle as a proportion (0.0 to 1.0). + * @return Returns successful termination or dutyc cyle error. */ Status setDutyCycle(float dc); - /** Sets the frequency of the motor in Hertz. - * @param f Frequency (Hertz). - * @return Returns successful termination or frequency error. + /** + * Sets the frequency of the motor in Hertz. + * + * @param f Frequency (Hertz). + * @return Returns successful termination or frequency error. */ Status setFrequency(float freq); - /** Sets the period in microseconds. Also sets the pulse width by - * calculation with the current value of the duty cycle. Period will be - * changed even if motor is currently running. + /** + * Sets the period in microseconds. Also sets the pulse width by + * calculation with the current value of the duty cycle. Period will be + * changed even if motor is currently running. * - * @param per PWM Period in microseconds. - * @return Returns successful termination or period error. + * @param per PWM Period in microseconds. + * @return Returns successful termination or period error. */ Status setPeriod_us(float per); - /** Sets the pulse with in microseconds. Also sets the duty cycle by - * calculation with the current value of the period. Pulse width will be - * changed even if motor is currently running. + /** + * Sets the pulse with in microseconds. Also sets the duty cycle by + * calculation with the current value of the period. Pulse width will be + * changed even if motor is currently running. * - * @param pw Pulse width in microseconds. - * @return Returns successful termination or pulse width error. + * @param pw Pulse width in microseconds. + * @return Returns successful termination or pulse width error. */ Status setPulseWidth_us(float pw); - /** Engages the motor. + /** + * Engages the motor. + * + * @return Returns successful termination or pulse width error. */ Status startMotor(void); - /** Stops forced rotation of the motor. + /** + * Stops forced rotation of the motor. + * + * @return Returns successful termination or pulse width error. */ Status stopMotor(void); - /** Applies forced braking of motor. + /** + * Applies forced braking of motor. + * + * @return Returns successful termination or pulse width error. */ Status brakeMotor(void); /** + * Removes force from the motor and allows it to spin freely. + * + * @return Returns successful termination or pulse width error. */ Status coastMotor(void);