Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MotorLib by
Diff: motor.h
- Revision:
- 17:86e5af6f7628
- Parent:
- 16:d818c1a4dafb
- Child:
- 18:00e3d8c71a9c
--- a/motor.h	Wed Nov 28 09:44:34 2018 +0000
+++ b/motor.h	Wed Nov 28 21:04:24 2018 +0000
@@ -25,13 +25,13 @@
 #define MOTOR_STEPS_FOR_A_TURN 4096     /**< Default number of motor steps to complete a turn = 4096 steps  */
 
 /** \enum motorStates 
-* \brief Motor States of Motor state machine
+* \brief Possible States of Motor state machine
 * 
 * Motor_CALIB is deprecated, was removed from the enum structure */
 typedef enum {
     Motor_OFF = 0,  /**< All phase currents is off, replaces Motor_STOP. */  
-    Motor_ZERO,     /**< Motor at phase position 0 and ON, only reached by call of Zero() command. */  
-    Motor_ON,       /**< Phases are engaged, but Motor does not run, replaces Motor_PAUSE. */  
+    Motor_ZERO,     /**< Motor at phase position 0 and ON, only reached by call of Zero() procedure. */  
+    Motor_ON,       /**< Phases are engaged, but Motor state machine stopped, replaces Motor_PAUSE. */  
     Motor_RUN       /**< Phases are engaged, and Motor state machine runs*/  
 } motorStates;
 
@@ -45,7 +45,7 @@
 
 * MOTOR_restart is equivalent to and replaced by MOTOR_run.
 */
-typedef enum { // Define Motor State Machine Commands
+typedef enum {
     MOTOR_nop = 0,  /**< No active command to execute. */
     MOTOR_run,      /**< Run Motor until Nsteps are achieved. */
     MOTOR_stop,     /**< Stop immediately all activity, turn off Motor. */
@@ -53,12 +53,12 @@
 } motorCommands;
 
 /** \enum motorDir 
-* \brief Define Motor direction to be Clockwise or Anticlockwise 
+* \brief Gives Motor direction to be Clockwise or Anticlockwise 
 */
 typedef enum motorDir {
     CLOCKWISE = 0,      /**< Turn Motor in clockwise direction. */
     COUNTERCLOCKWISE    /**< Turn Motor in anti-clockwise direction. */
-} motorDir;
+};
 
 /** \struct MotStatus
 * \brief Structure of Motor Status registers.
@@ -70,7 +70,7 @@
     motorCommands cmd;  /**< Command asked to be executed currently by the state machine.*/
     motorDir      dir;  /**< Direction that the Motor is asked to run.*/
     int32_t       NSteps;/**< Number of steps remain for the Motor to run. 
-    NSteps=0: all steps finsihed; NSteps<0: indicates to run "forever" */
+    NSteps=0: all steps finished; NSteps<0: indicates to run "forever" */
     bool         TickIsAttached; /**< Indicates if Ticker is attached.
     Ticker is automatically attached while Motor runs, or paused; 
     detaches when finished a run, or stopped.  */
@@ -105,12 +105,13 @@
     * Creates the class, initiallizes all fields, creates Phase Pins.  
     * Time between two steps defaults here to MOTOR_STEP_TIME_DEFAULT_US=5000usec.
     *
-    * @code
-    *    PinName MotPhases[] = {PB_1, PB_15, PB_14, PB_13};
-    *    Motor MotorName(MotPhases); // Call this creator for example like this:  
-    * @endcode 
+    @code
+       PinName MotPhases[] = {PB_1, PB_15, PB_14, PB_13};
+       Motor MotorName(MotPhases); // Call this creator for example like this:  
+    @endcode 
     * 
