Library to handle the X-NUCLEO-IHM06A1 Motor Control Expansion Board based on the STSPIN220 component.

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_IHM06A1

Fork of X-NUCLEO-IHM06A1 by ST Expansion SW Team

Motor Control Library

Library to handle the X-NUCLEO-IHM06A1 Motor Control Expansion Board based on the STSPIN220 component.

It features the:

  • Read and write of the device parameters; GPIO, PWM and IRQ configuration; microstepping, direction position, speed, acceleration, deceleration and torque controls
  • Automatic full-step switch management; high impedance or hold stop mode selection; enable and standby management
  • Fault interrupts handling (over current, short-circuit and over temperature)
  • Command locking until the device completes movement

The API allows to easily:

  • perform various positioning, moves and stops
  • get/set or monitor the motor positions
  • set the home position and mark another position
  • get/set the minimum and maximum speed
  • get the current speed
  • get/set the acceleration and deceleration
  • get/set the stop mode (hold, hiz or standby)
  • get/set the torque
  • get/set the torque boost
  • get/set the step mode (up to 1/256)

Platform compatibility

Compatible platforms have been tested with the configurations provided by the HelloWorld_IHM06A1 example.

Files at this revision

API Documentation at this revision

Comitter:
davide.aliprandi@st.com
Date:
Fri Mar 24 10:59:19 2017 +0100
Parent:
2:2ba230b24f25
Child:
4:265c30b9112a
Commit message:
Aligning to ARM mbed coding style.

Changed in this revision

