Expansion SW library to control high power stepper motor(s) using IHM03A1 expansion board(s) with Powerstep01 driver.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   IHM03A1_ExampleFor1Motor HelloWorld_IHM03A1 IHM03A1_ExampleFor3Motors KYPHOS_Stepper_Motor_Control

Fork of X_NUCLEO_IHM03A1 by ST Expansion SW Team

Motor Control Library

Library to handle the X-NUCLEO-IHM03A1 Motor Control Expansion Board based on the Powerstep01 component.

It features the:

  • read and write of Powerstep01 registers
  • Nucleo and expansion board configuration (GPIOs, PWMs, IRQs, etc.)
  • Powerstep01 application commands handling
  • FLAG and BUSY interrupt handling (alarm reporting)
  • Daisy chain handling

The API allows to easily:

  • perform various positioning, moves and stops
  • get/set or monitor the motor positions
  • set home position and mark another position
  • get/set minimum and maximum speed
  • get current speed
  • get/set acceleration and deceleration
  • get/set the step mode (up to 1/128)
  • get/set the control method
  • get/set parameters for voltage mode driving
  • get/set parameters for current mode driving
  • get/set parameters for gate driving
  • configure various protections such as overcurrent detection
  • enable/disable alarms
  • handle step-clock
  • get system status

Daisy-Chain Configuration

The IHM03A1 board can be stacked up to three times so that the Powerstep01 components will be connected in daisy-chain configuration. For this purpose, some resistors must be correctly connected on the boards as depicted here below:

/media/uploads/nucleosam/driving1steppermotor.png /media/uploads/nucleosam/driving2steppermotors.png /media/uploads/nucleosam/driving3steppermotors.png

Platform compatibility

Compatible platforms have been tested with the default configuration provided by the HelloWorld_IHM03A1 example.

Files at this revision

API Documentation at this revision

Comitter:
nucleosam
Date:
Thu Apr 07 16:11:47 2016 +0000
Parent:
0:00a3c3f5a8f0
Child:
2:06f3a5360a45
Commit message:
StepperMotor class modification and induced changes

Changed in this revision

Components/Common/motor.h Show annotated file Show diff for this revision Revisions of this file
Components/Interfaces/Component_class.h Show annotated file Show diff for this revision Revisions of this file
Components/Interfaces/StepperMotor_class.h Show annotated file Show diff for this revision Revisions of this file
Components/powerstep01/powerstep01.h Show annotated file Show diff for this revision Revisions of this file
Components/powerstep01/powerstep01_class.cpp Show annotated file Show diff for this revision Revisions of this file
Components/powerstep01/powerstep01_class.h Show annotated file Show diff for this revision Revisions of this file
--- a/Components/Common/motor.h	Tue Apr 05 15:18:56 2016 +0000
+++ b/Components/Common/motor.h	Thu Apr 07 16:11:47 2016 +0000
@@ -2,8 +2,8 @@
   ******************************************************************************
   * @file    motor.h
   * @author  IPC Rennes
-  * @version V1.5.0
-  * @date    January 25, 2016
+  * @version V1.6.0
+  * @date    April 7th, 2016
   * @brief   This file contains all the functions prototypes for motor drivers.   
   ******************************************************************************
   * @attention
@@ -269,7 +269,7 @@
   /// Function pointer to GetDeviceState
   motorState_t(*GetDeviceState)(void *handle); 
   /// Function pointer to GetFwVersion
-  uint8_t (*GetFwVersion)(void *handle); 
+  uint32_t (*GetFwVersion)(void *handle); 
   /// Function pointer to GetMark
   int32_t (*GetMark)(void *handle); 
   /// Function pointer to GetMaxSpeed
@@ -329,7 +329,7 @@
   /// Function pointer to Reset
   void (*Reset)(void *handle); 
   /// Function pointer to SelectStepMode
-  void (*SelectStepMode)(void *handle, motorStepMode_t);
+  bool (*SelectStepMode)(void *handle, motorStepMode_t);
   /// Function pointer to SetDirection
   void (*SetDirection)(void *handle, motorDir_t direction);
   /// Function pointer to CmdGoToDir
--- a/Components/Interfaces/Component_class.h	Tue Apr 05 15:18:56 2016 +0000
+++ b/Components/Interfaces/Component_class.h	Thu Apr 07 16:11:47 2016 +0000
@@ -68,14 +68,6 @@
      * @retval     "0" in case of success, an error code otherwise.
      */
     virtual int ReadID(uint8_t *id) = 0;