-    * @param _MPh[4] Array of Names of the 4 Digital Pins of type PinNames */
+    * @param _MPh Array of Names of the 4 Digital Pins of type PinNames 
+    */
     Motor(PinName _MPh[4] );
     
     /** Motor Class Creator
@@ -118,12 +119,13 @@
     * Creates the class, initiallizes all fields, creates Phase Pins.  
     * Time between two steps defaults here to MOTOR_STEP_TIME_DEFAULT_US=5000usec.
     *
-    * @param <PB_1, PB_15, PB_14, PB_13> List of Names of the 4 Digital Pins of type PinNames    
+    @code
+      // Call this creator for example like this:
+       Motor MotorName(PB_1, PB_15, PB_14, PB_13);
+    @endcode 
     * 
-    * @code
-    *   // Call this creator for example like this:
-    *    Motor MotorName(PB_1, PB_15, PB_14, PB_13);
-    * @endcode */
+    * @param <_MPh0, _MPh1, _MPh2, _MPh3> List of Names of the 4 Digital Pins of type PinNames    
+    */
     Motor(PinName _MPh0, PinName _MPh1, PinName _MPh2, PinName _MPh3);
     
     /** Motor Class Creator
@@ -131,13 +133,14 @@
     * Creates the class, initiallizes all fields, creates Phase Pins.  
     * Time between two steps is passed as parameter.
     *
-    * @code
-    *   // Call this creator for example like this:
-    *    Motor MotorName(PB_1, PB_15, PB_14, PB_13);
-    * @endcode 
+    @code
+      // Call this creator for example like this:
+       Motor MotorName(PB_1, PB_15, PB_14, PB_13);
+    @endcode 
     *
-    * @param <PB_1, PB_15, PB_14, PB_13> List of Names of the 4 Digital Pins of type PinNames    
-    * @param <aStepTime_us> Lthe time in usec between two steps, thats used initially.   */
+    * @param <_MPh0, _MPh1, _MPh2, _MPh3> List of Names of the 4 Digital Pins of type PinNames    
+    * @param <aStepTime_us> Lthe time in usec between two steps, thats used initially.   
+    */
     Motor(PinName _MPh0, PinName _MPh1, PinName _MPh2, PinName _MPh3, uint32_t aStepTime_us);
 
 private:
@@ -151,6 +154,7 @@
     * Not called when the Motor is stopped by a call of Stop Function, or any other events.
     * For use see precautions at Class description above. 
     * Formerly called setMotorCallback()
+    *
     @code
     // Simple callback function, state variable endMove can be polled elsewhere
     void CallBackFunction()
@@ -174,14 +178,14 @@
     * @param <*CBfunction> Callback function, must not be member of a class.
 
     */
-    void callbackSet(void (*CBfunction)());
+    void callbackSet(void (*CBfunction)(void));
 
     /** Attach a Callback function, member of a class.
     * Only called when a Run Command reaches it's requested end.
     * Not called when the Motor is stopped by a call of Stop Function, or any other events.
     * For use see precautions at Class description above. 
-    * @param <T *object> Class pointer who possesses callback member.
-    * @param <T::*CBmember> Pointer to callback function, member of Class.
+    * @param <*object> Class pointer which possesses callback member.
+    * @param <*CBmember> Pointer to callback function, member of Class.
     * 
     @code
     // Class Creator:
@@ -197,7 +201,7 @@
     {  endMove=true;  }
     @endcode
     */
-    template<typename T>
+    template<typename T>;
     void callbackSet(T *object, void (T::*CBmember)(void)) {
         _callback = callback(object,CBmember);
     }
@@ -213,7 +217,7 @@
     * @param[in] <Direction> Given Direction, can be: CLOCKWISE, or COUNTERCLOCKWISE.
     * @param[in] <Nsteps> Number of steps to run for; must be >0 ; Nsteps<=0 will not be executed.    
     */
-   void RunSteps (motorDir direction, uint32_t Nsteps);
+   void RunSteps (motorDir Direction, uint32_t Nsteps);
 
     /** High Level: Run Motor for a given angle
     
@@ -224,7 +228,7 @@
     * @param[in] <Direction> Given Direction, can be: CLOCKWISE, or COUNTERCLOCKWISE.
     * @param[in] <angle_deg> Angle>0 to rotate for, in degrees, Angles<=0 are not executed.     
     */