Components/Common/component.h Show diff for this revision Revisions of this file
Components/Common/component_def.h Show annotated file Show diff for this revision Revisions of this file
Components/Common/motor.h Show diff for this revision Revisions of this file
Components/Common/motor_def.h Show annotated file Show diff for this revision Revisions of this file
Components/Interfaces/Component_class.h Show diff for this revision Revisions of this file
Components/Interfaces/StepperMotor_class.h Show diff for this revision Revisions of this file
Components/stspin220/STSpin220.cpp Show annotated file Show diff for this revision Revisions of this file
Components/stspin220/STSpin220_config.h Show annotated file Show diff for this revision Revisions of this file
Components/stspin220/STSpin220_def.h Show annotated file Show diff for this revision Revisions of this file
Components/stspin220/stspin220.h Show annotated file Show diff for this revision Revisions of this file
Components/stspin220/stspin220_class.cpp Show diff for this revision Revisions of this file
Components/stspin220/stspin220_class.h Show diff for this revision Revisions of this file
Components/stspin220/stspin220_target_config.h Show diff for this revision Revisions of this file
ST_INTERFACES.lib Show annotated file Show diff for this revision Revisions of this file
--- a/Components/Common/component.h	Wed Jul 27 12:00:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/**
- ******************************************************************************
- * @file    component.h
- * @author  AST
- * @version V1.0.0
- * @date    1 April 2015
- * @brief   Generic header file containing a generic component's definitions
- *          and I/O functions.
- ******************************************************************************
- * @attention
- *
- * <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:
- *   1. Redistributions of source code must retain the above copyright notice,
- *      this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright notice,
- *      this list of conditions and the following disclaimer in the documentation
- *      and/or other materials provided with the distribution.
- *   3. Neither the name of STMicroelectronics nor the names of its contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-
-#ifndef __COMPONENT_H
-#define __COMPONENT_H
-
-
-/* Types ---------------------------------------------------------------------*/
-
-/**
- * @brief  Component's Context structure definition.
- */
-typedef struct
-{  
-    /* Identity. */
-    uint8_t who_am_i;
-
-    /* ACTION ----------------------------------------------------------------*/
-    /* There should be only a unique identifier for each component, which     */
-    /* should be the "who_am_i" parameter, hence this parameter is optional.  */
-    /* -----------------------------------------------------------------------*/
-    /* Type. */
-    uint8_t type;
-
-    /* Configuration. */
-    uint8_t address;
-
-    /* Pointer to the Data. */
-    void *pData;
-
-    /* Pointer to the Virtual Table. */
-    void *pVTable;
-
-    /* ACTION ----------------------------------------------------------------*/
-    /* There should be only a unique virtual table for each component, which  */
-    /* should be the "pVTable" parameter, hence this parameter is optional.   */
-    /* -----------------------------------------------------------------------*/
-    /* Pointer to the Extended Virtual Table. */
-    void *pExtVTable;
-} Handle_t;
-
-/**
- * @brief  Component's Status enumerator definition.
- */
-typedef enum
-{
-    COMPONENT_OK = 0,
-    COMPONENT_ERROR,
-    COMPONENT_TIMEOUT,
-    COMPONENT_NOT_IMPLEMENTED
-} Status_t;
-
-#endif /* __COMPONENT_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/component_def.h	Fri Mar 24 10:59:19 2017 +0100
@@ -0,0 +1,93 @@
+/**
+ ******************************************************************************
+ * @file    component_def.h
+ * @author  AST
+ * @version V1.0.0
+ * @date    1 April 2015
+ * @brief   Generic header file containing a generic component's definitions
+ *          and I/O functions.
+ ******************************************************************************
+ * @attention
+ *
+ * <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:
+ *   1. Redistributions of source code must retain the above copyright notice,
+ *      this list of conditions and the following disclaimer.
+ *   2. Redistributions in binary form must reproduce the above copyright notice,
+ *      this list of conditions and the following disclaimer in the documentation
+ *      and/or other materials provided with the distribution.
+ *   3. Neither the name of STMicroelectronics nor the names of its contributors
+ *      may be used to endorse or promote products derived from this software
+ *      without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+
+#ifndef __COMPONENT_H
+#define __COMPONENT_H
+
+
+/* Types ---------------------------------------------------------------------*/
+
+/**
+ * @brief  Component's Context structure definition.
+ */
+typedef struct
+{  
+    /* Identity. */
+    uint8_t who_am_i;
+
+    /* ACTION ----------------------------------------------------------------*/
+    /* There should be only a unique identifier for each component, which     */
+    /* should be the "who_am_i" parameter, hence this parameter is optional.  */
+    /* -----------------------------------------------------------------------*/
+    /* Type. */
+    uint8_t type;
+
+    /* Configuration. */
+    uint8_t address;
+
+    /* Pointer to the Data. */
+    void *p_data;
+
+    /* Pointer to the Virtual Table. */
+    void *p_vt;
+
+    /* ACTION ----------------------------------------------------------------*/
+    /* There should be only a unique virtual table for each component, which  */
+    /* should be the "p_vt" parameter, hence this parameter is optional.      */
+    /* -----------------------------------------------------------------------*/
+    /* Pointer to the Extended Virtual Table. */
+    void *p_ext_vt;
+} handle_t;
+
+/**
+ * @brief  Component's Status enumerator definition.
+ */
+typedef enum
+{
+    COMPONENT_OK = 0,
+    COMPONENT_ERROR,
+    COMPONENT_TIMEOUT,
+    COMPONENT_NOT_IMPLEMENTED
+} status_t;
+
+#endif /* __COMPONENT_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/Common/motor.h	Wed Jul 27 12:00:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,446 +0,0 @@
-/**
-  ******************************************************************************
-  * @file    motor.h
-  * @author  IPC Rennes
-  * @version V1.5.0
-  * @date    January 25, 2016
-  * @brief   This file contains all the functions prototypes for motor drivers.   
-  ******************************************************************************
-  * @attention
-  *
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */ 
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __MOTOR_H
-#define __MOTOR_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif 
-
-/* Includes ------------------------------------------------------------------*/
-#include <stdint.h>
-#include "component.h"
-
-/* Definitions ---------------------------------------------------------------*/
-/// boolean for false condition 
-#ifndef FALSE
-#define FALSE (0)
-#endif
-/// boolean for true condition 
-#ifndef TRUE
-#define TRUE  (1)
-#endif
-
-/* Types ---------------------------------------------------------------------*/
-/** @addtogroup BSP
-  * @{
-  */
-
-/** @addtogroup Components
-  * @{
-  */ 
-
-/** @defgroup Motor Motor
-  * @{
-  */
-   
-/** @defgroup Motor_Exported_Types Motor Exported Types
-  * @{
-  */
-   
-/** @defgroup Device_Direction_Options Device Direction Options
-  * @{
-  */
-/// Direction options
-typedef enum {
-  BACKWARD = 0,
-  FORWARD = 1,
-  UNKNOW_DIR = ((uint8_t)0xFF)
-} motorDir_t;
-/**
-  * @}
-  */
-  
-/** @defgroup Device_Action_Options Device Action Options
-  * @{
-  */
-/// Action options
-typedef enum {
-  ACTION_RESET = ((uint8_t)0x00),
-  ACTION_COPY  = ((uint8_t)0x08)
-} motorAction_t;
-/**
-  * @}
-  */  
-
-/** @defgroup Device_States Device States
-  * @{
-  */
-/// Device states
-typedef enum {
-  ACCELERATING       = 0,
-  DECELERATINGTOSTOP = 1,  
-  DECELERATING       = 2, 
-  STEADY             = 3,
-  INDEX_ACCEL        = 4,
-  INDEX_RUN          = 5,
-  INDEX_DECEL        = 6,
-  INDEX_DWELL        = 7,
-  INACTIVE           = 8,
-  STANDBY            = 9,
-  STANDBYTOINACTIVE  = 10
-} motorState_t;
-/**
-  * @}
-  */   
-
-/** @defgroup Device_Step_mode Device Step mode
-  * @{
-  */
- /// Stepping options 
-typedef enum {
-  STEP_MODE_FULL   = ((uint8_t)0x00), 
-  STEP_MODE_HALF   = ((uint8_t)0x01),
-  STEP_MODE_1_4    = ((uint8_t)0x02),
-  STEP_MODE_1_8    = ((uint8_t)0x03),
-  STEP_MODE_1_16   = ((uint8_t)0x04),
-  STEP_MODE_1_32   = ((uint8_t)0x05),
-  STEP_MODE_1_64   = ((uint8_t)0x06),
-  STEP_MODE_1_128  = ((uint8_t)0x07),
-  STEP_MODE_1_256  = ((uint8_t)0x08),
-  STEP_MODE_UNKNOW = ((uint8_t)0xFE),
-  STEP_MODE_WAVE   = ((uint8_t)0xFF)  
-} motorStepMode_t;
-
-/**
-  * @}
-  */
-  
-/** @defgroup Decay_mode Decay mode
-  * @{
-  */
-/// Decay Mode 
-typedef enum {
-  SLOW_DECAY = 0,
-  FAST_DECAY = 1,
-  UNKNOW_DECAY = ((uint8_t)0xFF)
-} motorDecayMode_t;
-/**
-  * @}
-  */
-  
-/** @defgroup Stop_mode Stop mode
-  * @{
-  */
-/// Stop mode
-typedef enum
-{ 
-  HOLD_MODE = 0,
-  HIZ_MODE = 1,
-  STANDBY_MODE = 2,
-  UNKNOW_STOP_MODE = ((uint8_t)0xFF)
-} motorStopMode_t;
-/**
-  * @}
-  */  
-
-/** @defgroup Torque_mode Torque mode
-  * @{
-  */
-/// Torque mode
-typedef enum
-{ 
-  ACC_TORQUE = 0,
-  DEC_TORQUE = 1,
-  RUN_TORQUE = 2,
-  HOLD_TORQUE = 3,
-  CURRENT_TORQUE = 4,
-  UNKNOW_TORQUE = ((uint8_t)0xFF)
-} motorTorqueMode_t;
-/**
-  * @}
-  */  
-    
-/** @defgroup Dual_Full_Bridge_Configuration Dual Full Bridge Configuration
-  * @{
-  */
-///Dual full bridge configurations for brush DC motors
-typedef enum {
-  PARALLELING_NONE___1_BIDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 0,
-  PARALLELING_NONE___1_BIDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 1,
-  PARALLELING_NONE___2_UNDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 2,
-  PARALLELING_NONE___2_UNDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 3,
-  PARALLELING_IN1A_IN2A__1_UNDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 4,
-  PARALLELING_IN1A_IN2A__1_UNDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 5,
-  PARALLELING_IN1B_IN2B__1_BIDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 6,
-  PARALLELING_IN1B_IN2B__2_UNDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 7,
-  PARALLELING_IN1A_IN2A__IN1B_IN2B__1_UNDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 8,
-  PARALLELING_IN1A_IN2A__IN1B_IN2B__1_BIDIR_MOTOR = 9,
-  PARALLELING_IN1A_IN1B__IN2A_IN2B__1_UNDIR_MOTOR_BRIDGE_1A__1_UNDIR_MOTOR_BRIDGE_2A = 10,
-  PARALLELING_IN1A_IN1B__IN2A_IN2B__1_BIDIR_MOTOR = 11,
-  PARALLELING_ALL_WITH_IN1A___1_UNDIR_MOTOR = 12,
-  PARALLELING_END_ENUM = 13 
-} dualFullBridgeConfig_t;
-/**
-  * @}
-  */
-
-/** @defgroup Motor_Driver_Structure Motor Driver Structure
-  * @{
-  */
-/** 
- * @brief  MOTOR driver virtual table structure definition.
- */  
-typedef struct
-{
-  /* ACTION ----------------------------------------------------------------*
-   * Declare here the component's generic functions.                        *
-   * Tag this group of functions with the " Generic " C-style comment.      *
-   * A component's interface has to define at least the two generic         *
-   * functions provided here below within the "Example" section, as the     *
-   * first and second functions of its Virtual Table. They have to be       *
-   * specified exactly in the given way.                                    *
-   *                                                                        *
-   * Example:                                                               *
-   *   Status_t (*Init)   (void *handle, void *init);                       *
-   *   Status_t (*ReadID) (void *handle, uint8_t *id);                      *
-   *------------------------------------------------------------------------*/
-  /* Generic */
-  Status_t (*Init)(void *handle, void *init);
-  Status_t (*ReadID)(void *handle, uint8_t *id);
-  /* ACTION ----------------------------------------------------------------*
-   * Declare here the component's interrupts related functions.             *
-   * Tag this group of functions with the " Interrupts " C-style comment.   *
-   * Do not specify any function if not required.                           *
-   *                                                                        *
-   * Example:                                                               *
-   *   void     (*ConfigIT) (void *handle, int a);                          *
-   *------------------------------------------------------------------------*/
-  /* Interrupts */
-  /// Function pointer to AttachErrorHandler
-  void (*AttachErrorHandler)(void *handle, void (*callback)(void *handle, uint16_t error));
-  /// Function pointer to AttachFlagInterrupt
-  void (*AttachFlagInterrupt)(void *handle, void (*callback)(void *handle));
-  /// Function pointer to AttachBusyInterrupt
-  void (*AttachBusyInterrupt)(void *handle, void (*callback)(void *handle));
-  /// Function pointer to FlagInterruptHandler
-  void (*FlagInterruptHandler)(void *handle);
-  /* ACTION ----------------------------------------------------------------*
-   * Declare here the component's specific functions.                       *
-   * Tag this group of functions with the " Specific " C-style comment.     *
-   * Do not specify any function if not required.                           *
-   *                                                                        *
-   * Example:                                                               *
-   *   Status_t (*GetValue) (void *handle, float *f);                       *
-   *------------------------------------------------------------------------*/
-  /* Specific */  
-  /// Function pointer to GetAcceleration
-  uint16_t (*GetAcceleration)(void *handle); 
-  /// Function pointer to GetCurrentSpeed
-  uint16_t (*GetCurrentSpeed)(void *handle); 
-  /// Function pointer to GetDeceleration
-  uint16_t (*GetDeceleration)(void *handle); 
-  /// Function pointer to GetDeviceState
-  motorState_t(*GetDeviceState)(void *handle); 
-  /// Function pointer to GetFwVersion
-  uint8_t (*GetFwVersion)(void *handle); 
-  /// Function pointer to GetMark
-  int32_t (*GetMark)(void *handle); 
-  /// Function pointer to GetMaxSpeed
-  uint16_t (*GetMaxSpeed)(void *handle); 
-  /// Function pointer to GetMinSpeed
-  uint16_t (*GetMinSpeed)(void *handle); 
-  /// Function pointer to GetPosition
-  int32_t (*GetPosition)(void *handle);
-  /// Function pointer to GoHome
-  void (*GoHome)(void *handle); 
-  /// Function pointer to GoMark
-  void (*GoMark)(void *handle); 
-  /// Function pointer to GoTo
-  void (*GoTo)(void *handle, int32_t targetPosition); 
-  /// Function pointer to HardStop
-  void (*HardStop)(void *handle); 
-  /// Function pointer to Move
-  void (*Move)(void *handle, motorDir_t direction, uint32_t stepCount); 
-  /// Function pointer to ResetAllDevices
-  //void (*ResetAllDevices)(void *handle); 
-  /// Function pointer to Run
-  void (*Run)(void *handle, motorDir_t direction);
-  /// Function pointer to SetAcceleration
-  bool (*SetAcceleration)(void *handle, uint16_t newAcc);
-  /// Function pointer to SetDeceleration
-  bool (*SetDeceleration)(void *handle, uint16_t newDec);
-  /// Function pointer to SetHome
-  void (*SetHome)(void *handle); 
-  /// Function pointer to SetMark
-  void (*SetMark)(void *handle); 
-  /// Function pointer to SetMaxSpeed
-  bool (*SetMaxSpeed)(void *handle, uint16_t newMaxSpeed); 
-  /// Function pointer to SetMinSpeed
-  bool (*SetMinSpeed)(void *handle, uint16_t newMinSpeed); 
-  /// Function pointer to SoftStop
-  bool (*SoftStop)(void *handle); 
-  /// Function pointer to StepClockHandler
-  void (*StepClockHandler)(void *handle);  
-  /// Function pointer to WaitWhileActive
-  void (*WaitWhileActive)(void *handle);
-  /// Function pointer to CmdDisable
-  void (*CmdDisable)(void *handle); 
-  /// Function pointer to CmdEnable
-  void (*CmdEnable)(void *handle);
-  /// Function pointer to CmdGetParam
-  uint32_t (*CmdGetParam)(void *handle, uint32_t param);
-  /// Function pointer to CmdGetStatus
-  uint16_t (*CmdGetStatus)(void *handle); 
-  /// Function pointer to CmdNop
-  void (*CmdNop)(void *handle); 
-  /// Function pointer to CmdSetParam
-  void (*CmdSetParam)(void *handle, uint32_t param, uint32_t value);
-  /// Function pointer to ReadStatusRegister
-  uint16_t (*ReadStatusRegister)(void *handle); 
-  /// Function pointer to ReleaseReset
-  void (*ReleaseReset)(void *handle);
-  /// Function pointer to Reset
-  void (*Reset)(void *handle); 
-  /// Function pointer to SelectStepMode
-  void (*SelectStepMode)(void *handle, motorStepMode_t);
-  /// Function pointer to SetDirection
-  void (*SetDirection)(void *handle, motorDir_t direction);
-  /// Function pointer to CmdGoToDir
-  void (*CmdGoToDir)(void *handle, motorDir_t direction, int32_t targetPosition);
-  /// Function pointer to CheckBusyHw
-  uint8_t (*CheckBusyHw)(void *handle);
-  /// Function pointer to CheckStatusHw
-  uint8_t (*CheckStatusHw)(void *handle);
-  /// Function pointer to CmdGoUntil
-  void (*CmdGoUntil)(void *handle, motorAction_t action, motorDir_t direction, uint32_t targetPosition);
-  /// Function pointer to CmdHardHiZ
-  void (*CmdHardHiZ)(void *handle);
-  /// Function pointer to CmdReleaseSw
-  void (*CmdReleaseSw)(void *handle, motorAction_t action, motorDir_t direction);
-  /// Function pointer to CmdResetDevice
-  void (*CmdResetDevice)(void *handle);
-  /// Function pointer to CmdResetPos
-  void (*CmdResetPos)(void *handle);
-  /// Function pointer to CmdRun
-  void (*CmdRun)(void *handle, motorDir_t direction, uint32_t targetPosition);
-  /// Function pointer to CmdSoftHiZ
-  void (*CmdSoftHiZ)(void *handle);
-  /// Function pointer to CmdStepClock
-  void (*CmdStepClock)(void *handle, motorDir_t direction);
-  /// Function pointer to FetchAndClearAllStatus
-  void (*FetchAndClearAllStatus)(void *handle);
-  /// Function pointer to GetFetchedStatus
-  uint16_t (*GetFetchedStatus)(void *handle);
-  /// Function pointer to GetNbDevices
-  uint8_t (*GetNbDevices)(void *handle);
-  /// Function pointer to IsDeviceBusy
-  bool (*IsDeviceBusy)(void *handle);
-  /// Function pointer to SendQueuedCommands
-  void (*SendQueuedCommands)(void *handle);
-  /// Function pointer to QueueCommands
-  void (*QueueCommands)(void *handle, uint8_t command, int32_t value);
-  /// Function pointer to WaitForAllDevicesNotBusy
-  void (*WaitForAllDevicesNotBusy)(void *handle);
-  /// Function pointer to ErrorHandler
-  void (*ErrorHandler)(void *handle, uint16_t error);
-  /// Function pointer to BusyInterruptHandler
-  void (*BusyInterruptHandler)(void *handle);
-  /// Function pointer to CmdSoftStop
-  void (*CmdSoftStop)(void *handle);
-  /// Function pointer to StartStepClock
-  void (*StartStepClock)(void *handle, uint16_t newFreq);
-  /// Function pointer to StopStepClock
-  void (*StopStepClock)(void *handle);
-  /// Function pointer to SetDualFullBridgeConfig
-  void (*SetDualFullBridgeConfig)(void *handle, uint8_t config);
-  /// Function pointer to GetBridgeInputPwmFreq
-  uint32_t (*GetBridgeInputPwmFreq)(void *handle);
-  /// Function pointer to SetBridgeInputPwmFreq
-  void (*SetBridgeInputPwmFreq)(void *handle, uint32_t newFreq);
-  /// Function pointer to SetStopMode
-  void (*SetStopMode)(void *handle, motorStopMode_t stopMode);
-  /// Function pointer to GetStopMode
-  motorStopMode_t (*GetStopMode)(void *handle);
-  /// Function pointer to SetDecayMode
-  void (*SetDecayMode)(void *handle, motorDecayMode_t decayMode);
-  /// Function pointer to GetDecayMode
-  motorDecayMode_t (*GetDecayMode)(void *handle);
-  /// Function pointer to GetStepMode
-  motorStepMode_t (*GetStepMode)(void *handle);
-  /// Function pointer to GetDirection
-  motorDir_t (*GetDirection)(void *handle);
-  /// Function pointer to ExitDeviceFromReset
-  void (*ExitDeviceFromReset)(void *handle);
-  /// Function pointer to SetTorque
-  void (*SetTorque)(void *handle, motorTorqueMode_t torqueMode, uint8_t torqueValue);
-  /// Function pointer to GetTorque
-  uint8_t (*GetTorque)(void *handle, motorTorqueMode_t torqueMode);
-  /// Function pointer to SetVRefFreq
-  void (*SetRefFreq)(void *handle, uint32_t newFreq);
-  /// Function pointer to GetVRefFreq
-  uint32_t (*GetRefFreq)(void *handle);
-  /// Function pointer to SetVRefDc
-  void (*SetRefDc)(void *handle, uint8_t newDc);
-  /// Function pointer to GetVRefDc
-  uint8_t (*GetRefDc)(void *handle);
-  /// Function pointer to SetNbDevices
-  bool (*SetNbDevices)(void *handle, uint8_t nbDevices);
-  /// Function pointer to set a parameter
-  bool (*SetAnalogValue)(void *handle, uint32_t param, float value);
-  /// Function pointer to get a parameter 
-  float (*GetAnalogValue)(void *handle, uint32_t param); 
-} MOTOR_VTable_t;
-/**
-* @}
-  */
-
-/**
-  * @}
-  */ 
-
-/**
-  * @}
-  */
-  
-/**
-  * @}
-  */ 
-
-/**
-  * @}
-  */ 
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MOTOR_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/Common/motor_def.h	Fri Mar 24 10:59:19 2017 +0100
@@ -0,0 +1,446 @@
+/**
+  ******************************************************************************
+  * @file    motor_def.h
+  * @author  IPC Rennes
+  * @version V1.5.0
+  * @date    January 25, 2016
+  * @brief   This file contains all the functions prototypes for motor drivers.   
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */ 
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __MOTOR_H
+#define __MOTOR_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/* Includes ------------------------------------------------------------------*/
+#include <stdint.h>
+#include "component_def.h"
+
+/* Definitions ---------------------------------------------------------------*/
+/// boolean for false condition 
+#ifndef FALSE
+#define FALSE (0)
+#endif
+/// boolean for true condition 
+#ifndef TRUE
+#define TRUE  (1)
+#endif
+
+/* Types ---------------------------------------------------------------------*/
+/** @addtogroup BSP
+  * @{
+  */
+
+/** @addtogroup Components
+  * @{
+  */ 
+
+/** @defgroup Motor Motor
+  * @{
+  */
+   
+/** @defgroup Motor_Exported_Types Motor Exported Types
+  * @{
+  */
+   
+/** @defgroup Device_Direction_Options Device Direction Options
+  * @{
+  */
+/// Direction options
+typedef enum {
+  BACKWARD = 0,
+  FORWARD = 1,
+  UNKNOW_DIR = ((uint8_t)0xFF)
+} motorDir_t;
+/**
+  * @}
+  */
+  
+/** @defgroup Device_Action_Options Device Action Options
+  * @{
+  */
+/// Action options
+typedef enum {
+  ACTION_RESET = ((uint8_t)0x00),
+  ACTION_COPY  = ((uint8_t)0x08)
+} motorAction_t;
+/**
+  * @}
+  */  
+
+/** @defgroup Device_States Device States
+  * @{
+  */
+/// Device states
+typedef enum {
+  ACCELERATING       = 0,
+  DECELERATINGTOSTOP = 1,  
+  DECELERATING       = 2, 
+  STEADY             = 3,
+  INDEX_ACCEL        = 4,
+  INDEX_RUN          = 5,
+  INDEX_DECEL        = 6,
+  INDEX_DWELL        = 7,
+  INACTIVE           = 8,
+  STANDBY            = 9,
+  STANDBYTOINACTIVE  = 10
+} motorState_t;
+/**
+  * @}
+  */   
+
+/** @defgroup Device_Step_mode Device Step mode
+  * @{
+  */
+ /// Stepping options 
+typedef enum {
+  STEP_MODE_FULL   = ((uint8_t)0x00), 
+  STEP_MODE_HALF   = ((uint8_t)0x01),
+  STEP_MODE_1_4    = ((uint8_t)0x02),
+  STEP_MODE_1_8    = ((uint8_t)0x03),
+  STEP_MODE_1_16   = ((uint8_t)0x04),
+  STEP_MODE_1_32   = ((uint8_t)0x05),
+  STEP_MODE_1_64   = ((uint8_t)0x06),
+  STEP_MODE_1_128  = ((uint8_t)0x07),
+  STEP_MODE_1_256  = ((uint8_t)0x08),
+  STEP_MODE_UNKNOW = ((uint8_t)0xFE),
+  STEP_MODE_WAVE   = ((uint8_t)0xFF)  
+} motorStepMode_t;
+
+/**
+  * @}
+  */
+  
+/** @defgroup Decay_mode Decay mode
+  * @{
+  */
+/// Decay Mode 
+typedef enum {
+  SLOW_DECAY = 0,
+  FAST_DECAY = 1,
+  UNKNOW_DECAY = ((uint8_t)0xFF)
+} motorDecayMode_t;
+/**
+  * @}
+  */
+  
+/** @defgroup Stop_mode Stop mode
+  * @{
+  */
+/// Stop mode
+typedef enum
+{ 
+  HOLD_MODE = 0,
+  HIZ_MODE = 1,
+  STANDBY_MODE = 2,
+  UNKNOW_STOP_MODE = ((uint8_t)0xFF)
+} motorStopMode_t;
+/**
+  * @}
+  */  
+
+/** @defgroup Torque_mode Torque mode
+  * @{
+  */
+/// Torque mode
+typedef enum
+{ 
+  ACC_TORQUE = 0,
+  DEC_TORQUE = 1,
+  RUN_TORQUE = 2,
+  HOLD_TORQUE = 3,
+  CURRENT_TORQUE = 4,
+  UNKNOW_TORQUE = ((uint8_t)0xFF)
+} motorTorqueMode_t;
+/**
+  * @}
+  */  
+    
+/** @defgroup Dual_Full_Bridge_Configuration Dual Full Bridge Configuration
+  * @{
+  */
+///Dual full bridge configurations for brush DC motors
+typedef enum {
+  PARALLELING_NONE___1_BIDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 0,
+  PARALLELING_NONE___1_BIDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 1,
+  PARALLELING_NONE___2_UNDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 2,
+  PARALLELING_NONE___2_UNDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 3,
+  PARALLELING_IN1A_IN2A__1_UNDIR_MOTOR_BRIDGE_A__1_BIDIR_MOTOR_BRIDGE_B = 4,
+  PARALLELING_IN1A_IN2A__1_UNDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B = 5,
+  PARALLELING_IN1B_IN2B__1_BIDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 6,
+  PARALLELING_IN1B_IN2B__2_UNDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 7,
+  PARALLELING_IN1A_IN2A__IN1B_IN2B__1_UNDIR_MOTOR_BRIDGE_A__1_UNDIR_MOTOR_BRIDGE_B = 8,
+  PARALLELING_IN1A_IN2A__IN1B_IN2B__1_BIDIR_MOTOR = 9,
+  PARALLELING_IN1A_IN1B__IN2A_IN2B__1_UNDIR_MOTOR_BRIDGE_1A__1_UNDIR_MOTOR_BRIDGE_2A = 10,
+  PARALLELING_IN1A_IN1B__IN2A_IN2B__1_BIDIR_MOTOR = 11,
+  PARALLELING_ALL_WITH_IN1A___1_UNDIR_MOTOR = 12,
+  PARALLELING_END_ENUM = 13 
+} dualFullBridgeConfig_t;
+/**
+  * @}
+  */
+
+/** @defgroup Motor_Driver_Structure Motor Driver Structure
+  * @{
+  */
+/** 
+ * @brief  MOTOR driver virtual table structure definition.
+ */  
+typedef struct
+{
+  /* ACTION ----------------------------------------------------------------*
+   * Declare here the component's generic functions.                        *
+   * Tag this group of functions with the " Generic " C-style comment.      *
+   * A component's interface has to define at least the two generic         *
+   * functions provided here below within the "Example" section, as the     *
+   * first and second functions of its Virtual Table. They have to be       *
+   * specified exactly in the given way.                                    *
+   *                                                                        *
+   * Example:                                                               *
+   *   status_t (*init)   (void *handle, void *init);                       *
+   *   status_t (*read_id) (void *handle, uint8_t *id);                      *
+   *------------------------------------------------------------------------*/
+  /* Generic */
+  status_t (*init)(void *handle, void *init);
+  status_t (*read_id)(void *handle, uint8_t *id);
+  /* ACTION ----------------------------------------------------------------*
+   * Declare here the component's interrupts related functions.             *
+   * Tag this group of functions with the " Interrupts " C-style comment.   *
+   * Do not specify any function if not required.                           *
+   *                                                                        *
+   * Example:                                                               *
+   *   void     (*ConfigIT) (void *handle, int a);                          *
+   *------------------------------------------------------------------------*/
+  /* Interrupts */
+  /// Function pointer to attach_error_handler
+  void (*attach_error_handler)(void *handle, void (*callback)(void *handle, uint16_t error));
+  /// Function pointer to attach_flag_interrupt
+  void (*attach_flag_interrupt)(void *handle, void (*callback)(void *handle));
+  /// Function pointer to AttachBusyInterrupt
+  void (*AttachBusyInterrupt)(void *handle, void (*callback)(void *handle));
+  /// Function pointer to FlagInterruptHandler
+  void (*FlagInterruptHandler)(void *handle);
+  /* ACTION ----------------------------------------------------------------*
+   * Declare here the component's specific functions.                       *
+   * Tag this group of functions with the " Specific " C-style comment.     *
+   * Do not specify any function if not required.                           *
+   *                                                                        *
+   * Example:                                                               *
+   *   status_t (*GetValue) (void *handle, float *f);                       *
+   *------------------------------------------------------------------------*/
+  /* Specific */  
+  /// Function pointer to get_acceleration
+  uint16_t (*get_acceleration)(void *handle); 
+  /// Function pointer to GetCurrentSpeed
+  uint16_t (*GetCurrentSpeed)(void *handle); 
+  /// Function pointer to get_deceleration
+  uint16_t (*get_deceleration)(void *handle); 
+  /// Function pointer to get_device_state
+  motorState_t(*get_device_state)(void *handle); 
+  /// Function pointer to get_fw_version
+  uint8_t (*get_fw_version)(void *handle); 
+  /// Function pointer to get_mark
+  int32_t (*get_mark)(void *handle); 
+  /// Function pointer to get_max_speed
+  uint16_t (*get_max_speed)(void *handle); 
+  /// Function pointer to get_min_speed
+  uint16_t (*get_min_speed)(void *handle); 
+  /// Function pointer to get_position
+  int32_t (*get_position)(void *handle);
+  /// Function pointer to go_home
+  void (*go_home)(void *handle); 
+  /// Function pointer to go_mark
+  void (*go_mark)(void *handle); 
+  /// Function pointer to go_to
+  void (*go_to)(void *handle, int32_t targetPosition); 
+  /// Function pointer to hard_stop
+  void (*hard_stop)(void *handle); 
+  /// Function pointer to move
+  void (*move)(void *handle, motorDir_t direction, uint32_t stepCount); 
+  /// Function pointer to ResetAllDevices
+  //void (*ResetAllDevices)(void *handle); 
+  /// Function pointer to run
+  void (*run)(void *handle, motorDir_t direction);
+  /// Function pointer to set_acceleration
+  bool (*set_acceleration)(void *handle, uint16_t newAcc);
+  /// Function pointer to set_deceleration
+  bool (*set_deceleration)(void *handle, uint16_t newDec);
+  /// Function pointer to set_home
+  void (*set_home)(void *handle); 
+  /// Function pointer to set_mark
+  void (*set_mark)(void *handle); 
+  /// Function pointer to set_max_speed
+  bool (*set_max_speed)(void *handle, uint16_t newMaxSpeed); 
+  /// Function pointer to set_min_speed
+  bool (*set_min_speed)(void *handle, uint16_t newMinSpeed); 
+  /// Function pointer to soft_stop
+  bool (*soft_stop)(void *handle); 
+  /// Function pointer to StepClockHandler
+  void (*StepClockHandler)(void *handle);  
+  /// Function pointer to wait_while_active
+  void (*wait_while_active)(void *handle);
+  /// Function pointer to CmdDisable
+  void (*CmdDisable)(void *handle); 
+  /// Function pointer to CmdEnable
+  void (*CmdEnable)(void *handle);
+  /// Function pointer to CmdGetParam
+  uint32_t (*CmdGetParam)(void *handle, uint32_t param);
+  /// Function pointer to CmdGetStatus
+  uint16_t (*CmdGetStatus)(void *handle); 
+  /// Function pointer to CmdNop
+  void (*CmdNop)(void *handle); 
+  /// Function pointer to CmdSetParam
+  void (*CmdSetParam)(void *handle, uint32_t param, uint32_t value);
+  /// Function pointer to read_status_register
+  uint16_t (*read_status_register)(void *handle); 
+  /// Function pointer to release_reset
+  void (*release_reset)(void *handle);
+  /// Function pointer to Reset
+  void (*Reset)(void *handle); 
+  /// Function pointer to SelectStepMode
+  void (*SelectStepMode)(void *handle, motorStepMode_t);
+  /// Function pointer to set_direction
+  void (*set_direction)(void *handle, motorDir_t direction);
+  /// Function pointer to CmdGoToDir
+  void (*CmdGoToDir)(void *handle, motorDir_t direction, int32_t targetPosition);
+  /// Function pointer to check_busy_hw
+  uint8_t (*check_busy_hw)(void *handle);
+  /// Function pointer to check_status_hw
+  uint8_t (*check_status_hw)(void *handle);
+  /// Function pointer to CmdGoUntil
+  void (*CmdGoUntil)(void *handle, motorAction_t action, motorDir_t direction, uint32_t targetPosition);
+  /// Function pointer to CmdHardHiZ
+  void (*CmdHardHiZ)(void *handle);
+  /// Function pointer to CmdReleaseSw
+  void (*CmdReleaseSw)(void *handle, motorAction_t action, motorDir_t direction);
+  /// Function pointer to CmdResetDevice
+  void (*CmdResetDevice)(void *handle);
+  /// Function pointer to CmdResetPos
+  void (*CmdResetPos)(void *handle);
+  /// Function pointer to CmdRun
+  void (*CmdRun)(void *handle, motorDir_t direction, uint32_t targetPosition);
+  /// Function pointer to CmdSoftHiZ
+  void (*CmdSoftHiZ)(void *handle);
+  /// Function pointer to CmdStepClock
+  void (*CmdStepClock)(void *handle, motorDir_t direction);
+  /// Function pointer to fetch_and_clear_all_status
+  void (*fetch_and_clear_all_status)(void *handle);
+  /// Function pointer to get_fetched_status
+  uint16_t (*get_fetched_status)(void *handle);
+  /// Function pointer to get_nb_devices
+  uint8_t (*get_nb_devices)(void *handle);
+  /// Function pointer to is_device_busy
+  bool (*is_device_busy)(void *handle);
+  /// Function pointer to send_queued_commands
+  void (*send_queued_commands)(void *handle);
+  /// Function pointer to queue_commands
+  void (*queue_commands)(void *handle, uint8_t command, int32_t value);
+  /// Function pointer to WaitForAllDevicesNotBusy
+  void (*WaitForAllDevicesNotBusy)(void *handle);
+  /// Function pointer to error_handler
+  void (*error_handler)(void *handle, uint16_t error);
+  /// Function pointer to BusyInterruptHandler
+  void (*BusyInterruptHandler)(void *handle);
+  /// Function pointer to CmdSoftStop
+  void (*CmdSoftStop)(void *handle);
+  /// Function pointer to StartStepClock
+  void (*StartStepClock)(void *handle, uint16_t newFreq);
+  /// Function pointer to StopStepClock
+  void (*StopStepClock)(void *handle);
+  /// Function pointer to set_dual_full_bridge_config
+  void (*set_dual_full_bridge_config)(void *handle, uint8_t config);
+  /// Function pointer to get_bridge_input_pwm_freq
+  uint32_t (*get_bridge_input_pwm_freq)(void *handle);
+  /// Function pointer to set_bridge_input_pwm_freq
+  void (*set_bridge_input_pwm_freq)(void *handle, uint32_t newFreq);
+  /// Function pointer to set_stop_mode
+  void (*set_stop_mode)(void *handle, motorStopMode_t stopMode);
+  /// Function pointer to get_stop_mode
+  motorStopMode_t (*get_stop_mode)(void *handle);
+  /// Function pointer to set_decay_mode
+  void (*set_decay_mode)(void *handle, motorDecayMode_t decayMode);
+  /// Function pointer to get_decay_mode
+  motorDecayMode_t (*get_decay_mode)(void *handle);
+  /// Function pointer to get_step_mode
+  motorStepMode_t (*get_step_mode)(void *handle);
+  /// Function pointer to get_direction
+  motorDir_t (*get_direction)(void *handle);
+  /// Function pointer to ExitDeviceFromReset
+  void (*ExitDeviceFromReset)(void *handle);
+  /// Function pointer to set_torque
+  void (*set_torque)(void *handle, motorTorqueMode_t torqueMode, uint8_t torqueValue);
+  /// Function pointer to get_torque
+  uint8_t (*get_torque)(void *handle, motorTorqueMode_t torqueMode);
+  /// Function pointer to SetVRefFreq
+  void (*SetRefFreq)(void *handle, uint32_t newFreq);
+  /// Function pointer to GetVRefFreq
+  uint32_t (*GetRefFreq)(void *handle);
+  /// Function pointer to SetVRefDc
+  void (*SetRefDc)(void *handle, uint8_t newDc);
+  /// Function pointer to GetVRefDc
+  uint8_t (*GetRefDc)(void *handle);
+  /// Function pointer to set_nb_devices
+  bool (*set_nb_devices)(void *handle, uint8_t nbDevices);
+  /// Function pointer to set a parameter
+  bool (*set_analog_value)(void *handle, uint32_t param, float value);
+  /// Function pointer to get a parameter 
+  float (*get_analog_value)(void *handle, uint32_t param); 
+} MOTOR_VTable_t;
+/**
+* @}
+  */
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */
+  
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */ 
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MOTOR_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/Interfaces/Component_class.h	Wed Jul 27 12:00:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/**
- ******************************************************************************
- * @file    Component_class.h
- * @author  AST
- * @version V1.0.0
- * @date    April 13th, 2015
- * @brief   This file contains the abstract class describing the interface of a
- *          generic component.
- ******************************************************************************
- * @attention
- *
- * <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:
- *   1. Redistributions of source code must retain the above copyright notice,
- *      this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright notice,
- *      this list of conditions and the following disclaimer in the documentation
- *      and/or other materials provided with the distribution.
- *   3. Neither the name of STMicroelectronics nor the names of its contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-
-#ifndef __COMPONENT_CLASS_H
-#define __COMPONENT_CLASS_H
-
-
-/* Includes ------------------------------------------------------------------*/
-
-#include <stdint.h>
-
-
-/* Classes  ------------------------------------------------------------------*/
-
-/** An abstract class for Generic components.
- */
-class Component
-{
-public:
-    /**
-     * @brief     Initializing the component.
-     * @param[in] init pointer to device specific initalization structure.
-     * @retval    "0" in case of success, an error code otherwise.
-     */
-    virtual int Init(void *init) = 0;
-
-    /**
-     * @brief      Getting the ID of the component.
-     * @param[out] id pointer to an allocated variable to store the ID into.
-     * @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 */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/Interfaces/StepperMotor_class.h	Wed Jul 27 12:00:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,271 +0,0 @@
-/**
- ******************************************************************************
- * @file    StepperMotor_class.h
- * @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) 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:
- *   1. Redistributions of source code must retain the above copyright notice,
- *      this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright notice,
- *      this list of conditions and the following disclaimer in the documentation
- *      and/or other materials provided with the distribution.
- *   3. Neither the name of STMicroelectronics nor the names of its contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-
-/* Define to prevent from recursive inclusion --------------------------------*/
-
-#ifndef __STEPPERMOTOR_CLASS_H
-#define __STEPPERMOTOR_CLASS_H
-
-
-/* Includes ------------------------------------------------------------------*/
-
-#include <Component_class.h>
-
-
-/* Classes  ------------------------------------------------------------------*/
-
-/** An abstract class for StepperMotor components.
- */
-class StepperMotor : public Component
-{
-public:
-    /**
-     * @brief Rotation modes.
-     */
-    typedef enum
-    {
-        BWD = 0, /* Backward. */
-        FWD = 1  /* Forward. */
-    } direction_t;
-
-    /**
-     * @brief Step modes.
-     */
-    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.
-     * @retval The status.
-     */
-    virtual unsigned int GetStatus(void) = 0;
-
-    /**
-     * @brief  Getting the position.
-     * @param  None.
-     * @retval The position.
-     */
-    virtual signed int GetPosition(void) = 0;
-
-    /**
-     * @brief  Getting the marked position.
-     * @param  None.
-     * @retval The marked position.
-     */
-    virtual signed int GetMark(void) = 0;
-
-    /**
-     * @brief  Getting the current speed in pps.
-     * @param  None.
-     * @retval The current speed in pps.
-     */
-    virtual unsigned int GetSpeed(void) = 0;
-
-    /**
-     * @brief  Getting the maximum speed in pps.
-     * @param  None.
-     * @retval The maximum speed in pps.
-     */
-    virtual unsigned int GetMaxSpeed(void) = 0;
-
-    /**
-     * @brief  Getting the minimum speed in pps.
-     * @param  None.
-     * @retval The minimum speed in pps.
-     */
-    virtual unsigned int GetMinSpeed(void) = 0;
-
-    /**
-     * @brief  Getting the acceleration in pps^2.
-     * @param  None.
-     * @retval The acceleration in pps^2.
-     */
-    virtual unsigned int GetAcceleration(void) = 0;
-
-    /**
-     * @brief  Getting the deceleration in pps^2.
-     * @param  None.
-     * @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 the current position to be the home position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SetHome(void) = 0;
-
-    /**
-     * @brief  Setting the current position to be the marked position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SetMark(void) = 0;
-
-    /**
-     * @brief  Setting the maximum speed in pps.
-     * @param  speed The maximum speed in pps.
-     * @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" 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" in case of success, "false" otherwise.
-     */
-    virtual bool SetAcceleration(unsigned int acceleration) = 0;
-
-    /**
-     * @brief  Setting the deceleration in pps^2.
-     * @param  deceleration The deceleration in pps^2.
-     * @retval "true" in case of success, "false" otherwise.
-     */
-    virtual bool SetDeceleration(unsigned int deceleration) = 0;
-
-    /**
-     * @brief  Setting the Step Mode.
-     * @param  step_mode The Step Mode.
-     * @retval "true" in case of success, "false" otherwise.
-     */
-    virtual bool SetStepMode(step_mode_t step_mode) = 0;
-
-    /**
-     * @brief  Going to a specified position.
-     * @param  position The desired position.
-     * @retval None.
-     */
-    virtual void GoTo(signed int position) = 0;
-
-    /**
-     * @brief  Going to the home position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void GoHome(void) = 0;
-
-    /**
-     * @brief  Going to the marked position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void GoMark(void) = 0;
-
-    /**
-     * @brief  Running the motor towards a specified direction.
-     * @param  direction The direction of rotation.
-     * @retval None.
-     */
-    virtual void Run(direction_t direction) = 0;
-
-    /**
-     * @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.
-     * @retval None.
-     */
-    virtual void Move(direction_t direction, unsigned int steps) = 0;
-
-    /**
-     * @brief  Stopping the motor through an immediate deceleration up to zero speed.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SoftStop(void) = 0;
-
-    /**
-     * @brief  Stopping the motor through an immediate infinite deceleration.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void HardStop(void) = 0;
-
-    /**
-     * @brief  Disabling the power bridge after performing a deceleration to zero.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SoftHiZ(void) = 0;
-
-    /**
-     * @brief  Disabling the power bridge immediately.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void HardHiZ(void) = 0;
-
-    /**
-     * @brief  Waiting while the motor is active.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void WaitWhileActive(void) = 0;
-};
-
-#endif /* __STEPPERMOTOR_CLASS_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/stspin220/STSpin220.cpp	Fri Mar 24 10:59:19 2017 +0100
@@ -0,0 +1,1528 @@
+/**
+  ******************************************************************************
+  * @file    STSpin220.cpp
+  * @author  IPC Rennes
+  * @version V1.0.0
+  * @date    July 27th, 2016
+  * @brief   STSpin220 product related routines
+  * @note    (C) COPYRIGHT 2016 STMicroelectronics
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+
+/* Includes ------------------------------------------------------------------*/
+#include "STSpin220.h"
+
+/* Definitions ---------------------------------------------------------------*/
+
+/* Variables  ----------------------------------------------------------------*/
+/* Number of devices. */
+uint8_t STSpin220::numberOfDevices = 0;
+
+/* Methods -------------------------------------------------------------------*/
+/******************************************************//**
+ * @brief Start the STSpin220 library
+ * @param[in] pInit pointer to the initialization data
+ * @retval COMPONENT_OK in case of success.
+ **********************************************************/
+status_t STSpin220::Stspin220_Init(void* pInit)
+{ 
+  Stspin220_Disable();
+  if (pInit == NULL)
+  {
+    /* Set context variables to the predefined values from Stspin220_target_config.h */
+    /* Set GPIO according to these values */
+    Stspin220_SetDeviceParamsToPredefinedValues();
+  }
+  else
+  {
+    Stspin220_SetDeviceParamsToGivenValues((Stspin220_init_t*) pInit);
+  }
+  Stspin220_Board_TimStckInit(false);
+  return COMPONENT_OK;
+}
+
+/**********************************************************
+ * @brief Read id
+ * @param id pointer to the identifier to be read.
+ * @retval COMPONENT_OK in case of success.
+ **********************************************************/
+status_t STSpin220::Stspin220_ReadID(uint8_t *id)
+{
+  *id = deviceInstance;
+
+  return COMPONENT_OK;
+}
+
+/**********************************************************
+ * @brief  Attaches a user callback to the error Handler.
+ * The call back will be then called each time the library 
+ * detects an error
+ * @param[in] callback Name of the callback to attach 
+ * to the error Hanlder
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_AttachErrorHandler(void (*callback)(uint16_t error))
+{
+  errorHandlerCallback = (void (*)(uint16_t error)) callback;
+}
+
+/******************************************************//**
+ * @brief Apply the set torque
+ * @param[in] torqueMode torque mode
+ * @retval None
+ * @note
+ **********************************************************/
+void STSpin220::Stspin220_ApplyTorque(motorTorqueMode_t torqueMode)
+{
+  uint8_t torqueValue = 0;
+  devicePrm.updateTorque = false;
+  switch(torqueMode)
+  {
+    case ACC_TORQUE:
+      devicePrm.currentTorque = devicePrm.accelTorque;
+      break;
+    case DEC_TORQUE:
+      devicePrm.currentTorque = devicePrm.decelTorque;
+      break;
+    case RUN_TORQUE:
+      devicePrm.currentTorque = devicePrm.runTorque;
+      break;
+    case HOLD_TORQUE:
+      devicePrm.currentTorque = devicePrm.holdTorque;
+      break;
+    case CURRENT_TORQUE:
+      break;
+    default:
+      return; //ignore error
+  }
+  torqueValue = devicePrm.currentTorque;
+  Stspin220_Board_PwmRefSetDutyCycle(torqueValue);
+}
+
+/******************************************************//**
+ * @brief Disable the power bridges (leave the output bridges HiZ)
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_disable(void)
+{
+  Stspin220_Board_Disable();
+}
+
+/******************************************************//**
+ * @brief Enable the power bridges
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_enable(void)
+{
+  Stspin220_Board_Enable();
+}
+
+/******************************************************//**
+ * @brief Error handler which calls the user callback (if defined)
+ * @param[in] error Number of the error
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_ErrorHandler(uint16_t error)
+{
+  if (errorHandlerCallback != 0)
+  {
+    errorHandlerCallback(error);
+  }
+  else   
+  {
+    while(1)
+    {
+      /* Infinite loop */
+    }
+  }
+}
+
+/******************************************************//**
+ * @brief Exit STSpin220 device from standby (low power consumption)
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_ExitDeviceFromStandby(void)
+{
+  uint32_t sequencerPosition = devicePrm.sequencerPosition;
+  
+  /* Exit standby and set step mode */
+  Stspin220_SetStepModeWithoutReset(devicePrm.stepMode);
+  
+  if (devicePrm.sequencerPosition != 0)
+  {
+    /* Set direction to FORWARD to ensure the HW sequencer is increased at */
+    /* each step clock rising edge */
+    Stspin220_SetDirection(FORWARD);
+    /* Going out of standby */
+    devicePrm.motionState = STANDBYTOINACTIVE;
+    /* Program the step clock */
+    Stspin220_Board_TimStckInit(true);
+    Stspin220_Board_TimStckSetFreq(STSPIN220_MAX_STCK_FREQ);
+    toggleOdd = 0;
+    while (devicePrm.sequencerPosition != 0);
+    while (toggleOdd!=0);
+    devicePrm.sequencerPosition = sequencerPosition;    
+  }
+  
+  devicePrm.motionState = INACTIVE;
+}
+
+/******************************************************//**
+ * @brief Return the acceleration
+ * @retval Acceleration in pps^2
+ **********************************************************/
+uint16_t STSpin220::Stspin220_GetAcceleration(void)
+{                                                  
+  return (devicePrm.acceleration);
+}
+
+/******************************************************//**
+ * @brief Return the current speed
+ * @retval Speed in pps
+ **********************************************************/
+uint16_t STSpin220::Stspin220_GetCurrentSpeed(void)
+{
+  return devicePrm.speed;
+}
+
+/******************************************************//**
+ * @brief Return the deceleration
+ * @retval Deceleration in pps^2
+ **********************************************************/
+uint16_t STSpin220::Stspin220_GetDeceleration(void)
+{
+  return (devicePrm.deceleration);
+}
+
+/******************************************************//**
+ * @brief Return the device state
+ * @retval State (ACCELERATING, DECELERATING, STEADY or INACTIVE)
+ **********************************************************/
+motorState_t STSpin220::Stspin220_get_device_state(void)
+{
+  return devicePrm.motionState;
+}
+
+/******************************************************//**
+ * @brief Get the motor current direction
+ * @retval direction
+ **********************************************************/
+motorDir_t STSpin220::Stspin220_GetDirection(void)
+{
+  return devicePrm.direction;
+}
+
+/******************************************************//**
+ * @brief Return the FW version.
+ * @retval FW version
+ **********************************************************/
+uint32_t STSpin220::Stspin220_GetFwVersion(void)
+{
+  return (STSPIN220_FW_VERSION);
+}
+
+/******************************************************//**
+ * @brief Get the mark position (32b signed) 
+ * @retval mark position
+ **********************************************************/
+int32_t STSpin220::Stspin220_GetMark(void)
+{
+  return devicePrm.markPosition;
+}
+
+/******************************************************//**
+ * @brief Return the max speed
+ * @retval maxSpeed in pps
+ **********************************************************/
+uint16_t STSpin220::Stspin220_GetMaxSpeed(void)
+{
+  return (devicePrm.maxSpeed);
+}
+
+/******************************************************//**
+ * @brief Get the min speed
+ * in step/s for full, half and wave modes
+ * in microsteps/s for microstep modes
+ * @retval return the min speed in step/s or microstep/s
+ * @note
+ **********************************************************/
+uint16_t STSpin220::Stspin220_GetMinSpeed(void)
+{
+  return (devicePrm.minSpeed);
+}
+
+/******************************************************//**
+ * @brief Get the current position (32b signed) 
+ * @retval current position value
+ **********************************************************/
+int32_t STSpin220::Stspin220_GetPosition(void)
+{
+  return devicePrm.currentPosition;
+}
+
+/******************************************************//**
+ * @brief Get the motor step mode
+ * @retval step mode
+ **********************************************************/
+motorStepMode_t STSpin220::Stspin220_get_step_mode(void)
+{
+  return devicePrm.stepMode;
+}
+
+/******************************************************//**
+ * @brief Get the selected stop mode
+ * @retval the selected stop mode
+ **********************************************************/
+motorStopMode_t STSpin220::Stspin220_GetStopMode(void)
+{
+  return devicePrm.stopMode;
+}
+
+/******************************************************//**
+ * @brief Get the torque
+ * @param[in] torqueMode torque mode
+ * @retval the torqueValue in % (from 0 to 100)
+ * @note
+ **********************************************************/
+uint8_t STSpin220::Stspin220_GetTorque(motorTorqueMode_t torqueMode)
+{
+  uint8_t torqueValue = 0;
+  switch(torqueMode)
+  {
+    case ACC_TORQUE:
+      torqueValue = devicePrm.accelTorque;
+      break;
+    case DEC_TORQUE:
+      torqueValue = devicePrm.decelTorque;
+      break;
+    case RUN_TORQUE:
+      torqueValue = devicePrm.runTorque;
+      break;
+    case HOLD_TORQUE:
+      torqueValue = devicePrm.holdTorque;
+      break;
+    case CURRENT_TORQUE:
+      torqueValue = devicePrm.currentTorque;
+      break;
+    default:
+      break;
+  }
+  return torqueValue;
+}
+
+/******************************************************//**
+ * @brief Get the torque boost feature status
+ * @retval TRUE if enabled, FALSE if disabled
+ **********************************************************/
+bool STSpin220::Stspin220_GetTorqueBoostenable(void)
+{
+  return devicePrm.torqueBoostEnable;
+}
+
+/******************************************************//**
+ * @brief Get the torque boost threshold
+ * @retval The torque boost threshold above which the step mode is
+ * changed to full step
+ **********************************************************/
+uint16_t STSpin220::Stspin220_GetTorqueBoostThreshold(void)
+{
+  return devicePrm.torqueBoostSpeedThreshold;
+}
+
+/******************************************************//**
+ * @brief Go to the home position
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_GoHome(void)
+{
+  Stspin220_GoTo(0);
+}
+
+/******************************************************//**
+ * @brief Go to the Mark position
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_GoMark(void)
+{
+  Stspin220_GoTo(devicePrm.markPosition);
+}
+
+/******************************************************//**
+ * @brief Request the motor to move to the specified position 
+ * @param[in] targetPosition absolute position in steps
+ * @retval None 
+ * @note The position is at the resolution corresponding to the
+ * selected step mode.
+ * STEP_MODE_FULL                   : step
+ * STEP_MODE_HALF                   : 1/2 step
+ * STEP_MODE_1_4                    : 1/4 step
+ * STEP_MODE_1_8                    : 1/8 step
+ * STEP_MODE_1_16                   : 1/16 step
+ * STEP_MODE_1_32                   : 1/32 step
+ * STEP_MODE_1_64                   : 1/64 step
+ * STEP_MODE_1_128                  : 1/128 step
+ * STEP_MODE_1_256                  : 1/256 step
+ **********************************************************/
+void STSpin220::Stspin220_GoTo(int32_t targetPosition)
+{
+  motorDir_t direction;
+  
+  /* Exit from standby if needed */
+  if (devicePrm.motionState == STANDBY)
+  {
+    Stspin220_ExitDeviceFromStandby();
+  }
+  /* Deactivate motor if needed */
+  else if (devicePrm.motionState != INACTIVE)
+  { 
+    Stspin220_HardHiZ();
+  }
+  
+  if (targetPosition > devicePrm.currentPosition)
+  {
+    devicePrm.stepsToTake = targetPosition -\
+                                      devicePrm.currentPosition;
+    if (devicePrm.stepsToTake < (STSPIN220_POSITION_RANGE>>1))
+    {
+      direction = FORWARD;
+    }
+    else
+    {
+      direction = BACKWARD;
+      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE -\
+                                        devicePrm.stepsToTake;
+    }
+  }
+  else
+  {
+    devicePrm.stepsToTake = devicePrm.currentPosition -\
+                                      targetPosition;
+    if (devicePrm.stepsToTake < (STSPIN220_POSITION_RANGE>>1))
+    {
+      direction = BACKWARD;
+    }
+    else
+    {
+      direction = FORWARD; 
+      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE -\
+                                        devicePrm.stepsToTake;
+    }
+  }
+  
+  if (devicePrm.stepsToTake != 0) 
+  {
+    devicePrm.commandExecuted = MOVE_CMD;
+    
+    /* Direction setup */
+    Stspin220_SetDirection(direction);
+    
+    Stspin220_ComputeSpeedProfile(devicePrm.stepsToTake);
+    
+    /* Motor activation */
+    Stspin220_StartMovement();
+  }
+}
+
+/******************************************************//**
+ * @brief move the motor to the absolute position
+ * @param[in] direction FORWARD or BACKWARD
+ * @param[in] targetPosition 32 bit signed value position
+ * @retval None
+ * @note The position is at the resolution corresponding to the
+ * selected step mode.
+ * STEP_MODE_FULL                   : step
+ * STEP_MODE_HALF                   : 1/2 step
+ * STEP_MODE_1_4                    : 1/4 step
+ * STEP_MODE_1_8                    : 1/8 step
+ * STEP_MODE_1_16                   : 1/16 step
+ * STEP_MODE_1_32                   : 1/32 step
+ * STEP_MODE_1_64                   : 1/64 step
+ * STEP_MODE_1_128                  : 1/128 step
+ * STEP_MODE_1_256                  : 1/256 step
+ **********************************************************/
+void STSpin220::Stspin220_GoToDir(motorDir_t direction, int32_t targetPosition)
+{
+  /* Exit from standby if needed */
+  if (devicePrm.motionState == STANDBY)
+  {
+    Stspin220_ExitDeviceFromStandby();
+  }
+  /* Deactivate motor if needed */
+  else if (devicePrm.motionState != INACTIVE)
+  { 
+    Stspin220_HardHiZ();
+  }
+  
+  if (direction != BACKWARD)
+  {
+    if (targetPosition > devicePrm.currentPosition)
+    {
+      devicePrm.stepsToTake = targetPosition -\
+                                        devicePrm.currentPosition;
+    }
+    else
+    {
+      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE +\
+                                       (targetPosition -\
+                                        devicePrm.currentPosition);
+    }
+  }
+  else
+  {
+    if (targetPosition > devicePrm.currentPosition)
+    {
+      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE +\
+                                        (devicePrm.currentPosition -\
+                                         targetPosition);
+    }
+    else
+    {
+      devicePrm.stepsToTake = devicePrm.currentPosition -\
+                                        targetPosition;
+    }
+  }
+
+  if (devicePrm.stepsToTake != 0) 
+  {
+    devicePrm.commandExecuted = MOVE_CMD;
+    
+    /* Direction setup */
+    Stspin220_SetDirection(direction);
+    
+    Stspin220_ComputeSpeedProfile(devicePrm.stepsToTake);
+    
+    /* Motor activation */
+    Stspin220_StartMovement();
+  }  
+}
+
+/******************************************************//**
+ * @brief Immediately stop the motor and disables the power bridges
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_HardHiZ(void)
+{
+  /* Set inactive state */
+  devicePrm.motionState = INACTIVE;
+  
+  /* Disable step clock */
+  if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
+  {
+    Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
+  }
+
+  /* Let the PWM REF and bridges enabled at least for DISABLE_DELAY time */
+  /* after the last step clock rising edge triggering the last step */
+  Stspin220_Board_Delay(DISABLE_DELAY);
+  
+  /* Set reference voltage to 0 */
+  Stspin220_SetTorque(CURRENT_TORQUE, 0);
+
+  /* Disable power bridges */
+  Stspin220_Board_Disable();
+  
+  /* Comeback to nominal step mode */
+  if (devicePrm.stepModeLatched != devicePrm.stepMode)
+  {
+    Stspin220_Board_UnsetFullStep();
+    devicePrm.stepMode = devicePrm.stepModeLatched;
+  }
+
+  devicePrm.commandExecuted = NO_CMD;
+  devicePrm.stepsToTake = 0;  
+  devicePrm.speed = 0;
+}
+
+/******************************************************//**
+ * @brief  Immediatly stop the motor
+ * and either set holding torque when stop mode is HOLD_MODE,
+ * or call Stspin220_HardHiz function when stop mode is HIZ_MODE,
+ * or call Stspin220_PutDeviceInStandby function when stop mode is STANDBY_MODE
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_HardStop(void) 
+{
+  if (devicePrm.stopMode == HOLD_MODE)
+  {
+    /* Set inactive state */
+    devicePrm.motionState = INACTIVE;
+
+    /* Disable step clock */
+    if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
+    {
+      Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
+    }
+    
+    /* Set holding torque */
+    Stspin220_ApplyTorque(HOLD_TORQUE);
+ 
+    /* Comeback to nominal step mode */
+    if (devicePrm.stepModeLatched != devicePrm.stepMode)
+    {
+      Stspin220_Board_UnsetFullStep();
+      devicePrm.stepMode = devicePrm.stepModeLatched;
+    }    
+    
+    devicePrm.commandExecuted = NO_CMD;
+    devicePrm.stepsToTake = 0;  
+    devicePrm.speed = 0;
+  }
+  else if (devicePrm.stopMode == HIZ_MODE)
+  {
+    Stspin220_HardHiZ();
+  }
+  else if (devicePrm.stopMode == STANDBY_MODE)
+  {
+    Stspin220_PutDeviceInStandby();
+  }
+}
+
+/******************************************************//**
+ * @brief  Moves the motor of the specified number of steps
+ * @param[in] direction FORWARD or BACKWARD
+ * @param[in] stepCount Number of steps to perform
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_Move(motorDir_t direction, uint32_t stepCount)
+{
+  /* Exit from standby if needed */
+  if (devicePrm.motionState == STANDBY)
+  {
+    Stspin220_ExitDeviceFromStandby();
+  }
+  /* Deactivate motor if needed */
+  else if (devicePrm.motionState != INACTIVE)
+  {
+    Stspin220_HardHiZ();
+  }
+  
+  if (stepCount != 0) 
+  {
+    devicePrm.stepsToTake = stepCount;    
+    devicePrm.commandExecuted = MOVE_CMD;
+    
+    /* Direction setup */
+    Stspin220_SetDirection(direction);
+    
+    Stspin220_ComputeSpeedProfile(stepCount);
+    
+    /* Motor activation */
+    Stspin220_StartMovement();
+  }  
+}
+
+/******************************************************//**
+ * @brief Put STSpin220 device in standby (low power consumption)
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_PutDeviceInStandby(void)
+{
+  /* Stop movement */
+  Stspin220_HardHiZ();
+  
+  /* Enter standby */
+  Stspin220_Board_Reset();
+  
+  devicePrm.motionState = STANDBY;
+}
+
+/******************************************************//**
+ * @brief  Runs the motor. It will accelerate from the min 
+ * speed up to the max speed by using the device acceleration.
+ * @param[in] direction FORWARD or BACKWARD
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_Run(motorDir_t direction)
+{
+  /* Exit from standby if needed */
+  if (devicePrm.motionState == STANDBY)
+  {
+    Stspin220_ExitDeviceFromStandby();
+  }
+  /* Deactivate motor if needed */
+  else if (devicePrm.motionState != INACTIVE)
+  {
+    Stspin220_HardHiZ();
+  }
+  
+    /* Direction setup */
+    Stspin220_SetDirection(direction);
+    devicePrm.commandExecuted = RUN_CMD;
+    /* Motor activation */
+    Stspin220_StartMovement(); 
+}
+
+/******************************************************//**
+ * @brief  Changes the acceleration
+ * @param[in] newAcc New acceleration to apply in pps^2
+ * @retval true if the command is successfully executed, else false
+ * @note The command is not performed if the device is executing 
+ * a MOVE or GOTO command (but it can be used during a RUN command)
+ **********************************************************/
+bool STSpin220::Stspin220_SetAcceleration(uint16_t newAcc)
+{                                                  
+  bool cmdExecuted = false;
+  if ((newAcc != 0)&&
+      (((devicePrm.motionState & INACTIVE) == INACTIVE)||
+       (devicePrm.commandExecuted == RUN_CMD)))
+  {
+    devicePrm.acceleration = newAcc;
+    cmdExecuted = true;
+  }    
+  return cmdExecuted;
+}
+
+/******************************************************//**
+ * @brief  Changes the deceleration
+ * @param[in] newDec New deceleration to apply in pps^2
+ * @retval true if the command is successfully executed, else false
+ * @note The command is not performed if the device is executing 
+ * a MOVE or GOTO command (but it can be used during a RUN command)
+ **********************************************************/
+bool STSpin220::Stspin220_SetDeceleration(uint16_t newDec)
+{                                                  
+  bool cmdExecuted = false;
+  if ((newDec != 0)&& 
+      (((devicePrm.motionState & INACTIVE) == INACTIVE)||
+       (devicePrm.commandExecuted == RUN_CMD)))
+  {
+    devicePrm.deceleration = newDec;
+    cmdExecuted = true;
+  }      
+  return cmdExecuted;
+}
+
+/******************************************************//**
+ * @brief  Specifies the direction 
+ * @param[in] dir FORWARD or BACKWARD
+ * @note The direction change is applied if the device 
+ * is in INACTIVE or STANDBY state or if the device is 
+ * executing a run command
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetDirection(motorDir_t dir)
+{
+  if ((devicePrm.motionState == INACTIVE)||\
+      (devicePrm.motionState == STANDBY))
+  {
+    devicePrm.direction = dir;
+    Stspin220_Board_SetDirectionGpio(dir);
+  }
+  else if ((devicePrm.commandExecuted&RUN_CMD)!=0)
+  {
+    devicePrm.commandExecuted=(deviceCommand_t)
+      (STSPIN220_DIR_CHANGE_BIT_MASK|devicePrm.commandExecuted);
+  }
+}
+
+/******************************************************//**
+ * @brief  Set current position to be the Home position
+ * (current position set to 0)
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetHome(void)
+{
+  devicePrm.currentPosition = 0;
+}
+
+/******************************************************//**
+ * @brief  Set current position to be the Mark position 
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetMark(void)
+{
+  devicePrm.markPosition = devicePrm.currentPosition;
+}
+
+/******************************************************//**
+ * @brief  Changes the max speed
+ * @param[in] newMaxSpeed New max speed  to apply in pps
+ * @retval true if the command is successfully executed, else false
+ * @note The command is not performed is the device is executing 
+ * a MOVE or GOTO command (but it can be used during a RUN command).
+ **********************************************************/
+bool STSpin220::Stspin220_SetMaxSpeed(uint16_t newMaxSpeed)
+{
+  bool cmdExecuted = false;
+  if ((newMaxSpeed >= STSPIN220_MIN_STCK_FREQ)&&\
+      ((newMaxSpeed <= STSPIN220_MAX_STCK_FREQ)||\
+       ((devicePrm.torqueBoostEnable != false)&&\
+        ((newMaxSpeed>>Stspin220_get_step_mode())<= STSPIN220_MAX_STCK_FREQ)))&&\
+      (devicePrm.minSpeed <= newMaxSpeed) &&\
+      (((devicePrm.motionState & INACTIVE) == INACTIVE)||\
+      (devicePrm.commandExecuted == RUN_CMD)))
+  {
+    devicePrm.maxSpeed = newMaxSpeed;
+    cmdExecuted = true;
+  }
+  return cmdExecuted;
+}
+
+/******************************************************//**
+ * @brief  Changes the min speed
+ * @param[in] newMinSpeed New min speed  to apply in pps
+ * @retval true if the command is successfully executed, else false
+ * @note The command is not performed is the device is executing 
+ * a MOVE or GOTO command (but it can be used during a RUN command).
+ **********************************************************/
+bool STSpin220::Stspin220_SetMinSpeed(uint16_t newMinSpeed)
+{                                                  
+  bool cmdExecuted = false;
+  if ((newMinSpeed >= STSPIN220_MIN_STCK_FREQ)&&
+      (newMinSpeed <= STSPIN220_MAX_STCK_FREQ) &&
+      (newMinSpeed <= devicePrm.maxSpeed) && 
+      (((devicePrm.motionState & INACTIVE) == INACTIVE)||
+       (devicePrm.commandExecuted == RUN_CMD)))
+  {
+    devicePrm.minSpeed = newMinSpeed;
+    cmdExecuted = true;
+  }  
+  return cmdExecuted;
+}
+
+/******************************************************//**
+ * @brief Set the stepping mode 
+ * @param[in] stepMode from full step to 1/256 microstep
+ * as specified in enum motorStepMode_t
+ * @retval true if the command is successfully executed, else false
+ **********************************************************/
+bool STSpin220::Stspin220_SetStepMode(motorStepMode_t stepMode)
+{
+  /* Eventually deactivate motor */
+  if ((devicePrm.motionState != INACTIVE)&&\
+      (devicePrm.motionState != STANDBY))
+  {
+    Stspin220_HardHiZ();
+  }
+
+  /* Enter standby */
+  Stspin220_Board_Reset();
+  
+  /* Reset the microstepping sequencer position */
+  devicePrm.sequencerPosition = 0;
+  
+  /* Reset current and mark positions */
+  devicePrm.currentPosition = 0; 
+  devicePrm.markPosition = 0;
+  
+  /* Set the step mode */
+  return (Stspin220_SetStepModeWithoutReset(stepMode));
+}
+
+/******************************************************//**
+ * @brief Select the mode to stop the motor.
+ * @param[in] stopMode HOLD_MODE to let power bridge enabled
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetStopMode(motorStopMode_t stopMode)
+{
+  devicePrm.stopMode = stopMode;
+}
+
+/******************************************************//**
+ * @brief Set the torque
+ * @param[in] torqueMode Torque mode as specified in enum motorTorqueMode_t
+ * @param[in] torqueValue in % (from 0 to 100)
+ * @retval None
+ * @note
+ **********************************************************/
+void STSpin220::Stspin220_SetTorque(motorTorqueMode_t torqueMode, uint8_t torqueValue)
+{
+  devicePrm.updateTorque = true;
+  if (torqueValue>100) torqueValue = 100;
+  switch(torqueMode)
+  {
+    case ACC_TORQUE:
+      devicePrm.accelTorque = torqueValue;
+      break;
+    case DEC_TORQUE:
+      devicePrm.decelTorque = torqueValue;
+      break;
+    case RUN_TORQUE:
+      devicePrm.runTorque = torqueValue;
+      break;
+    case HOLD_TORQUE:
+      devicePrm.holdTorque = torqueValue;
+      if (devicePrm.motionState != INACTIVE)
+      {
+        break;
+      }
+    case CURRENT_TORQUE:
+      devicePrm.currentTorque = torqueValue;
+      Stspin220_Board_PwmRefSetDutyCycle(torqueValue);
+    default:
+      devicePrm.updateTorque = false;
+      break; //ignore error
+  }
+}
+
+/******************************************************//**
+ * @brief Enable or disable the torque boost feature
+ * @param[in] enable true to enable torque boost, false to disable
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetTorqueBoostEnable(bool enable)
+{
+  devicePrm.torqueBoostEnable = enable;
+}
+
+/******************************************************//**
+ * @brief Set the torque boost threshold
+ * @param[in] speedThreshold speed threshold above which the step mode is
+ * changed to full step
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetTorqueBoostThreshold(uint16_t speedThreshold)
+{
+  devicePrm.torqueBoostSpeedThreshold = speedThreshold;
+}
+
+/******************************************************//**
+ * @brief  Stops the motor by using the device deceleration
+ * @retval true if the command is successfully executed, else false
+ * @note The command is not performed if the device is in INACTIVE,
+ * STANDBYTOINACTIVE or STANDBY state.
+ **********************************************************/
+bool STSpin220::Stspin220_SoftStop(void)
+{   
+  bool cmdExecuted = false;
+  if ((devicePrm.motionState & INACTIVE) != INACTIVE)
+  {
+    devicePrm.commandExecuted=(deviceCommand_t)
+      (STSPIN220_SOFT_STOP_BIT_MASK|devicePrm.commandExecuted);
+    cmdExecuted = true;
+  }
+  return (cmdExecuted);
+}
+
+/******************************************************//**
+ * @brief Get the frequency of REF PWM
+ * @retval the frequency of REF PWM in Hz
+ * @note
+ **********************************************************/
+uint32_t STSpin220::Stspin220_VrefPwmGetFreq(void)
+{
+  return devicePrm.refPwmFreq;
+}
+
+/******************************************************//**
+ * @brief Set the frequency of REF PWM
+ * @param[in] newFreq in Hz
+ * @retval None
+ * @note
+ **********************************************************/
+void STSpin220::Stspin220_VrefPwmSetFreq(uint32_t newFreq)
+{ 
+  devicePrm.refPwmFreq = newFreq;
+  Stspin220_Board_PwmRefSetFreq(newFreq);
+}
+
+/******************************************************//**
+ * @brief  Locks until the device state becomes Inactive
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_WaitWhileActive(void)
+{
+  /* Wait while motor is running */
+  while (((Stspin220_get_device_state()&INACTIVE)!=INACTIVE)||\
+   (((Stspin220_get_device_state()&INACTIVE)==INACTIVE)&&(toggleOdd!=0)));
+}
+
+/* ------------------------------------------------------------------------- */
+/* Internal functions ------------------------------------------------------ */
+/* ------------------------------------------------------------------------- */
+/******************************************************//**
+ * @brief Updates the current speed of the device
+ * @param[in] newSpeed in pps
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_ApplySpeed(uint16_t newSpeed)
+{
+  if (devicePrm.torqueBoostEnable != false)
+  {
+    if (devicePrm.stepMode > (motorStepMode_t)STEP_MODE_1_256)
+    {
+      Stspin220_ErrorHandler(STSPIN220_ERROR_APPLY_SPEED);
+    }
+    if (devicePrm.stepMode != (motorStepMode_t)STEP_MODE_FULL)
+    {
+      if (((newSpeed>>devicePrm.stepModeLatched)>\
+           devicePrm.torqueBoostSpeedThreshold)&&\
+          (((devicePrm.commandExecuted & STSPIN220_MOVE_BIT_MASK) != MOVE_CMD) ||\
+           ((devicePrm.stepsToTake-devicePrm.relativePos)>=\
+            (1<<devicePrm.stepModeLatched))))
+      {
+        if ((devicePrm.sequencerPosition & 0xFF) == 0X80)
+        {
+          Stspin220_Board_SetFullStep();
+          devicePrm.stepMode = (motorStepMode_t)STEP_MODE_FULL;
+          devicePrm.accu >>= devicePrm.stepModeLatched;
+          newSpeed >>= devicePrm.stepModeLatched;
+        }
+      }
+    }
+    else if (((newSpeed <= devicePrm.torqueBoostSpeedThreshold) &&\
+              (devicePrm.stepModeLatched != (motorStepMode_t)STEP_MODE_FULL))||\
+             (((devicePrm.commandExecuted & STSPIN220_MOVE_BIT_MASK) == MOVE_CMD)&&\
+               ((devicePrm.stepsToTake-devicePrm.relativePos)<=\
+                (1<<devicePrm.stepModeLatched))))
+    {
+      Stspin220_Board_UnsetFullStep();
+      devicePrm.stepMode = devicePrm.stepModeLatched;
+      devicePrm.accu <<= devicePrm.stepModeLatched;
+      newSpeed <<= devicePrm.stepModeLatched;
+    }
+  }
+  else if (devicePrm.stepMode != devicePrm.stepModeLatched)
+  {
+    //torqueBoostEnable has just been disabled
+    Stspin220_Board_UnsetFullStep();
+    devicePrm.stepMode = devicePrm.stepModeLatched;
+    devicePrm.accu <<= devicePrm.stepModeLatched;
+    newSpeed <<= devicePrm.stepModeLatched;
+  }
+  
+  if (newSpeed < STSPIN220_MIN_STCK_FREQ)
+  {
+    newSpeed = STSPIN220_MIN_STCK_FREQ;  
+  }
+  if (newSpeed > STSPIN220_MAX_STCK_FREQ)
+  {
+    newSpeed = STSPIN220_MAX_STCK_FREQ;
+  }
+  
+  devicePrm.speed = newSpeed;
+  Stspin220_Board_TimStckSetFreq(newSpeed);
+
+}
+
+/******************************************************//**
+ * @brief  Computes the speed profile according to the number of steps to move
+ * @param[in] nbSteps number of steps to perform
+ * @retval None
+ * @note Using the acceleration and deceleration of the device,
+ * this function determines the duration in steps of the acceleration,
+ * steady and deceleration phases.
+ * If the total number of steps to perform is big enough, a trapezoidal move
+ * is performed (i.e. there is a steady phase where the motor runs at the maximum
+ * speed.
+ * Else, a triangular move is performed (no steady phase: the maximum speed is never
+ * reached.
+ **********************************************************/
+void STSpin220::Stspin220_ComputeSpeedProfile(uint32_t nbSteps)
+{
+  uint32_t reqAccSteps;
+  uint32_t reqDecSteps;
+   
+  /* compute the number of steps to get the targeted speed */
+  uint16_t minSpeed = devicePrm.minSpeed;
+  reqAccSteps = (devicePrm.maxSpeed - minSpeed);
+  reqAccSteps *= (devicePrm.maxSpeed + minSpeed);
+  reqDecSteps = reqAccSteps;
+  reqAccSteps /= (uint32_t)devicePrm.acceleration;
+  reqAccSteps /= 2;
+
+  /* compute the number of steps to stop */
+  reqDecSteps /= (uint32_t)devicePrm.deceleration;
+  reqDecSteps /= 2;
+
+    if(( reqAccSteps + reqDecSteps ) > nbSteps)
+    {   
+    /* Triangular move  */
+    /* reqDecSteps = (Pos * Dec) /(Dec+Acc) */
+    uint32_t dec = devicePrm.deceleration;
+    uint32_t acc = devicePrm.acceleration;
+    
+    reqDecSteps =  ((uint32_t) dec * nbSteps) / (acc + dec);
+    if (reqDecSteps > 1)
+    {
+      reqAccSteps = reqDecSteps - 1;
+      if(reqAccSteps == 0)
+      {
+        reqAccSteps = 1;
+      }      
+    }
+    else
+    {
+      reqAccSteps = 0;
+    }
+    devicePrm.endAccPos = reqAccSteps;
+    devicePrm.startDecPos = reqDecSteps;
+    }
+    else
+    {    
+    /* Trapezoidal move */
+    /* accelerating phase to endAccPos */
+    /* steady phase from  endAccPos to startDecPos */
+    /* decelerating from startDecPos to stepsToTake*/
+    devicePrm.endAccPos = reqAccSteps;
+    devicePrm.startDecPos = nbSteps - reqDecSteps - 1;
+    }
+}
+
+/******************************************************//**
+ * @brief  Set the parameters of the device whose values are not defined in
+ * stspin220_target_config.h
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetDeviceParamsOtherValues(void)
+{
+  uint16_t tmp;
+
+  devicePrm.accu = 0;
+  devicePrm.currentPosition = 0;
+  devicePrm.sequencerPosition = 0;
+  devicePrm.endAccPos = 0;
+  devicePrm.relativePos = 0;
+  devicePrm.startDecPos = 0;
+  devicePrm.stepsToTake = 0;
+  devicePrm.updateTorque = false;
+  devicePrm.speed = 0;
+  devicePrm.commandExecuted = NO_CMD;
+  devicePrm.direction = FORWARD;
+  tmp = devicePrm.minSpeed;
+  if (((devicePrm.torqueBoostEnable != false)&&\
+       (devicePrm.torqueBoostSpeedThreshold>STSPIN220_MAX_STCK_FREQ))||\
+      (tmp>devicePrm.maxSpeed))
+  {
+    Stspin220_ErrorHandler(STSPIN220_ERROR_INIT);
+  }
+}
+
+/******************************************************//**
+ * @brief  Set the parameters of the device to values of the structure pointed
+ * by pInitDevicePrm. Set GPIO according to these values.
+ * @param pInitDevicePrm pointer onto the structure containing values to
+ * initialize the device parameters.
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetDeviceParamsToGivenValues(Stspin220_init_t* pInitDevicePrm)
+{
+  devicePrm.motionState = STANDBY;
+
+  if (Stspin220_SetAcceleration(pInitDevicePrm->acceleration)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_ACCELERATION); 
+  if (Stspin220_SetDeceleration(pInitDevicePrm->deceleration)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_DECELERATION);
+  if (Stspin220_SetMaxSpeed(pInitDevicePrm->maxSpeed)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MAX_SPEED);
+  if (Stspin220_SetMinSpeed(pInitDevicePrm->minSpeed)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MIN_SPEED);
+
+  Stspin220_VrefPwmSetFreq(pInitDevicePrm->vrefPwmFreq);
+  Stspin220_SetTorque(ACC_TORQUE,pInitDevicePrm->accelTorque);
+  Stspin220_SetTorque(DEC_TORQUE,pInitDevicePrm->decelTorque);
+  Stspin220_SetTorque(RUN_TORQUE,pInitDevicePrm->runTorque);
+  Stspin220_SetTorque(HOLD_TORQUE,pInitDevicePrm->holdTorque);
+  devicePrm.torqueBoostEnable = pInitDevicePrm->torqueBoostEnable;
+  devicePrm.torqueBoostSpeedThreshold = pInitDevicePrm->torqueBoostSpeedThreshold;
+  Stspin220_SetStopMode(pInitDevicePrm->stopMode);
+
+  Stspin220_SetDeviceParamsOtherValues();
+  
+  /* Set predefined step mode */
+  /* Standby-reset deactivation included to latch the MODEX inputs */
+  Stspin220_SetStepMode(pInitDevicePrm->stepMode);
+}
+
+/******************************************************//**
+ * @brief  Sets the parameters of the device to predefined values
+ * from stspin220_target_config.h
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_SetDeviceParamsToPredefinedValues(void)
+{
+  devicePrm.motionState = STANDBY;
+
+  if (Stspin220_SetAcceleration(STSPIN220_CONF_PARAM_ACC)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_ACCELERATION);
+  if (Stspin220_SetDeceleration(STSPIN220_CONF_PARAM_DEC)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_DECELERATION);
+  if (Stspin220_SetMaxSpeed(STSPIN220_CONF_PARAM_RUNNING_SPEED)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MAX_SPEED);
+  if (Stspin220_SetMinSpeed(STSPIN220_CONF_PARAM_MIN_SPEED)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MIN_SPEED);
+
+  Stspin220_VrefPwmSetFreq(STSPIN220_CONF_PARAM_REF_PWM_FREQUENCY);  
+  Stspin220_SetTorque(ACC_TORQUE,STSPIN220_CONF_PARAM_ACC_TORQUE);
+  Stspin220_SetTorque(DEC_TORQUE,STSPIN220_CONF_PARAM_DEC_TORQUE);
+  Stspin220_SetTorque(RUN_TORQUE,STSPIN220_CONF_PARAM_RUNNING_TORQUE);
+  Stspin220_SetTorque(HOLD_TORQUE,STSPIN220_CONF_PARAM_HOLDING_TORQUE);
+  devicePrm.torqueBoostEnable = STSPIN220_CONF_PARAM_TORQUE_BOOST_EN;
+  devicePrm.torqueBoostSpeedThreshold = STSPIN220_CONF_PARAM_TORQUE_BOOST_TH;
+  Stspin220_SetStopMode(STSPIN220_CONF_PARAM_AUTO_HIZ_STOP);
+
+  Stspin220_SetDeviceParamsOtherValues();
+  
+  /* Set predefined step mode */
+  /* Standby-reset deactivation included to latch the MODEX inputs */
+  Stspin220_SetStepMode((motorStepMode_t)STSPIN220_CONF_PARAM_STEP_MODE);
+}
+
+/******************************************************//**
+ * @brief Set the stepping mode without reset
+ * @param[in] stepMode from full step to 1/256 microstep
+ * as specified in enum motorStepMode_t
+ * @retval true if the command is successfully executed, else false
+ **********************************************************/
+bool STSpin220::Stspin220_SetStepModeWithoutReset(motorStepMode_t stepMode)
+{
+  /* Store step mode */
+  devicePrm.stepMode = stepMode;
+  devicePrm.stepModeLatched = stepMode;
+  
+  /* Set the mode pins to the levels corresponding to the selected step mode */
+  switch (stepMode)
+  {
+    case STEP_MODE_FULL:
+      Stspin220_Board_SetFullStep();
+      break;
+    case STEP_MODE_HALF:
+      Stspin220_Board_SetModePins(1, 0, 1, 0);
+      break;    
+    case STEP_MODE_1_4:
+      Stspin220_Board_SetModePins(0, 1, 0, 1);
+      break;        
+    case STEP_MODE_1_8:
+      Stspin220_Board_SetModePins(1, 1, 1, 0);
+      break;
+    case STEP_MODE_1_16:
+      Stspin220_Board_SetModePins(1, 1, 1, 1);
+      break;   
+    case STEP_MODE_1_32:
+      Stspin220_Board_SetModePins(0, 0, 0, 1);
+      break;   
+    case STEP_MODE_1_64:
+      Stspin220_Board_SetModePins(1, 1, 0, 1);
+      break;
+    case STEP_MODE_1_128:
+      Stspin220_Board_SetModePins(0, 0, 1, 0);
+      break;  
+    case STEP_MODE_1_256:
+      Stspin220_Board_SetModePins(1, 1, 0, 0);
+      break;
+    default:
+      return false;
+  }
+
+  /* Wait */
+  Stspin220_Board_Delay(SELECT_STEP_MODE_DELAY);
+  
+  /* Exit standby, selected step mode is latched */
+  Stspin220_Board_ReleaseReset();
+  
+  /* Let a delay after reset release and step mode latching*/
+  Stspin220_Board_Delay(AFTER_STANDBY_EXIT_DEAD_TIME);
+  
+  /* If full step mode is not selected, do not keep MODE1 = MODE2 = 0 */
+  /* after the device quit the standby condition */
+  if (stepMode!=(motorStepMode_t)STEP_MODE_FULL)
+  {
+    Stspin220_Board_UnsetFullStep();
+  }
+  
+  return true;
+}
+
+/******************************************************//**
+ * @brief Initialises the bridge parameters to start the movement
+ * and enable the power bridge
+ * @retval None
+ **********************************************************/
+void STSpin220::Stspin220_StartMovement(void)
+{
+  /* Enable STSpin220 powerstage */
+  Stspin220_Enable();
+  toggleOdd = 0;
+  devicePrm.accu = 0;
+  devicePrm.relativePos = 0;
+  Stspin220_Board_TimStckInit(true);  
+  if ((devicePrm.endAccPos == 0)&&\
+      (devicePrm.commandExecuted != RUN_CMD))
+  {
+    devicePrm.motionState = DECELERATING;
+    Stspin220_Board_PwmRefStart(devicePrm.refPwmFreq, DEC_TORQUE);
+  }
+  else
+  {
+    devicePrm.motionState = ACCELERATING;
+    Stspin220_Board_PwmRefStart(devicePrm.refPwmFreq, ACC_TORQUE);
+  }
+  /* Program the step clock */
+  Stspin220_ApplySpeed(devicePrm.minSpeed);
+}
+
+/******************************************************//**
+ * @brief  Handles the device state machine at each pulse
+ * @retval None
+ * @note Must only be called by the timer ISR
+ **********************************************************/
+void STSpin220::Stspin220_StepClockHandler(void)
+{
+  uint32_t stepModeShift = devicePrm.stepModeLatched - devicePrm.stepMode;
+  uint16_t tmp;
+  Stspin220_Board_Monitor_Set();
+  if (devicePrm.motionState == STANDBYTOINACTIVE)
+  {
+    if (toggleOdd != 0)
+    {
+      Stspin220_Board_StckMode3_Reset();
+      toggleOdd = 0;
+      if (devicePrm.sequencerPosition == 0)
+      {
+        if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
+        {
+          Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
+        }
+        return;
+      }      
+    }
+    else
+    {
+      Stspin220_Board_StckMode3_Set();
+      toggleOdd = 1;
+      tmp = (1 << ((motorStepMode_t)STEP_MODE_1_256-devicePrm.stepMode));
+      devicePrm.sequencerPosition -= tmp;
+    }
+    Stspin220_Board_TimStckSetFreq(STSPIN220_MAX_STCK_FREQ);
+    return;
+  }  
+  
+  if (toggleOdd == 0)
+  {
+    Stspin220_Board_StckMode3_Set();
+    toggleOdd = 1;
+  }
+  else
+  {
+    Stspin220_Board_StckMode3_Reset();
+    toggleOdd = 0;
+    /* Incrementation of the relative position */
+    devicePrm.relativePos += (1 << stepModeShift);
+
+    /* Incrementation of the current position */
+    if (devicePrm.direction != BACKWARD)
+    {
+      devicePrm.currentPosition += (1 << stepModeShift);
+      tmp = (1 << ((motorStepMode_t)STEP_MODE_1_256-devicePrm.stepMode));
+      devicePrm.sequencerPosition += tmp;
+      if (devicePrm.sequencerPosition >= (SEQUENCER_MAX_VALUE+1))
+      {
+        devicePrm.sequencerPosition -= (SEQUENCER_MAX_VALUE+1);
+      }
+    }
+    else
+    {
+      devicePrm.currentPosition -= (1 << stepModeShift);
+      tmp = (1 << ((motorStepMode_t)STEP_MODE_1_256-devicePrm.stepMode));
+      devicePrm.sequencerPosition -= tmp;
+      if (devicePrm.sequencerPosition < 0)
+      {
+        devicePrm.sequencerPosition += (SEQUENCER_MAX_VALUE+1);
+      }
+    }
+
+    switch (devicePrm.motionState) 
+    {
+      case ACCELERATING: 
+      {
+          uint32_t relPos = devicePrm.relativePos;
+          uint32_t endAccPos = devicePrm.endAccPos;
+          uint16_t speed = devicePrm.speed;
+          uint32_t acc = ((uint32_t)devicePrm.acceleration << 16)>>stepModeShift;
+        
+          if (((devicePrm.commandExecuted&(STSPIN220_SOFT_STOP_BIT_MASK|STSPIN220_DIR_CHANGE_BIT_MASK))!=0)||\
+              ((devicePrm.commandExecuted==MOVE_CMD)&&(relPos>=devicePrm.startDecPos)))
+          {
+            devicePrm.motionState = DECELERATING;
+            devicePrm.accu = 0;
+            /* Apply decelerating torque */
+            Stspin220_ApplyTorque(DEC_TORQUE);
+          }
+          else if ((speed>=(devicePrm.maxSpeed>>stepModeShift))||\
+                   ((devicePrm.commandExecuted==MOVE_CMD)&&(relPos >= endAccPos)))
+          {
+            devicePrm.motionState = STEADY;
+            /* Apply running torque */
+            Stspin220_ApplyTorque(RUN_TORQUE);
+          }
+          else
+          {
+            bool speedUpdated = false;
+            /* Go on accelerating */
+            if (speed==0) speed =1;
+            devicePrm.accu += acc / speed;
+            while (devicePrm.accu>=(0X10000L))
+            {
+              devicePrm.accu -= (0X10000L);
+              speed +=1;
+              speedUpdated = true;
+            }
+          
+            if (speedUpdated)
+            {
+              if (speed>(devicePrm.maxSpeed>>stepModeShift))
+              {
+                speed = devicePrm.maxSpeed>>stepModeShift;
+              }    
+              devicePrm.speed = speed;
+            }
+            
+            if (devicePrm.updateTorque!=false)
+            {
+              /* Apply accelerating torque */
+              Stspin220_ApplyTorque(ACC_TORQUE);              
+            }
+          }
+          break;
+      }
+      case STEADY: 
+      {
+        uint16_t maxSpeed = devicePrm.maxSpeed>>stepModeShift;
+        uint32_t relativePos = devicePrm.relativePos;
+        if (devicePrm.updateTorque!=false)
+        {
+          /* Apply accelerating torque */
+          Stspin220_ApplyTorque(RUN_TORQUE);
+        }
+        if  (((devicePrm.commandExecuted&(STSPIN220_SOFT_STOP_BIT_MASK|STSPIN220_DIR_CHANGE_BIT_MASK))!=0)||\
+             ((devicePrm.commandExecuted==MOVE_CMD)&&\
+              (relativePos>=(devicePrm.startDecPos)))||\
+             ((devicePrm.commandExecuted==RUN_CMD)&&\
+              (devicePrm.speed>maxSpeed)))
+        {
+          devicePrm.motionState = DECELERATING;
+          devicePrm.accu = 0;
+          /* Apply decelerating torque */
+          Stspin220_ApplyTorque(DEC_TORQUE);
+        }
+        else if ((devicePrm.commandExecuted==RUN_CMD)&&(devicePrm.speed<maxSpeed))
+        {
+          devicePrm.motionState = ACCELERATING;
+          devicePrm.accu = 0;
+          /* Apply accelerating torque */
+          Stspin220_ApplyTorque(ACC_TORQUE);
+        }
+        break;
+      }
+      case DECELERATING: 
+      {
+        uint32_t relativePos = devicePrm.relativePos;
+        uint16_t speed = devicePrm.speed;
+        uint32_t dec = ((uint32_t)devicePrm.deceleration << 16)>>stepModeShift;
+        if ((((devicePrm.commandExecuted&(STSPIN220_SOFT_STOP_BIT_MASK|STSPIN220_DIR_CHANGE_BIT_MASK))!=0)&&\
+             (speed<=(devicePrm.minSpeed>>stepModeShift)))||\
+            ((devicePrm.commandExecuted==MOVE_CMD)&&(relativePos>=devicePrm.stepsToTake)))
+        {
+          /* Motion process complete */
+          if ((devicePrm.commandExecuted&STSPIN220_DIR_CHANGE_BIT_MASK)!=0)
+          {
+            devicePrm.commandExecuted=(deviceCommand_t)((~STSPIN220_DIR_CHANGE_BIT_MASK)&devicePrm.commandExecuted);
+            if (devicePrm.direction==BACKWARD) devicePrm.direction=FORWARD;
+            else devicePrm.direction=BACKWARD;
+            Stspin220_Board_SetDirectionGpio(devicePrm.direction);
+            if ((devicePrm.commandExecuted&STSPIN220_SOFT_STOP_BIT_MASK)==0)
+            {
+              devicePrm.motionState = ACCELERATING;
+              devicePrm.accu = 0;
+              /* Apply accelerating torque */
+              Stspin220_ApplyTorque(ACC_TORQUE);
+              break;
+            }
+          }
+          if (devicePrm.stopMode==HOLD_MODE)
+          {
+            Stspin220_HardStop();
+          }
+          else if (devicePrm.stopMode==STANDBY_MODE)
+          {
+            Stspin220_PutDeviceInStandby();
+          }
+          else
+          {
+            Stspin220_HardHiZ();
+          }
+        }
+        else if ((devicePrm.commandExecuted==RUN_CMD)&&
+                 (speed<=(devicePrm.maxSpeed>>stepModeShift)))
+        {
+          devicePrm.motionState = STEADY;
+          /* Apply running torque */
+          Stspin220_ApplyTorque(RUN_TORQUE);
+        }
+        else
+        {
+          /* Go on decelerating */
+          if (speed>(devicePrm.minSpeed>>stepModeShift))
+          {
+            bool speedUpdated = false;
+            if (speed==0) speed =1;
+            devicePrm.accu += dec / speed;
+            while (devicePrm.accu>=(0X10000L))
+            {
+              devicePrm.accu -= (0X10000L);
+              if (speed>1)
+              {  
+                speed -=1;
+              }
+              speedUpdated = true;
+            }
+          
+            if (speedUpdated)
+            {
+              if (speed<(devicePrm.minSpeed>>stepModeShift))
+              {
+                speed = devicePrm.minSpeed>>stepModeShift;
+              }  
+              devicePrm.speed = speed;
+            }
+            
+            if (devicePrm.updateTorque!=false)
+            {
+              /* Apply decelerating torque */
+              Stspin220_ApplyTorque(DEC_TORQUE);
+            }
+          }
+        }
+        break;
+      }
+      default: 
+      {
+        break;
+      }
+    }
+  }
+  if ((devicePrm.motionState & INACTIVE) != INACTIVE)
+  {
+    Stspin220_ApplySpeed(devicePrm.speed);
+  }
+  else
+  {
+    if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
+    {
+      Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
+    }
+  }
+  Stspin220_Board_Monitor_Reset();
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/stspin220/STSpin220_config.h	Fri Mar 24 10:59:19 2017 +0100
@@ -0,0 +1,120 @@
+/**************************************************************************//**
+  * @file    STSpin220_config.h
+  * @author  IPC Rennes
+  * @version V1.1.0
+  * @date    May 26th, 2016
+  * @brief   Predefines values for the STSpin220 registers
+  * and for the devices parameters
+  * @note    (C) COPYRIGHT 2016 STMicroelectronics
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STSPIN220_CONFIG_H
+#define __STSPIN220_CONFIG_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif  
+   
+/** @addtogroup STSpin220
+  * @{
+  */
+
+/** @addtogroup Stspin220_Exported_Constants
+  * @{
+  */
+   
+/** @defgroup Predefined_Stspin220_Registers_Values Predefined Stspin220 Registers Values
+  * @{
+  */
+
+/************************ Speed Profile  *******************************/
+
+/// Acceleration rate in pulse/s2 (must be greater than 0)
+#define STSPIN220_CONF_PARAM_ACC                               (480)
+   
+/// Deceleration rate in pulse/s2 (must be greater than 0)
+#define STSPIN220_CONF_PARAM_DEC                               (480)
+   
+/// Running speed in pulse/s (8 pulse/s < Maximum speed <= 10 000 pulse/s )
+#define STSPIN220_CONF_PARAM_RUNNING_SPEED                     (1600)
+   
+/// Minimum speed in pulse/s (8 pulse/s <= Minimum speed < 10 000 pulse/s)
+#define STSPIN220_CONF_PARAM_MIN_SPEED                         (400)
+
+/************************ Torque  *******************************/
+
+/// Acceleration torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_ACC_TORQUE                        (20)
+
+/// Deceleration torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_DEC_TORQUE                        (15)
+
+/// Running torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_RUNNING_TORQUE                    (10)
+
+/// Holding torque in % (from 0 to 100)
+#define STSPIN220_CONF_PARAM_HOLDING_TORQUE                    (25)
+
+/// Torque boost speed enable
+#define STSPIN220_CONF_PARAM_TORQUE_BOOST_EN                   (TRUE)
+
+/// Torque boost speed threshold in fullstep/s
+#define STSPIN220_CONF_PARAM_TORQUE_BOOST_TH                   (200)
+    
+/******************************* Others ***************************************/
+
+/// Step mode selection settings
+#define STSPIN220_CONF_PARAM_STEP_MODE                         (STEP_MODE_1_32)
+   
+/// Automatic HIZ STOP
+#define STSPIN220_CONF_PARAM_AUTO_HIZ_STOP                     (HOLD_MODE)
+
+/// REF PWM frequency (Hz)
+#define STSPIN220_CONF_PARAM_REF_PWM_FREQUENCY                 (100000)
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif /* __STSPIN220_CONFIG_H */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/stspin220/STSpin220_def.h	Fri Mar 24 10:59:19 2017 +0100
@@ -0,0 +1,344 @@
+/******************************************************//**
+  * @file    STSpin220.h 
+  * @author  IPC Rennes
+  * @version V1.1.0
+  * @date    May 26th, 2016
+  * @brief   Header for STSpin220 driver (fully integrated microstepping motor driver)
+  * @note    (C) COPYRIGHT 2016 STMicroelectronics
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STSPIN220_H
+#define __STSPIN220_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/* Includes ------------------------------------------------------------------*/
+#include "STSpin220_config.h"
+#include "motor_def.h"
+
+/* Definitions ---------------------------------------------------------------*/
+
+/** @addtogroup Components
+ * @{
+ */
+    
+/** @defgroup STSpin220
+  * @{
+  */
+
+/** @defgroup Stspin220_Exported_Constants Stspin220 Exported Constants
+  * @{
+  */
+/// Current FW major version
+#define STSPIN220_FW_MAJOR_VERSION (uint8_t)(1)
+/// Current FW minor version
+#define STSPIN220_FW_MINOR_VERSION (uint8_t)(1)
+/// Current FW patch version
+#define STSPIN220_FW_PATCH_VERSION (uint8_t)(0)
+/// Current FW version
+#define STSPIN220_FW_VERSION       (uint32_t)((STSPIN220_FW_MAJOR_VERSION<<16)|\
+                                              (STSPIN220_FW_MINOR_VERSION<<8)|\
+                                              (STSPIN220_FW_PATCH_VERSION))
+
+/// Max position
+#define STSPIN220_MAX_POSITION           (0x7FFFFFFF)
+
+/// Min position
+#define STSPIN220_MIN_POSITION           (0x80000000)
+
+/// Position range
+#define STSPIN220_POSITION_RANGE         ((uint32_t)(STSPIN220_MAX_POSITION -\
+                                                        STSPIN220_MIN_POSITION))
+/// STSpin220 error base number
+#define STSPIN220_ERROR_BASE             (0xA000)
+
+/// run bit mask
+#define STSPIN220_RUN_BIT_MASK           (0x01)
+
+/// move bit mask
+#define STSPIN220_MOVE_BIT_MASK          (0x02)
+
+/// soft stop bit mask
+#define STSPIN220_SOFT_STOP_BIT_MASK     (0x04)
+   
+/// direction change bit mask
+#define STSPIN220_DIR_CHANGE_BIT_MASK    (0x08)
+
+/// Maximum frequency of the step clock frequency in Hz
+#define STSPIN220_MAX_STCK_FREQ          (10000)
+
+/// Minimum frequency of the step clock frequency in Hz
+#define STSPIN220_MIN_STCK_FREQ          (8)
+
+/// Minimum duration of standby 
+#define STANDBY_MIN_DURATION             (1)
+    
+/// Dead time after standby exit
+#define AFTER_STANDBY_EXIT_DEAD_TIME     (1)
+
+/// Reset delay to select step mode
+#define SELECT_STEP_MODE_DELAY           (1)
+
+/// PWM REF and bridges disable delay
+#define DISABLE_DELAY                    (1)
+
+/// Microstepping sequencer maximum value
+#define SEQUENCER_MAX_VALUE              (uint16_t)(0x3FF)
+
+/// MCU wait time after power bridges are enabled
+#define BRIDGE_TURN_ON_DELAY                                     (10)
+
+/// RC Filtering delay on the PWM
+#define PWM_FILTER_TIME_CONSTANT                                 (5)
+/**
+  * @}
+  */
+
+/* Types ---------------------------------------------------------------------*/
+
+/** @defgroup Stspin220_Exported_Types Stspin220 Exported Types
+  * @{
+  */
+
+/** @defgroup Error_Types Error Types
+  * @{
+  */
+/// Errors
+typedef enum {
+  STSPIN220_ERROR_SET_HOME         = STSPIN220_ERROR_BASE,      /// Error while setting home position
+  STSPIN220_ERROR_SET_MAX_SPEED    = STSPIN220_ERROR_BASE + 1,  /// Error while setting max speed
+  STSPIN220_ERROR_SET_MIN_SPEED    = STSPIN220_ERROR_BASE + 2,  /// Error while setting min speed
+  STSPIN220_ERROR_SET_ACCELERATION = STSPIN220_ERROR_BASE + 3,  /// Error while setting acceleration
+  STSPIN220_ERROR_SET_DECELERATION = STSPIN220_ERROR_BASE + 4,  /// Error while setting decelaration
+  STSPIN220_ERROR_MCU_OSC_CONFIG   = STSPIN220_ERROR_BASE + 5,  /// Error while configuring mcu oscillator
+  STSPIN220_ERROR_MCU_CLOCK_CONFIG = STSPIN220_ERROR_BASE + 6,  /// Error while configuring mcu clock
+  STSPIN220_ERROR_POSITION         = STSPIN220_ERROR_BASE + 7,  /// Unexpected current position (wrong number of steps)
+  STSPIN220_ERROR_SPEED            = STSPIN220_ERROR_BASE + 8,  /// Unexpected current speed
+  STSPIN220_ERROR_INIT             = STSPIN220_ERROR_BASE + 9,  /// Unexpected number of devices or unexpected value for predefined parameter
+  STSPIN220_ERROR_SET_DIRECTION    = STSPIN220_ERROR_BASE + 10, /// Error while setting direction
+  STSPIN220_ERROR_SET_STEP_MODE    = STSPIN220_ERROR_BASE + 11, /// Attempt to set an unsupported step mode
+  STSPIN220_ERROR_APPLY_SPEED      = STSPIN220_ERROR_BASE + 12, /// Error while applying speed
+  STSPIN220_ERROR_SET_TORQUE       = STSPIN220_ERROR_BASE + 13, /// Error while setting torque
+  STSPIN220_ERROR_STEP_CLOCK       = STSPIN220_ERROR_BASE + 14  /// Error related to step clock
+}errorTypes_t;
+/**
+  * @}
+  */
+
+/** @defgroup Device_Commands Device Commands
+  * @{
+  */
+/// Device commands 
+typedef enum {
+  NO_CMD              = 0x00, 
+  RUN_CMD             = (STSPIN220_RUN_BIT_MASK),
+  MOVE_CMD            = (STSPIN220_MOVE_BIT_MASK),
+} deviceCommand_t;
+/**
+  * @}
+  */
+
+/** @defgroup Device_Parameters Device Parameters
+  * @{
+  */
+/// Device Parameters Structure Type
+typedef struct {
+    /// accumulator used to store speed increase smaller than 1 pps
+    volatile uint32_t accu;           
+    /// Position in microstep according to current step mode
+    volatile int32_t currentPosition;
+    /// Position of sequencer
+    volatile int16_t sequencerPosition;
+    /// mark position in microstep (motor position control mode)
+    volatile int32_t markPosition;
+    /// position in microstep at the end of the accelerating phase
+    volatile uint32_t endAccPos;      
+    /// nb of in microstep performed from the beggining of the goto or the move command 
+    volatile uint32_t relativePos;    
+    /// position in microstep step at the start of the decelerating phase
+    volatile uint32_t startDecPos;    
+    /// nb of microstep steps to perform for the goto or move commands
+    uint32_t stepsToTake;
+    
+    /// constant speed phase torque value (%)
+    volatile uint8_t runTorque;
+    /// acceleration phase torque value (%)
+    volatile uint8_t accelTorque;
+    /// deceleration phase torque value (%)
+    volatile uint8_t decelTorque;
+    /// holding phase torque value (%)
+    volatile uint8_t holdTorque;
+    /// current selected torque value
+    volatile uint8_t currentTorque;
+    /// torque update
+    volatile bool updateTorque;
+    /// PWM frequency used to generate REF voltage
+    volatile uint32_t refPwmFreq;
+    /// torque boost enable
+    volatile bool torqueBoostEnable;
+    /// torque boost speed threshold
+    volatile uint16_t torqueBoostSpeedThreshold;
+    
+    /// acceleration in pps^2 
+    volatile uint16_t acceleration;
+    /// deceleration in pps^2
+    volatile uint16_t deceleration;
+    /// max speed in pps (speed use for goto or move command)
+    volatile uint16_t maxSpeed;
+    /// min speed in pps
+    volatile uint16_t minSpeed;
+    /// current speed in pps
+    volatile uint16_t speed;
+    
+    /// command under execution
+    volatile deviceCommand_t commandExecuted; 
+    /// FORWARD or BACKWARD direction
+    volatile motorDir_t direction;                 
+    /// current state of the device
+    volatile motorState_t motionState;
+    /// current step mode
+    volatile motorStepMode_t stepMode;
+    /// latched step mode
+    motorStepMode_t stepModeLatched;
+    /// current stop mode
+    motorStopMode_t stopMode;
+    
+}deviceParams_t; 
+/**
+  * @}
+  */
+
+/// Motor driver initialization structure definition  
+typedef struct
+{
+  /// acceleration in pps^2
+  uint16_t acceleration;
+  /// deceleration in pps^2
+  uint16_t deceleration;
+  /// max speed in pps (speed use for goto or move command)
+  uint16_t maxSpeed;
+  /// min speed in pps
+  uint16_t minSpeed;
+  /// acceleration phase torque value (%)
+  uint8_t accelTorque;
+  /// deceleration phase torque value (%)
+  uint8_t decelTorque;
+  /// constant speed phase torque value (%)
+  uint8_t runTorque;
+  /// holding phase torque value (%)
+  uint8_t holdTorque;
+  /// torque boost enable
+  bool torqueBoostEnable;
+  /// torque boost speed threshold
+  uint16_t torqueBoostSpeedThreshold;
+  /// step mode
+  motorStepMode_t stepMode;
+  /// stop mode
+  motorStopMode_t stopMode;
+  /// PWM frequency used to generate REF voltage
+  uint32_t vrefPwmFreq;
+} Stspin220_init_t;
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/* Functions --------------------------------------------------------*/
+
+/** @defgroup MotorControl_Board_Linked_Functions MotorControl Board Linked Functions
+  * @{
+  */
+///Delay of the requested number of milliseconds
+extern void Stspin220_Board_Delay(uint32_t delay);
+///Enable Irq
+extern void Stspin220_Board_EnableIrq(void);
+///Disable Irq
+extern void Stspin220_Board_DisableIrq(void);
+///Setting the Stck Timeout delay and attaching a callback function to it
+extern void Stspin220_Board_TimStckSetFreq(uint16_t newFreq);
+///Initialises the step clock pin level
+extern void Stspin220_Board_TimStckInit(void);
+///Stopping the Timeout
+extern uint8_t Stspin220_Board_TimStckStop(volatile uint8_t *pToggleOdd);
+///Set the duty cycle of the PwmOut used for the REF
+extern void Stspin220_Board_PwmRefSetDutyCycle(uint8_t dutyCycle);
+///Set the frequency of the PwmOut used for the REF
+extern void Stspin220_Board_PwmRefSetFreq(uint32_t newFreq);
+///Start the reference voltage pwm
+extern void Stspin220_Board_PwmRefStart(void);
+///Reset the STSpin220 reset pin
+extern void Stspin220_Board_Releasereset(void);
+///Set the STSpin220 reset pin 
+extern void Stspin220_Board_reset(void);
+///Set direction GPIO
+extern void Stspin220_Board_SetDirectionGpio(uint8_t gpioState);
+///Reset the STCK\MODE3 pin
+extern void Stspin220_Board_StckMode3_reset(void);
+///Set the STCK\MODE3 pin
+extern void Stspin220_Board_StckMode3_Set(void);
+///Enable the power bridges (leave the output bridges HiZ)
+extern void Stspin220_Board_enable(void); 
+///Disable the power bridges (leave the output bridges HiZ)    
+extern void Stspin220_Board_disable(void); 
+///Select the STSpin220 mode1, mode2, mode3 and mode4 pins levels
+extern bool Stspin220_Board_SetModePins(uint8_t modePin1Level,\
+  uint8_t modePin2Level,\
+  uint8_t modePin3Level,\
+  uint8_t modePin4Level);
+///Select Full Step mode
+extern void Stspin220_Board_SetFullStep(void);
+///Unselect Full Step mode
+extern void Stspin220_Board_UnsetFullStep(void);
+/**
+  * @}
+  */
+
+  /**
+  * @}
+  */
+
+/**
+  * @}
+  */
+  
+#ifdef __cplusplus
+  }
+#endif
+
+#endif /* #ifndef __STSPIN220_H */
+
+/******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
--- a/Components/stspin220/stspin220.h	Wed Jul 27 12:00:06 2016 +0000
+++ b/Components/stspin220/stspin220.h	Fri Mar 24 10:59:19 2017 +0100
@@ -1,344 +1,1200 @@
-/******************************************************//**
-  * @file    stspin220.h 
-  * @author  IPC Rennes
-  * @version V1.1.0
-  * @date    May 26th, 2016
-  * @brief   Header for STSPIN220 driver (fully integrated microstepping motor driver)
-  * @note    (C) COPYRIGHT 2016 STMicroelectronics
-  ******************************************************************************
-  * @attention
-  *
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
+/**
+ ******************************************************************************
+ * @file    stspin220_class.h
+ * @author  IPC Rennes
+ * @version V1.0.0
+ * @date    July 27th, 2016
+ * @brief   This file contains the class of a STSpin220 Motor Control component.
+ * @note    (C) COPYRIGHT 2016 STMicroelectronics
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *   1. Redistributions of source code must retain the above copyright notice,
+ *      this list of conditions and the following disclaimer.
+ *   2. Redistributions in binary form must reproduce the above copyright notice,
+ *      this list of conditions and the following disclaimer in the documentation
+ *      and/or other materials provided with the distribution.
+ *   3. Neither the name of STMicroelectronics nor the names of its contributors
+ *      may be used to endorse or promote products derived from this software
+ *      without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
 
 /* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STSPIN220_H
-#define __STSPIN220_H
 
-#ifdef __cplusplus
- extern "C" {
-#endif 
+#ifndef __STSPIN220_CLASS_H
+#define __STSPIN220_CLASS_H
+
 
 /* Includes ------------------------------------------------------------------*/