-    
-    /**
-     * @brief  Getting the version of the firmware.
-     * @param  None.
-     * @retval The version of the firmware.
-     */
-    virtual unsigned int GetFwVersion(void) = 0;
-
 };
 
 #endif /* __COMPONENT_CLASS_H */
--- a/Components/Interfaces/StepperMotor_class.h	Tue Apr 05 15:18:56 2016 +0000
+++ b/Components/Interfaces/StepperMotor_class.h	Thu Apr 07 16:11:47 2016 +0000
@@ -1,15 +1,15 @@
 /**
  ******************************************************************************
  * @file    StepperMotor_class.h
- * @author  IPC Rennes
- * @version V1.2.0
- * @date    March 18th, 2016
+ * @author  Davide Aliprandi, STMicroelectronics
+ * @version V1.1.0
+ * @date    April 6th, 2016
  * @brief   This file contains the abstract class describing the interface of a
  *          stepper-motor component.
  ******************************************************************************
  * @attention
  *
- * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+ * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
@@ -60,17 +60,28 @@
      */
     typedef enum
     {
-      BWD = 0, /* Backward. */
-      FWD = 1  /* Forward. */
+        BWD = 0, /* Backward. */
+        FWD = 1  /* Forward. */
     } direction_t;
 
     /**
-     * @brief  Attaching an error handler.
-     * @param  fptr An error handler.
-     * @retval None.
+     * @brief Step modes.
      */
-    virtual void AttachErrorHandler(void (*fptr)(uint16_t error)) = 0;
-    
+    typedef enum
+    {
+        STEP_MODE_FULL = 0, /* Full-step. */
+        STEP_MODE_HALF,     /* Half-step. */
+        STEP_MODE_1_4,      /* 1/4 microstep. */
+        STEP_MODE_1_8,      /* 1/8 microstep. */
+        STEP_MODE_1_16,     /* 1/16 microstep. */
+        STEP_MODE_1_32,     /* 1/32 microstep. */
+        STEP_MODE_1_64,     /* 1/64 microstep. */
+        STEP_MODE_1_128,    /* 1/128 microstep. */
+        STEP_MODE_1_256,    /* 1/256 microstep. */
+        STEP_MODE_UNKNOWN,
+        STEP_MODE_WAVE      /* Full-step one-phase-on*/
+    } step_mode_t;
+
     /**
      * @brief  Getting the status.
      * @param  None.
@@ -79,20 +90,6 @@
     virtual unsigned int GetStatus(void) = 0;
 
     /**
-     * @brief  Getting a parameter in the register format
-     * @param  parameter The parameter's identifier (or its register address).
-     * @retval The parameter's value in the register format (digital value)
-     */
-    virtual unsigned int GetParameter(unsigned int parameter) = 0;
-
-    /**
-     * @brief  Getting a parameter value in float format
-     * @param  parameter The parameter's identifier (or its register address).
-     * @retval The parameter's value in float format (analog value)
-     */
-    virtual float GetAnalogValue(unsigned int parameter) = 0;
-
-    /**
      * @brief  Getting the position.
      * @param  None.
      * @retval The position.
@@ -105,7 +102,7 @@
      * @retval The marked position.
      */
     virtual signed int GetMark(void) = 0;
-    
+
     /**
      * @brief  Getting the current speed in pps.
      * @param  None.
@@ -140,29 +137,13 @@
      * @retval The deceleration in pps^2.
      */
     virtual unsigned int GetDeceleration(void) = 0;
-    
+
     /**
      * @brief  Getting the direction of rotation.
      * @param  None.
      * @retval The direction of rotation.
      */
     virtual direction_t GetDirection(void) = 0;