-   void RunDegrees  (motorDir direction, float angle_deg);
+   void RunDegrees  (motorDir Direction, float angle_deg);
 
     /** High Level: Run Motor "unlimited"
     
@@ -233,7 +237,7 @@
     * Call Pause() or Stop() to pause or end the Motor run.
     * @param[in] <Direction> Given Direction, can be: CLOCKWISE, or COUNTERCLOCKWISE.
     */
-    void RunInfinite (motorDir direction);
+    void RunInfinite (motorDir Direction);
 
     /** High Level: Pause a motor Run.
      * Put Motor into Pause state, Run is suspended, but only effective if Status.cmd=MOTOR_run.
@@ -258,10 +262,10 @@
 public: // All the ticker timing related parameters
 
     /** MidLevel: Get Motor status
-    
+    *
     * Gets the Status of the different internal mechanisms. 
     * See documentation of MotStatus Structure.
-    * @return <MotStatus> The structure of Motor status registers. */
+    * \return MotStatus The structure of Motor status registers. */
     MotStatus getStatus();
 
     /** MidLevel: Get number of Steps per Full turn
@@ -269,7 +273,7 @@
     * Defaults to MOTOR_STEPS_FOR_A_TURN = 4096.
     * Used by RunDegrees() to translate from angle in degrees to number of steps.
     * Old Name was: getCalibration, but that was not a good explicit name. 
-    * @return <MotStatus> The structure of Motor status registers. */
+    * \return uint32_t The structure of Motor status registers. */
     uint32_t getStepsFullTurn();
 
     /** MidLevel: Set number of Steps per Full turn.
@@ -283,20 +287,20 @@
 
     /** Mid Level: Get the Motor step time. 
     
-     * Step time is time between two Motor steps, and is given in microseconds
-     * and is passed to the ticker as delay time. 
-     * So the larger the value the slower the motor speed.  
-     * Defaults to MOTOR_STEP_TIME_DEFAULT_US = 5000.
-    * @return <uint32_t> The structure of Motor status registers.
-     */
+    * Step time is time between two Motor steps, and is given in microseconds
+    * and is passed to the ticker as delay time. 
+    * So the larger the value the slower the motor speed.  
+    * Defaults to MOTOR_STEP_TIME_DEFAULT_US = 5000.
+    * \return uint32_t The structure of Motor status registers.
+    */
     uint32_t getStepTime_us;
     
     /** Set the time in microseconds between two Motor steps.
-     *  Defaults to MOTOR_STEP_TIME_DEFAULT_US = 5000usec.
-     *  Filters values below Minimum Value = 700.
-     *  Passed to the ticker as delay time.
-     *  Can be called while ticker is running, and takes immediate effect. 
-     *  Was previously called setStepTime(), but was not clear which units.  
+    *  Defaults to MOTOR_STEP_TIME_DEFAULT_US = 5000usec.
+    *  Filters values below Minimum Value = 700.
+    *  Passed to the ticker as delay time.
+    *  Can be called while ticker is running, and takes immediate effect. 
+    *  Was previously called setStepTime(), but was not clear which units.  
     * @param <aStepTime_us> the time in microseconds between two Motor steps
     */
     void setStepTime_us(uint32_t aStepTime_us);
@@ -329,16 +333,16 @@
     void MotorTest();
 
     /** Low Level: turn off all Motor Phases
-     * No more current flows, reduces holding force.
-     * After: State: Motor_OFF.
-     * StepPhases memorizes the last used phase.
-     * Equivalent what previously the function "void Stop();" did .  */
+    * No more current flows, reduces holding force.
+    * After: State: Motor_OFF.
+    * StepPhases memorizes the last used phase.
+    * Equivalent what previously the function "void Stop();" did .  */
     void MotorOFF();
     
     /** Low Level: turn on the Motor Phases in the last used phase.
-     * The last used phase is held in StepPhases.
-     * After: State: Motor_ON, or Motor_ZERO if StepPhases==0
-     * Equivalent to what previously the function "void Start();" did.  */
+    * The last used phase is held in StepPhases.
+    * After: State: Motor_ON, or Motor_ZERO if StepPhases==0
+    * Equivalent to what previously the function "void Start();" did.  */
     void MotorON();
     
     /** Low Level: Advance Motor one step, rotates in direction of variable direction. */
    