-#include "stspin220_target_config.h"
-#include "motor.h"
 
-/* Definitions ---------------------------------------------------------------*/
-
-/** @addtogroup Components
- * @{
- */
-    
-/** @defgroup STSPIN220
-  * @{
-  */
-
-/** @defgroup Stspin220_Exported_Constants Stspin220 Exported Constants
-  * @{
-  */
-/// Current FW major version
-#define STSPIN220_FW_MAJOR_VERSION (uint8_t)(1)
-/// Current FW minor version
-#define STSPIN220_FW_MINOR_VERSION (uint8_t)(1)
-/// Current FW patch version
-#define STSPIN220_FW_PATCH_VERSION (uint8_t)(0)
-/// Current FW version
-#define STSPIN220_FW_VERSION       (uint32_t)((STSPIN220_FW_MAJOR_VERSION<<16)|\
-                                              (STSPIN220_FW_MINOR_VERSION<<8)|\
-                                              (STSPIN220_FW_PATCH_VERSION))
-
-/// Max position
-#define STSPIN220_MAX_POSITION           (0x7FFFFFFF)
-
-/// Min position
-#define STSPIN220_MIN_POSITION           (0x80000000)
-
-/// Position range
-#define STSPIN220_POSITION_RANGE         ((uint32_t)(STSPIN220_MAX_POSITION -\
-                                                        STSPIN220_MIN_POSITION))
-/// STSPIN220 error base number
-#define STSPIN220_ERROR_BASE             (0xA000)
-
-/// run bit mask
-#define STSPIN220_RUN_BIT_MASK           (0x01)
-
-/// move bit mask
-#define STSPIN220_MOVE_BIT_MASK          (0x02)
-
-/// soft stop bit mask
-#define STSPIN220_SOFT_STOP_BIT_MASK     (0x04)
-   
-/// direction change bit mask
-#define STSPIN220_DIR_CHANGE_BIT_MASK    (0x08)
-
-/// Maximum frequency of the step clock frequency in Hz
-#define STSPIN220_MAX_STCK_FREQ          (10000)
-
-/// Minimum frequency of the step clock frequency in Hz
-#define STSPIN220_MIN_STCK_FREQ          (8)
-
-/// Minimum duration of standby 
-#define STANDBY_MIN_DURATION             (1)
-    
-/// Dead time after standby exit
-#define AFTER_STANDBY_EXIT_DEAD_TIME     (1)
-
-/// Reset delay to select step mode
-#define SELECT_STEP_MODE_DELAY           (1)
-
-/// PWM REF and bridges disable delay
-#define DISABLE_DELAY                    (1)
-
-/// Microstepping sequencer maximum value
-#define SEQUENCER_MAX_VALUE              (uint16_t)(0x3FF)
-
-/// MCU wait time after power bridges are enabled
-#define BRIDGE_TURN_ON_DELAY                                     (10)
-
-/// RC Filtering delay on the PWM
-#define PWM_FILTER_TIME_CONSTANT                                 (5)
-/**
-  * @}
-  */
-
-/* Types ---------------------------------------------------------------------*/
-
-/** @defgroup Stspin220_Exported_Types Stspin220 Exported Types
-  * @{
-  */
-
-/** @defgroup Error_Types Error Types
-  * @{
-  */
-/// Errors
-typedef enum {
-  STSPIN220_ERROR_SET_HOME         = STSPIN220_ERROR_BASE,      /// Error while setting home position
-  STSPIN220_ERROR_SET_MAX_SPEED    = STSPIN220_ERROR_BASE + 1,  /// Error while setting max speed
-  STSPIN220_ERROR_SET_MIN_SPEED    = STSPIN220_ERROR_BASE + 2,  /// Error while setting min speed
-  STSPIN220_ERROR_SET_ACCELERATION = STSPIN220_ERROR_BASE + 3,  /// Error while setting acceleration
-  STSPIN220_ERROR_SET_DECELERATION = STSPIN220_ERROR_BASE + 4,  /// Error while setting decelaration
-  STSPIN220_ERROR_MCU_OSC_CONFIG   = STSPIN220_ERROR_BASE + 5,  /// Error while configuring mcu oscillator
-  STSPIN220_ERROR_MCU_CLOCK_CONFIG = STSPIN220_ERROR_BASE + 6,  /// Error while configuring mcu clock
-  STSPIN220_ERROR_POSITION         = STSPIN220_ERROR_BASE + 7,  /// Unexpected current position (wrong number of steps)
-  STSPIN220_ERROR_SPEED            = STSPIN220_ERROR_BASE + 8,  /// Unexpected current speed
-  STSPIN220_ERROR_INIT             = STSPIN220_ERROR_BASE + 9,  /// Unexpected number of devices or unexpected value for predefined parameter
-  STSPIN220_ERROR_SET_DIRECTION    = STSPIN220_ERROR_BASE + 10, /// Error while setting direction
-  STSPIN220_ERROR_SET_STEP_MODE    = STSPIN220_ERROR_BASE + 11, /// Attempt to set an unsupported step mode
-  STSPIN220_ERROR_APPLY_SPEED      = STSPIN220_ERROR_BASE + 12, /// Error while applying speed
-  STSPIN220_ERROR_SET_TORQUE       = STSPIN220_ERROR_BASE + 13, /// Error while setting torque
-  STSPIN220_ERROR_STEP_CLOCK       = STSPIN220_ERROR_BASE + 14  /// Error related to step clock
-}errorTypes_t;
-/**
-  * @}
-  */
+/* ACTION 1 ------------------------------------------------------------------*
+ * Include here platform specific header files.                               *
+ *----------------------------------------------------------------------------*/        
+#include "mbed.h"
 