-    
-   /**
-     * @brief  Setting a parameter.
-     * @param  parameter The parameter's identifier (or its register address).
-     * @param  value The parameter's value in the register format (digital value)
-     * @retval None.
-     */
-    virtual void SetParameter(unsigned int parameter, unsigned int value) = 0;
-
-   /**
-     * @brief  Setting a parameter.
-     * @param  parameter The parameter's identifier (or its register address).
-     * @param  value The parameter's value in a float format (analog value)
-     * @retval None.
-     */
-    virtual bool SetAnalogValue(unsigned int parameter, float value) = 0;
 
     /**
      * @brief  Setting the current position to be the home position.
@@ -181,37 +162,37 @@
     /**
      * @brief  Setting the maximum speed in pps.
      * @param  speed The maximum speed in pps.
-     * @retval TRUE if value is valid, FALSE otherwise.
+     * @retval "true" in case of success, "false" otherwise.
      */
     virtual bool SetMaxSpeed(unsigned int speed) = 0;
 
     /**
      * @brief  Setting the minimum speed in pps.
      * @param  speed The minimum speed in pps.
-     * @retval TRUE if value is valid, FALSE otherwise.
+     * @retval "true" in case of success, "false" otherwise.
      */
     virtual bool SetMinSpeed(unsigned int speed) = 0;
 
     /**
      * @brief  Setting the acceleration in pps^2.
      * @param  acceleration The acceleration in pps^2.
-     * @retval TRUE if value is valid, FALSE otherwise.
+     * @retval "true" in case of success, "false" otherwise.
      */
-    virtual bool SetAcceleration(unsigned int speed) = 0;
+    virtual bool SetAcceleration(unsigned int acceleration) = 0;
 
     /**
      * @brief  Setting the deceleration in pps^2.
      * @param  deceleration The deceleration in pps^2.
-     * @retval TRUE if value is valid, FALSE otherwise.
+     * @retval "true" in case of success, "false" otherwise.
      */
-    virtual bool SetDeceleration(unsigned int speed) = 0;
-   
+    virtual bool SetDeceleration(unsigned int deceleration) = 0;
+
     /**
      * @brief  Setting the Step Mode.
      * @param  step_mode The Step Mode.
-     * @retval None.
+     * @retval "true" in case of success, "false" otherwise.
      */
-    virtual void SetStepMode(motorStepMode_t step_mode) = 0;
+    virtual bool SetStepMode(step_mode_t step_mode) = 0;
 
     /**
      * @brief  Going to a specified position.
@@ -283,9 +264,8 @@
      * @retval None.
      */
     virtual void WaitWhileActive(void) = 0;
-
 };
 
 #endif /* __STEPPERMOTOR_CLASS_H */
 
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 
--- a/Components/powerstep01/powerstep01.h	Tue Apr 05 15:18:56 2016 +0000
+++ b/Components/powerstep01/powerstep01.h	Thu Apr 07 16:11:47 2016 +0000
@@ -62,8 +62,16 @@
 /** @defgroup Powerstep01_Exported_Defines Powerstep01_Exported_Defines
  * @{
  */
+/// Current FW major version
+#define POWERSTEP01_FW_MAJOR_VERSION (uint8_t)(1)
+/// Current FW minor version
+#define POWERSTEP01_FW_MINOR_VERSION (uint8_t)(2)
+/// Current FW patch version
+#define POWERSTEP01_FW_PATCH_VERSION (uint8_t)(0)
 /// Current FW version
-#define POWERSTEP01_FW_VERSION (2)
+#define POWERSTEP01_FW_VERSION (uint32_t)((POWERSTEP01_FW_MAJOR_VERSION<<16)|\
+                                          (POWERSTEP01_FW_MINOR_VERSION<<8)|\
+                                          (POWERSTEP01_FW_PATCH_VERSION))
 
 /// Powerstep01 max number of bytes of command & arguments to set a parameter
 #define POWERSTEP01_CMD_ARG_MAX_NB_BYTES              (4)
@@ -116,7 +124,7 @@
 #define POWERSTEP01_MIN_POSITION (int32_t)(0xFFE00000)
     
 /// powerSTEP01 error base number
-#define POWERSTEP01_ERROR_BASE              (0x7000)
+#define POWERSTEP01_ERROR_BASE              (0xB000)
 
 /// powerSTEP01 acceleration and deceleration max value
 #define POWERSTEP01_ACC_DEC_MAX_VALUE       (float)(59590)
--- a/Components/powerstep01/powerstep01_class.cpp	Tue Apr 05 15:18:56 2016 +0000
+++ b/Components/powerstep01/powerstep01_class.cpp	Thu Apr 07 16:11:47 2016 +0000
@@ -41,11 +41,8 @@
 
 /* Definitions ---------------------------------------------------------------*/
 
-/* Error while initialising the SPI. */
-#define POWERSTEP01_ERROR_0        (0x8000)   
-
 /* Error of bad SPI transaction. */
-#define POWERSTEP01_ERROR_1        (0x8001)
+#define POWERSTEP01_ERROR_1        (POWERSTEP01_ERROR_BASE|0x0001)
 
 /* Variables  ----------------------------------------------------------------*/
 
@@ -453,7 +450,7 @@
  * @brief Returns the FW version of the library
  * @retval POWERSTEP01_FW_VERSION
  **********************************************************/
-uint8_t POWERSTEP01::Powerstep01_GetFwVersion(void)
+uint32_t POWERSTEP01::Powerstep01_GetFwVersion(void)
 {
   return (POWERSTEP01_FW_VERSION);
 }
@@ -512,7 +509,7 @@
  * as specified in enum motorStepMode_t
  * @retval None
  **********************************************************/
-void POWERSTEP01::Powerstep01_SelectStepMode(motorStepMode_t stepMode)
+bool POWERSTEP01::Powerstep01_SelectStepMode(motorStepMode_t stepMode)
 {
   uint8_t stepModeRegister;
   powerstep01_StepSel_t powerstep01StepMode;
@@ -541,9 +538,10 @@
       powerstep01StepMode = POWERSTEP01_STEP_SEL_1_64;
       break;
     case STEP_MODE_1_128:
+      powerstep01StepMode = POWERSTEP01_STEP_SEL_1_128;
+      break;
     default:
-      powerstep01StepMode = POWERSTEP01_STEP_SEL_1_128;
-      break;       
+      return false;
   }
   
   /* Set the powerstep01 in HiZ state */
@@ -558,6 +556,7 @@
   /* Reset abs pos register */
   Powerstep01_CmdResetPos();
 