-/** @defgroup Device_Commands Device Commands
-  * @{
-  */
-/// Device commands 
-typedef enum {
-  NO_CMD              = 0x00, 
-  RUN_CMD             = (STSPIN220_RUN_BIT_MASK),
-  MOVE_CMD            = (STSPIN220_MOVE_BIT_MASK),
-} deviceCommand_t;
-/**
-  * @}
-  */
+/* ACTION 2 ------------------------------------------------------------------*
+ * Include here component specific header files.                              *
+ *----------------------------------------------------------------------------*/        
+#include "STSpin220.h"
+/* ACTION 3 ------------------------------------------------------------------*
+ * Include here interface specific header files.                              *
+ *                                                                            *
+ * Example:                                                                   *
+ *   #include "HumiditySensor.h"                                              *
+ *   #include "TemperatureSensor.h"                                           *
+ *----------------------------------------------------------------------------*/
+#include "StepperMotor.h"
 
-/** @defgroup Device_Parameters Device Parameters
-  * @{
-  */
-/// Device Parameters Structure Type
-typedef struct {
-    /// accumulator used to store speed increase smaller than 1 pps
-    volatile uint32_t accu;           
-    /// Position in microstep according to current step mode
-    volatile int32_t currentPosition;
-    /// Position of sequencer
-    volatile int16_t sequencerPosition;
-    /// mark position in microstep (motor position control mode)
-    volatile int32_t markPosition;
-    /// position in microstep at the end of the accelerating phase
-    volatile uint32_t endAccPos;      
-    /// nb of in microstep performed from the beggining of the goto or the move command 
-    volatile uint32_t relativePos;    
-    /// position in microstep step at the start of the decelerating phase
-    volatile uint32_t startDecPos;    
-    /// nb of microstep steps to perform for the goto or move commands
-    uint32_t stepsToTake;
-    
-    /// constant speed phase torque value (%)
-    volatile uint8_t runTorque;
-    /// acceleration phase torque value (%)
-    volatile uint8_t accelTorque;
-    /// deceleration phase torque value (%)
-    volatile uint8_t decelTorque;
-    /// holding phase torque value (%)
-    volatile uint8_t holdTorque;
-    /// current selected torque value
-    volatile uint8_t currentTorque;
-    /// torque update
-    volatile bool updateTorque;
-    /// PWM frequency used to generate REF voltage
-    volatile uint32_t refPwmFreq;
-    /// torque boost enable
-    volatile bool torqueBoostEnable;
-    /// torque boost speed threshold
-    volatile uint16_t torqueBoostSpeedThreshold;
-    
-    /// acceleration in pps^2 
-    volatile uint16_t acceleration;
-    /// deceleration in pps^2
-    volatile uint16_t deceleration;
-    /// max speed in pps (speed use for goto or move command)
-    volatile uint16_t maxSpeed;
-    /// min speed in pps
-    volatile uint16_t minSpeed;
-    /// current speed in pps
-    volatile uint16_t speed;
-    
-    /// command under execution
-    volatile deviceCommand_t commandExecuted; 
-    /// FORWARD or BACKWARD direction
-    volatile motorDir_t direction;                 
-    /// current state of the device
-    volatile motorState_t motionState;
-    /// current step mode
-    volatile motorStepMode_t stepMode;
-    /// latched step mode
-    motorStepMode_t stepModeLatched;
-    /// current stop mode
-    motorStopMode_t stopMode;
-    
-}deviceParams_t; 
-/**
-  * @}
-  */
 