+  return true;
 }
 
 /**********************************************************
--- a/Components/powerstep01/powerstep01_class.h	Tue Apr 05 15:18:56 2016 +0000
+++ b/Components/powerstep01/powerstep01_class.h	Thu Apr 07 16:11:47 2016 +0000
@@ -158,30 +158,10 @@
     }
 
     /**
-     * @brief  Getting the version of the firmware.
-     * @param  None.
-     * @retval The version of the firmware.
-     */
-    virtual unsigned int GetFwVersion(void)
-    {
-        return (unsigned int) Powerstep01_GetFwVersion();
-    }
-
-    /**
      * @brief Public functions inherited from the StepperMotor Class
      */
 
     /**
-     * @brief  Attaching an error handler.
-     * @param  fptr An error handler.
-     * @retval None.
-     */
-    virtual void AttachErrorHandler(void (*fptr)(uint16_t error))
-    {
-        Powerstep01_AttachErrorHandler((void (*)(uint16_t error)) fptr);
-    }
-
-    /**
      * @brief  Getting the value of the Status Register.
      * @param  None.
      * @retval None.
@@ -192,86 +172,6 @@
         return (unsigned int) Powerstep01_CmdGetStatus();
     }
 
-   /**
-     * @brief  Getting a parameter register value.
-     * @param  parameter A parameter's register adress.
-     * @retval The parameter's register value.
-     *         parameter can be one of the following:
-     *           + POWERSTEP01_ABS_POS
-     *           + POWERSTEP01_EL_POS
-     *           + POWERSTEP01_MARK
-     *           + POWERSTEP01_SPEED
-     *           + POWERSTEP01_ACC
-     *           + POWERSTEP01_DEC
-     *           + POWERSTEP01_MAX_SPEED
-     *           + POWERSTEP01_MIN_SPEED
-     *           (voltage mode) + POWERSTEP01_KVAL_HOLD : value in %
-     *           (current mode) + POWERSTEP01_TVAL_HOLD : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_RUN  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_RUN  : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_ACC  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_ACC  : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_DEC  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_DEC  : value in mV
-     *           (voltage mode) + POWERSTEP01_INT_SPD
-     *           (voltage mode) + POWERSTEP01_ST_SLP
-     *           (current mode) + POWERSTEP01_T_FAST
-     *           (voltage mode) + POWERSTEP01_FN_SLP_ACC
-     *           (current mode) + POWERSTEP01_TON_MIN
-     *           (voltage mode) + POWERSTEP01_FN_SLP_DEC
-     *           (current mode) + POWERSTEP01_TOFF_MIN
-     *           (voltage mode) + POWERSTEP01_K_THERM
-     *           + POWERSTEP01_ADC_OUT
-     *           + POWERSTEP01_OCD_TH
-     *           (voltage mode) + POWERSTEP01_STALL_TH
-     *           + POWERSTEP01_FS_SPD
-     *           + POWERSTEP01_STEP_MODE
-     *           + POWERSTEP01_ALARM_EN
-     *           + POWERSTEP01_GATECFG1
-     *           + POWERSTEP01_GATECFG2
-     *           + POWERSTEP01_CONFIG
-     *           + POWERSTEP01_STATUS
-     */
-    virtual unsigned int GetParameter(unsigned int parameter)
-    {
-      return (unsigned int) Powerstep01_CmdGetParam((powerstep01_Registers_t)parameter);
-    }
-
-   /**
-     * @brief  Getting a parameter float value.
-     * @param  parameter A parameter's register adress.
-     * @retval The parameter's float value.
-     *         parameter can be one of the following:
-     *           + POWERSTEP01_ABS_POS
-     *           + POWERSTEP01_MARK
-     *           + POWERSTEP01_ACC
-     *           + POWERSTEP01_DEC
-     *           + POWERSTEP01_SPEED     
-     *           + POWERSTEP01_MAX_SPEED
-     *           + POWERSTEP01_MIN_SPEED
-     *           + POWERSTEP01_FS_SPD
-     *           (voltage mode) + POWERSTEP01_INT_SPD
-     *           (voltage mode) + POWERSTEP01_K_THERM
-     *           + POWERSTEP01_OCD_TH
-     *           (voltage mode) + POWERSTEP01_STALL_TH
-     *           (voltage mode) + POWERSTEP01_KVAL_HOLD : value in %
-     *           (current mode) + POWERSTEP01_TVAL_HOLD : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_RUN  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_RUN  : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_ACC  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_ACC  : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_DEC  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_DEC  : value in mV
-     *           (voltage mode) + POWERSTEP01_ST_SLP
-     *           (voltage mode) + POWERSTEP01_FN_SLP_ACC
-     *           (voltage mode) + POWERSTEP01_FN_SLP_DEC
-     */
-    virtual float GetAnalogValue(unsigned int parameter)
-    {
-      return Powerstep01_GetAnalogValue((powerstep01_Registers_t)parameter);
-    }
-
-
     /**
      * @brief  Getting the position.
      * @param  None.
@@ -359,87 +259,6 @@
         }
     }
     
-   /**
-     * @brief  Setting a parameter.
-     * @param  parameter A parameter's register adress.
-     * @param  value The parameter's value.
-     * @retval None.
-     *         parameter can be one of the following:
-     *           + POWERSTEP01_ABS_POS
-     *           + POWERSTEP01_EL_POS
-     *           + POWERSTEP01_MARK
-     *           + POWERSTEP01_ACC
-     *           + POWERSTEP01_DEC
-     *           + POWERSTEP01_MAX_SPEED
-     *           + POWERSTEP01_MIN_SPEED
-     *           (voltage mode) + POWERSTEP01_KVAL_HOLD : value in %
-     *           (current mode) + POWERSTEP01_TVAL_HOLD : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_RUN  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_RUN  : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_ACC  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_ACC  : value in mV
-     *           (voltage mode) + POWERSTEP01_KVAL_DEC  : value in %
-     *           (current mode) + POWERSTEP01_TVAL_DEC  : value in mV
-     *           (voltage mode) + POWERSTEP01_INT_SPD
-     *           (voltage mode) + POWERSTEP01_ST_SLP
-     *           (current mode) + POWERSTEP01_T_FAST
-     *           (voltage mode) + POWERSTEP01_FN_SLP_ACC
-     *           (current mode) + POWERSTEP01_TON_MIN
-     *           (voltage mode) + POWERSTEP01_FN_SLP_DEC
-     *           (current mode) + POWERSTEP01_TOFF_MIN
-     *           (voltage mode) + POWERSTEP01_K_THERM
-     *           + POWERSTEP01_ADC_OUT
-     *           + POWERSTEP01_OCD_TH
-     *           (voltage mode) + POWERSTEP01_STALL_TH
-     *           + POWERSTEP01_FS_SPD
-     *           + POWERSTEP01_STEP_MODE
-     *           + POWERSTEP01_ALARM_EN
-     *           + POWERSTEP01_GATECFG1
-     *           + POWERSTEP01_GATECFG2
-     *           + POWERSTEP01_CONFIG
-     */
-    virtual void SetParameter(unsigned int parameter, unsigned int value)
-    {
-        Powerstep01_CmdSetParam((powerstep01_Registers_t)parameter, (uint32_t)value);
-    }
-
-   /**
-     * @brief  Setting a parameter with an input float value.
-     * @param  param Register adress.
-     * @param  value Float value to convert and set into the register.
-     * @retval TRUE if param and value are valid, FALSE otherwise
-     * @note   parameter can be one of the following:
-     *           + POWERSTEP01_EL_POS
-     *           + POWERSTEP01_ABS_POS
-     *           + POWERSTEP01_MARK
-     *           + POWERSTEP01_ACC
-     *           + POWERSTEP01_DEC
-     *           + POWERSTEP01_MAX_SPEED
-     *           + POWERSTEP01_MIN_SPEED
-     *           + POWERSTEP01_FS_SPD
-     *           + POWERSTEP01_INT_SPD
-     *           + POWERSTEP01_K_THERM
-     *           + POWERSTEP01_OCD_TH
-     *           + POWERSTEP01_STALL_TH
-     *           + POWERSTEP01_KVAL_HOLD
-     *           + POWERSTEP01_KVAL_RUN
-     *           + POWERSTEP01_KVAL_ACC
-     *           + POWERSTEP01_KVAL_DEC
-     *           + POWERSTEP01_ST_SLP
-     *           + POWERSTEP01_FN_SLP_ACC
-     *           + POWERSTEP01_FN_SLP_DEC
-     *           + POWERSTEP01_TVAL_HOLD
-     *           + POWERSTEP01_TVAL_RUN
-     *           + POWERSTEP01_TVAL_ACC
-     *           + POWERSTEP01_TVAL_DEC
-     *           + POWERSTEP01_TON_MIN
-     *           + POWERSTEP01_TOFF_MIN
-     */
-    virtual bool SetAnalogValue(unsigned int param, float value)
-    {
-      return Powerstep01_SetAnalogValue((powerstep01_Registers_t)param, value);
-    }
-
     /**
      * @brief  Setting the current position to be the home position.
      * @param  None.
@@ -514,9 +333,9 @@
      *           + STEP_MODE_1_64
      *           + STEP_MODE_1_128
      */
-    virtual void SetStepMode(motorStepMode_t step_mode)
+    virtual bool SetStepMode(step_mode_t step_mode)
     {
-        Powerstep01_SelectStepMode((motorStepMode_t) step_mode);
+        return Powerstep01_SelectStepMode((motorStepMode_t) step_mode);
     }
 
     /**
@@ -565,17 +384,6 @@
     }
 
     /**
-     * @brief  Running the motor towards a specified direction.
-     * @param  direction The direction of rotation.
-     * @param  speed in steps/s.
-     * @retval None.
-     */
-    virtual void Run(direction_t direction, float speed)
-    {
-        Powerstep01_CmdRun((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD), Speed_Steps_s_to_RegVal(speed));
-    }
-
-    /**
      * @brief  Moving the motor towards a specified direction for a certain number of steps.
      * @param  direction The direction of rotation.
      * @param  steps The desired number of steps.
@@ -639,7 +447,17 @@
     /**
      * @brief Public functions NOT inherited
      */
-
+     
+    /**
+     * @brief  Attaching an error handler.
+     * @param  fptr An error handler.
+     * @retval None.
+     */
+    virtual void AttachErrorHandler(void (*fptr)(uint16_t error))
+    {
+        Powerstep01_AttachErrorHandler((void (*)(uint16_t error)) fptr);
+    }
+    
     /**
      * @brief  Checks if the device is busy by reading the busy pin position.
      * @param  None.
@@ -680,6 +498,40 @@
     }
 
     /**
+     * @brief  Getting a parameter float value.
+     * @param  parameter A parameter's register adress.
+     * @retval The parameter's float value.
+     *         parameter can be one of the following:
+     *           + POWERSTEP01_ABS_POS
+     *           + POWERSTEP01_MARK
+     *           + POWERSTEP01_ACC
+     *           + POWERSTEP01_DEC
+     *           + POWERSTEP01_SPEED     
+     *           + POWERSTEP01_MAX_SPEED
+     *           + POWERSTEP01_MIN_SPEED
+     *           + POWERSTEP01_FS_SPD
+     *           (voltage mode) + POWERSTEP01_INT_SPD
+     *           (voltage mode) + POWERSTEP01_K_THERM
+     *           + POWERSTEP01_OCD_TH
+     *           (voltage mode) + POWERSTEP01_STALL_TH
+     *           (voltage mode) + POWERSTEP01_KVAL_HOLD : value in %
+     *           (current mode) + POWERSTEP01_TVAL_HOLD : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_RUN  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_RUN  : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_ACC  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_ACC  : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_DEC  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_DEC  : value in mV
+     *           (voltage mode) + POWERSTEP01_ST_SLP
+     *           (voltage mode) + POWERSTEP01_FN_SLP_ACC
+     *           (voltage mode) + POWERSTEP01_FN_SLP_DEC
+     */
+    virtual float GetAnalogValue(unsigned int parameter)
+    {
+      return Powerstep01_GetAnalogValue((powerstep01_Registers_t)parameter);
+    }
+
+    /**
      * @brief Get the value of the STATUS register which was 
      * fetched by using Powerstep01_FetchAndClearAllStatus.
      * The fetched values are available  as long as there
@@ -690,6 +542,61 @@
     {
         return Powerstep01_GetFetchedStatus();
     }
+
+    /**
+     * @brief  Getting the version of the firmware.
+     * @param  None.
+     * @retval The version of the firmware.
+     */
+    virtual unsigned int GetFwVersion(void)
+    {
+        return (unsigned int) Powerstep01_GetFwVersion();
+    }
+
+    /**
+     * @brief  Getting a parameter register value.
+     * @param  parameter A parameter's register adress.
+     * @retval The parameter's register value.
+     *         parameter can be one of the following:
+     *           + POWERSTEP01_ABS_POS
+     *           + POWERSTEP01_EL_POS
+     *           + POWERSTEP01_MARK
+     *           + POWERSTEP01_SPEED
+     *           + POWERSTEP01_ACC
+     *           + POWERSTEP01_DEC
+     *           + POWERSTEP01_MAX_SPEED
+     *           + POWERSTEP01_MIN_SPEED
+     *           (voltage mode) + POWERSTEP01_KVAL_HOLD : value in %
+     *           (current mode) + POWERSTEP01_TVAL_HOLD : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_RUN  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_RUN  : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_ACC  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_ACC  : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_DEC  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_DEC  : value in mV
+     *           (voltage mode) + POWERSTEP01_INT_SPD
+     *           (voltage mode) + POWERSTEP01_ST_SLP
+     *           (current mode) + POWERSTEP01_T_FAST
+     *           (voltage mode) + POWERSTEP01_FN_SLP_ACC
+     *           (current mode) + POWERSTEP01_TON_MIN
+     *           (voltage mode) + POWERSTEP01_FN_SLP_DEC
+     *           (current mode) + POWERSTEP01_TOFF_MIN
+     *           (voltage mode) + POWERSTEP01_K_THERM
+     *           + POWERSTEP01_ADC_OUT
+     *           + POWERSTEP01_OCD_TH
+     *           (voltage mode) + POWERSTEP01_STALL_TH
+     *           + POWERSTEP01_FS_SPD
+     *           + POWERSTEP01_STEP_MODE
+     *           + POWERSTEP01_ALARM_EN
+     *           + POWERSTEP01_GATECFG1
+     *           + POWERSTEP01_GATECFG2
+     *           + POWERSTEP01_CONFIG
+     *           + POWERSTEP01_STATUS
+     */
+    virtual unsigned int GetRawParameter(unsigned int parameter)
+    {
+      return (unsigned int) Powerstep01_CmdGetParam((powerstep01_Registers_t)parameter);
+    }
     
     /**
      * @brief  Issues PowerStep01 Go Until command.
@@ -783,7 +690,18 @@
     {
         Powerstep01_CmdResetPos();
     }
-    
+
+    /**
+     * @brief  Running the motor towards a specified direction.
+     * @param  direction The direction of rotation.
+     * @param  speed in steps/s.
+     * @retval None.
+     */
+    virtual void Run(direction_t direction, float speed)
+    {
+        Powerstep01_CmdRun((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD), Speed_Steps_s_to_RegVal(speed));
+    }
+        
     /**
      * @brief Sends commands stored previously in the queue by QueueCommands.
      * @param  None.
@@ -795,6 +713,87 @@
     }
     
     /**
+     * @brief  Setting a parameter with an input float value.
+     * @param  param Register adress.
+     * @param  value Float value to convert and set into the register.
+     * @retval TRUE if param and value are valid, FALSE otherwise
+     * @note   parameter can be one of the following:
+     *           + POWERSTEP01_EL_POS
+     *           + POWERSTEP01_ABS_POS
+     *           + POWERSTEP01_MARK
+     *           + POWERSTEP01_ACC
+     *           + POWERSTEP01_DEC
+     *           + POWERSTEP01_MAX_SPEED
+     *           + POWERSTEP01_MIN_SPEED
+     *           + POWERSTEP01_FS_SPD
+     *           + POWERSTEP01_INT_SPD
+     *           + POWERSTEP01_K_THERM
+     *           + POWERSTEP01_OCD_TH
+     *           + POWERSTEP01_STALL_TH
+     *           + POWERSTEP01_KVAL_HOLD
+     *           + POWERSTEP01_KVAL_RUN
+     *           + POWERSTEP01_KVAL_ACC
+     *           + POWERSTEP01_KVAL_DEC
+     *           + POWERSTEP01_ST_SLP
+     *           + POWERSTEP01_FN_SLP_ACC
+     *           + POWERSTEP01_FN_SLP_DEC
+     *           + POWERSTEP01_TVAL_HOLD
+     *           + POWERSTEP01_TVAL_RUN
+     *           + POWERSTEP01_TVAL_ACC
+     *           + POWERSTEP01_TVAL_DEC
+     *           + POWERSTEP01_TON_MIN
+     *           + POWERSTEP01_TOFF_MIN
+     */
+    virtual bool SetAnalogValue(unsigned int param, float value)
+    {
+      return Powerstep01_SetAnalogValue((powerstep01_Registers_t)param, value);
+    }
+    
+    /**
+     * @brief  Setting a parameter.
+     * @param  parameter A parameter's register adress.
+     * @param  value The parameter's value.
+     * @retval None.
+     *         parameter can be one of the following:
+     *           + POWERSTEP01_ABS_POS
+     *           + POWERSTEP01_EL_POS
+     *           + POWERSTEP01_MARK
+     *           + POWERSTEP01_ACC
+     *           + POWERSTEP01_DEC
+     *           + POWERSTEP01_MAX_SPEED
+     *           + POWERSTEP01_MIN_SPEED
+     *           (voltage mode) + POWERSTEP01_KVAL_HOLD : value in %
+     *           (current mode) + POWERSTEP01_TVAL_HOLD : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_RUN  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_RUN  : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_ACC  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_ACC  : value in mV
+     *           (voltage mode) + POWERSTEP01_KVAL_DEC  : value in %
+     *           (current mode) + POWERSTEP01_TVAL_DEC  : value in mV
+     *           (voltage mode) + POWERSTEP01_INT_SPD
+     *           (voltage mode) + POWERSTEP01_ST_SLP
+     *           (current mode) + POWERSTEP01_T_FAST
+     *           (voltage mode) + POWERSTEP01_FN_SLP_ACC
+     *           (current mode) + POWERSTEP01_TON_MIN
+     *           (voltage mode) + POWERSTEP01_FN_SLP_DEC
+     *           (current mode) + POWERSTEP01_TOFF_MIN
+     *           (voltage mode) + POWERSTEP01_K_THERM
+     *           + POWERSTEP01_ADC_OUT
+     *           + POWERSTEP01_OCD_TH
+     *           (voltage mode) + POWERSTEP01_STALL_TH
+     *           + POWERSTEP01_FS_SPD
+     *           + POWERSTEP01_STEP_MODE
+     *           + POWERSTEP01_ALARM_EN
+     *           + POWERSTEP01_GATECFG1
+     *           + POWERSTEP01_GATECFG2
+     *           + POWERSTEP01_CONFIG
+     */
+    virtual void SetRawParameter(unsigned int parameter, unsigned int value)
+    {
+        Powerstep01_CmdSetParam((powerstep01_Registers_t)parameter, (uint32_t)value);
+    }
+    
+    /**
      * @brief  Enable the step clock mode.
      * @param  frequency the frequency of PWM.
      * @retval None.
@@ -1250,12 +1249,12 @@
     void Powerstep01_ErrorHandler(uint16_t error);
     void Powerstep01_FetchAndClearAllStatus(void); 
     uint16_t Powerstep01_GetFetchedStatus(void);
-    uint8_t Powerstep01_GetFwVersion(void);
+    uint32_t Powerstep01_GetFwVersion(void);
     int32_t Powerstep01_GetMark(void);
     int32_t Powerstep01_GetPosition(void);
     bool Powerstep01_IsDeviceBusy(void);
     uint16_t Powerstep01_ReadStatusRegister(void);
-    void Powerstep01_SelectStepMode(motorStepMode_t stepMode);
+    bool Powerstep01_SelectStepMode(motorStepMode_t stepMode);
     void Powerstep01_SetHome(void);
     void Powerstep01_SetMark(void);
     void Powerstep01_WaitForAllDevicesNotBusy(void);