-/// Motor driver initialization structure definition  
-typedef struct
-{
-  /// acceleration in pps^2
-  uint16_t acceleration;
-  /// deceleration in pps^2
-  uint16_t deceleration;
-  /// max speed in pps (speed use for goto or move command)
-  uint16_t maxSpeed;
-  /// min speed in pps
-  uint16_t minSpeed;
-  /// acceleration phase torque value (%)
-  uint8_t accelTorque;
-  /// deceleration phase torque value (%)
-  uint8_t decelTorque;
-  /// constant speed phase torque value (%)
-  uint8_t runTorque;
-  /// holding phase torque value (%)
-  uint8_t holdTorque;
-  /// torque boost enable
-  bool torqueBoostEnable;
-  /// torque boost speed threshold
-  uint16_t torqueBoostSpeedThreshold;
-  /// step mode
-  motorStepMode_t stepMode;
-  /// stop mode
-  motorStopMode_t stopMode;
-  /// PWM frequency used to generate REF voltage
-  uint32_t vrefPwmFreq;
-} Stspin220_Init_t;
-/**
-  * @}
-  */
+/* Classes -------------------------------------------------------------------*/
 
 /**
-  * @}
-  */
+ * @brief Class representing a STSpin220 component.
+ */
+class STSpin220 : public StepperMotor
+{
+public:
+    /*** Constructor and Destructor Methods ***/
+    /**
+     * @brief Constructor.
+     * @param fault_and_enable_pin  pin name of the EN\FAULT pin of the component.
+     * @param stby_reset_pin        pin name of the STBY\RESET pin of the component.
+     * @param direction_mode4_pin   pin name of the MODE4\DIR pin of the component.
+     * @param mode1_pin             pin name of the MODE1 pin of the component.
+     * @param mode2_pin             pin name of the MODE2 pin of the component.
+     * @param stck_mode3_pin        pin name of the MODE3\STCK pin of the component.
+     * @param pwm_ref_pin           pin name of the PWM connected to the REF pin of the component.
+     * @param Monitor_pin           pin name for the step clock handler duration Monitoring.
+     */
+    STSpin220(PinName fault_and_enable_pin,
+              PinName stby_reset_pin,
+              PinName direction_mode4_pin,
+              PinName mode1_pin,
+              PinName mode2_pin,
+              PinName stck_mode3_pin,
+              PinName pwm_ref_pin,
+              PinName monitor_pin = NC) : StepperMotor(),
+                                     fault_and_enable(fault_and_enable_pin),
+                                     stby_reset(stby_reset_pin),
+                                     direction_mode4(direction_mode4_pin),
+                                     mode1(mode1_pin),
+                                     mode2(mode2_pin),
+                                     stck_mode3(stck_mode3_pin),
+                                     pwm_ref(pwm_ref_pin),
+                                     monitor(monitor_pin)
+    {
+        /* Checking stackability. */
+        if (numberOfDevices!=0)
+            error("Instantiation of the STSpin220 component failed: it can't be stacked on itself.\r\n");
+
+        /* ACTION 4 ----------------------------------------------------------*
+         * Initialize here the component's member variables, one variable per *
+         * line.                                                              *
+         *                                                                    *
+         * Example:                                                           *
+         *   measure = 0;                                                     *
+         *   instance_id = number_of_instances++;                             *
+         *--------------------------------------------------------------------*/
+        errorHandlerCallback = 0;
+        memset(&devicePrm, 0, sizeof(devicePrm));
+        deviceInstance = numberOfDevices++;
+        
+        fault_and_enable_pinName = fault_and_enable_pin;
+    }
+    
+    /**
+     * @brief Destructor.
+     */
+    virtual ~STSpin220(void) {}
+    
+
+    /*** Public Component Related Methods ***/
+
+    /* ACTION 5 --------------------------------------------------------------*
+     * Implement here the component's public methods, as wrappers of the C    *
+     * component's functions.                                                 *
+     * They should be:                                                        *
+     *   + Methods with the same name of the C component's virtual table's    *
+     *     functions (1);                                                     *
+     *   + Methods with the same name of the C component's extended virtual   *
+     *     table's functions, if any (2).                                     *
+     *                                                                        *
+     * Example:                                                               *
+     *   virtual int GetValue(float *pData) //(1)                             *
+     *   {                                                                    *
+     *     return COMPONENT_GetValue(float *pfData);                          *
+     *   }                                                                    *
+     *                                                                        *
+     *   virtual int EnableFeature(void) //(2)                                *
+     *   {                                                                    *
+     *     return COMPONENT_EnableFeature();                                  *
+     *   }                                                                    *
+     *------------------------------------------------------------------------*/
+
+    /**
+     * @brief Public functions inherited from the Component Class
+     */
+
+    /**
+     * @brief  Initialize the component.
+     * @param  init Pointer to device specific initalization structure.
+     * @retval "0" in case of success, an error code otherwise.
+     */
+    virtual int init(void *init = NULL)
+    {
+        return (int) Stspin220_Init((void *) init);
+    }
+
+    /**
+     * @brief  Getting the ID of the component.
+     * @param  id Pointer to an allocated variable to store the ID into.
+     * @retval "0" in case of success, an error code otherwise.
+     */
+    virtual int read_id(uint8_t *id = NULL)
+    {
+        return (int) Stspin220_ReadID((uint8_t *) id);
+    }
+
+    /**
+     * @brief Public functions inherited from the StepperMotor Class
+     */
+
+    /**
+     * @brief  Getting the value of the motor state .
+     * @param  None.
+     * @retval The motor state accoring to motorState_t in motor.h
+     */
+    virtual unsigned int get_status(void)
+    {
+        return (unsigned int) Stspin220_get_device_state();
+    }
+
+    /**
+     * @brief  Getting the position.
+     * @param  None.
+     * @retval The position.
+     */
+    virtual signed int get_position(void)
+    {
+        return (signed int)Stspin220_GetPosition();
+    }
+
+    /**
+     * @brief  Getting the marked position.
+     * @param  None.
+     * @retval The marked position.
+     */
+    virtual signed int get_mark(void)
+    {
+        return (signed int)Stspin220_GetMark();
+    }
+
+    /**
+     * @brief  Getting the current speed in pps.
+     * @param  None.
+     * @retval The current speed in pps.
+     */
+    virtual unsigned int get_speed(void)
+    {
+        return (unsigned int)Stspin220_GetCurrentSpeed();
+    }
+
+    /**
+     * @brief  Getting the maximum speed in pps.
+     * @param  None.
+     * @retval The maximum speed in pps.
+     */
+    virtual unsigned int get_max_speed(void)
+    {
+        return (unsigned int)Stspin220_GetMaxSpeed();
+    }
+
+    /**
+     * @brief  Getting the minimum speed in pps.
+     * @param  None.
+     * @retval The minimum speed in pps.
+     */
+    virtual unsigned int get_min_speed(void)
+    {
+        return (unsigned int)Stspin220_GetMinSpeed();
+    }
+
+    /**
+     * @brief  Getting the acceleration in pps^2.
+     * @param  None.
+     * @retval The acceleration in pps^2.
+     */
+    virtual unsigned int get_acceleration(void)
+    {
+        return (unsigned int)Stspin220_GetAcceleration();
+    }
+
+    /**
+     * @brief  Getting the deceleration in pps^2.
+     * @param  None.
+     * @retval The deceleration in pps^2.
+     */
+    virtual unsigned int get_deceleration(void)
+    {
+        return (unsigned int)Stspin220_GetDeceleration();
+    }
+    
+    /**
+     * @brief  Getting the direction of rotation.
+     * @param  None.
+     * @retval The direction of rotation.
+     */
+    virtual direction_t get_direction(void)
+    {
+        if (Stspin220_GetDirection()!=BACKWARD)
+        {
+            return FWD;
+        }
+        else
+        {
+            return BWD;
+        }
+    }
+    
+    /**
+     * @brief  Setting the current position to be the home position.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void set_home(void)
+    {
+        Stspin220_SetHome();
+    }
+
+    /**
+     * @brief  Setting the current position to be the marked position.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void set_mark(void)
+    {
+        Stspin220_SetMark();
+    }
+
+    /**
+     * @brief  Setting the maximum speed in pps.
+     * @param  speed The maximum speed in pps.
+     * @retval "true" in case of success, "false" otherwise.
+     */
+    virtual bool set_max_speed(unsigned int speed)
+    {
+        if (speed <= 0xFFFF)
+        {
+            return Stspin220_SetMaxSpeed((uint16_t) speed);
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * @brief  Setting the minimum speed in pps.
+     * @param  speed The minimum speed in pps.
+     * @retval "true" in case of success, "false" otherwise.
+     */
+    virtual bool set_min_speed(unsigned int speed)
+    {
+        if (speed <= 0xFFFF)
+        {
+            return Stspin220_SetMinSpeed((uint16_t) speed);
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * @brief  Setting the acceleration in pps^2.
+     * @param  acceleration The acceleration in pps/s^2.
+     * @retval "true" in case of success, "false" otherwise.
+     */
+    virtual bool set_acceleration(unsigned int acceleration)
+    {
+        if (acceleration <= 0xFFFF)
+        {
+            return Stspin220_SetAcceleration((uint16_t) acceleration);
+        }
+        else
+        {
+            return false;
+        }
+    }
 
-/* Functions --------------------------------------------------------*/
+    /**
+     * @brief  Setting the deceleration in pps^2.
+     * @param  deceleration The deceleration in pps^2.
+     * @retval "true" in case of success, "false" otherwise.
+     */
+    virtual bool set_deceleration(unsigned int deceleration)
+    {
+        if (deceleration <= 0xFFFF)
+        {
+            return Stspin220_SetDeceleration((uint16_t) deceleration);
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * @brief  Setting the Step Mode.
+     * @param  step_mode The Step Mode.
+     * @retval "true" in case of success, "false" otherwise.
+     * @note   step_mode can be one of the following:
+     *           + STEP_MODE_FULL
+     *           + STEP_MODE_WAVE
+     *           + STEP_MODE_HALF
+     *           + STEP_MODE_1_4
+     *           + STEP_MODE_1_8
+     *           + STEP_MODE_1_16
+     */
+    virtual bool set_step_mode(step_mode_t step_mode)
+    {
+        return Stspin220_SetStepMode((motorStepMode_t) step_mode);
+    }
+
+    /**
+     * @brief  Going to a specified position.
+     * @param  position The desired position.
+     * @retval None.
+     */
+    virtual void go_to(signed int position)
+    {
+        Stspin220_GoTo((int32_t)position);
+    }
+
+    /**
+     * @brief  Going to the home position.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void go_home(void)
+    {
+        Stspin220_GoHome();
+    }
+
+    /**
+     * @brief  Going to the marked position.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void go_mark(void)
+    {
+        Stspin220_GoMark();
+    }
+
+    /**
+     * @brief  Running the motor towards a specified direction.
+     * @param  direction The direction of rotation.
+     * @retval None.
+     */
+    virtual void run(direction_t direction)
+    {
+        Stspin220_Run((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD));
+    }
+
+    /**
+     * @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.
+     * @retval None.
+     */
+    virtual void move(direction_t direction, unsigned int steps)
+    {
+        Stspin220_Move((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD), (uint32_t)steps);
+    }
+
+    /**
+     * @brief  Stopping the motor through an immediate deceleration up to zero speed.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void soft_stop(void)
+    {
+        Stspin220_SoftStop();
+    }
+
+    /**
+     * @brief  Stopping the motor through an immediate infinite deceleration.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void hard_stop(void)
+    {
+        Stspin220_HardStop();
+    }
+
+    /**
+     * @brief  Disabling the power bridge after performing a deceleration to zero.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void soft_hiz(void)
+    {
+        Stspin220_SetStopMode(HIZ_MODE);
+        Stspin220_SoftStop();
+    }
+
+    /**
+     * @brief  Disabling the power bridge immediately.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void hard_hiz(void)
+    {
+        Stspin220_HardHiZ();
+    }
+
+    /**
+     * @brief  Waiting while the motor is active.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void wait_while_active(void)
+    {
+        Stspin220_WaitWhileActive();
+    }  
+
+    /**
+     * @brief Public functions NOT inherited
+     */
+     
+    /**
+     * @brief  Attaching an error handler.
+     * @param  fptr An error handler.
+     * @retval None.
+     */
+    virtual void attach_error_handler(void (*fptr)(uint16_t error))
+    {
+        Stspin220_AttachErrorHandler((void (*)(uint16_t error)) fptr);
+    }
+
+    /**
+     * @brief  Checks if the device is disabled or/and has an alarm flag set 
+     * by reading the EN FAULT pin position.
+     * @param  None.
+     * @retval One if the EN FAULT pin is low (the device is disabled or/and 
+     * has an alarm flag set), otherwise zero.
+     */
+    virtual unsigned int check_status_hw(void)
+    {
+        if (!fault_and_enable.read()) return 0x01;
+        else return 0x00;
+    }
+    
+    /**
+     * @brief  Disabling the device.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void disable(void)
+    {
+        Stspin220_Disable();
+    }
+    
+    /**
+     * @brief  Enabling the device.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void enable(void)
+    {
+        Stspin220_Enable();
+    }
+    
+    /**
+     * @brief  Exit STSpin220 device from standby (low power consumption) by
+     * setting STBY\RESET pin to high level and changing the motion state to
+     * INACTIVE.
+     * @param  None.
+     * @retval None.
+     */    
+    virtual void exit_device_from_standby(void)
+    {
+        Stspin220_ExitDeviceFromStandby();
+    }
+    
+    /**
+     * @brief  Set the frequency of the VREFA and VREFB PWM
+     * @param  frequency in Hz
+     * @retval None.
+     */  
+    virtual uint32_t get_freq_vref_pwm(void)
+    {
+        return Stspin220_VrefPwmGetFreq();
+    }    
+    
+    /**
+     * @brief  Getting the version of the firmware.
+     * @param  None.
+     * @retval The version of the firmware.
+     */
+    virtual unsigned int get_fw_version(void)
+    {
+        return (unsigned int) Stspin220_GetFwVersion();
+    }
+    
+    /**
+     * @brief  Getting the motor step mode.
+     * @param  None.
+     * @retval The motor step mode.
+     */
+    virtual step_mode_t get_step_mode(void)
+    {
+      return (step_mode_t) Stspin220_get_step_mode();
+    }
+    
+    /**
+     * @brief  Getting the motor stop mode.
+     * @param  None.
+     * @retval The motor stop mode.
+     */  
+    virtual motorStopMode_t get_stop_mode(void)
+    {
+      return Stspin220_GetStopMode();
+    }
+    
+    /**
+     * @brief  Get the motor torque.
+     * @param  torqueMode Torque mode as specified in enum motorTorqueMode_t
+     * @retval the torqueValue in % (from 0 to 100)
+     */       
+    virtual uint8_t get_torque(motorTorqueMode_t torqueMode)
+    {
+        return Stspin220_GetTorque(torqueMode);
+    }
+    
+    /**
+     * @brief  Get the torque boost feature status.
+     * @param  None.
+     * @retval true if enabled, false if disabled
+     */       
+    virtual bool get_torque_boost_enable(void)
+    {
+        return Stspin220_GetTorqueBoostEnable();
+    }
+    
+    /**
+     * @brief  Get the torque boost threshold
+     * @retval The torque boost threshold above which the step mode is
+     * changed to full step
+     */       
+    virtual uint16_t get_torque_boost_threshold(void)
+    {
+        return Stspin220_GetTorqueBoostThreshold();
+    }
+    
+    /**
+     * @brief  Going to a specified position with a specificied direction.
+     * @param  direction The desired direction.
+     * @param  position The desired position.
+     * @retval None.
+     */
+    virtual void go_to(direction_t direction, signed int position)
+    {
+        Stspin220_GoToDir((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD),(int32_t)position);
+    }
+
+    /**
+     * @brief  Put STSpin220 device in standby (low power consumption) by 
+     * setting STBY\RESET pin to low level and changing the motion state to
+     * STANDBY.
+     * @param  None.
+     * @retval None.
+     */    
+    virtual void put_device_in_standby(void)
+    {
+        Stspin220_PutDeviceInStandby();
+    }
 
-/** @defgroup MotorControl_Board_Linked_Functions MotorControl Board Linked Functions
-  * @{
-  */
-///Delay of the requested number of milliseconds
-extern void Stspin220_Board_Delay(uint32_t delay);
-///Enable Irq
-extern void Stspin220_Board_EnableIrq(void);
-///Disable Irq
-extern void Stspin220_Board_DisableIrq(void);
-///Setting the Stck Timeout delay and attaching a callback function to it
-extern void Stspin220_Board_TimStckSetFreq(uint16_t newFreq);
-///Initialises the step clock pin level
-extern void Stspin220_Board_TimStckInit(void);
-///Stopping the Timeout
-extern uint8_t Stspin220_Board_TimStckStop(volatile uint8_t *pToggleOdd);
-///Set the duty cycle of the PwmOut used for the REF
-extern void Stspin220_Board_PwmRefSetDutyCycle(uint8_t dutyCycle);
-///Set the frequency of the PwmOut used for the REF
-extern void Stspin220_Board_PwmRefSetFreq(uint32_t newFreq);
-///Start the reference voltage pwm
-extern void Stspin220_Board_PwmRefStart(void);
-///Reset the STSPIN220 reset pin
-extern void Stspin220_Board_ReleaseReset(void);
-///Set the STSPIN220 reset pin 
-extern void Stspin220_Board_Reset(void);
-///Set direction GPIO
-extern void Stspin220_Board_SetDirectionGpio(uint8_t gpioState);
-///Reset the STCK\MODE3 pin
-extern void Stspin220_Board_StckMode3_Reset(void);
-///Set the STCK\MODE3 pin
-extern void Stspin220_Board_StckMode3_Set(void);
-///Enable the power bridges (leave the output bridges HiZ)
-extern void Stspin220_Board_Enable(void); 
-///Disable the power bridges (leave the output bridges HiZ)    
-extern void Stspin220_Board_Disable(void); 
-///Select the STSPIN220 mode1, mode2, mode3 and mode4 pins levels
-extern bool Stspin220_Board_SetModePins(uint8_t modePin1Level,\
-  uint8_t modePin2Level,\
-  uint8_t modePin3Level,\
-  uint8_t modePin4Level);
-///Select Full Step mode
-extern void Stspin220_Board_SetFullStep(void);
-///Unselect Full Step mode
-extern void Stspin220_Board_UnsetFullStep(void);
-/**
-  * @}
-  */
+    /**
+     * @brief  Release the STSpin220 reset (Reset pin set to high level).
+     * @param  None.
+     * @retval None.
+     */    
+    virtual void release_reset(void)
+    {
+        Stspin220_Board_ReleaseReset();
+    }
+    
+    /**
+     * @brief  Reset the STSpin220 (Reset pin set to low level).
+     * @param  None.
+     * @retval None.
+     */    
+    virtual void reset(void)
+    {
+        Stspin220_Board_Reset();
+    }
+
+    /**
+     * @brief  Set the motor direction.
+     * @param  direction The desired direction.
+     * @retval None.
+     */
+    virtual void set_direction(direction_t direction)
+    { 
+        Stspin220_SetDirection((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD));
+    }
+
+    /**
+     * @brief  Set the frequency of the PWM for REF pin
+     * @param  frequency in Hz
+     * @retval None.
+     */  
+    virtual void set_freq_vref_pwm(uint32_t frequency)
+    {
+        Stspin220_VrefPwmSetFreq(frequency);
+    }
+
+    /**
+     * @brief  Set the motor stop mode.
+     * @param  stopMode The desired stop mode (HOLD_MODE, HIZ_MODE or
+     * STANDBY_MODE).
+     * @retval None.
+     */       
+    virtual void set_stop_mode(motorStopMode_t stopMode)
+    {
+        Stspin220_SetStopMode(stopMode);
+    }
+
+    /**
+     * @brief  Set the motor torque.
+     * @param  torqueMode Torque mode as specified in enum motorTorqueMode_t
+     * @param  torqueValue in % (from 0 to 100)
+     * @retval None.
+     */       
+    virtual void set_torque(motorTorqueMode_t torqueMode, uint8_t torqueValue)
+    {
+        Stspin220_SetTorque(torqueMode, torqueValue);
+    }
+
+    /**
+     * @brief  Enable or disable the motor torque boost feature.
+     * @param  enable enable true to enable torque boost, false to disable
+     * @retval None.
+     */       
+    virtual void set_torque_boost_enable(bool enable)
+    {
+        Stspin220_SetTorqueBoostEnable(enable);
+    }
+    
+    /**
+     * @brief Set the torque boost threshold
+     * @param[in] speedThreshold speed threshold above which the step mode is
+     * changed to full step
+     * @retval None.
+     */       
+    virtual void set_torque_boost_threshold(uint16_t speedThreshold)
+    {
+        Stspin220_SetTorqueBoostThreshold(speedThreshold);
+    }
+
+    /*** Public Interrupt Related Methods ***/
+
+    /* ACTION 6 --------------------------------------------------------------*
+     * Implement here interrupt related methods, if any.                      *
+     * Note that interrupt handling is platform dependent, e.g.:              *
+     *   + mbed:                                                              *
+     *     InterruptIn feature_irq(pin); //Interrupt object.                  *
+     *     feature_irq.rise(callback);   //Attach a callback.                 *
+     *     feature_irq.mode(PullNone);   //Set interrupt mode.                *
+     *     feature_irq.enable_irq();     //Enable interrupt.                  *
+     *     feature_irq.disable_irq();    //Disable interrupt.                 *
+     *   + Arduino:                                                           *
+     *     attachInterrupt(pin, callback, RISING); //Attach a callback.       *
+     *     detachInterrupt(pin);                   //Detach a callback.       *
+     *                                                                        *
+     * Example (mbed):                                                        *
+     *   void attach_feature_irq(void (*fptr) (void))                         *
+     *   {                                                                    *
+     *     feature_irq.rise(fptr);                                            *
+     *   }                                                                    *
+     *                                                                        *
+     *   void enable_feature_irq(void)                                        *
+     *   {                                                                    *
+     *     feature_irq.enable_irq();                                          *
+     *   }                                                                    *
+     *                                                                        *
+     *   void disable_feature_irq(void)                                       *
+     *   {                                                                    *
+     *     feature_irq.disable_irq();                                         *
+     *   }                                                                    *
+     *------------------------------------------------------------------------*/
+    /**
+     * @brief  Attaching an interrupt handler to the FLAG interrupt.
+     * @param  fptr An interrupt handler.
+     * @retval None.
+     */
+     
+    void attach_flag_irq(void (*fptr)(void))
+    {
+        fault_and_enable_irqFunctionPointer = &(*fptr);
+        fault_and_enable.fall(fptr);
+        fault_and_enable.mode(PullDown);
+        wait_ms(1);
+    }
+    
+    /**
+     * @brief  Enabling the FLAG interrupt handling.
+     * @param  None.
+     * @retval None.
+     */
+    void enable_flag_irq(void)
+    {
+        fault_and_enable.enable_irq();
+    }
+    
+protected:
+
+    /*** Protected Component Related Methods ***/
+
+    /* ACTION 7 --------------------------------------------------------------*
+     * Declare here the component's specific methods.                         *
+     * They should be:                                                        *
+     *   + Methods with the same name of the C component's virtual table's    *
+     *     functions (1);                                                     *
+     *   + Methods with the same name of the C component's extended virtual   *
+     *     table's functions, if any (2);                                     *
+     *   + Helper methods, if any, like functions declared in the component's *
+     *     source files but not pointed by the component's virtual table (3). *
+     *                                                                        *
+     * Example:                                                               *
+     *   status_t COMPONENT_get_value(float *f);   //(1)                      *
+     *   status_t COMPONENT_enable_feature(void);  //(2)                      *
+     *   status_t COMPONENT_compute_average(void); //(3)                      *
+     *------------------------------------------------------------------------*/
+    status_t Stspin220_Init(void *init);
+    status_t Stspin220_ReadID(uint8_t *id);
+    void Stspin220_AttachErrorHandler(void (*callback)(uint16_t error));
+    void Stspin220_ApplyTorque(motorTorqueMode_t torqueMode);
+    void Stspin220_disable(void);
+    void Stspin220_ErrorHandler(uint16_t error);
+    void Stspin220_enable(void);
+    void Stspin220_ExitDeviceFromStandby(void);
+    uint16_t Stspin220_GetAcceleration(void);
+    uint16_t Stspin220_GetCurrentSpeed(void);
+    uint16_t Stspin220_GetDeceleration(void);
+    motorState_t Stspin220_get_device_state(void);
+    motorDir_t Stspin220_GetDirection(void);
+    uint32_t Stspin220_GetFwVersion(void);
+    int32_t Stspin220_GetMark(void);
+    uint16_t Stspin220_GetMaxSpeed(void);
+    uint16_t Stspin220_GetMinSpeed(void);
+    int32_t Stspin220_GetPosition(void);
+    motorStepMode_t Stspin220_get_step_mode(void);
+    motorStopMode_t Stspin220_GetStopMode(void);
+    uint8_t Stspin220_GetTorque(motorTorqueMode_t torqueMode);
+    bool Stspin220_GetTorqueBoostenable(void);
+    uint16_t Stspin220_GetTorqueBoostThreshold(void);
+    void Stspin220_GoHome(void);  
+    void Stspin220_GoMark(void);
+    void Stspin220_GoTo(int32_t targetPosition);
+    void Stspin220_GoToDir(motorDir_t direction, int32_t targetPosition);   
+    void Stspin220_HardHiZ(void);
+    void Stspin220_HardStop(void);
+    void Stspin220_Move(motorDir_t direction, uint32_t stepCount);
+    void Stspin220_PutDeviceInStandby(void);
+    void Stspin220_Run(motorDir_t direction);
+    bool Stspin220_SetAcceleration(uint16_t newAcc);
+    bool Stspin220_SetDeceleration(uint16_t newDec);
+    void Stspin220_SetDirection(motorDir_t direction);
+    void Stspin220_SetHome(void);
+    void Stspin220_SetMark(void);
+    bool Stspin220_SetMaxSpeed(uint16_t volatile newSpeed);
+    bool Stspin220_SetMinSpeed(uint16_t volatile newSpeed);    
+    bool Stspin220_SetStepMode(motorStepMode_t stepMode);
+    void Stspin220_SetStopMode(motorStopMode_t stopMode);
+    bool Stspin220_SoftStop(void);
+    void Stspin220_SetTorque(motorTorqueMode_t torqueMode, uint8_t torqueValue);
+    void Stspin220_SetTorqueBoostEnable(bool enable);
+    void Stspin220_SetTorqueBoostThreshold(uint16_t speedThreshold);
+    uint32_t Stspin220_VrefPwmGetFreq(void);
+    void Stspin220_VrefPwmSetFreq(uint32_t newFreq);
+    void Stspin220_WaitWhileActive(void);
+    
+    /*** Functions intended to be used only internally ***/
+    void Stspin220_ApplySpeed(uint16_t newSpeed);
+    void Stspin220_ComputeSpeedProfile(uint32_t nbSteps);    
+    void Stspin220_SetDeviceParamsToGivenValues(Stspin220_init_t* pInitDevicePrm);
+    void Stspin220_SetDeviceParamsOtherValues(void);    
+    void Stspin220_SetDeviceParamsToPredefinedValues(void);
+    bool Stspin220_SetStepModeWithoutReset(motorStepMode_t stepMode);
+    void Stspin220_StartMovement(void);
+    void Stspin220_StepClockHandler(void);
+    
+    /*** Component's I/O Methods ***/
+
+    /* ACTION 8 --------------------------------------------------------------*
+     * Implement here other I/O methods beyond those already implemented      *
+     * above, which are declared extern within the component's header file.   *
+     *------------------------------------------------------------------------*/
+    /**
+     * @brief  Making the CPU wait.
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_Delay(uint32_t delay)
+    {
+        wait_ms(delay);
+    }
+    
+    /**
+     * @brief  Disable the power bridges (leave the output bridges HiZ).
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_disable(void)
+    {
+        fault_and_enable.disable_irq();
+        DigitalOut fault_and_enable(fault_and_enable_pinName);
+        fault_and_enable.write(0);
+    }
+
+    /**
+     * @brief  Disabling interrupts.
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_DisableIrq(void)
+    {
+        __disable_irq();
+    }
+    
+    /**
+     * @brief  Enable the power bridges (leave the output bridges HiZ).
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_enable(void)
+    {
+        DigitalOut fault_and_enable_do(fault_and_enable_pinName);
+        fault_and_enable_do.write(1);
+        fault_and_enable.fall(fault_and_enable_irqFunctionPointer);
+        fault_and_enable.mode(PullUp);
+        wait_ms(1);
+        fault_and_enable.enable_irq();
+    }
+    
+    /**
+     * @brief  Enabling interrupts.
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_EnableIrq(void)
+    {
+        __enable_irq();
+    }
 
-  /**
-  * @}
-  */
+    /**
+     * @brief  Set the duty cycle of the PwmOut used for the REF
+     * reference voltage generation and actually start the pwm if the duty cycle
+     * is not zero.
+     * @param[in] dutyCycle 0 - 100%
+     * @retval None
+     */
+    void Stspin220_Board_PwmRefSetDutyCycle(uint8_t dutyCycle)
+    {
+        pwm_ref.write(((float)(100-dutyCycle))/100);
+    }
+
+    /**
+     * @brief  Set the frequency of the PwmOut used for the REF
+     * reference voltage generation.
+     * @param[in] newFreq in Hz.
+     * @retval None.
+     */
+    void Stspin220_Board_PwmRefSetFreq(uint32_t newFreq)
+    {
+        pwm_ref.period_us(1000000.0f/newFreq);
+    }
+    
+    /**
+     * @brief  Start the PwmOut for the REF pin.
+     * @param[in] frequency frequency of the PwmOut used to generate the REF
+     * reference voltage for the bridges.
+     * @param[in] torqueMode Torque mode as specified in enum motorTorqueMode_t    
+     * @retval None.
+     */ 
+    void Stspin220_Board_PwmRefStart(uint32_t frequency, motorTorqueMode_t torqueMode)
+    { 
+        /* Setting the period of the PwmOut. */
+        pwm_ref.period_us(1000000.0f/frequency);
+        /* Setting the duty cycle and actually starting the of the PwmOut. */
+        Stspin220_ApplyTorque(torqueMode);
+        wait_ms(5*PWM_FILTER_TIME_CONSTANT);
+    }
+
+    /**
+     * @brief  Exit the device from standby reset mode.
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_Releasereset(void)
+    {
+        stby_reset = 1;
+    }
+
+    /**
+     * @brief  Put the device in standby reset mode.
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_reset(void)
+    {
+        stby_reset = 0;
+    }
+
+    /**
+     * @brief  Set the DIR\MODE4 pin.
+     * @param  dir motor direction FORWARD or BACKWARD.
+     * @retval None.
+     */
+    void Stspin220_Board_SetDirectionGpio(motorDir_t dir)
+    {
+        if (dir==BACKWARD) direction_mode4 = 0;
+        else direction_mode4 = 1;
+    }
+ 
+    /**
+     * @brief Select Full Step mode
+     * @param  None.
+     * @retval None
+     */
+    void Stspin220_Board_SetFullStep(void)
+    {
+        mode1 = 0;
+        mode2 = 0;
+    }
+    
+    /**
+     * @brief Select the STSpin220 mode1, mode2, mode3 and mode4 pins levels.
+     * @param[in] modePin1Level level of the mode1 gpio (0 low, 1+ high)
+     * @param[in] modePin2Level level of the mode2 gpio (0 low, 1+ high)
+     * @param[in] modePin3Level level of the mode3 gpio (0 low, 1+ high)
+     * @param[in] modePin4Level level of the mode4 gpio (0 low, 1+ high)
+     * @retval 1
+     */
+    uint8_t Stspin220_Board_SetModePins(uint8_t modePin1Level,\
+        uint8_t modePin2Level,\
+        uint8_t modePin3Level,\
+        uint8_t modePin4Level)
+    {
+        mode1 = modePin1Level;
+        mode2 = modePin2Level;
+        stck_mode3 = modePin3Level;
+        direction_mode4 = modePin4Level;
+        return 1;
+    }
+
+    /**
+     * @brief  Reset the STCK\MODE3 pin.
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_StckMode3_reset(void)
+    {
+        stck_mode3 = 0;
+    }
+
+    /**
+     * @brief  Set the STCK\MODE3 pin.
+     * @param  None.
+     * @retval None.
+     */
+    void Stspin220_Board_StckMode3_Set(void)
+    {
+        stck_mode3 = 1;
+    }
+
+    /**
+     * @brief Initialises the step clock pin level
+     * @param  None.
+     * @retval None
+     */
+    void Stspin220_Board_TimStckInit(bool check)
+    {
+        if (monitor.is_connected()) monitor = 0;
+        if (check==false) stck_mode3 = 0;
+        else if (stck_mode3==1) Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
+    }
 
-/**
-  * @}
-  */
-  
-#ifdef __cplusplus
-  }
-#endif
+    /**
+     * @brief  Setting the Stck Timeout delay
+     * and attaching a callback function to it.
+     * @param  frequency The frequency corresponding to the delay.
+     * @retval None.
+     */
+    void Stspin220_Board_TimStckSetFreq(uint16_t newFreq)
+    {
+        /* Computing the delay of the Timeout. */
+        float delay_us = (1000000.0f / 2 )/ newFreq;
+        
+        /* Attaching a function which updates */
+        /* the state machine after the elapsed period_us time. */
+        tim_stck.attach_us(this, &STSpin220::Stspin220_StepClockHandler, delay_us);
+    }
+
+    void Stspin220_Board_Monitor_Set(void)
+    {
+        if (monitor.is_connected()) monitor = 1;
+    }
+    
+    void Stspin220_Board_Monitor_reset(void)
+    {
+        if (monitor.is_connected()) monitor = 0;
+    }
+
+    /**
+     * @brief  Stopping the Timeout.
+     * @param  None.
+     * @retval None.
+     */
+    uint8_t Stspin220_Board_TimStckStop(volatile uint8_t *pToggleOdd)
+    {
+        __disable_irq();
+        if (*pToggleOdd == 1)
+        {
+            __enable_irq();
+            return 1;
+        }
+        if (stck_mode3 != 0)
+        {
+            __enable_irq();
+            return 0;
+        }
+        tim_stck.detach();
+        __enable_irq();
+        return 1;
+    }
+
+    /**
+     * @brief Unselect Full Step mode
+     * @param  None.
+     * @retval None
+     */
+    void Stspin220_Board_UnsetFullStep(void)
+    {
+        mode1 = 1;
+    }
+
+protected:
+
+    /*** Component's Instance Variables ***/
 
-#endif /* #ifndef __STSPIN220_H */
+    /* ACTION 9 --------------------------------------------------------------*
+     * Declare here interrupt related variables, if needed.                   *
+     * Note that interrupt handling is platform dependent, see                *
+     * "Interrupt Related Methods" above.                                     *
+     *                                                                        *
+     * Example:                                                               *
+     *   + mbed:                                                              *
+     *     InterruptIn feature_irq;                                           *
+     *------------------------------------------------------------------------*/
+    /* Fault Interrupt and chip enable. */
+    InterruptIn fault_and_enable;
+    
+    /* Interrupt to toggle the MODE3\STCK pin */
+    Timeout tim_stck;
+
+    /* ACTION 10 -------------------------------------------------------------*
+     * Declare here other pin related variables, if needed.                   *
+     *                                                                        *
+     * Example:                                                               *
+     *   + mbed:                                                              *
+     *     DigitalOut standby_reset;                                          *
+     *------------------------------------------------------------------------*/
+    /* STBY\RESET pin. */
+    DigitalOut stby_reset;
+    /* MODE4\DIR pin. */
+    DigitalOut direction_mode4;
+    /* MODE1 pin */
+    DigitalOut mode1;
+    /* MODE2 pin */
+    DigitalOut mode2;
+    /* MODE3\STCK pin. */
+    DigitalOut stck_mode3;
+
+    /* Pulse Width Modulation pin for REF pin */
+    PwmOut pwm_ref;
+ 
+    /* Monitoring of step clock handler duration */
+    DigitalOut monitor;
 
-/******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
+    /* fault and enable pin */
+    PinName fault_and_enable_pinName;
+    
+    /* ACTION 11 -------------------------------------------------------------*
+     * Declare here communication related variables, if needed.               *
+     *                                                                        *
+     * Example:                                                               *
+     *   + mbed:                                                              *
+     *     DigitalOut ssel;                                                   *
+     *     DevSPI &dev_spi;                                                   *
+     *------------------------------------------------------------------------*/
+    /* Configuration. */
+
+    /* IO Device. */
+
+    /* ACTION 12 -------------------------------------------------------------*
+     * Declare here identity related variables, if needed.                    *
+     * Note that there should be only a unique identifier for each component, *
+     * which should be the "who_am_i" parameter.                              *
+     *------------------------------------------------------------------------*/
+    /* Identity */
+    uint8_t who_am_i;
+
+    /* ACTION 13 -------------------------------------------------------------*
+     * Declare here the component's static and non-static data, one variable  *
+     * per line.                                                              *
+     *                                                                        *
+     * Example:                                                               *
+     *   float measure;                                                       *
+     *   int instance_id;                                                     *
+     *   static int number_of_instances;                                      *
+     *------------------------------------------------------------------------*/
+    /* Data. */
+    void (*fault_and_enable_irqFunctionPointer)(void);
+    void (*errorHandlerCallback)(uint16_t error);
+    deviceParams_t devicePrm;
+    uint8_t deviceInstance;
+    volatile uint8_t toggleOdd;
+
+    /* Static data. */
+    static uint8_t numberOfDevices;
+
+public:
+
+    /* Static data. */
+    
+};
+
+#endif // __STSPIN220_CLASS_H
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/stspin220/stspin220_class.cpp	Wed Jul 27 12:00:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1528 +0,0 @@
-/**
-  ******************************************************************************
-  * @file    stspin220_class.cpp
-  * @author  IPC Rennes
-  * @version V1.0.0
-  * @date    July 27th, 2016
-  * @brief   STSPIN220 product related routines
-  * @note    (C) COPYRIGHT 2016 STMicroelectronics
-  ******************************************************************************
-  * @attention
-  *
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stspin220_class.h"
-
-/* Definitions ---------------------------------------------------------------*/
-
-/* Variables  ----------------------------------------------------------------*/
-/* Number of devices. */
-uint8_t STSPIN220::numberOfDevices = 0;
-
-/* Methods -------------------------------------------------------------------*/
-/******************************************************//**
- * @brief Start the STSPIN220 library
- * @param[in] pInit pointer to the initialization data
- * @retval COMPONENT_OK in case of success.
- **********************************************************/
-Status_t STSPIN220::Stspin220_Init(void* pInit)
-{ 
-  Stspin220_Disable();
-  if (pInit == NULL)
-  {
-    /* Set context variables to the predefined values from Stspin220_target_config.h */
-    /* Set GPIO according to these values */
-    Stspin220_SetDeviceParamsToPredefinedValues();
-  }
-  else
-  {
-    Stspin220_SetDeviceParamsToGivenValues((Stspin220_Init_t*) pInit);
-  }
-  Stspin220_Board_TimStckInit(false);
-  return COMPONENT_OK;
-}
-
-/**********************************************************
- * @brief Read id
- * @param id pointer to the identifier to be read.
- * @retval COMPONENT_OK in case of success.
- **********************************************************/
-Status_t STSPIN220::Stspin220_ReadID(uint8_t *id)
-{
-  *id = deviceInstance;
-
-  return COMPONENT_OK;
-}
-
-/**********************************************************
- * @brief  Attaches a user callback to the error Handler.
- * The call back will be then called each time the library 
- * detects an error
- * @param[in] callback Name of the callback to attach 
- * to the error Hanlder
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_AttachErrorHandler(void (*callback)(uint16_t error))
-{
-  errorHandlerCallback = (void (*)(uint16_t error)) callback;
-}
-
-/******************************************************//**
- * @brief Apply the set torque
- * @param[in] torqueMode torque mode
- * @retval None
- * @note
- **********************************************************/
-void STSPIN220::Stspin220_ApplyTorque(motorTorqueMode_t torqueMode)
-{
-  uint8_t torqueValue = 0;
-  devicePrm.updateTorque = false;
-  switch(torqueMode)
-  {
-    case ACC_TORQUE:
-      devicePrm.currentTorque = devicePrm.accelTorque;
-      break;
-    case DEC_TORQUE:
-      devicePrm.currentTorque = devicePrm.decelTorque;
-      break;
-    case RUN_TORQUE:
-      devicePrm.currentTorque = devicePrm.runTorque;
-      break;
-    case HOLD_TORQUE:
-      devicePrm.currentTorque = devicePrm.holdTorque;
-      break;
-    case CURRENT_TORQUE:
-      break;
-    default:
-      return; //ignore error
-  }
-  torqueValue = devicePrm.currentTorque;
-  Stspin220_Board_PwmRefSetDutyCycle(torqueValue);
-}
-
-/******************************************************//**
- * @brief Disable the power bridges (leave the output bridges HiZ)
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_Disable(void)
-{
-  Stspin220_Board_Disable();
-}
-
-/******************************************************//**
- * @brief Enable the power bridges
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_Enable(void)
-{
-  Stspin220_Board_Enable();
-}
-
-/******************************************************//**
- * @brief Error handler which calls the user callback (if defined)
- * @param[in] error Number of the error
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_ErrorHandler(uint16_t error)
-{
-  if (errorHandlerCallback != 0)
-  {
-    errorHandlerCallback(error);
-  }
-  else   
-  {
-    while(1)
-    {
-      /* Infinite loop */
-    }
-  }
-}
-
-/******************************************************//**
- * @brief Exit STSPIN220 device from standby (low power consumption)
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_ExitDeviceFromStandby(void)
-{
-  uint32_t sequencerPosition = devicePrm.sequencerPosition;
-  
-  /* Exit standby and set step mode */
-  Stspin220_SetStepModeWithoutReset(devicePrm.stepMode);
-  
-  if (devicePrm.sequencerPosition != 0)
-  {
-    /* Set direction to FORWARD to ensure the HW sequencer is increased at */
-    /* each step clock rising edge */
-    Stspin220_SetDirection(FORWARD);
-    /* Going out of standby */
-    devicePrm.motionState = STANDBYTOINACTIVE;
-    /* Program the step clock */
-    Stspin220_Board_TimStckInit(true);
-    Stspin220_Board_TimStckSetFreq(STSPIN220_MAX_STCK_FREQ);
-    toggleOdd = 0;
-    while (devicePrm.sequencerPosition != 0);
-    while (toggleOdd!=0);
-    devicePrm.sequencerPosition = sequencerPosition;    
-  }
-  
-  devicePrm.motionState = INACTIVE;
-}
-
-/******************************************************//**
- * @brief Return the acceleration
- * @retval Acceleration in pps^2
- **********************************************************/
-uint16_t STSPIN220::Stspin220_GetAcceleration(void)
-{                                                  
-  return (devicePrm.acceleration);
-}
-
-/******************************************************//**
- * @brief Return the current speed
- * @retval Speed in pps
- **********************************************************/
-uint16_t STSPIN220::Stspin220_GetCurrentSpeed(void)
-{
-  return devicePrm.speed;
-}
-
-/******************************************************//**
- * @brief Return the deceleration
- * @retval Deceleration in pps^2
- **********************************************************/
-uint16_t STSPIN220::Stspin220_GetDeceleration(void)
-{
-  return (devicePrm.deceleration);
-}
-
-/******************************************************//**
- * @brief Return the device state
- * @retval State (ACCELERATING, DECELERATING, STEADY or INACTIVE)
- **********************************************************/
-motorState_t STSPIN220::Stspin220_GetDeviceState(void)
-{
-  return devicePrm.motionState;
-}
-
-/******************************************************//**
- * @brief Get the motor current direction
- * @retval direction
- **********************************************************/
-motorDir_t STSPIN220::Stspin220_GetDirection(void)
-{
-  return devicePrm.direction;
-}
-
-/******************************************************//**
- * @brief Return the FW version.
- * @retval FW version
- **********************************************************/
-uint32_t STSPIN220::Stspin220_GetFwVersion(void)
-{
-  return (STSPIN220_FW_VERSION);
-}
-
-/******************************************************//**
- * @brief Get the mark position (32b signed) 
- * @retval mark position
- **********************************************************/
-int32_t STSPIN220::Stspin220_GetMark(void)
-{
-  return devicePrm.markPosition;
-}
-
-/******************************************************//**
- * @brief Return the max speed
- * @retval maxSpeed in pps
- **********************************************************/
-uint16_t STSPIN220::Stspin220_GetMaxSpeed(void)
-{
-  return (devicePrm.maxSpeed);
-}
-
-/******************************************************//**
- * @brief Get the min speed
- * in step/s for full, half and wave modes
- * in microsteps/s for microstep modes
- * @retval return the min speed in step/s or microstep/s
- * @note
- **********************************************************/
-uint16_t STSPIN220::Stspin220_GetMinSpeed(void)
-{
-  return (devicePrm.minSpeed);
-}
-
-/******************************************************//**
- * @brief Get the current position (32b signed) 
- * @retval current position value
- **********************************************************/
-int32_t STSPIN220::Stspin220_GetPosition(void)
-{
-  return devicePrm.currentPosition;
-}
-
-/******************************************************//**
- * @brief Get the motor step mode
- * @retval step mode
- **********************************************************/
-motorStepMode_t STSPIN220::Stspin220_GetStepMode(void)
-{
-  return devicePrm.stepMode;
-}
-
-/******************************************************//**
- * @brief Get the selected stop mode
- * @retval the selected stop mode
- **********************************************************/
-motorStopMode_t STSPIN220::Stspin220_GetStopMode(void)
-{
-  return devicePrm.stopMode;
-}
-
-/******************************************************//**
- * @brief Get the torque
- * @param[in] torqueMode torque mode
- * @retval the torqueValue in % (from 0 to 100)
- * @note
- **********************************************************/
-uint8_t STSPIN220::Stspin220_GetTorque(motorTorqueMode_t torqueMode)
-{
-  uint8_t torqueValue = 0;
-  switch(torqueMode)
-  {
-    case ACC_TORQUE:
-      torqueValue = devicePrm.accelTorque;
-      break;
-    case DEC_TORQUE:
-      torqueValue = devicePrm.decelTorque;
-      break;
-    case RUN_TORQUE:
-      torqueValue = devicePrm.runTorque;
-      break;
-    case HOLD_TORQUE:
-      torqueValue = devicePrm.holdTorque;
-      break;
-    case CURRENT_TORQUE:
-      torqueValue = devicePrm.currentTorque;
-      break;
-    default:
-      break;
-  }
-  return torqueValue;
-}
-
-/******************************************************//**
- * @brief Get the torque boost feature status
- * @retval TRUE if enabled, FALSE if disabled
- **********************************************************/
-bool STSPIN220::Stspin220_GetTorqueBoostEnable(void)
-{
-  return devicePrm.torqueBoostEnable;
-}
-
-/******************************************************//**
- * @brief Get the torque boost threshold
- * @retval The torque boost threshold above which the step mode is
- * changed to full step
- **********************************************************/
-uint16_t STSPIN220::Stspin220_GetTorqueBoostThreshold(void)
-{
-  return devicePrm.torqueBoostSpeedThreshold;
-}
-
-/******************************************************//**
- * @brief Go to the home position
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_GoHome(void)
-{
-  Stspin220_GoTo(0);
-}
-
-/******************************************************//**
- * @brief Go to the Mark position
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_GoMark(void)
-{
-  Stspin220_GoTo(devicePrm.markPosition);
-}
-
-/******************************************************//**
- * @brief Request the motor to move to the specified position 
- * @param[in] targetPosition absolute position in steps
- * @retval None 
- * @note The position is at the resolution corresponding to the
- * selected step mode.
- * STEP_MODE_FULL                   : step
- * STEP_MODE_HALF                   : 1/2 step
- * STEP_MODE_1_4                    : 1/4 step
- * STEP_MODE_1_8                    : 1/8 step
- * STEP_MODE_1_16                   : 1/16 step
- * STEP_MODE_1_32                   : 1/32 step
- * STEP_MODE_1_64                   : 1/64 step
- * STEP_MODE_1_128                  : 1/128 step
- * STEP_MODE_1_256                  : 1/256 step
- **********************************************************/
-void STSPIN220::Stspin220_GoTo(int32_t targetPosition)
-{
-  motorDir_t direction;
-  
-  /* Exit from standby if needed */
-  if (devicePrm.motionState == STANDBY)
-  {
-    Stspin220_ExitDeviceFromStandby();
-  }
-  /* Deactivate motor if needed */
-  else if (devicePrm.motionState != INACTIVE)
-  { 
-    Stspin220_HardHiZ();
-  }
-  
-  if (targetPosition > devicePrm.currentPosition)
-  {
-    devicePrm.stepsToTake = targetPosition -\
-                                      devicePrm.currentPosition;
-    if (devicePrm.stepsToTake < (STSPIN220_POSITION_RANGE>>1))
-    {
-      direction = FORWARD;
-    }
-    else
-    {
-      direction = BACKWARD;
-      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE -\
-                                        devicePrm.stepsToTake;
-    }
-  }
-  else
-  {
-    devicePrm.stepsToTake = devicePrm.currentPosition -\
-                                      targetPosition;
-    if (devicePrm.stepsToTake < (STSPIN220_POSITION_RANGE>>1))
-    {
-      direction = BACKWARD;
-    }
-    else
-    {
-      direction = FORWARD; 
-      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE -\
-                                        devicePrm.stepsToTake;
-    }
-  }
-  
-  if (devicePrm.stepsToTake != 0) 
-  {
-    devicePrm.commandExecuted = MOVE_CMD;
-    
-    /* Direction setup */
-    Stspin220_SetDirection(direction);
-    
-    Stspin220_ComputeSpeedProfile(devicePrm.stepsToTake);
-    
-    /* Motor activation */
-    Stspin220_StartMovement();
-  }
-}
-
-/******************************************************//**
- * @brief Move the motor to the absolute position
- * @param[in] direction FORWARD or BACKWARD
- * @param[in] targetPosition 32 bit signed value position
- * @retval None
- * @note The position is at the resolution corresponding to the
- * selected step mode.
- * STEP_MODE_FULL                   : step
- * STEP_MODE_HALF                   : 1/2 step
- * STEP_MODE_1_4                    : 1/4 step
- * STEP_MODE_1_8                    : 1/8 step
- * STEP_MODE_1_16                   : 1/16 step
- * STEP_MODE_1_32                   : 1/32 step
- * STEP_MODE_1_64                   : 1/64 step
- * STEP_MODE_1_128                  : 1/128 step
- * STEP_MODE_1_256                  : 1/256 step
- **********************************************************/
-void STSPIN220::Stspin220_GoToDir(motorDir_t direction, int32_t targetPosition)
-{
-  /* Exit from standby if needed */
-  if (devicePrm.motionState == STANDBY)
-  {
-    Stspin220_ExitDeviceFromStandby();
-  }
-  /* Deactivate motor if needed */
-  else if (devicePrm.motionState != INACTIVE)
-  { 
-    Stspin220_HardHiZ();
-  }
-  
-  if (direction != BACKWARD)
-  {
-    if (targetPosition > devicePrm.currentPosition)
-    {
-      devicePrm.stepsToTake = targetPosition -\
-                                        devicePrm.currentPosition;
-    }
-    else
-    {
-      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE +\
-                                       (targetPosition -\
-                                        devicePrm.currentPosition);
-    }
-  }
-  else
-  {
-    if (targetPosition > devicePrm.currentPosition)
-    {
-      devicePrm.stepsToTake = STSPIN220_POSITION_RANGE +\
-                                        (devicePrm.currentPosition -\
-                                         targetPosition);
-    }
-    else
-    {
-      devicePrm.stepsToTake = devicePrm.currentPosition -\
-                                        targetPosition;
-    }
-  }
-
-  if (devicePrm.stepsToTake != 0) 
-  {
-    devicePrm.commandExecuted = MOVE_CMD;
-    
-    /* Direction setup */
-    Stspin220_SetDirection(direction);
-    
-    Stspin220_ComputeSpeedProfile(devicePrm.stepsToTake);
-    
-    /* Motor activation */
-    Stspin220_StartMovement();
-  }  
-}
-
-/******************************************************//**
- * @brief Immediately stop the motor and disables the power bridges
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_HardHiZ(void)
-{
-  /* Set inactive state */
-  devicePrm.motionState = INACTIVE;
-  
-  /* Disable step clock */
-  if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
-  {
-    Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
-  }
-
-  /* Let the PWM REF and bridges enabled at least for DISABLE_DELAY time */
-  /* after the last step clock rising edge triggering the last step */
-  Stspin220_Board_Delay(DISABLE_DELAY);
-  
-  /* Set reference voltage to 0 */
-  Stspin220_SetTorque(CURRENT_TORQUE, 0);
-
-  /* Disable power bridges */
-  Stspin220_Board_Disable();
-  
-  /* Comeback to nominal step mode */
-  if (devicePrm.stepModeLatched != devicePrm.stepMode)
-  {
-    Stspin220_Board_UnsetFullStep();
-    devicePrm.stepMode = devicePrm.stepModeLatched;
-  }
-
-  devicePrm.commandExecuted = NO_CMD;
-  devicePrm.stepsToTake = 0;  
-  devicePrm.speed = 0;
-}
-
-/******************************************************//**
- * @brief  Immediatly stop the motor
- * and either set holding torque when stop mode is HOLD_MODE,
- * or call Stspin220_HardHiz function when stop mode is HIZ_MODE,
- * or call Stspin220_PutDeviceInStandby function when stop mode is STANDBY_MODE
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_HardStop(void) 
-{
-  if (devicePrm.stopMode == HOLD_MODE)
-  {
-    /* Set inactive state */
-    devicePrm.motionState = INACTIVE;
-
-    /* Disable step clock */
-    if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
-    {
-      Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
-    }
-    
-    /* Set holding torque */
-    Stspin220_ApplyTorque(HOLD_TORQUE);
- 
-    /* Comeback to nominal step mode */
-    if (devicePrm.stepModeLatched != devicePrm.stepMode)
-    {
-      Stspin220_Board_UnsetFullStep();
-      devicePrm.stepMode = devicePrm.stepModeLatched;
-    }    
-    
-    devicePrm.commandExecuted = NO_CMD;
-    devicePrm.stepsToTake = 0;  
-    devicePrm.speed = 0;
-  }
-  else if (devicePrm.stopMode == HIZ_MODE)
-  {
-    Stspin220_HardHiZ();
-  }
-  else if (devicePrm.stopMode == STANDBY_MODE)
-  {
-    Stspin220_PutDeviceInStandby();
-  }
-}
-
-/******************************************************//**
- * @brief  Moves the motor of the specified number of steps
- * @param[in] direction FORWARD or BACKWARD
- * @param[in] stepCount Number of steps to perform
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_Move(motorDir_t direction, uint32_t stepCount)
-{
-  /* Exit from standby if needed */
-  if (devicePrm.motionState == STANDBY)
-  {
-    Stspin220_ExitDeviceFromStandby();
-  }
-  /* Deactivate motor if needed */
-  else if (devicePrm.motionState != INACTIVE)
-  {
-    Stspin220_HardHiZ();
-  }
-  
-  if (stepCount != 0) 
-  {
-    devicePrm.stepsToTake = stepCount;    
-    devicePrm.commandExecuted = MOVE_CMD;
-    
-    /* Direction setup */
-    Stspin220_SetDirection(direction);
-    
-    Stspin220_ComputeSpeedProfile(stepCount);
-    
-    /* Motor activation */
-    Stspin220_StartMovement();
-  }  
-}
-
-/******************************************************//**
- * @brief Put STSPIN220 device in standby (low power consumption)
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_PutDeviceInStandby(void)
-{
-  /* Stop movement */
-  Stspin220_HardHiZ();
-  
-  /* Enter standby */
-  Stspin220_Board_Reset();
-  
-  devicePrm.motionState = STANDBY;
-}
-
-/******************************************************//**
- * @brief  Runs the motor. It will accelerate from the min 
- * speed up to the max speed by using the device acceleration.
- * @param[in] direction FORWARD or BACKWARD
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_Run(motorDir_t direction)
-{
-  /* Exit from standby if needed */
-  if (devicePrm.motionState == STANDBY)
-  {
-    Stspin220_ExitDeviceFromStandby();
-  }
-  /* Deactivate motor if needed */
-  else if (devicePrm.motionState != INACTIVE)
-  {
-    Stspin220_HardHiZ();
-  }
-  
-    /* Direction setup */
-    Stspin220_SetDirection(direction);
-    devicePrm.commandExecuted = RUN_CMD;
-    /* Motor activation */
-    Stspin220_StartMovement(); 
-}
-
-/******************************************************//**
- * @brief  Changes the acceleration
- * @param[in] newAcc New acceleration to apply in pps^2
- * @retval true if the command is successfully executed, else false
- * @note The command is not performed if the device is executing 
- * a MOVE or GOTO command (but it can be used during a RUN command)
- **********************************************************/
-bool STSPIN220::Stspin220_SetAcceleration(uint16_t newAcc)
-{                                                  
-  bool cmdExecuted = false;
-  if ((newAcc != 0)&&
-      (((devicePrm.motionState & INACTIVE) == INACTIVE)||
-       (devicePrm.commandExecuted == RUN_CMD)))
-  {
-    devicePrm.acceleration = newAcc;
-    cmdExecuted = true;
-  }    
-  return cmdExecuted;
-}
-
-/******************************************************//**
- * @brief  Changes the deceleration
- * @param[in] newDec New deceleration to apply in pps^2
- * @retval true if the command is successfully executed, else false
- * @note The command is not performed if the device is executing 
- * a MOVE or GOTO command (but it can be used during a RUN command)
- **********************************************************/
-bool STSPIN220::Stspin220_SetDeceleration(uint16_t newDec)
-{                                                  
-  bool cmdExecuted = false;
-  if ((newDec != 0)&& 
-      (((devicePrm.motionState & INACTIVE) == INACTIVE)||
-       (devicePrm.commandExecuted == RUN_CMD)))
-  {
-    devicePrm.deceleration = newDec;
-    cmdExecuted = true;
-  }      
-  return cmdExecuted;
-}
-
-/******************************************************//**
- * @brief  Specifies the direction 
- * @param[in] dir FORWARD or BACKWARD
- * @note The direction change is applied if the device 
- * is in INACTIVE or STANDBY state or if the device is 
- * executing a run command
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetDirection(motorDir_t dir)
-{
-  if ((devicePrm.motionState == INACTIVE)||\
-      (devicePrm.motionState == STANDBY))
-  {
-    devicePrm.direction = dir;
-    Stspin220_Board_SetDirectionGpio(dir);
-  }
-  else if ((devicePrm.commandExecuted&RUN_CMD)!=0)
-  {
-    devicePrm.commandExecuted=(deviceCommand_t)
-      (STSPIN220_DIR_CHANGE_BIT_MASK|devicePrm.commandExecuted);
-  }
-}
-
-/******************************************************//**
- * @brief  Set current position to be the Home position
- * (current position set to 0)
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetHome(void)
-{
-  devicePrm.currentPosition = 0;
-}
-
-/******************************************************//**
- * @brief  Set current position to be the Mark position 
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetMark(void)
-{
-  devicePrm.markPosition = devicePrm.currentPosition;
-}
-
-/******************************************************//**
- * @brief  Changes the max speed
- * @param[in] newMaxSpeed New max speed  to apply in pps
- * @retval true if the command is successfully executed, else false
- * @note The command is not performed is the device is executing 
- * a MOVE or GOTO command (but it can be used during a RUN command).
- **********************************************************/
-bool STSPIN220::Stspin220_SetMaxSpeed(uint16_t newMaxSpeed)
-{
-  bool cmdExecuted = false;
-  if ((newMaxSpeed >= STSPIN220_MIN_STCK_FREQ)&&\
-      ((newMaxSpeed <= STSPIN220_MAX_STCK_FREQ)||\
-       ((devicePrm.torqueBoostEnable != false)&&\
-        ((newMaxSpeed>>Stspin220_GetStepMode())<= STSPIN220_MAX_STCK_FREQ)))&&\
-      (devicePrm.minSpeed <= newMaxSpeed) &&\
-      (((devicePrm.motionState & INACTIVE) == INACTIVE)||\
-      (devicePrm.commandExecuted == RUN_CMD)))
-  {
-    devicePrm.maxSpeed = newMaxSpeed;
-    cmdExecuted = true;
-  }
-  return cmdExecuted;
-}
-
-/******************************************************//**
- * @brief  Changes the min speed
- * @param[in] newMinSpeed New min speed  to apply in pps
- * @retval true if the command is successfully executed, else false
- * @note The command is not performed is the device is executing 
- * a MOVE or GOTO command (but it can be used during a RUN command).
- **********************************************************/
-bool STSPIN220::Stspin220_SetMinSpeed(uint16_t newMinSpeed)
-{                                                  
-  bool cmdExecuted = false;
-  if ((newMinSpeed >= STSPIN220_MIN_STCK_FREQ)&&
-      (newMinSpeed <= STSPIN220_MAX_STCK_FREQ) &&
-      (newMinSpeed <= devicePrm.maxSpeed) && 
-      (((devicePrm.motionState & INACTIVE) == INACTIVE)||
-       (devicePrm.commandExecuted == RUN_CMD)))
-  {
-    devicePrm.minSpeed = newMinSpeed;
-    cmdExecuted = true;
-  }  
-  return cmdExecuted;
-}
-
-/******************************************************//**
- * @brief Set the stepping mode 
- * @param[in] stepMode from full step to 1/256 microstep
- * as specified in enum motorStepMode_t
- * @retval true if the command is successfully executed, else false
- **********************************************************/
-bool STSPIN220::Stspin220_SetStepMode(motorStepMode_t stepMode)
-{
-  /* Eventually deactivate motor */
-  if ((devicePrm.motionState != INACTIVE)&&\
-      (devicePrm.motionState != STANDBY))
-  {
-    Stspin220_HardHiZ();
-  }
-
-  /* Enter standby */
-  Stspin220_Board_Reset();
-  
-  /* Reset the microstepping sequencer position */
-  devicePrm.sequencerPosition = 0;
-  
-  /* Reset current and mark positions */
-  devicePrm.currentPosition = 0; 
-  devicePrm.markPosition = 0;
-  
-  /* Set the step mode */
-  return (Stspin220_SetStepModeWithoutReset(stepMode));
-}
-
-/******************************************************//**
- * @brief Select the mode to stop the motor.
- * @param[in] stopMode HOLD_MODE to let power bridge enabled
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetStopMode(motorStopMode_t stopMode)
-{
-  devicePrm.stopMode = stopMode;
-}
-
-/******************************************************//**
- * @brief Set the torque
- * @param[in] torqueMode Torque mode as specified in enum motorTorqueMode_t
- * @param[in] torqueValue in % (from 0 to 100)
- * @retval None
- * @note
- **********************************************************/
-void STSPIN220::Stspin220_SetTorque(motorTorqueMode_t torqueMode, uint8_t torqueValue)
-{
-  devicePrm.updateTorque = true;
-  if (torqueValue>100) torqueValue = 100;
-  switch(torqueMode)
-  {
-    case ACC_TORQUE:
-      devicePrm.accelTorque = torqueValue;
-      break;
-    case DEC_TORQUE:
-      devicePrm.decelTorque = torqueValue;
-      break;
-    case RUN_TORQUE:
-      devicePrm.runTorque = torqueValue;
-      break;
-    case HOLD_TORQUE:
-      devicePrm.holdTorque = torqueValue;
-      if (devicePrm.motionState != INACTIVE)
-      {
-        break;
-      }
-    case CURRENT_TORQUE:
-      devicePrm.currentTorque = torqueValue;
-      Stspin220_Board_PwmRefSetDutyCycle(torqueValue);
-    default:
-      devicePrm.updateTorque = false;
-      break; //ignore error
-  }
-}
-
-/******************************************************//**
- * @brief Enable or disable the torque boost feature
- * @param[in] enable true to enable torque boost, false to disable
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetTorqueBoostEnable(bool enable)
-{
-  devicePrm.torqueBoostEnable = enable;
-}
-
-/******************************************************//**
- * @brief Set the torque boost threshold
- * @param[in] speedThreshold speed threshold above which the step mode is
- * changed to full step
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetTorqueBoostThreshold(uint16_t speedThreshold)
-{
-  devicePrm.torqueBoostSpeedThreshold = speedThreshold;
-}
-
-/******************************************************//**
- * @brief  Stops the motor by using the device deceleration
- * @retval true if the command is successfully executed, else false
- * @note The command is not performed if the device is in INACTIVE,
- * STANDBYTOINACTIVE or STANDBY state.
- **********************************************************/
-bool STSPIN220::Stspin220_SoftStop(void)
-{   
-  bool cmdExecuted = false;
-  if ((devicePrm.motionState & INACTIVE) != INACTIVE)
-  {
-    devicePrm.commandExecuted=(deviceCommand_t)
-      (STSPIN220_SOFT_STOP_BIT_MASK|devicePrm.commandExecuted);
-    cmdExecuted = true;
-  }
-  return (cmdExecuted);
-}
-
-/******************************************************//**
- * @brief Get the frequency of REF PWM
- * @retval the frequency of REF PWM in Hz
- * @note
- **********************************************************/
-uint32_t STSPIN220::Stspin220_VrefPwmGetFreq(void)
-{
-  return devicePrm.refPwmFreq;
-}
-
-/******************************************************//**
- * @brief Set the frequency of REF PWM
- * @param[in] newFreq in Hz
- * @retval None
- * @note
- **********************************************************/
-void STSPIN220::Stspin220_VrefPwmSetFreq(uint32_t newFreq)
-{ 
-  devicePrm.refPwmFreq = newFreq;
-  Stspin220_Board_PwmRefSetFreq(newFreq);
-}
-
-/******************************************************//**
- * @brief  Locks until the device state becomes Inactive
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_WaitWhileActive(void)
-{
-  /* Wait while motor is running */
-  while (((Stspin220_GetDeviceState()&INACTIVE)!=INACTIVE)||\
-   (((Stspin220_GetDeviceState()&INACTIVE)==INACTIVE)&&(toggleOdd!=0)));
-}
-
-/* ------------------------------------------------------------------------- */
-/* Internal functions ------------------------------------------------------ */
-/* ------------------------------------------------------------------------- */
-/******************************************************//**
- * @brief Updates the current speed of the device
- * @param[in] newSpeed in pps
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_ApplySpeed(uint16_t newSpeed)
-{
-  if (devicePrm.torqueBoostEnable != false)
-  {
-    if (devicePrm.stepMode > (motorStepMode_t)STEP_MODE_1_256)
-    {
-      Stspin220_ErrorHandler(STSPIN220_ERROR_APPLY_SPEED);
-    }
-    if (devicePrm.stepMode != (motorStepMode_t)STEP_MODE_FULL)
-    {
-      if (((newSpeed>>devicePrm.stepModeLatched)>\
-           devicePrm.torqueBoostSpeedThreshold)&&\
-          (((devicePrm.commandExecuted & STSPIN220_MOVE_BIT_MASK) != MOVE_CMD) ||\
-           ((devicePrm.stepsToTake-devicePrm.relativePos)>=\
-            (1<<devicePrm.stepModeLatched))))
-      {
-        if ((devicePrm.sequencerPosition & 0xFF) == 0X80)
-        {
-          Stspin220_Board_SetFullStep();
-          devicePrm.stepMode = (motorStepMode_t)STEP_MODE_FULL;
-          devicePrm.accu >>= devicePrm.stepModeLatched;
-          newSpeed >>= devicePrm.stepModeLatched;
-        }
-      }
-    }
-    else if (((newSpeed <= devicePrm.torqueBoostSpeedThreshold) &&\
-              (devicePrm.stepModeLatched != (motorStepMode_t)STEP_MODE_FULL))||\
-             (((devicePrm.commandExecuted & STSPIN220_MOVE_BIT_MASK) == MOVE_CMD)&&\
-               ((devicePrm.stepsToTake-devicePrm.relativePos)<=\
-                (1<<devicePrm.stepModeLatched))))
-    {
-      Stspin220_Board_UnsetFullStep();
-      devicePrm.stepMode = devicePrm.stepModeLatched;
-      devicePrm.accu <<= devicePrm.stepModeLatched;
-      newSpeed <<= devicePrm.stepModeLatched;
-    }
-  }
-  else if (devicePrm.stepMode != devicePrm.stepModeLatched)
-  {
-    //torqueBoostEnable has just been disabled
-    Stspin220_Board_UnsetFullStep();
-    devicePrm.stepMode = devicePrm.stepModeLatched;
-    devicePrm.accu <<= devicePrm.stepModeLatched;
-    newSpeed <<= devicePrm.stepModeLatched;
-  }
-  
-  if (newSpeed < STSPIN220_MIN_STCK_FREQ)
-  {
-    newSpeed = STSPIN220_MIN_STCK_FREQ;  
-  }
-  if (newSpeed > STSPIN220_MAX_STCK_FREQ)
-  {
-    newSpeed = STSPIN220_MAX_STCK_FREQ;
-  }
-  
-  devicePrm.speed = newSpeed;
-  Stspin220_Board_TimStckSetFreq(newSpeed);
-
-}
-
-/******************************************************//**
- * @brief  Computes the speed profile according to the number of steps to move
- * @param[in] nbSteps number of steps to perform
- * @retval None
- * @note Using the acceleration and deceleration of the device,
- * this function determines the duration in steps of the acceleration,
- * steady and deceleration phases.
- * If the total number of steps to perform is big enough, a trapezoidal move
- * is performed (i.e. there is a steady phase where the motor runs at the maximum
- * speed.
- * Else, a triangular move is performed (no steady phase: the maximum speed is never
- * reached.
- **********************************************************/
-void STSPIN220::Stspin220_ComputeSpeedProfile(uint32_t nbSteps)
-{
-  uint32_t reqAccSteps;
-  uint32_t reqDecSteps;
-   
-  /* compute the number of steps to get the targeted speed */
-  uint16_t minSpeed = devicePrm.minSpeed;
-  reqAccSteps = (devicePrm.maxSpeed - minSpeed);
-  reqAccSteps *= (devicePrm.maxSpeed + minSpeed);
-  reqDecSteps = reqAccSteps;
-  reqAccSteps /= (uint32_t)devicePrm.acceleration;
-  reqAccSteps /= 2;
-
-  /* compute the number of steps to stop */
-  reqDecSteps /= (uint32_t)devicePrm.deceleration;
-  reqDecSteps /= 2;
-
-    if(( reqAccSteps + reqDecSteps ) > nbSteps)
-    {   
-    /* Triangular move  */
-    /* reqDecSteps = (Pos * Dec) /(Dec+Acc) */
-    uint32_t dec = devicePrm.deceleration;
-    uint32_t acc = devicePrm.acceleration;
-    
-    reqDecSteps =  ((uint32_t) dec * nbSteps) / (acc + dec);
-    if (reqDecSteps > 1)
-    {
-      reqAccSteps = reqDecSteps - 1;
-      if(reqAccSteps == 0)
-      {
-        reqAccSteps = 1;
-      }      
-    }
-    else
-    {
-      reqAccSteps = 0;
-    }
-    devicePrm.endAccPos = reqAccSteps;
-    devicePrm.startDecPos = reqDecSteps;
-    }
-    else
-    {    
-    /* Trapezoidal move */
-    /* accelerating phase to endAccPos */
-    /* steady phase from  endAccPos to startDecPos */
-    /* decelerating from startDecPos to stepsToTake*/
-    devicePrm.endAccPos = reqAccSteps;
-    devicePrm.startDecPos = nbSteps - reqDecSteps - 1;
-    }
-}
-
-/******************************************************//**
- * @brief  Set the parameters of the device whose values are not defined in
- * stspin220_target_config.h
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetDeviceParamsOtherValues(void)
-{
-  uint16_t tmp;
-
-  devicePrm.accu = 0;
-  devicePrm.currentPosition = 0;
-  devicePrm.sequencerPosition = 0;
-  devicePrm.endAccPos = 0;
-  devicePrm.relativePos = 0;
-  devicePrm.startDecPos = 0;
-  devicePrm.stepsToTake = 0;
-  devicePrm.updateTorque = false;
-  devicePrm.speed = 0;
-  devicePrm.commandExecuted = NO_CMD;
-  devicePrm.direction = FORWARD;
-  tmp = devicePrm.minSpeed;
-  if (((devicePrm.torqueBoostEnable != false)&&\
-       (devicePrm.torqueBoostSpeedThreshold>STSPIN220_MAX_STCK_FREQ))||\
-      (tmp>devicePrm.maxSpeed))
-  {
-    Stspin220_ErrorHandler(STSPIN220_ERROR_INIT);
-  }
-}
-
-/******************************************************//**
- * @brief  Set the parameters of the device to values of the structure pointed
- * by pInitDevicePrm. Set GPIO according to these values.
- * @param pInitDevicePrm pointer onto the structure containing values to
- * initialize the device parameters.
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetDeviceParamsToGivenValues(Stspin220_Init_t* pInitDevicePrm)
-{
-  devicePrm.motionState = STANDBY;
-
-  if (Stspin220_SetAcceleration(pInitDevicePrm->acceleration)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_ACCELERATION); 
-  if (Stspin220_SetDeceleration(pInitDevicePrm->deceleration)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_DECELERATION);
-  if (Stspin220_SetMaxSpeed(pInitDevicePrm->maxSpeed)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MAX_SPEED);
-  if (Stspin220_SetMinSpeed(pInitDevicePrm->minSpeed)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MIN_SPEED);
-
-  Stspin220_VrefPwmSetFreq(pInitDevicePrm->vrefPwmFreq);
-  Stspin220_SetTorque(ACC_TORQUE,pInitDevicePrm->accelTorque);
-  Stspin220_SetTorque(DEC_TORQUE,pInitDevicePrm->decelTorque);
-  Stspin220_SetTorque(RUN_TORQUE,pInitDevicePrm->runTorque);
-  Stspin220_SetTorque(HOLD_TORQUE,pInitDevicePrm->holdTorque);
-  devicePrm.torqueBoostEnable = pInitDevicePrm->torqueBoostEnable;
-  devicePrm.torqueBoostSpeedThreshold = pInitDevicePrm->torqueBoostSpeedThreshold;
-  Stspin220_SetStopMode(pInitDevicePrm->stopMode);
-
-  Stspin220_SetDeviceParamsOtherValues();
-  
-  /* Set predefined step mode */
-  /* Standby-reset deactivation included to latch the MODEX inputs */
-  Stspin220_SetStepMode(pInitDevicePrm->stepMode);
-}
-
-/******************************************************//**
- * @brief  Sets the parameters of the device to predefined values
- * from stspin220_target_config.h
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_SetDeviceParamsToPredefinedValues(void)
-{
-  devicePrm.motionState = STANDBY;
-
-  if (Stspin220_SetAcceleration(STSPIN220_CONF_PARAM_ACC)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_ACCELERATION);
-  if (Stspin220_SetDeceleration(STSPIN220_CONF_PARAM_DEC)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_DECELERATION);
-  if (Stspin220_SetMaxSpeed(STSPIN220_CONF_PARAM_RUNNING_SPEED)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MAX_SPEED);
-  if (Stspin220_SetMinSpeed(STSPIN220_CONF_PARAM_MIN_SPEED)==false) Stspin220_ErrorHandler(STSPIN220_ERROR_SET_MIN_SPEED);
-
-  Stspin220_VrefPwmSetFreq(STSPIN220_CONF_PARAM_REF_PWM_FREQUENCY);  
-  Stspin220_SetTorque(ACC_TORQUE,STSPIN220_CONF_PARAM_ACC_TORQUE);
-  Stspin220_SetTorque(DEC_TORQUE,STSPIN220_CONF_PARAM_DEC_TORQUE);
-  Stspin220_SetTorque(RUN_TORQUE,STSPIN220_CONF_PARAM_RUNNING_TORQUE);
-  Stspin220_SetTorque(HOLD_TORQUE,STSPIN220_CONF_PARAM_HOLDING_TORQUE);
-  devicePrm.torqueBoostEnable = STSPIN220_CONF_PARAM_TORQUE_BOOST_EN;
-  devicePrm.torqueBoostSpeedThreshold = STSPIN220_CONF_PARAM_TORQUE_BOOST_TH;
-  Stspin220_SetStopMode(STSPIN220_CONF_PARAM_AUTO_HIZ_STOP);
-
-  Stspin220_SetDeviceParamsOtherValues();
-  
-  /* Set predefined step mode */
-  /* Standby-reset deactivation included to latch the MODEX inputs */
-  Stspin220_SetStepMode((motorStepMode_t)STSPIN220_CONF_PARAM_STEP_MODE);
-}
-
-/******************************************************//**
- * @brief Set the stepping mode without reset
- * @param[in] stepMode from full step to 1/256 microstep
- * as specified in enum motorStepMode_t
- * @retval true if the command is successfully executed, else false
- **********************************************************/
-bool STSPIN220::Stspin220_SetStepModeWithoutReset(motorStepMode_t stepMode)
-{
-  /* Store step mode */
-  devicePrm.stepMode = stepMode;
-  devicePrm.stepModeLatched = stepMode;
-  
-  /* Set the mode pins to the levels corresponding to the selected step mode */
-  switch (stepMode)
-  {
-    case STEP_MODE_FULL:
-      Stspin220_Board_SetFullStep();
-      break;
-    case STEP_MODE_HALF:
-      Stspin220_Board_SetModePins(1, 0, 1, 0);
-      break;    
-    case STEP_MODE_1_4:
-      Stspin220_Board_SetModePins(0, 1, 0, 1);
-      break;        
-    case STEP_MODE_1_8:
-      Stspin220_Board_SetModePins(1, 1, 1, 0);
-      break;
-    case STEP_MODE_1_16:
-      Stspin220_Board_SetModePins(1, 1, 1, 1);
-      break;   
-    case STEP_MODE_1_32:
-      Stspin220_Board_SetModePins(0, 0, 0, 1);
-      break;   
-    case STEP_MODE_1_64:
-      Stspin220_Board_SetModePins(1, 1, 0, 1);
-      break;
-    case STEP_MODE_1_128:
-      Stspin220_Board_SetModePins(0, 0, 1, 0);
-      break;  
-    case STEP_MODE_1_256:
-      Stspin220_Board_SetModePins(1, 1, 0, 0);
-      break;
-    default:
-      return false;
-  }
-
-  /* Wait */
-  Stspin220_Board_Delay(SELECT_STEP_MODE_DELAY);
-  
-  /* Exit standby, selected step mode is latched */
-  Stspin220_Board_ReleaseReset();
-  
-  /* Let a delay after reset release and step mode latching*/
-  Stspin220_Board_Delay(AFTER_STANDBY_EXIT_DEAD_TIME);
-  
-  /* If full step mode is not selected, do not keep MODE1 = MODE2 = 0 */
-  /* after the device quit the standby condition */
-  if (stepMode!=(motorStepMode_t)STEP_MODE_FULL)
-  {
-    Stspin220_Board_UnsetFullStep();
-  }
-  
-  return true;
-}
-
-/******************************************************//**
- * @brief Initialises the bridge parameters to start the movement
- * and enable the power bridge
- * @retval None
- **********************************************************/
-void STSPIN220::Stspin220_StartMovement(void)
-{
-  /* Enable STSPIN220 powerstage */
-  Stspin220_Enable();
-  toggleOdd = 0;
-  devicePrm.accu = 0;
-  devicePrm.relativePos = 0;
-  Stspin220_Board_TimStckInit(true);  
-  if ((devicePrm.endAccPos == 0)&&\
-      (devicePrm.commandExecuted != RUN_CMD))
-  {
-    devicePrm.motionState = DECELERATING;
-    Stspin220_Board_PwmRefStart(devicePrm.refPwmFreq, DEC_TORQUE);
-  }
-  else
-  {
-    devicePrm.motionState = ACCELERATING;
-    Stspin220_Board_PwmRefStart(devicePrm.refPwmFreq, ACC_TORQUE);
-  }
-  /* Program the step clock */
-  Stspin220_ApplySpeed(devicePrm.minSpeed);
-}
-
-/******************************************************//**
- * @brief  Handles the device state machine at each pulse
- * @retval None
- * @note Must only be called by the timer ISR
- **********************************************************/
-void STSPIN220::Stspin220_StepClockHandler(void)
-{
-  uint32_t stepModeShift = devicePrm.stepModeLatched - devicePrm.stepMode;
-  uint16_t tmp;
-  Stspin220_Board_Monitor_Set();
-  if (devicePrm.motionState == STANDBYTOINACTIVE)
-  {
-    if (toggleOdd != 0)
-    {
-      Stspin220_Board_StckMode3_Reset();
-      toggleOdd = 0;
-      if (devicePrm.sequencerPosition == 0)
-      {
-        if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
-        {
-          Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
-        }
-        return;
-      }      
-    }
-    else
-    {
-      Stspin220_Board_StckMode3_Set();
-      toggleOdd = 1;
-      tmp = (1 << ((motorStepMode_t)STEP_MODE_1_256-devicePrm.stepMode));
-      devicePrm.sequencerPosition -= tmp;
-    }
-    Stspin220_Board_TimStckSetFreq(STSPIN220_MAX_STCK_FREQ);
-    return;
-  }  
-  
-  if (toggleOdd == 0)
-  {
-    Stspin220_Board_StckMode3_Set();
-    toggleOdd = 1;
-  }
-  else
-  {
-    Stspin220_Board_StckMode3_Reset();
-    toggleOdd = 0;
-    /* Incrementation of the relative position */
-    devicePrm.relativePos += (1 << stepModeShift);
-
-    /* Incrementation of the current position */
-    if (devicePrm.direction != BACKWARD)
-    {
-      devicePrm.currentPosition += (1 << stepModeShift);
-      tmp = (1 << ((motorStepMode_t)STEP_MODE_1_256-devicePrm.stepMode));
-      devicePrm.sequencerPosition += tmp;
-      if (devicePrm.sequencerPosition >= (SEQUENCER_MAX_VALUE+1))
-      {
-        devicePrm.sequencerPosition -= (SEQUENCER_MAX_VALUE+1);
-      }
-    }
-    else
-    {
-      devicePrm.currentPosition -= (1 << stepModeShift);
-      tmp = (1 << ((motorStepMode_t)STEP_MODE_1_256-devicePrm.stepMode));
-      devicePrm.sequencerPosition -= tmp;
-      if (devicePrm.sequencerPosition < 0)
-      {
-        devicePrm.sequencerPosition += (SEQUENCER_MAX_VALUE+1);
-      }
-    }
-
-    switch (devicePrm.motionState) 
-    {
-      case ACCELERATING: 
-      {
-          uint32_t relPos = devicePrm.relativePos;
-          uint32_t endAccPos = devicePrm.endAccPos;
-          uint16_t speed = devicePrm.speed;
-          uint32_t acc = ((uint32_t)devicePrm.acceleration << 16)>>stepModeShift;
-        
-          if (((devicePrm.commandExecuted&(STSPIN220_SOFT_STOP_BIT_MASK|STSPIN220_DIR_CHANGE_BIT_MASK))!=0)||\
-              ((devicePrm.commandExecuted==MOVE_CMD)&&(relPos>=devicePrm.startDecPos)))
-          {
-            devicePrm.motionState = DECELERATING;
-            devicePrm.accu = 0;
-            /* Apply decelerating torque */
-            Stspin220_ApplyTorque(DEC_TORQUE);
-          }
-          else if ((speed>=(devicePrm.maxSpeed>>stepModeShift))||\
-                   ((devicePrm.commandExecuted==MOVE_CMD)&&(relPos >= endAccPos)))
-          {
-            devicePrm.motionState = STEADY;
-            /* Apply running torque */
-            Stspin220_ApplyTorque(RUN_TORQUE);
-          }
-          else
-          {
-            bool speedUpdated = false;
-            /* Go on accelerating */
-            if (speed==0) speed =1;
-            devicePrm.accu += acc / speed;
-            while (devicePrm.accu>=(0X10000L))
-            {
-              devicePrm.accu -= (0X10000L);
-              speed +=1;
-              speedUpdated = true;
-            }
-          
-            if (speedUpdated)
-            {
-              if (speed>(devicePrm.maxSpeed>>stepModeShift))
-              {
-                speed = devicePrm.maxSpeed>>stepModeShift;
-              }    
-              devicePrm.speed = speed;
-            }
-            
-            if (devicePrm.updateTorque!=false)
-            {
-              /* Apply accelerating torque */
-              Stspin220_ApplyTorque(ACC_TORQUE);              
-            }
-          }
-          break;
-      }
-      case STEADY: 
-      {
-        uint16_t maxSpeed = devicePrm.maxSpeed>>stepModeShift;
-        uint32_t relativePos = devicePrm.relativePos;
-        if (devicePrm.updateTorque!=false)
-        {
-          /* Apply accelerating torque */
-          Stspin220_ApplyTorque(RUN_TORQUE);
-        }
-        if  (((devicePrm.commandExecuted&(STSPIN220_SOFT_STOP_BIT_MASK|STSPIN220_DIR_CHANGE_BIT_MASK))!=0)||\
-             ((devicePrm.commandExecuted==MOVE_CMD)&&\
-              (relativePos>=(devicePrm.startDecPos)))||\
-             ((devicePrm.commandExecuted==RUN_CMD)&&\
-              (devicePrm.speed>maxSpeed)))
-        {
-          devicePrm.motionState = DECELERATING;
-          devicePrm.accu = 0;
-          /* Apply decelerating torque */
-          Stspin220_ApplyTorque(DEC_TORQUE);
-        }
-        else if ((devicePrm.commandExecuted==RUN_CMD)&&(devicePrm.speed<maxSpeed))
-        {
-          devicePrm.motionState = ACCELERATING;
-          devicePrm.accu = 0;
-          /* Apply accelerating torque */
-          Stspin220_ApplyTorque(ACC_TORQUE);
-        }
-        break;
-      }
-      case DECELERATING: 
-      {
-        uint32_t relativePos = devicePrm.relativePos;
-        uint16_t speed = devicePrm.speed;
-        uint32_t dec = ((uint32_t)devicePrm.deceleration << 16)>>stepModeShift;
-        if ((((devicePrm.commandExecuted&(STSPIN220_SOFT_STOP_BIT_MASK|STSPIN220_DIR_CHANGE_BIT_MASK))!=0)&&\
-             (speed<=(devicePrm.minSpeed>>stepModeShift)))||\
-            ((devicePrm.commandExecuted==MOVE_CMD)&&(relativePos>=devicePrm.stepsToTake)))
-        {
-          /* Motion process complete */
-          if ((devicePrm.commandExecuted&STSPIN220_DIR_CHANGE_BIT_MASK)!=0)
-          {
-            devicePrm.commandExecuted=(deviceCommand_t)((~STSPIN220_DIR_CHANGE_BIT_MASK)&devicePrm.commandExecuted);
-            if (devicePrm.direction==BACKWARD) devicePrm.direction=FORWARD;
-            else devicePrm.direction=BACKWARD;
-            Stspin220_Board_SetDirectionGpio(devicePrm.direction);
-            if ((devicePrm.commandExecuted&STSPIN220_SOFT_STOP_BIT_MASK)==0)
-            {
-              devicePrm.motionState = ACCELERATING;
-              devicePrm.accu = 0;
-              /* Apply accelerating torque */
-              Stspin220_ApplyTorque(ACC_TORQUE);
-              break;
-            }
-          }
-          if (devicePrm.stopMode==HOLD_MODE)
-          {
-            Stspin220_HardStop();
-          }
-          else if (devicePrm.stopMode==STANDBY_MODE)
-          {
-            Stspin220_PutDeviceInStandby();
-          }
-          else
-          {
-            Stspin220_HardHiZ();
-          }
-        }
-        else if ((devicePrm.commandExecuted==RUN_CMD)&&
-                 (speed<=(devicePrm.maxSpeed>>stepModeShift)))
-        {
-          devicePrm.motionState = STEADY;
-          /* Apply running torque */
-          Stspin220_ApplyTorque(RUN_TORQUE);
-        }
-        else
-        {
-          /* Go on decelerating */
-          if (speed>(devicePrm.minSpeed>>stepModeShift))
-          {
-            bool speedUpdated = false;
-            if (speed==0) speed =1;
-            devicePrm.accu += dec / speed;
-            while (devicePrm.accu>=(0X10000L))
-            {
-              devicePrm.accu -= (0X10000L);
-              if (speed>1)
-              {  
-                speed -=1;
-              }
-              speedUpdated = true;
-            }
-          
-            if (speedUpdated)
-            {
-              if (speed<(devicePrm.minSpeed>>stepModeShift))
-              {
-                speed = devicePrm.minSpeed>>stepModeShift;
-              }  
-              devicePrm.speed = speed;
-            }
-            
-            if (devicePrm.updateTorque!=false)
-            {
-              /* Apply decelerating torque */
-              Stspin220_ApplyTorque(DEC_TORQUE);
-            }
-          }
-        }
-        break;
-      }
-      default: 
-      {
-        break;
-      }
-    }
-  }
-  if ((devicePrm.motionState & INACTIVE) != INACTIVE)
-  {
-    Stspin220_ApplySpeed(devicePrm.speed);
-  }
-  else
-  {
-    if (Stspin220_Board_TimStckStop(&toggleOdd) == 0)
-    {
-      Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
-    }
-  }
-  Stspin220_Board_Monitor_Reset();
-}
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/stspin220/stspin220_class.h	Wed Jul 27 12:00:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1200 +0,0 @@
-/**
- ******************************************************************************
- * @file    stspin220_class.h
- * @author  IPC Rennes
- * @version V1.0.0
- * @date    July 27th, 2016
- * @brief   This file contains the class of a STSPIN220 Motor Control component.
- * @note    (C) COPYRIGHT 2016 STMicroelectronics
- ******************************************************************************
- * @attention
- *
- * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *   1. Redistributions of source code must retain the above copyright notice,
- *      this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright notice,
- *      this list of conditions and the following disclaimer in the documentation
- *      and/or other materials provided with the distribution.
- *   3. Neither the name of STMicroelectronics nor the names of its contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
-
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-
-#ifndef __STSPIN220_CLASS_H
-#define __STSPIN220_CLASS_H
-
-
-/* Includes ------------------------------------------------------------------*/
-
-/* ACTION 1 ------------------------------------------------------------------*
- * Include here platform specific header files.                               *
- *----------------------------------------------------------------------------*/        
-#include "mbed.h"
-
-/* ACTION 2 ------------------------------------------------------------------*
- * Include here component specific header files.                              *
- *----------------------------------------------------------------------------*/        
-#include "stspin220.h"
-/* ACTION 3 ------------------------------------------------------------------*
- * Include here interface specific header files.                              *
- *                                                                            *
- * Example:                                                                   *
- *   #include "../Interfaces/Humidity_class.h"                                *
- *   #include "../Interfaces/Temperature_class.h"                             *
- *----------------------------------------------------------------------------*/
-#include "../Interfaces/StepperMotor_class.h"
-
-
-/* Classes -------------------------------------------------------------------*/
-
-/**
- * @brief Class representing a STSPIN220 component.
- */
-class STSPIN220 : public StepperMotor
-{
-public:
-    /*** Constructor and Destructor Methods ***/
-    /**
-     * @brief Constructor.
-     * @param fault_and_enable_pin  pin name of the EN\FAULT pin of the component.
-     * @param stby_reset_pin        pin name of the STBY\RESET pin of the component.
-     * @param direction_mode4_pin   pin name of the MODE4\DIR pin of the component.
-     * @param mode1_pin             pin name of the MODE1 pin of the component.
-     * @param mode2_pin             pin name of the MODE2 pin of the component.
-     * @param stck_mode3_pin        pin name of the MODE3\STCK pin of the component.
-     * @param pwm_ref_pin           pin name of the PWM connected to the REF pin of the component.
-     * @param Monitor_pin           pin name for the step clock handler duration Monitoring.
-     */
-    STSPIN220(PinName fault_and_enable_pin,
-              PinName stby_reset_pin,
-              PinName direction_mode4_pin,
-              PinName mode1_pin,
-              PinName mode2_pin,
-              PinName stck_mode3_pin,
-              PinName pwm_ref_pin,
-              PinName monitor_pin = NC) : StepperMotor(),
-                                     fault_and_enable(fault_and_enable_pin),
-                                     stby_reset(stby_reset_pin),
-                                     direction_mode4(direction_mode4_pin),
-                                     mode1(mode1_pin),
-                                     mode2(mode2_pin),
-                                     stck_mode3(stck_mode3_pin),
-                                     pwm_ref(pwm_ref_pin),
-                                     monitor(monitor_pin)
-    {
-        /* Checking stackability. */
-        if (numberOfDevices!=0)
-            error("Instantiation of the STSPIN220 component failed: it can't be stacked on itself.\r\n");
-
-        /* ACTION 4 ----------------------------------------------------------*
-         * Initialize here the component's member variables, one variable per *
-         * line.                                                              *
-         *                                                                    *
-         * Example:                                                           *
-         *   measure = 0;                                                     *
-         *   instance_id = number_of_instances++;                             *
-         *--------------------------------------------------------------------*/
-        errorHandlerCallback = 0;
-        memset(&devicePrm, 0, sizeof(devicePrm));
-        deviceInstance = numberOfDevices++;
-        
-        fault_and_enable_pinName = fault_and_enable_pin;
-    }
-    
-    /**
-     * @brief Destructor.
-     */
-    virtual ~STSPIN220(void) {}
-    
-
-    /*** Public Component Related Methods ***/
-
-    /* ACTION 5 --------------------------------------------------------------*
-     * Implement here the component's public methods, as wrappers of the C    *
-     * component's functions.                                                 *
-     * They should be:                                                        *
-     *   + Methods with the same name of the C component's virtual table's    *
-     *     functions (1);                                                     *
-     *   + Methods with the same name of the C component's extended virtual   *
-     *     table's functions, if any (2).                                     *
-     *                                                                        *
-     * Example:                                                               *
-     *   virtual int GetValue(float *pData) //(1)                             *
-     *   {                                                                    *
-     *     return COMPONENT_GetValue(float *pfData);                          *
-     *   }                                                                    *
-     *                                                                        *
-     *   virtual int EnableFeature(void) //(2)                                *
-     *   {                                                                    *
-     *     return COMPONENT_EnableFeature();                                  *
-     *   }                                                                    *
-     *------------------------------------------------------------------------*/
-
-    /**
-     * @brief Public functions inherited from the Component Class
-     */
-
-    /**
-     * @brief  Initialize the component.
-     * @param  init Pointer to device specific initalization structure.
-     * @retval "0" in case of success, an error code otherwise.
-     */
-    virtual int Init(void *init = NULL)
-    {
-        return (int) Stspin220_Init((void *) init);
-    }
-
-    /**
-     * @brief  Getting the ID of the component.
-     * @param  id Pointer to an allocated variable to store the ID into.
-     * @retval "0" in case of success, an error code otherwise.
-     */
-    virtual int ReadID(uint8_t *id = NULL)
-    {
-        return (int) Stspin220_ReadID((uint8_t *) id);
-    }
-
-    /**
-     * @brief Public functions inherited from the StepperMotor Class
-     */
-
-    /**
-     * @brief  Getting the value of the motor state .
-     * @param  None.
-     * @retval The motor state accoring to motorState_t in motor.h
-     */
-    virtual unsigned int GetStatus(void)
-    {
-        return (unsigned int) Stspin220_GetDeviceState();
-    }
-
-    /**
-     * @brief  Getting the position.
-     * @param  None.
-     * @retval The position.
-     */
-    virtual signed int GetPosition(void)
-    {
-        return (signed int)Stspin220_GetPosition();
-    }
-
-    /**
-     * @brief  Getting the marked position.
-     * @param  None.
-     * @retval The marked position.
-     */
-    virtual signed int GetMark(void)
-    {
-        return (signed int)Stspin220_GetMark();
-    }
-
-    /**
-     * @brief  Getting the current speed in pps.
-     * @param  None.
-     * @retval The current speed in pps.
-     */
-    virtual unsigned int GetSpeed(void)
-    {
-        return (unsigned int)Stspin220_GetCurrentSpeed();
-    }
-
-    /**
-     * @brief  Getting the maximum speed in pps.
-     * @param  None.
-     * @retval The maximum speed in pps.
-     */
-    virtual unsigned int GetMaxSpeed(void)
-    {
-        return (unsigned int)Stspin220_GetMaxSpeed();
-    }
-
-    /**
-     * @brief  Getting the minimum speed in pps.
-     * @param  None.
-     * @retval The minimum speed in pps.
-     */
-    virtual unsigned int GetMinSpeed(void)
-    {
-        return (unsigned int)Stspin220_GetMinSpeed();
-    }
-
-    /**
-     * @brief  Getting the acceleration in pps^2.
-     * @param  None.
-     * @retval The acceleration in pps^2.
-     */
-    virtual unsigned int GetAcceleration(void)
-    {
-        return (unsigned int)Stspin220_GetAcceleration();
-    }
-
-    /**
-     * @brief  Getting the deceleration in pps^2.
-     * @param  None.
-     * @retval The deceleration in pps^2.
-     */
-    virtual unsigned int GetDeceleration(void)
-    {
-        return (unsigned int)Stspin220_GetDeceleration();
-    }
-    
-    /**
-     * @brief  Getting the direction of rotation.
-     * @param  None.
-     * @retval The direction of rotation.
-     */
-    virtual direction_t GetDirection(void)
-    {
-        if (Stspin220_GetDirection()!=BACKWARD)
-        {
-            return FWD;
-        }
-        else
-        {
-            return BWD;
-        }
-    }
-    
-    /**
-     * @brief  Setting the current position to be the home position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SetHome(void)
-    {
-        Stspin220_SetHome();
-    }
-
-    /**
-     * @brief  Setting the current position to be the marked position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SetMark(void)
-    {
-        Stspin220_SetMark();
-    }
-
-    /**
-     * @brief  Setting the maximum speed in pps.
-     * @param  speed The maximum speed in pps.
-     * @retval "true" in case of success, "false" otherwise.
-     */
-    virtual bool SetMaxSpeed(unsigned int speed)
-    {
-        if (speed <= 0xFFFF)
-        {
-            return Stspin220_SetMaxSpeed((uint16_t) speed);
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    /**
-     * @brief  Setting the minimum speed in pps.
-     * @param  speed The minimum speed in pps.
-     * @retval "true" in case of success, "false" otherwise.
-     */
-    virtual bool SetMinSpeed(unsigned int speed)
-    {
-        if (speed <= 0xFFFF)
-        {
-            return Stspin220_SetMinSpeed((uint16_t) speed);
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    /**
-     * @brief  Setting the acceleration in pps^2.
-     * @param  acceleration The acceleration in pps/s^2.
-     * @retval "true" in case of success, "false" otherwise.
-     */
-    virtual bool SetAcceleration(unsigned int acceleration)
-    {
-        if (acceleration <= 0xFFFF)
-        {
-            return Stspin220_SetAcceleration((uint16_t) acceleration);
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    /**
-     * @brief  Setting the deceleration in pps^2.
-     * @param  deceleration The deceleration in pps^2.
-     * @retval "true" in case of success, "false" otherwise.
-     */
-    virtual bool SetDeceleration(unsigned int deceleration)
-    {
-        if (deceleration <= 0xFFFF)
-        {
-            return Stspin220_SetDeceleration((uint16_t) deceleration);
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    /**
-     * @brief  Setting the Step Mode.
-     * @param  step_mode The Step Mode.
-     * @retval "true" in case of success, "false" otherwise.
-     * @note   step_mode can be one of the following:
-     *           + STEP_MODE_FULL
-     *           + STEP_MODE_WAVE
-     *           + STEP_MODE_HALF
-     *           + STEP_MODE_1_4
-     *           + STEP_MODE_1_8
-     *           + STEP_MODE_1_16
-     */
-    virtual bool SetStepMode(step_mode_t step_mode)
-    {
-        return Stspin220_SetStepMode((motorStepMode_t) step_mode);
-    }
-
-    /**
-     * @brief  Going to a specified position.
-     * @param  position The desired position.
-     * @retval None.
-     */
-    virtual void GoTo(signed int position)
-    {
-        Stspin220_GoTo((int32_t)position);
-    }
-
-    /**
-     * @brief  Going to the home position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void GoHome(void)
-    {
-        Stspin220_GoHome();
-    }
-
-    /**
-     * @brief  Going to the marked position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void GoMark(void)
-    {
-        Stspin220_GoMark();
-    }
-
-    /**
-     * @brief  Running the motor towards a specified direction.
-     * @param  direction The direction of rotation.
-     * @retval None.
-     */
-    virtual void Run(direction_t direction)
-    {
-        Stspin220_Run((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD));
-    }
-
-    /**
-     * @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.
-     * @retval None.
-     */
-    virtual void Move(direction_t direction, unsigned int steps)
-    {
-        Stspin220_Move((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD), (uint32_t)steps);
-    }
-
-    /**
-     * @brief  Stopping the motor through an immediate deceleration up to zero speed.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SoftStop(void)
-    {
-        Stspin220_SoftStop();
-    }
-
-    /**
-     * @brief  Stopping the motor through an immediate infinite deceleration.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void HardStop(void)
-    {
-        Stspin220_HardStop();
-    }
-
-    /**
-     * @brief  Disabling the power bridge after performing a deceleration to zero.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SoftHiZ(void)
-    {
-        Stspin220_SetStopMode(HIZ_MODE);
-        Stspin220_SoftStop();
-    }
-
-    /**
-     * @brief  Disabling the power bridge immediately.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void HardHiZ(void)
-    {
-        Stspin220_HardHiZ();
-    }
-
-    /**
-     * @brief  Waiting while the motor is active.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void WaitWhileActive(void)
-    {
-        Stspin220_WaitWhileActive();
-    }  
-
-    /**
-     * @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))
-    {
-        Stspin220_AttachErrorHandler((void (*)(uint16_t error)) fptr);
-    }
-
-    /**
-     * @brief  Checks if the device is disabled or/and has an alarm flag set 
-     * by reading the EN FAULT pin position.
-     * @param  None.
-     * @retval One if the EN FAULT pin is low (the device is disabled or/and 
-     * has an alarm flag set), otherwise zero.
-     */
-    virtual unsigned int CheckStatusHw(void)
-    {
-        if (!fault_and_enable.read()) return 0x01;
-        else return 0x00;
-    }
-    
-    /**
-     * @brief  Disabling the device.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void Disable(void)
-    {
-        Stspin220_Disable();
-    }
-    
-    /**
-     * @brief  Enabling the device.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void Enable(void)
-    {
-        Stspin220_Enable();
-    }
-    
-    /**
-     * @brief  Exit STSPIN220 device from standby (low power consumption) by
-     * setting STBY\RESET pin to high level and changing the motion state to
-     * INACTIVE.
-     * @param  None.
-     * @retval None.
-     */    
-    virtual void ExitDeviceFromStandby(void)
-    {
-        Stspin220_ExitDeviceFromStandby();
-    }
-    
-    /**
-     * @brief  Set the frequency of the VREFA and VREFB PWM
-     * @param  frequency in Hz
-     * @retval None.
-     */  
-    virtual uint32_t GetFreqVrefPwm(void)
-    {
-        return Stspin220_VrefPwmGetFreq();
-    }    
-    
-    /**
-     * @brief  Getting the version of the firmware.
-     * @param  None.
-     * @retval The version of the firmware.
-     */
-    virtual unsigned int GetFwVersion(void)
-    {
-        return (unsigned int) Stspin220_GetFwVersion();
-    }
-    
-    /**
-     * @brief  Getting the motor step mode.
-     * @param  None.
-     * @retval The motor step mode.
-     */
-    virtual step_mode_t GetStepMode(void)
-    {
-      return (step_mode_t) Stspin220_GetStepMode();
-    }
-    
-    /**
-     * @brief  Getting the motor stop mode.
-     * @param  None.
-     * @retval The motor stop mode.
-     */  
-    virtual motorStopMode_t GetStopMode(void)
-    {
-      return Stspin220_GetStopMode();
-    }
-    
-    /**
-     * @brief  Get the motor torque.
-     * @param  torqueMode Torque mode as specified in enum motorTorqueMode_t
-     * @retval the torqueValue in % (from 0 to 100)
-     */       
-    virtual uint8_t GetTorque(motorTorqueMode_t torqueMode)
-    {
-        return Stspin220_GetTorque(torqueMode);
-    }
-    
-    /**
-     * @brief  Get the torque boost feature status.
-     * @param  None.
-     * @retval true if enabled, false if disabled
-     */       
-    virtual bool GetTorqueBoostEnable(void)
-    {
-        return Stspin220_GetTorqueBoostEnable();
-    }
-    
-    /**
-     * @brief  Get the torque boost threshold
-     * @retval The torque boost threshold above which the step mode is
-     * changed to full step
-     */       
-    virtual uint16_t GetTorqueBoostThreshold(void)
-    {
-        return Stspin220_GetTorqueBoostThreshold();
-    }
-    
-    /**
-     * @brief  Going to a specified position with a specificied direction.
-     * @param  direction The desired direction.
-     * @param  position The desired position.
-     * @retval None.
-     */
-    virtual void GoTo(direction_t direction, signed int position)
-    {
-        Stspin220_GoToDir((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD),(int32_t)position);
-    }
-
-    /**
-     * @brief  Put STSPIN220 device in standby (low power consumption) by 
-     * setting STBY\RESET pin to low level and changing the motion state to
-     * STANDBY.
-     * @param  None.
-     * @retval None.
-     */    
-    virtual void PutDeviceInStandby(void)
-    {
-        Stspin220_PutDeviceInStandby();
-    }
-
-    /**
-     * @brief  Release the STSPIN220 reset (Reset pin set to high level).
-     * @param  None.
-     * @retval None.
-     */    
-    virtual void ReleaseReset(void)
-    {
-        Stspin220_Board_ReleaseReset();
-    }
-    
-    /**
-     * @brief  Reset the STSPIN220 (Reset pin set to low level).
-     * @param  None.
-     * @retval None.
-     */    
-    virtual void Reset(void)
-    {
-        Stspin220_Board_Reset();
-    }
-
-    /**
-     * @brief  Set the motor direction.
-     * @param  direction The desired direction.
-     * @retval None.
-     */
-    virtual void SetDirection(direction_t direction)
-    { 
-        Stspin220_SetDirection((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD));
-    }
-
-    /**
-     * @brief  Set the frequency of the PWM for REF pin
-     * @param  frequency in Hz
-     * @retval None.
-     */  
-    virtual void SetFreqVrefPwm(uint32_t frequency)
-    {
-        Stspin220_VrefPwmSetFreq(frequency);
-    }
-
-    /**
-     * @brief  Set the motor stop mode.
-     * @param  stopMode The desired stop mode (HOLD_MODE, HIZ_MODE or
-     * STANDBY_MODE).
-     * @retval None.
-     */       
-    virtual void SetStopMode(motorStopMode_t stopMode)
-    {
-        Stspin220_SetStopMode(stopMode);
-    }
-
-    /**
-     * @brief  Set the motor torque.
-     * @param  torqueMode Torque mode as specified in enum motorTorqueMode_t
-     * @param  torqueValue in % (from 0 to 100)
-     * @retval None.
-     */       
-    virtual void SetTorque(motorTorqueMode_t torqueMode, uint8_t torqueValue)
-    {
-        Stspin220_SetTorque(torqueMode, torqueValue);
-    }
-
-    /**
-     * @brief  Enable or disable the motor torque boost feature.
-     * @param  enable enable true to enable torque boost, false to disable
-     * @retval None.
-     */       
-    virtual void SetTorqueBoostEnable(bool enable)
-    {
-        Stspin220_SetTorqueBoostEnable(enable);
-    }
-    
-    /**
-     * @brief Set the torque boost threshold
-     * @param[in] speedThreshold speed threshold above which the step mode is
-     * changed to full step
-     * @retval None.
-     */       
-    virtual void SetTorqueBoostThreshold(uint16_t speedThreshold)
-    {
-        Stspin220_SetTorqueBoostThreshold(speedThreshold);
-    }
-
-    /*** Public Interrupt Related Methods ***/
-
-    /* ACTION 6 --------------------------------------------------------------*
-     * Implement here interrupt related methods, if any.                      *
-     * Note that interrupt handling is platform dependent, e.g.:              *
-     *   + mbed:                                                              *
-     *     InterruptIn feature_irq(pin); //Interrupt object.                  *
-     *     feature_irq.rise(callback);   //Attach a callback.                 *
-     *     feature_irq.mode(PullNone);   //Set interrupt mode.                *
-     *     feature_irq.enable_irq();     //Enable interrupt.                  *
-     *     feature_irq.disable_irq();    //Disable interrupt.                 *
-     *   + Arduino:                                                           *
-     *     attachInterrupt(pin, callback, RISING); //Attach a callback.       *
-     *     detachInterrupt(pin);                   //Detach a callback.       *
-     *                                                                        *
-     * Example (mbed):                                                        *
-     *   void AttachFeatureIRQ(void (*fptr) (void))                           *
-     *   {                                                                    *
-     *     feature_irq.rise(fptr);                                            *
-     *   }                                                                    *
-     *                                                                        *
-     *   void EnableFeatureIRQ(void)                                          *
-     *   {                                                                    *
-     *     feature_irq.enable_irq();                                          *
-     *   }                                                                    *
-     *                                                                        *
-     *   void DisableFeatureIRQ(void)                                         *
-     *   {                                                                    *
-     *     feature_irq.disable_irq();                                         *
-     *   }                                                                    *
-     *------------------------------------------------------------------------*/
-    /**
-     * @brief  Attaching an interrupt handler to the FLAG interrupt.
-     * @param  fptr An interrupt handler.
-     * @retval None.
-     */
-     
-    void AttachFlagIRQ(void (*fptr)(void))
-    {
-        fault_and_enable_irqFunctionPointer = &(*fptr);
-        fault_and_enable.fall(fptr);
-        fault_and_enable.mode(PullDown);
-        wait_ms(1);
-    }
-    
-    /**
-     * @brief  Enabling the FLAG interrupt handling.
-     * @param  None.
-     * @retval None.
-     */
-    void EnableFlagIRQ(void)
-    {
-        fault_and_enable.enable_irq();
-    }
-    
-protected:
-
-    /*** Protected Component Related Methods ***/
-
-    /* ACTION 7 --------------------------------------------------------------*
-     * Declare here the component's specific methods.                         *
-     * They should be:                                                        *
-     *   + Methods with the same name of the C component's virtual table's    *
-     *     functions (1);                                                     *
-     *   + Methods with the same name of the C component's extended virtual   *
-     *     table's functions, if any (2);                                     *
-     *   + Helper methods, if any, like functions declared in the component's *
-     *     source files but not pointed by the component's virtual table (3). *
-     *                                                                        *
-     * Example:                                                               *
-     *   Status_t COMPONENT_GetValue(float *f);   //(1)                       *
-     *   Status_t COMPONENT_EnableFeature(void);  //(2)                       *
-     *   Status_t COMPONENT_ComputeAverage(void); //(3)                       *
-     *------------------------------------------------------------------------*/
-    Status_t Stspin220_Init(void *init);
-    Status_t Stspin220_ReadID(uint8_t *id);
-    void Stspin220_AttachErrorHandler(void (*callback)(uint16_t error));
-    void Stspin220_ApplyTorque(motorTorqueMode_t torqueMode);
-    void Stspin220_Disable(void);
-    void Stspin220_ErrorHandler(uint16_t error);
-    void Stspin220_Enable(void);
-    void Stspin220_ExitDeviceFromStandby(void);
-    uint16_t Stspin220_GetAcceleration(void);
-    uint16_t Stspin220_GetCurrentSpeed(void);
-    uint16_t Stspin220_GetDeceleration(void);
-    motorState_t Stspin220_GetDeviceState(void);
-    motorDir_t Stspin220_GetDirection(void);
-    uint32_t Stspin220_GetFwVersion(void);
-    int32_t Stspin220_GetMark(void);
-    uint16_t Stspin220_GetMaxSpeed(void);
-    uint16_t Stspin220_GetMinSpeed(void);
-    int32_t Stspin220_GetPosition(void);
-    motorStepMode_t Stspin220_GetStepMode(void);
-    motorStopMode_t Stspin220_GetStopMode(void);
-    uint8_t Stspin220_GetTorque(motorTorqueMode_t torqueMode);
-    bool Stspin220_GetTorqueBoostEnable(void);
-    uint16_t Stspin220_GetTorqueBoostThreshold(void);
-    void Stspin220_GoHome(void);  
-    void Stspin220_GoMark(void);
-    void Stspin220_GoTo(int32_t targetPosition);
-    void Stspin220_GoToDir(motorDir_t direction, int32_t targetPosition);   
-    void Stspin220_HardHiZ(void);
-    void Stspin220_HardStop(void);
-    void Stspin220_Move(motorDir_t direction, uint32_t stepCount);
-    void Stspin220_PutDeviceInStandby(void);
-    void Stspin220_Run(motorDir_t direction);
-    bool Stspin220_SetAcceleration(uint16_t newAcc);
-    bool Stspin220_SetDeceleration(uint16_t newDec);
-    void Stspin220_SetDirection(motorDir_t direction);
-    void Stspin220_SetHome(void);
-    void Stspin220_SetMark(void);
-    bool Stspin220_SetMaxSpeed(uint16_t volatile newSpeed);
-    bool Stspin220_SetMinSpeed(uint16_t volatile newSpeed);    
-    bool Stspin220_SetStepMode(motorStepMode_t stepMode);
-    void Stspin220_SetStopMode(motorStopMode_t stopMode);
-    bool Stspin220_SoftStop(void);
-    void Stspin220_SetTorque(motorTorqueMode_t torqueMode, uint8_t torqueValue);
-    void Stspin220_SetTorqueBoostEnable(bool enable);
-    void Stspin220_SetTorqueBoostThreshold(uint16_t speedThreshold);
-    uint32_t Stspin220_VrefPwmGetFreq(void);
-    void Stspin220_VrefPwmSetFreq(uint32_t newFreq);
-    void Stspin220_WaitWhileActive(void);
-    
-    /*** Functions intended to be used only internally ***/
-    void Stspin220_ApplySpeed(uint16_t newSpeed);
-    void Stspin220_ComputeSpeedProfile(uint32_t nbSteps);    
-    void Stspin220_SetDeviceParamsToGivenValues(Stspin220_Init_t* pInitDevicePrm);
-    void Stspin220_SetDeviceParamsOtherValues(void);    
-    void Stspin220_SetDeviceParamsToPredefinedValues(void);
-    bool Stspin220_SetStepModeWithoutReset(motorStepMode_t stepMode);
-    void Stspin220_StartMovement(void);
-    void Stspin220_StepClockHandler(void);
-    
-    /*** Component's I/O Methods ***/
-
-    /* ACTION 8 --------------------------------------------------------------*
-     * Implement here other I/O methods beyond those already implemented      *
-     * above, which are declared extern within the component's header file.   *
-     *------------------------------------------------------------------------*/
-    /**
-     * @brief  Making the CPU wait.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_Delay(uint32_t delay)
-    {
-        wait_ms(delay);
-    }
-    
-    /**
-     * @brief  Disable the power bridges (leave the output bridges HiZ).
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_Disable(void)
-    {
-        fault_and_enable.disable_irq();
-        DigitalOut fault_and_enable(fault_and_enable_pinName);
-        fault_and_enable.write(0);
-    }
-
-    /**
-     * @brief  Disabling interrupts.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_DisableIrq(void)
-    {
-        __disable_irq();
-    }
-    
-    /**
-     * @brief  Enable the power bridges (leave the output bridges HiZ).
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_Enable(void)
-    {
-        DigitalOut fault_and_enable_do(fault_and_enable_pinName);
-        fault_and_enable_do.write(1);
-        fault_and_enable.fall(fault_and_enable_irqFunctionPointer);
-        fault_and_enable.mode(PullUp);
-        wait_ms(1);
-        fault_and_enable.enable_irq();
-    }
-    
-    /**
-     * @brief  Enabling interrupts.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_EnableIrq(void)
-    {
-        __enable_irq();
-    }
-
-    /**
-     * @brief  Set the duty cycle of the PwmOut used for the REF
-     * reference voltage generation and actually start the pwm if the duty cycle
-     * is not zero.
-     * @param[in] dutyCycle 0 - 100%
-     * @retval None
-     */
-    void Stspin220_Board_PwmRefSetDutyCycle(uint8_t dutyCycle)
-    {
-        pwm_ref.write(((float)(100-dutyCycle))/100);
-    }
-
-    /**
-     * @brief  Set the frequency of the PwmOut used for the REF
-     * reference voltage generation.
-     * @param[in] newFreq in Hz.
-     * @retval None.
-     */
-    void Stspin220_Board_PwmRefSetFreq(uint32_t newFreq)
-    {
-        pwm_ref.period_us(1000000.0f/newFreq);
-    }
-    
-    /**
-     * @brief  Start the PwmOut for the REF pin.
-     * @param[in] frequency frequency of the PwmOut used to generate the REF
-     * reference voltage for the bridges.
-     * @param[in] torqueMode Torque mode as specified in enum motorTorqueMode_t    
-     * @retval None.
-     */ 
-    void Stspin220_Board_PwmRefStart(uint32_t frequency, motorTorqueMode_t torqueMode)
-    { 
-        /* Setting the period of the PwmOut. */
-        pwm_ref.period_us(1000000.0f/frequency);
-        /* Setting the duty cycle and actually starting the of the PwmOut. */
-        Stspin220_ApplyTorque(torqueMode);
-        wait_ms(5*PWM_FILTER_TIME_CONSTANT);
-    }
-
-    /**
-     * @brief  Exit the device from standby reset mode.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_ReleaseReset(void)
-    {
-        stby_reset = 1;
-    }
-
-    /**
-     * @brief  Put the device in standby reset mode.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_Reset(void)
-    {
-        stby_reset = 0;
-    }
-
-    /**
-     * @brief  Set the DIR\MODE4 pin.
-     * @param  dir motor direction FORWARD or BACKWARD.
-     * @retval None.
-     */
-    void Stspin220_Board_SetDirectionGpio(motorDir_t dir)
-    {
-        if (dir==BACKWARD) direction_mode4 = 0;
-        else direction_mode4 = 1;
-    }
- 
-    /**
-     * @brief Select Full Step mode
-     * @param  None.
-     * @retval None
-     */
-    void Stspin220_Board_SetFullStep(void)
-    {
-        mode1 = 0;
-        mode2 = 0;
-    }
-    
-    /**
-     * @brief Select the STSPIN220 mode1, mode2, mode3 and mode4 pins levels.
-     * @param[in] modePin1Level level of the mode1 gpio (0 low, 1+ high)
-     * @param[in] modePin2Level level of the mode2 gpio (0 low, 1+ high)
-     * @param[in] modePin3Level level of the mode3 gpio (0 low, 1+ high)
-     * @param[in] modePin4Level level of the mode4 gpio (0 low, 1+ high)
-     * @retval 1
-     */
-    uint8_t Stspin220_Board_SetModePins(uint8_t modePin1Level,\
-        uint8_t modePin2Level,\
-        uint8_t modePin3Level,\
-        uint8_t modePin4Level)
-    {
-        mode1 = modePin1Level;
-        mode2 = modePin2Level;
-        stck_mode3 = modePin3Level;
-        direction_mode4 = modePin4Level;
-        return 1;
-    }
-
-    /**
-     * @brief  Reset the STCK\MODE3 pin.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_StckMode3_Reset(void)
-    {
-        stck_mode3 = 0;
-    }
-
-    /**
-     * @brief  Set the STCK\MODE3 pin.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin220_Board_StckMode3_Set(void)
-    {
-        stck_mode3 = 1;
-    }
-
-    /**
-     * @brief Initialises the step clock pin level
-     * @param  None.
-     * @retval None
-     */
-    void Stspin220_Board_TimStckInit(bool check)
-    {
-        if (monitor.is_connected()) monitor = 0;
-        if (check==false) stck_mode3 = 0;
-        else if (stck_mode3==1) Stspin220_ErrorHandler(STSPIN220_ERROR_STEP_CLOCK);
-    }
-
-    /**
-     * @brief  Setting the Stck Timeout delay
-     * and attaching a callback function to it.
-     * @param  frequency The frequency corresponding to the delay.
-     * @retval None.
-     */
-    void Stspin220_Board_TimStckSetFreq(uint16_t newFreq)
-    {
-        /* Computing the delay of the Timeout. */
-        float delay_us = (1000000.0f / 2 )/ newFreq;
-        
-        /* Attaching a function which updates */
-        /* the state machine after the elapsed period_us time. */
-        tim_stck.attach_us(this, &STSPIN220::Stspin220_StepClockHandler, delay_us);
-    }
-
-    void Stspin220_Board_Monitor_Set(void)
-    {
-        if (monitor.is_connected()) monitor = 1;
-    }
-    
-    void Stspin220_Board_Monitor_Reset(void)
-    {
-        if (monitor.is_connected()) monitor = 0;
-    }
-
-    /**
-     * @brief  Stopping the Timeout.
-     * @param  None.
-     * @retval None.
-     */
-    uint8_t Stspin220_Board_TimStckStop(volatile uint8_t *pToggleOdd)
-    {
-        __disable_irq();
-        if (*pToggleOdd == 1)
-        {
-            __enable_irq();
-            return 1;
-        }
-        if (stck_mode3 != 0)
-        {
-            __enable_irq();
-            return 0;
-        }
-        tim_stck.detach();
-        __enable_irq();
-        return 1;
-    }
-
-    /**
-     * @brief Unselect Full Step mode
-     * @param  None.
-     * @retval None
-     */
-    void Stspin220_Board_UnsetFullStep(void)
-    {
-        mode1 = 1;
-    }
-
-protected:
-
-    /*** Component's Instance Variables ***/
-
-    /* ACTION 9 --------------------------------------------------------------*
-     * Declare here interrupt related variables, if needed.                   *
-     * Note that interrupt handling is platform dependent, see                *
-     * "Interrupt Related Methods" above.                                     *
-     *                                                                        *
-     * Example:                                                               *
-     *   + mbed:                                                              *
-     *     InterruptIn feature_irq;                                           *
-     *------------------------------------------------------------------------*/
-    /* Fault Interrupt and chip enable. */
-    InterruptIn fault_and_enable;
-    
-    /* Interrupt to toggle the MODE3\STCK pin */
-    Timeout tim_stck;
-
-    /* ACTION 10 -------------------------------------------------------------*
-     * Declare here other pin related variables, if needed.                   *
-     *                                                                        *
-     * Example:                                                               *
-     *   + mbed:                                                              *
-     *     DigitalOut standby_reset;                                          *
-     *------------------------------------------------------------------------*/
-    /* STBY\RESET pin. */
-    DigitalOut stby_reset;
-    /* MODE4\DIR pin. */
-    DigitalOut direction_mode4;
-    /* MODE1 pin */
-    DigitalOut mode1;
-    /* MODE2 pin */
-    DigitalOut mode2;
-    /* MODE3\STCK pin. */
-    DigitalOut stck_mode3;
-
-    /* Pulse Width Modulation pin for REF pin */
-    PwmOut pwm_ref;
- 
-    /* Monitoring of step clock handler duration */
-    DigitalOut monitor;
-
-    /* fault and enable pin */
-    PinName fault_and_enable_pinName;
-    
-    /* ACTION 11 -------------------------------------------------------------*
-     * Declare here communication related variables, if needed.               *
-     *                                                                        *
-     * Example:                                                               *
-     *   + mbed:                                                              *
-     *     DigitalOut ssel;                                                   *
-     *     DevSPI &dev_spi;                                                   *
-     *------------------------------------------------------------------------*/
-    /* Configuration. */
-
-    /* IO Device. */
-
-    /* ACTION 12 -------------------------------------------------------------*
-     * Declare here identity related variables, if needed.                    *
-     * Note that there should be only a unique identifier for each component, *
-     * which should be the "who_am_i" parameter.                              *
-     *------------------------------------------------------------------------*/
-    /* Identity */
-    uint8_t who_am_i;
-
-    /* ACTION 13 -------------------------------------------------------------*
-     * Declare here the component's static and non-static data, one variable  *
-     * per line.                                                              *
-     *                                                                        *
-     * Example:                                                               *
-     *   float measure;                                                       *
-     *   int instance_id;                                                     *
-     *   static int number_of_instances;                                      *
-     *------------------------------------------------------------------------*/
-    /* Data. */
-    void (*fault_and_enable_irqFunctionPointer)(void);
-    void (*errorHandlerCallback)(uint16_t error);
-    deviceParams_t devicePrm;
-    uint8_t deviceInstance;
-    volatile uint8_t toggleOdd;
-
-    /* Static data. */
-    static uint8_t numberOfDevices;
-
-public:
-
-    /* Static data. */
-    
-};
-
-#endif // __STSPIN220_CLASS_H
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/stspin220/stspin220_target_config.h	Wed Jul 27 12:00:06 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/**************************************************************************//**
-  * @file    stspin220_target_config.h
-  * @author  IPC Rennes
-  * @version V1.1.0
-  * @date    May 26th, 2016
-  * @brief   Predefines values for the STSPIN220 registers
-  * and for the devices parameters
-  * @note    (C) COPYRIGHT 2016 STMicroelectronics
-  ******************************************************************************
-  * @attention
-  *
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STSPIN220_TARGET_CONFIG_H
-#define __STSPIN220_TARGET_CONFIG_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif  
-   
-/** @addtogroup STSPIN220
-  * @{
-  */
-
-/** @addtogroup Stspin220_Exported_Constants
-  * @{
-  */
-   
-/** @defgroup Predefined_Stspin220_Registers_Values Predefined Stspin220 Registers Values
-  * @{
-  */
-
-/************************ Speed Profile  *******************************/
-
-/// Acceleration rate in pulse/s2 (must be greater than 0)
-#define STSPIN220_CONF_PARAM_ACC                               (480)
-   
-/// Deceleration rate in pulse/s2 (must be greater than 0)
-#define STSPIN220_CONF_PARAM_DEC                               (480)
-   
-/// Running speed in pulse/s (8 pulse/s < Maximum speed <= 10 000 pulse/s )
-#define STSPIN220_CONF_PARAM_RUNNING_SPEED                     (1600)
-   
-/// Minimum speed in pulse/s (8 pulse/s <= Minimum speed < 10 000 pulse/s)
-#define STSPIN220_CONF_PARAM_MIN_SPEED                         (400)
-
-/************************ Torque  *******************************/
-
-/// Acceleration torque in % (from 0 to 100)
-#define STSPIN220_CONF_PARAM_ACC_TORQUE                        (20)
-
-/// Deceleration torque in % (from 0 to 100)
-#define STSPIN220_CONF_PARAM_DEC_TORQUE                        (15)
-
-/// Running torque in % (from 0 to 100)
-#define STSPIN220_CONF_PARAM_RUNNING_TORQUE                    (10)
-
-/// Holding torque in % (from 0 to 100)
-#define STSPIN220_CONF_PARAM_HOLDING_TORQUE                    (25)
-
-/// Torque boost speed enable
-#define STSPIN220_CONF_PARAM_TORQUE_BOOST_EN                   (TRUE)
-
-/// Torque boost speed threshold in fullstep/s
-#define STSPIN220_CONF_PARAM_TORQUE_BOOST_TH                   (200)
-    
-/******************************* Others ***************************************/
-
-/// Step mode selection settings
-#define STSPIN220_CONF_PARAM_STEP_MODE                         (STEP_MODE_1_32)
-   
-/// Automatic HIZ STOP
-#define STSPIN220_CONF_PARAM_AUTO_HIZ_STOP                     (HOLD_MODE)
-
-/// REF PWM frequency (Hz)
-#define STSPIN220_CONF_PARAM_REF_PWM_FREQUENCY                 (100000)
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif /* __STSPIN220_TARGET_CONFIG_H */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ST_INTERFACES.lib	Fri Mar 24 10:59:19 2017 +0100
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/ST_INTERFACES/#8f70f7159316