Expansion SW library to control a bipolar stepper motor using X-NUCLEO-IHM05A1 expansion board based on L6208.

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_IHM05A1 TAU_ROTATING_PLATFORM_IHM05A1 Amaldi_13_Exercise_IHM05A1 Amaldi_13_Exercise_IHM05A1motore ... more

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

Motor Control Library

Library to handle the X-NUCLEO-IHM05A1 Motor Control Expansion Board based on the L6208 component.

It features the:

  • Read and write of device parameters
  • Configuration of GPIOs and IRQs (for enabling, direction, current decay and microstepping)
  • Control of position, speed, acceleration and deceleration
  • Command locking until the device completes movement
  • Handling of overcurrent and thermal alarms (flag interrupt handling)

The API allows to easily:

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

Board configuration

/media/uploads/nucleosam/mbed-x-nucleo-ihm05a1.png

Platform compatibility

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

Files at this revision

API Documentation at this revision

Comitter:
davide.aliprandi@st.com
Date:
Fri Mar 24 10:59:42 2017 +0100
Parent:
2:2af31245e67e
Child:
4:0b52159554b5
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/l6208/L6208.cpp Show annotated file Show diff for this revision Revisions of this file
Components/l6208/L6208_config.h Show annotated file Show diff for this revision Revisions of this file
Components/l6208/L6208_def.h Show annotated file Show diff for this revision Revisions of this file
Components/l6208/l6208.h Show annotated file Show diff for this revision Revisions of this file
Components/l6208/l6208_class.cpp Show diff for this revision Revisions of this file
Components/l6208/l6208_class.h Show diff for this revision Revisions of this file
Components/l6208/l6208_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	Fri Apr 29 14:58:30 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:42 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	Fri Apr 29 14:58:30 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:42 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	Fri Apr 29 14:58:30 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	Fri Apr 29 14:58:30 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/l6208/L6208.cpp	Fri Mar 24 10:59:42 2017 +0100
@@ -0,0 +1,1872 @@
+/**
+  ******************************************************************************
+  * @file    L6208.cpp
+  * @author  IPC Rennes
+  * @version V1.1.0
+  * @date    February 11th, 2016
+  * @brief   L6208 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 "L6208.h"
+
+/* Definitions ---------------------------------------------------------------*/
+/// Bridge A
+#define BRIDGE_A                     (0)
+/// Bridge B
+#define BRIDGE_B                     (1)
+
+/// Bitmaps for system flags
+#define EN_A_set              0x00000001    ///< EN_A pin status
+#define HiZstop               0x00000002    ///< motor has to be left in HiZ after stopping
+#define busy                  0x00000004    ///< stepper position command executing flag
+#define running               0x00000008    ///< running motor flag
+#define velocitymode          0x00000010    ///< velocity controlled stepper motor
+#define positionmode          0x00000020    ///< position controlled stepper motor
+#define fullstep              0x00000040    ///< full step mode controlled    
+#define halfstep              0x00000080    ///< half step mode controlled    
+#define microstep             0x00000100    ///< micro step mode controlled
+#define forward               0x00000200    ///< forward running motor
+#define dir2change            0x00000400    ///< direction has to be changed while the motor is running
+#define fastdecaymode         0x00000800    ///< decay mode is fast
+#define wavestep              0x00001000    ///< wave step mode controlled
+
+/* Variables  ----------------------------------------------------------------*/
+/* Number of devices. */
+uint8_t L6208::numberOfDevices = 0;
+
+/// RefMicroTable values are 2^L6208_SINE_WAVEFORM_POWER_OF_TWO_MAX_VALUE*|sin(n/16*PI/2)|
+/// where n is the index in the table
+const uint16_t L6208::RefMicroTable[L6208_USTEPS_PER_QUARTER_PERIOD*3] =
+{
+  0,3212,6393,9512,12540,15447,18205,20788,23170,25330,27246,28899,30274,31357,32138,32610,
+  32768,32610,32138,31357,30274,28899,27246,25330,23170,20788,18205,15447,12540,9512,6393,3212,
+  0,3212,6393,9512,12540,15447,18205,20788,23170,25330,27246,28899,30274,31357,32138,32610
+};
+
+/* Methods -------------------------------------------------------------------*/
+/******************************************************//**
+ * @brief Start the L6208 library
+ * @param[in] pInit pointer to the initialization data
+ * @retval COMPONENT_OK in case of success.
+ **********************************************************/
+status_t L6208::L6208_Init(void* pInit)
+{ 
+  if (pInit == NULL)
+  {
+    /* Set context variables to the predefined values from l6208_target_config.h */
+    /* Set GPIO according to these values */
+    L6208_SetDeviceParamsToPredefinedValues();
+  }
+  else
+  {
+    L6208_SetDeviceParamsToGivenValues((l6208_init_t*) pInit);
+  }
+  
+  /* Initialise the PWMs */
+  L6208_Board_VrefPwmInit(BRIDGE_A, devicePrm.vrefPwmPeriod);
+  L6208_Board_VrefPwmInit(BRIDGE_B, devicePrm.vrefPwmPeriod);
+
+  /* Initialise the tick */
+  L6208_Board_TickInit();
+  
+  /* Reset L6208 */
+  L6208_ResetDevice();
+  
+  /* Align motor mechanical position to driver position */
+  L6208_Board_VrefPwmStart(BRIDGE_A, devicePrm.vrefPwmPeriod);
+  L6208_Board_VrefPwmStart(BRIDGE_B, devicePrm.vrefPwmPeriod);
+  //L6208_Enable();
+  
+  return COMPONENT_OK;
+}
+
+/**********************************************************
+ * @brief Read id
+ * @param id pointer to the identifier to be read.
+ * @retval COMPONENT_OK in case of success.
+ **********************************************************/
+status_t L6208::L6208_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 L6208::L6208_AttachErrorHandler(void (*callback)(uint16_t error))
+{
+  errorHandlerCallback = (void (*)(uint16_t error)) callback;
+}
+
+/******************************************************//**
+ * @brief Disable the power bridges (leave the output bridges HiZ)
+ * @retval None
+ **********************************************************/
+void L6208::L6208_disable(void)
+{
+  L6208_Board_Disable();
+  L6208_ClearSysFlag(EN_A_set);
+}
+
+/******************************************************//**
+ * @brief Error handler which calls the user callback (if defined)
+ * @param[in] error Number of the error
+ * @retval None
+ **********************************************************/
+void L6208::L6208_ErrorHandler(uint16_t error)
+{
+  if (errorHandlerCallback != 0)
+  {
+    errorHandlerCallback(error);
+  }
+  else   
+  {
+    while(1)
+    {
+      /* Infinite loop */
+    }
+  }
+}
+
+/******************************************************//**
+ * @brief Enable the power bridges
+ * @retval None
+ **********************************************************/
+void L6208::L6208_enable(void)
+{
+  L6208_Board_Enable();
+  L6208_SetSysFlag(EN_A_set);
+}
+
+/******************************************************//**
+ * @brief Get the stepper acceleration rate
+ * in step/s^2 for full, half and wave modes
+ * in microsteps/s^2 for microstep modes
+ * @retval the stepper acceleration rate in step/s^2 or microstep/s^2
+ * @note
+ **********************************************************/
+uint16_t L6208::L6208_GetAcceleration(void)
+{
+    return devicePrm.accelerationSps2;
+}
+
+/******************************************************//**
+ * @brief Get the current speed
+ * in step/s for full, half and wave modes
+ * in microsteps/s for microstep modes
+ * @retval return the current speed in step/s or microstep/s
+ * @note
+ **********************************************************/
+uint16_t L6208::L6208_GetCurrentSpeed(void)
+{
+  uint64_t tmp64 = (uint64_t) devicePrm.speedSpt * L6208_Board_TickGetFreq();
+  
+  devicePrm.speedSps = (uint16_t)(tmp64 >> 23);
+  if (devicePrm.speedSps & 0x1)
+  {
+    devicePrm.speedSps = (devicePrm.speedSps >> 1) + 1;
+  }
+  else
+  {
+    devicePrm.speedSps = devicePrm.speedSps >> 1;
+  }
+  return devicePrm.speedSps;
+}
+
+/******************************************************//**
+ * @brief Get the motor decay mode
+ * @retval decay mode
+ **********************************************************/
+motorDecayMode_t L6208::L6208_get_decay_mode(void)
+{
+  if (L6208_IsSysFlag(fastdecaymode)) return (FAST_DECAY);
+  else return (SLOW_DECAY);
+}
+
+/******************************************************//**
+ * @brief Get the stepper deceleration rate
+ * in step/s^2 for full, half and wave modes
+ * in microsteps/s^2 for microstep modes
+ * @retval the stepper deceleration rate in step/s^2 or microstep/s^2
+ * @note
+ **********************************************************/
+uint16_t L6208::L6208_GetDeceleration(void)
+{
+    return devicePrm.decelerationSps2;
+}
+
+/******************************************************//**
+ * @brief Get the motor current direction
+ * @retval direction
+ **********************************************************/
+motorDir_t L6208::L6208_GetDirection(void)
+{
+  if (L6208_IsSysFlag(forward))
+  {
+    return FORWARD;
+  }
+  else
+  {
+    return BACKWARD;
+  }
+}
+
+/******************************************************//**
+ * @brief Return the FW version.
+ * @retval FW version
+ **********************************************************/
+uint32_t L6208::L6208_GetFwVersion(void)
+{
+  return L6208_FW_VERSION;
+}
+
+/******************************************************//**
+ * @brief Get the mark position (32b signed) 
+ * @retval mark position
+ **********************************************************/
+int32_t L6208::L6208_GetMark(void)
+{
+  return devicePrm.markPos;
+}
+
+/******************************************************//**
+ * @brief Get the max speed
+ * in step/s for full, half and wave modes
+ * in microsteps/s for microstep modes
+ * @retval return the max speed in step/s or microstep/s
+ * @note
+ **********************************************************/
+uint16_t L6208::L6208_GetMaxSpeed(void)
+{
+  return devicePrm.maxSpeedSps;
+}
+
+/******************************************************//**
+ * @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 L6208::L6208_GetMinSpeed(void)
+{
+  return devicePrm.minSpeedSps;
+}
+
+/******************************************************//**
+ * @brief Get the stepper state machine index
+ * @retval one of the stepper state machine index in the motorState_t enum
+ **********************************************************/
+motorState_t L6208::L6208_GetMotionState(void)
+{
+  // gets the new stepper state machine index
+  return devicePrm.motionState;    
+}
+
+/******************************************************//**
+ * @brief Get the current position (32b signed) 
+ * @retval current absoulte position
+ **********************************************************/
+int32_t L6208::L6208_GetPosition(void)
+{
+  return devicePrm.absolutePos;
+}
+
+/******************************************************//**
+ * @brief Get the motor step mode
+ * @retval step mode
+ **********************************************************/
+motorStepMode_t L6208::L6208_get_step_mode(void)
+{
+  return devicePrm.stepMode;
+}
+
+/******************************************************//**
+ * @brief Get the selected stop mode
+ * @retval the selected stop mode
+ **********************************************************/
+motorStopMode_t L6208::L6208_GetStopMode(void)
+{
+  if (L6208_IsSysFlag(HiZstop) == FALSE)
+  {
+      return (HOLD_MODE);
+  }
+  else
+  {
+      return (HIZ_MODE);
+  }
+}
+
+/******************************************************//**
+ * @brief Go to the home position
+ * @retval None
+ **********************************************************/
+void L6208::L6208_GoHome(void)
+{
+  L6208_GoTo(0);
+}
+
+/******************************************************//**
+ * @brief Go to the Mark position
+ * @retval None
+ **********************************************************/
+void L6208::L6208_GoMark(void)
+{
+  L6208_GoTo(devicePrm.markPos);
+}
+
+/******************************************************//**
+ * @brief move the motor to the absolute position using the shortest path
+ * @param[in] abs_pos 32 bit signed value position
+ * @retval None
+ * @note The position is at the resolution corresponding to the
+ * selected step mode.
+ * STEP_MODE_FULL or STEP_MODE_WAVE : 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 
+ **********************************************************/
+void L6208::L6208_GoTo(int32_t abs_pos)
+{
+  uint32_t steps = 0;
+  
+  if(L6208_IsSysFlag(running))
+  {
+    L6208_HardStop();
+  }
+  
+  if (abs_pos > devicePrm.absolutePos)
+  {
+    steps = abs_pos - devicePrm.absolutePos;
+    if (steps < (L6208_POSITION_RANGE>>1))
+    {
+      L6208_Move(FORWARD, steps);
+    }
+    else
+    {
+      L6208_Move(BACKWARD, (L6208_POSITION_RANGE - steps));
+    }
+  }
+  else
+  {
+    steps = devicePrm.absolutePos - abs_pos;
+    if (steps < (L6208_POSITION_RANGE>>1))
+    {
+      L6208_Move(BACKWARD, steps);
+    }
+    else
+    {
+      L6208_Move(FORWARD, (L6208_POSITION_RANGE - steps));
+    }
+  }
+}
+
+/******************************************************//**
+ * @brief move the motor to the absolute position
+ * @param[in] direction FORWARD or BACKWARD
+ * @param[in] abs_pos 32 bit signed value position
+ * @retval None
+ * @note The position is at the resolution corresponding to the
+ * selected step mode.
+ * STEP_MODE_FULL or STEP_MODE_WAVE : 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 
+ **********************************************************/
+void L6208::L6208_GoToDir(motorDir_t direction, int32_t abs_pos)
+{
+  uint32_t steps = 0;
+  
+  if(L6208_IsSysFlag(running))
+  {
+    L6208_HardStop();
+  }
+  
+  if (direction != BACKWARD)
+  {
+    if (abs_pos > devicePrm.absolutePos)
+    {
+      steps = abs_pos - devicePrm.absolutePos;
+    }
+    else
+    {
+      steps = L6208_POSITION_RANGE + (abs_pos - devicePrm.absolutePos);
+    }
+  }
+  else
+  {
+    if (abs_pos > devicePrm.absolutePos)
+    {
+      steps = L6208_POSITION_RANGE + (devicePrm.absolutePos - abs_pos);
+    }
+    else
+    {
+      steps = devicePrm.absolutePos - abs_pos;
+    }
+  }
+  L6208_Move(direction, steps);
+}
+
+/******************************************************//**
+ * @brief Immediately stop the motor and disables the power bridges
+ * @retval None
+ **********************************************************/
+void L6208::L6208_HardHiZ(void)
+{
+  /* Disables power stage */
+  L6208_Disable();
+  
+  /* Sets inactive state */
+  L6208_SetMotionState(INACTIVE);
+  
+  /* Clears the running motor and the position */
+  L6208_ClearSysFlag(running);
+ 
+  /* Disables PWMs */
+  L6208_Board_VrefPwmStop(BRIDGE_A);
+  L6208_Board_VrefPwmStop(BRIDGE_B);
+  
+  /* Disables tick timer */
+  L6208_Board_TickStop();
+}
+
+/******************************************************//**
+ * @brief Immediately stop the motor and keeps holding torque
+ * @retval None
+ **********************************************************/
+void L6208::L6208_HardStop(void) 
+{
+  /* Sets inactive state */
+  L6208_SetMotionState(INACTIVE);
+  
+  /* Clears the running motor and the position */
+  L6208_ClearSysFlag(running);
+  L6208_VectorCalc(devicePrm.holdTorque);
+    
+  /* Disables tick timer */
+  L6208_Board_TickStop();
+}
+
+/******************************************************//**
+ * @brief move the motor by the specified number of steps
+ * in the specified direction
+ * @param[in] direction FORWARD or BACKWARD
+ * @param[in] stepCount 32 bit unsigned step count
+ * @retval None
+ * @note The step count resolution is corresponding to the
+ * selected step mode.
+ * STEP_MODE_FULL or STEP_MODE_WAVE : 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 
+ **********************************************************/
+void L6208::L6208_Move(motorDir_t direction, uint32_t stepCount)
+{
+  if(L6208_IsSysFlag(running))
+  {
+    L6208_HardStop();
+  }
+
+  /* clear the velocity driving mode flag */
+  L6208_ClearSysFlag(velocitymode);
+  
+  /* Set the indexing driving mode flag */
+  /* and the user command executing flag */
+  L6208_SetSysFlag(positionmode);
+  
+  /* store relative number of steps to move */
+  devicePrm.positionTarget = stepCount;
+
+  L6208_SetDirection(direction); 
+  
+  /* Motor activation */
+  L6208_StartMovement(); 
+}
+
+/******************************************************//**
+ * @brief  Release the L6208 reset (Reset pin set to high level)
+ * @retval None
+ **********************************************************/
+void L6208::L6208_Releasereset(void)
+{ 
+  L6208_Board_ReleaseReset(); 
+}
+
+/******************************************************//**
+ * @brief Reset the L6208 (Reset pin set to low level)
+ * @retval None
+ **********************************************************/
+void L6208::L6208_reset(void)
+{
+  L6208_Board_Reset();
+}
+
+
+/******************************************************//**
+ * @brief Call L6208_SetStepMode with current step mode, 
+ * the L6208_SetStepMode function along with setting the step mode resets
+ * the L6208 device
+ * @retval None
+ **********************************************************/
+void L6208::L6208_ResetDevice(void)
+{
+  L6208_SetStepMode(L6208_get_step_mode());
+}
+
+/******************************************************//**
+ * @brief run the motor in the specified direction
+ * according to the speed profile defined by the minimum speed,
+ * maximum speed, and acceleration parameters. 
+ * The device accelerates from the minimum speed up to the maximum
+ * speed by using the device acceleration.
+ * @param[in] direction FORWARD or BACKWARD
+ * @retval None
+ **********************************************************/
+void L6208::L6208_Run(motorDir_t direction)
+{
+  if(L6208_IsSysFlag(running))
+  {
+    L6208_HardStop();
+  }
+  L6208_SetDirection(direction);
+  /* Clear the indexing driving mode flag */
+  L6208_ClearSysFlag(positionmode);
+  /* Set the velocity driving mode flag */
+  L6208_SetSysFlag(velocitymode);
+  /* Motor activation */
+  L6208_StartMovement(); 
+}
+
+/******************************************************//**
+ * @brief Set the stepper acceleration rate
+ * in step/s^2 and step/tick^2 for full, half and wave modes
+ * in microsteps/s^2 and microsteps/tick^2 for microstep modes
+ * @param[in] newAcc new acceleration rate in step/s^2 or microstep/s^2
+ * @retval TRUE
+ * @note
+ **********************************************************/
+bool L6208::L6208_SetAcceleration(uint16_t newAcc)
+{
+  uint16_t newAccSpt2 = L6208_ConvertAcceDecelRateValue(newAcc);
+  if (newAccSpt2)
+  {
+    devicePrm.accelerationSps2 = newAcc;
+    devicePrm.accelerationSpt2 = newAccSpt2; 
+  }
+  else
+  {
+    L6208_ErrorHandler(L6208_ERROR_SET_ACCELERATION);
+  }
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Select the motor decay mode
+ * @param[in] decayMode (SLOW_DECAY or FAST_DECAY)
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetDecayMode(motorDecayMode_t decayMode)
+{
+  if ((decayMode & L6208_FAST_DECAY_MODE_MASK) == L6208_FAST_DECAY_MODE_MASK)
+  {
+    L6208_Board_CONTROL_PIN_Set();
+    L6208_SetSysFlag(fastdecaymode);
+  }
+  else 
+  {
+    L6208_Board_CONTROL_PIN_Reset();
+    L6208_ClearSysFlag(fastdecaymode);
+  }
+}
+
+/******************************************************//**
+ * @brief Set the stepper deceleration rate
+ * in step/s^2 and step/tick^2 for full, half and wave modes
+ * in microsteps/s^2 and microsteps/tick^2 for microstep modes
+ * @param[in] newDec new deceleration rate in step/s^2 or microstep/s^2
+ * @retval TRUE
+ * @note
+ **********************************************************/
+bool L6208::L6208_SetDeceleration(uint16_t newDec)
+{
+  uint16_t newDecSpt2 = L6208_ConvertAcceDecelRateValue(newDec);
+  if (newDecSpt2)
+  {
+    devicePrm.decelerationSps2 = newDec;
+    devicePrm.decelerationSpt2 = newDecSpt2;
+  }
+  else
+  {
+    L6208_ErrorHandler(L6208_ERROR_SET_DECELERATION);
+  }
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Specify the direction
+ * @param[in] dir FORWARD or BACKWARD
+ * @note In velocity mode a direction change forces the device to stop and 
+ * then run in the new direction. In position mode, if the device is 
+ * running, a direction change will generate an error.
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetDirection(motorDir_t dir)
+{
+  L6208_ClearSysFlag(dir2change);
+  if (dir == FORWARD)
+  {
+    if (!L6208_IsSysFlag(forward))
+    {
+      if (L6208_IsSysFlag(running))
+      {
+        /* motor is running */
+        if (L6208_IsSysFlag(positionmode))
+        {
+          L6208_ErrorHandler(L6208_ERROR_SET_DIRECTION);
+        }
+        else
+        {
+          /* set the rotation direction to change flag */
+          L6208_SetSysFlag(dir2change);
+        }
+      }
+      else /* the motor is stopped, cw direction selected */
+      {
+        L6208_SetSysFlag(forward);
+        L6208_Board_DIR_PIN_Set();
+      }
+    }
+  }
+  else
+  {
+    if (L6208_IsSysFlag(forward))
+   {
+      if (L6208_IsSysFlag(running))
+      {
+        /* motor is running */
+        if (L6208_IsSysFlag(positionmode))
+        {
+          L6208_ErrorHandler(L6208_ERROR_SET_DIRECTION);
+        }
+        else
+        {
+          /* set the rotation direction to change flag */
+          L6208_SetSysFlag(dir2change);
+        }
+      }
+      else /* the motor is stopped, ccw direction selected */
+      {
+        L6208_ClearSysFlag(forward);
+        L6208_Board_DIR_PIN_Reset();
+      }
+    }
+  }
+  if(L6208_IsSysFlag(dir2change))
+  {
+    L6208_VectorCalc(devicePrm.decelTorque);     
+    L6208_SetMotionState(DECELERATINGTOSTOP);  
+  }
+}
+
+/******************************************************//**
+ * @brief Set current position to be the home position
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetHome(void)
+{
+  if (!L6208_IsSysFlag(running))
+  {
+      devicePrm.absolutePos = 0;
+  }
+  else
+  {
+      L6208_ErrorHandler(L6208_ERROR_SET_HOME);
+  }
+}
+
+/******************************************************//**
+ * @brief Set current position to be the mark position 
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetMark(void)
+{
+  devicePrm.markPos = devicePrm.absolutePos;
+}
+
+/******************************************************//**
+ * @brief Set the user selected maximum speed 
+ * in step/s and step/tick for full, half and wave modes
+ * in microsteps/s and microsteps/tick for microstep modes
+ * @param[in] newSpeed speed value (step/s or microstep/s)
+ * @retval TRUE
+ * @note One microstep is 1/16 step
+ **********************************************************/
+bool L6208::L6208_SetMaxSpeed(uint16_t newSpeed)
+{
+  if (L6208_SetSpeed(newSpeed, &devicePrm.maxSpeedSpt))
+  {
+    devicePrm.maxSpeedSps = newSpeed;
+  }
+  else
+  {
+    L6208_ErrorHandler(L6208_ERROR_SET_MAX_SPEED);
+  }
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Set the user selected minimum speed 
+ * in step/s and step/tick for full, half and wave modes
+ * in microsteps/s and microsteps/tick for microstep modes
+ * @param[in] newSpeed speed value (step/s or microstep/s)
+ * @retval TRUE
+ * @note One microstep is 1/16 step
+ **********************************************************/
+bool L6208::L6208_SetMinSpeed(uint16_t newSpeed)
+{
+  if (L6208_SetSpeed(newSpeed, &devicePrm.minSpeedSpt))
+  {
+    devicePrm.minSpeedSps = newSpeed;
+  }
+  else
+  {
+    L6208_ErrorHandler(L6208_ERROR_SET_MIN_SPEED);
+  }
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Set the step mode
+ * @param[in] stepMode
+ * @retval true if the command is successfully executed, else false
+ * @note Every time the step mode is changed, the step state machine is reset
+ **********************************************************/
+bool L6208::L6208_SetStepMode(motorStepMode_t stepMode)
+{
+  devicePrm.stepMode = stepMode;
+  L6208_ClearSysFlag(fullstep | halfstep | microstep | wavestep);
+  switch (stepMode)
+  {
+    case STEP_MODE_HALF:
+      /* Set the Half/Full pin low and Reset and the set the Half/Full pin high*/
+      L6208_Board_HALF_FULL_PIN_Reset(); 
+      L6208_Board_Reset();
+      L6208_Board_HALF_FULL_PIN_Set();
+      /* Set system flag */
+      L6208_SetSysFlag(halfstep);
+      break;
+    case STEP_MODE_FULL:
+       /* Set the Half/Full pin low and Reset */
+      L6208_Board_HALF_FULL_PIN_Reset(); 
+      L6208_Board_Reset();
+      /* Set system flag */
+      L6208_SetSysFlag(fullstep);
+      break;
+    case STEP_MODE_WAVE:
+      /* Set the Half/Full pin low and Reset and the set the Half/Full pin high*/
+      L6208_Board_CLOCK_PIN_Reset();
+      L6208_Board_HALF_FULL_PIN_Reset();
+      L6208_Board_Reset();
+      L6208_Board_CLOCK_PIN_Set();
+      L6208_Board_HALF_FULL_PIN_Set();
+      L6208_Board_Delay(2);
+      L6208_Board_CLOCK_PIN_Reset();
+      L6208_Board_Delay(2);
+      L6208_Board_HALF_FULL_PIN_Reset();
+      /* Set system flag */
+      L6208_SetSysFlag(wavestep);
+      break;
+      case STEP_MODE_1_4:
+      /* Set the Half/Full pin low and Reset */
+      L6208_Board_HALF_FULL_PIN_Reset();
+      L6208_Board_Reset();
+      /* Set system flag */
+      L6208_SetSysFlag(microstep);
+      devicePrm.uStepInc = 4;
+      break;
+    case STEP_MODE_1_8:
+      /* Set the Half/Full pin low and Reset */
+      L6208_Board_HALF_FULL_PIN_Reset();
+      L6208_Board_Reset();
+      /* Set system flag */
+      L6208_SetSysFlag(microstep);
+      devicePrm.uStepInc = 2;
+      break;
+      case STEP_MODE_1_16:
+      /* Set the Half/Full pin low and Reset */
+      L6208_Board_HALF_FULL_PIN_Reset();
+      L6208_Board_Reset();
+      /* Set system flag */
+      L6208_SetSysFlag(microstep);
+      devicePrm.uStepInc = 1;
+      break;
+    default:
+      return FALSE;
+    }
+  L6208_Board_Delay(2);
+  L6208_Board_ReleaseReset();
+  L6208_ResetSteps();
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Select the mode to stop the motor. When the motor
+ * is stopped, if autoHiZ is TRUE, the power bridges are disabled
+ * if autoHiZ is FALSE, the power bridges are kept enabled.
+ * @param[in] stopMode HOLD_MODE to let power bridge enabled
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetStopMode(motorStopMode_t stopMode)
+{
+  if (stopMode == HOLD_MODE)
+  {
+    L6208_ClearSysFlag(HiZstop);
+  }
+  else
+  {
+    L6208_SetSysFlag(HiZstop);
+  }
+}
+
+/******************************************************//**
+ * @brief  Stop the motor by using the device deceleration and set deceleration torque
+ * @retval true if the command is successfully executed, else false
+ * @note .
+ **********************************************************/
+bool L6208::L6208_SoftStop(void)
+{   
+  L6208_VectorCalc(devicePrm.decelTorque);
+  L6208_SetMotionState(DECELERATINGTOSTOP);
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief  Handle the device state machine at each tick timer pulse end.
+ * @retval None
+ **********************************************************/
+void L6208::L6208_TickHandler(void)
+{
+  uint32_t locMaxSpeedSpt = devicePrm.maxSpeedSpt;
+  uint32_t locMinSpeedSpt = devicePrm.minSpeedSpt;
+  
+  /* Update state, target speed, acceleration and deceleration rates */
+  L6208_Board_CLOCK_PIN_Reset();
+    
+  switch(L6208_GetMotionState())
+  {
+    /* ============ Velocity control mode states ======================== */
+    case ACCELERATING:
+      /* velocity mode: acceleration phase */
+      /* Increase Speed and update position */
+      L6208_DoAccel();
+      if(locMaxSpeedSpt < devicePrm.speedSpt)
+      {  
+        /*Target speed reached */
+        devicePrm.speedSpt = locMaxSpeedSpt;
+        L6208_VectorCalc(devicePrm.runTorque); 
+        L6208_SetMotionState(STEADY);
+      }
+      break;
+    case STEADY:  
+      /* velocity mode: constant speed phase */
+      /* Update position */
+      L6208_DoRun();  
+      if(locMaxSpeedSpt != devicePrm.speedSpt)
+      { 
+        /* targeted speed  has changed */
+        if(locMaxSpeedSpt< devicePrm.speedSpt)
+        { 
+          /* Slow down the motor */
+          L6208_VectorCalc(devicePrm.decelTorque);     
+          L6208_SetMotionState(DECELERATING); 
+        }
+        else
+        { 
+          /* speed up the motor */
+          L6208_VectorCalc(devicePrm.accelTorque);     
+          L6208_SetMotionState(ACCELERATING);
+        }
+      }
+      break;
+    case DECELERATING:  
+      /* velocity mode: running motor deceleration phase */
+      /* Decrease Speed and update position */
+      L6208_DoDecel();  
+      if(locMaxSpeedSpt > devicePrm.speedSpt)
+      { 
+        /*Target speed reached but motor has still to be run*/
+        devicePrm.speedSpt = locMaxSpeedSpt;
+        L6208_VectorCalc(devicePrm.runTorque);   
+        L6208_SetMotionState(STEADY);  
+      }
+      break;
+    case DECELERATINGTOSTOP: 
+      /* velocity mode: decelerate to stopped phase */
+      /* Decrease current speed */
+      L6208_DoDecel();
+      if(devicePrm.speedSpt == locMinSpeedSpt)
+      { 
+        if (L6208_IsSysFlag(dir2change))
+        { 
+          L6208_ClearSysFlag(running);
+          /* Change direction */
+          if (L6208_IsSysFlag(forward))
+          {
+            /* switch to reverse rotation */
+            L6208_SetDirection(BACKWARD);
+          }
+          else
+          {
+            /* switch to forward rotation */
+            L6208_SetDirection(FORWARD);
+          }
+          L6208_SetSysFlag(running);
+          L6208_SetMotionState(ACCELERATING);
+          /* Set VRefA and VRefB to the selected acceleration torque */
+          L6208_VectorCalc(devicePrm.accelTorque);
+        }
+        else
+        {
+          if (L6208_IsSysFlag(HiZstop))
+          { 
+            L6208_HardHiZ();
+          }
+          else
+          {
+            L6208_HardStop();
+          }
+        }
+      }
+      break;
+    
+    /* ============ Position (indexed) control mode states ======================== */
+
+    case INDEX_ACCEL:
+      /*  position mode: acceleration state*/
+      
+      /* Increase Speed and update position */
+      L6208_DoAccel();  
+
+      if(devicePrm.positionTarget1 <= devicePrm.step)
+      { 
+        /* End of acceleration phase */
+        L6208_VectorCalc(devicePrm.runTorque); 
+        L6208_SetMotionState(INDEX_RUN);    
+      }
+      break;
+
+      case INDEX_RUN:   
+        /* position mode: constant speed phase */
+        
+        /* Update position */
+        L6208_DoRun();  
+
+        if(devicePrm.positionTarget2 <= devicePrm.step)
+        {  
+          /* reach position targeted for constant speed */
+          L6208_VectorCalc(devicePrm.decelTorque);   
+          L6208_SetMotionState(INDEX_DECEL); 
+        }
+        break;
+
+      case INDEX_DECEL: 
+        /* position mode: deceleration phase */
+        
+        /* Decrease Speed and update position */
+        L6208_DoDecel();  
+
+        if(devicePrm.positionTarget3 <= devicePrm.step)
+        {  
+          /* reach position targeted for deceleration phase */
+          /* the motor terminated its run */
+          /* the torque will be the deceleration one */
+          devicePrm.step = devicePrm.positionTarget3;
+          L6208_SetMotionState(INDEX_DWELL);   
+        }
+        break;
+
+      case INDEX_DWELL: 
+        /* position mode: dwelling state */
+        if(devicePrm.dwellCounter > 0)
+        {
+          /* decrease the dwelling wait tick counter */
+          devicePrm.dwellCounter--;
+        }
+        if(devicePrm.dwellCounter == 0)
+        { 
+          /* dwelling wait time is elapsed */
+          /* so stop the motor */
+          if (L6208_IsSysFlag(HiZstop))
+          { 
+            L6208_HardHiZ();
+          }
+          else
+          {
+            L6208_HardStop();
+          }
+        }
+        break;
+        
+    /* ============ stopped state ======================== */
+    case INACTIVE:
+    {
+      if(L6208_IsSysFlag(running))
+      {
+        /* clear the user move command executing  */
+        /* and the motor running flags */
+        L6208_ClearSysFlag(running);
+      }
+      break;
+    }
+    default:
+      break;
+  } /* switch(L6208_GetMotionState()) */
+  if(L6208_GetMotionState() != INACTIVE)
+  {
+    if (L6208_IsSysFlag(microstep))
+    { 
+      /* Microstep handling */     
+      switch(devicePrm.uStepInc)
+      {
+        default:
+        case 1:  
+          /* 1 microstep increment */
+          devicePrm.lsbTicks = (uint8_t)(devicePrm.ticks>>16);
+          break;
+
+        case 2:  
+          /* 2 microsteps increment */           
+          devicePrm.lsbTicks = (uint8_t)(devicePrm.ticks>>17);
+          break;
+
+        case 4:  
+          /* 4 microsteps increment */
+          devicePrm.lsbTicks = (uint8_t)(devicePrm.ticks>>18);
+          break;
+      }
+      devicePrm.lsbTicks &= 0x01;
+      if(devicePrm.lsbOldUSteppingTicks != devicePrm.lsbTicks)
+      { 
+        /*  waveform sample to update */
+        devicePrm.lsbOldUSteppingTicks = devicePrm.lsbTicks;
+        devicePrm.step++;
+        if(L6208_IsSysFlag(forward))
+        { 
+          /* the motor is going forward */
+          devicePrm.absolutePos++;
+          /* Reset the absolute motor position in step/microsteps */
+          /* Get next microstep sample */
+          devicePrm.uStepSample += devicePrm.uStepInc;  
+          if(devicePrm.uStepSample > 31)
+          {
+            devicePrm.uStepSample = 0;
+          }
+        }
+        else
+        { 
+         /* the motor is going backward */
+          devicePrm.absolutePos--;
+          if(devicePrm.uStepSample >= devicePrm.uStepInc)
+          {
+            /* Get previous microstep sample */
+            devicePrm.uStepSample -= devicePrm.uStepInc; 
+          }
+          else
+          {
+            devicePrm.uStepSample = 32 - devicePrm.uStepInc;
+          }
+        }
+        /* set the PWM to update VRefs */
+        L6208_VrefPwmComputePulseWidth(BRIDGE_A, pMicroTable2[devicePrm.uStepSample], FALSE);
+        L6208_VrefPwmComputePulseWidth(BRIDGE_B, microTable1[devicePrm.uStepSample], FALSE);
+        if(devicePrm.uStepsample2update > 0)
+        { 
+          /*  the waveform samples table has been recalculated 
+          so update the waveform scanning table */
+          L6208_UpdateScanWaveformTable();
+          devicePrm.uStepsample2update = 0;
+        }
+      }
+      /* Microstep: use the bit4 toggling as step clock */
+      /* this bit is used because there are 16 microstep samples per quarter period */
+      devicePrm.lsbTicks = (uint8_t)((devicePrm.uStepSample>>4) & 0x01);
+      if(devicePrm.lsbOldTicks != devicePrm.lsbTicks)
+      { 
+        /* the selected bit status changed ==> get the next motor step
+        save the current masked motor tick position for step setting scope ... */
+        devicePrm.lsbOldTicks = devicePrm.lsbTicks;
+        L6208_Board_CLOCK_PIN_Set();
+      }
+    }
+    else
+    {
+      /* Full and half step handling code */ 
+      if(!L6208_IsSysFlag(halfstep))
+      { 
+        /* Full step: use the bit 16 toggling as step clock */
+        devicePrm.lsbTicks = (uint8_t)((devicePrm.ticks>>16) & 0x00000001);
+      }
+      else
+      { 
+        /* half step: use the bit 15 toggling as step clock */
+        devicePrm.lsbTicks = (uint8_t)((devicePrm.ticks>>15) & 0x00000001);
+      }
+      if(devicePrm.lsbOldTicks != devicePrm.lsbTicks)
+      { 
+        /* the selected bit status changed ==> get the next motor step */
+        devicePrm.step++;
+        if(L6208_IsSysFlag(forward))
+        { 
+          /* the motor is going forward */
+          devicePrm.absolutePos++;
+        }
+        else
+        {
+          /* the motor is going backward */
+          devicePrm.absolutePos--;          
+        }
+        /* save the current masked motor tick position for step setting scope ... */
+        devicePrm.lsbOldTicks = devicePrm.lsbTicks;
+        L6208_Board_CLOCK_PIN_Set();
+      }
+    }
+  }
+  L6208_UstepWaveformHandling();
+  L6208_VrefPwmUpdatePulseWidth();
+}
+
+/******************************************************//**
+ * @brief Get the frequency of VREFA and VREFB PWM
+ * @retval the frequency of VREFA and VREFB PWM in Hz
+ * @note
+ **********************************************************/
+uint32_t L6208::L6208_VrefPwmGetFreq(void)
+{
+  return devicePrm.vrefPwmFreq;
+}
+
+/******************************************************//**
+ * @brief Set the frequency of the VREFA and VREFB PWM
+ * @param[in] newFreq in Hz
+ * @retval None
+ * @note
+ **********************************************************/
+void L6208::L6208_VrefPwmSetFreq(uint32_t newFreq)
+{
+  devicePrm.vrefPwmFreq = newFreq;
+  /* Compute the pwm period in 1/256th of a microsecond */
+  devicePrm.vrefPwmPeriod = (uint16_t)((1000000<<8)/newFreq);
+  /* Re-Initialise the PWMs -----------------------------------------------------*/
+  L6208_Board_VrefPwmInit(BRIDGE_A, devicePrm.vrefPwmPeriod);
+  L6208_Board_VrefPwmInit(BRIDGE_B, devicePrm.vrefPwmPeriod);
+  /* Recompute the waveform samples according to the new PWM frequency */
+  L6208_ScaleWaveformTable();
+  /* Update the waveform scanning table */
+  L6208_UpdateScanWaveformTable();
+  if (L6208_IsSysFlag(running))
+  {
+    L6208_Board_VrefPwmStart(BRIDGE_A, devicePrm.vrefPwmPeriod);
+    L6208_Board_VrefPwmStart(BRIDGE_B, devicePrm.vrefPwmPeriod);
+  }
+}
+
+/******************************************************//**
+ * @brief Lock while motor is running
+ * @retval None
+ **********************************************************/
+void L6208::L6208_WaitWhileActive(void)
+{
+  /* Wait while motor is running */
+  while (L6208_IsSysFlag(running));
+}
+
+/* ------------------------------------------------------------------------- */
+/* Private functions ------------------------------------------------------- */
+/* ------------------------------------------------------------------------- */
+/******************************************************//**
+ * @brief Clear the bit/s of flags according to the specified mask
+ * @param[in] mask flag bit mask
+ * @retval None
+ **********************************************************/
+inline void L6208::L6208_ClearSysFlag(uint32_t mask)
+{
+  devicePrm.flags &= ~mask;    
+}
+
+/******************************************************//**
+ * @brief Compute the number of steps at the end of the accereration/deceleration phase
+ * P = position in steps at the end of the acceleration/deceleration phase
+ * T = acceleration/deceleration time in seconds
+ * A =  acceleration/deceleration rate in steps per second per second (steps/sec^2)
+ * V = peak velocity during acceleration/deceleration phase
+ * V1 = average velocity during acceleration/deceleration phase
+ * T = V/A
+ * V1 = V/2
+ * P = V1*T
+ * P = V^2/2A
+ * @param  accOrDecRate acceleration/deceleration rate in steps per second per second (steps/sec^2)
+ * @retval end position or 0xFFFFFFFF on error 
+ **********************************************************/
+uint32_t L6208::L6208_ComputeNbAccOrDecSteps(uint16_t accOrDecRate)
+{
+  uint32_t nbAccOrDecSteps;
+  uint32_t locMaxSpeedSps = (uint32_t)devicePrm.maxSpeedSps;
+  
+  if (L6208_IsSysFlag(microstep))
+  {
+    switch(devicePrm.uStepInc)
+    {
+      case 1:  
+        locMaxSpeedSps = (uint32_t)devicePrm.maxSpeedSps;
+        break;
+      case 2:            
+        locMaxSpeedSps = ((uint32_t)devicePrm.maxSpeedSps)>>1;
+        accOrDecRate >>= 1;
+        break;
+      case 4:  
+        locMaxSpeedSps = ((uint32_t)devicePrm.maxSpeedSps)>>2;
+        accOrDecRate >>= 2;
+        break;
+      default:
+        break;
+    }
+  }
+  else if (L6208_IsSysFlag(halfstep))
+  {
+    locMaxSpeedSps = ((uint32_t)devicePrm.maxSpeedSps)<<1;
+    accOrDecRate <<= 1;
+  }
+  
+  if(accOrDecRate == 0)
+  {
+    /* division by 0 error */
+    return 0xFFFFFFFF;
+  }
+  nbAccOrDecSteps = locMaxSpeedSps * locMaxSpeedSps;
+  nbAccOrDecSteps /= (uint32_t)accOrDecRate;
+  nbAccOrDecSteps /= 2;
+
+  return nbAccOrDecSteps;
+}
+
+/******************************************************//**
+ * @brief Compute the acceleration/deceleration speed increment value
+ * @param[in] newAccOrDecRate acceleration or deceleration value (steps/s^2) greater or equal than 24
+ * @retval the speed (step/tick) increment value
+ * LSB = 2^-24 step/tick^2 or 2^-20 microstep/tick^2
+ * @note return 0 if the rate is too low or if the tick frequency is too small
+ * or if the device is running in position mode
+ **********************************************************/
+uint16_t L6208::L6208_ConvertAcceDecelRateValue(uint16_t newAccOrDecRate)
+{
+  uint64_t tmp64;
+  uint32_t tmp32;
+
+  if (((L6208_IsSysFlag(running))&&(L6208_IsSysFlag(positionmode)))||\
+      (newAccOrDecRate < L6208_MIN_ACC_DEC_RATE))
+  {
+    return 0;
+  } 
+  /* Compute (tick frequency)^2 */
+  tmp32 = (uint32_t)L6208_Board_TickGetFreq();
+  tmp32 *= tmp32;
+  /* Return 0 if the (tick frequency)^2 is too small */
+  if ( tmp32 < (uint32_t)newAccOrDecRate )
+  {
+    return 0;
+  } 
+  /* Compute the decimal number of microstep or step per tick^2 */
+  /* Decimal part is on 32 bits */
+  tmp64 = (uint64_t)newAccOrDecRate << 32;
+  tmp64 /= ((uint64_t)tmp32);
+
+  return (uint16_t)((tmp64 & 0x00000000FFFFFFFF)>>8);
+}
+
+/******************************************************//**
+ * @brief Compute next position and speed according to the acceleration rate
+ * @retval None
+ **********************************************************/
+void L6208::L6208_DoAccel(void)
+{
+  /* Increase speed by acceleration rate */
+  uint32_t locAccelerationSpt2 = (uint32_t)devicePrm.accelerationSpt2;
+  uint32_t locMinSpeedSpt = devicePrm.minSpeedSpt;
+  if ((devicePrm.speedSpt + locAccelerationSpt2) < locMinSpeedSpt)
+  {
+    devicePrm.speedSpt = locMinSpeedSpt;
+  }
+  else
+  {
+    devicePrm.speedSpt += locAccelerationSpt2;
+  }
+  /* Compute next position */
+  L6208_DoRun();
+}
+
+/******************************************************//**
+ * @brief Compute next position and speed according to the deceleration rate
+ * @retval None
+ **********************************************************/
+void L6208::L6208_DoDecel(void)
+{
+  /* Decrease current speed by deceleration rate */
+  uint32_t locDecelerationSpt2 = (uint32_t)devicePrm.decelerationSpt2;
+  uint32_t locMinSpeedSpt = devicePrm.minSpeedSpt;
+  if((devicePrm.speedSpt - locMinSpeedSpt) > (uint32_t)locDecelerationSpt2)  
+  {
+    devicePrm.speedSpt -= (uint32_t)locDecelerationSpt2;
+  }
+  else
+  {
+    /* Set minimum speed */
+    devicePrm.speedSpt = locMinSpeedSpt;
+  }
+  /* Compute next position */
+  L6208_DoRun(); 
+}
+
+/******************************************************//**
+ * @brief Compute next position by adding current speed
+ * @retval None
+ **********************************************************/
+void L6208::L6208_DoRun(void)
+{
+  devicePrm.ticks += (devicePrm.speedSpt >> 8) & 0x0000FFFF;
+}
+
+/******************************************************//**
+ * @brief Get number of samples to rescale
+ * @retval uStepsample2scale the number of micro stepping waveform samples to rescale
+ **********************************************************/
+uint8_t L6208::L6208_GetMicrostepSample2Scale(void)
+{
+  return devicePrm.uStepsample2scale;
+}
+
+/******************************************************//**
+ * @brief  Initialize the system for position mode motor moving command
+ *  P = total move distance in steps
+ *  P1 = steps required to accel from 0 to V
+ *  P2 = steps required to decel from V to 0
+ *  V = peak velocity in steps per second (steps/sec)
+ *  V1 = average velocity during accel or decel*
+ *  A = required accel rate in steps per second per second (steps/sec2)
+ *  D = required decel rate in steps per second per second (steps/sec2)
+ *  T1 = acceleration time in seconds
+ *  T2 = deceleration time in seconds*
+ *
+ *  1) T1 = V / A
+ *  2) V1 = V / 2
+ *  3) P1 = V1 T1
+ *  Substituting 1 and 2 into 3 yields:
+ *  4) P1 = V2 / 2A
+ *  In the same manner we have:
+ *  5) P2 = V2 / 2D
+ *
+ *  P1 = PD/(D+A)
+ *
+ *  \sa Application Note: AN2044  
+ * @retval None
+ **********************************************************/
+void L6208::L6208_Indexmodeinit(void)
+{
+  uint32_t tmpVal0;
+  uint32_t tmpVal1;
+  uint32_t locAccelSteps;
+  uint32_t locDecSteps;
+
+  /* calculate the number of steps to get the running speed */
+  locAccelSteps = L6208_ComputeNbAccOrDecSteps(devicePrm.accelerationSps2);
+  /* calculate the number of steps to get the motor stopped */
+  locDecSteps = L6208_ComputeNbAccOrDecSteps(devicePrm.decelerationSps2);
+  if(( locAccelSteps + locDecSteps ) > devicePrm.positionTarget)
+  { 
+    /* Triangular move needed */
+    /* accelsteps = P1 = PD/(D+A) */
+    tmpVal0 = devicePrm.positionTarget * devicePrm.decelerationSps2;
+    tmpVal1 = (uint32_t)devicePrm.decelerationSps2;
+    tmpVal1 += (uint32_t)devicePrm.accelerationSps2;
+    locAccelSteps = tmpVal0 / tmpVal1;
+    devicePrm.positionTarget1 = locAccelSteps;
+    devicePrm.positionTarget2 = devicePrm.positionTarget1 + 1;
+    devicePrm.positionTarget3 = devicePrm.positionTarget;
+    if(devicePrm.positionTarget1 == 0)
+    {
+      devicePrm.positionTarget1 = 1;
+    }
+  }
+  else
+  {  
+    /* trapezoidal move needed */
+    /* P1 = V^2/2A */
+    /* P2 = P - V^2/2D */
+    devicePrm.positionTarget1 = locAccelSteps;
+    devicePrm.positionTarget2 = devicePrm.positionTarget - locDecSteps;
+    devicePrm.positionTarget3 = devicePrm.positionTarget;
+  }
+  L6208_SetMotionState(INDEX_ACCEL);  
+}
+
+/******************************************************//**
+ * @brief Check the bit/s of flags according to the specified mask
+ * @param[in] mask flag bit mask
+ * @retval TRUE if the bit of the mask are set
+ **********************************************************/
+inline bool L6208::L6208_IsSysFlag(uint32_t mask)
+{
+  return (bool)((devicePrm.flags & mask) == mask);    
+}
+
+/******************************************************//**
+ * @brief Stepper driver device step state reset subroutine
+ * @retval None
+ **********************************************************/
+void L6208::L6208_ResetSteps(void)
+{
+  devicePrm.speedSpt = 0;             // reset the current speed value
+  devicePrm.ticks = 0;                // reset the current ticks counter value
+  devicePrm.step = 0;                 // reset the current step counter value
+  devicePrm.lsbOldTicks = 0;          // reset copy of the previous position (tick)
+  devicePrm.lsbOldUSteppingTicks = 0; // reset copy of the previous position (tick) ( micro stepping )
+  devicePrm.lsbTicks = 0;             // reset copy of the current position (tick)
+  devicePrm.absolutePos = 0;          // reset the absolute motor position in step/microsteps
+  devicePrm.uStepSample = 0;          // reset the microstepping waveform sample index
+}
+
+/******************************************************//**
+ * @brief Compute the specified micro stepping waveform sample with the
+ * current selected torque and pwm period
+ * @param[in] sampleIndex sample Index
+ * @retval scaled sample value
+ **********************************************************/
+uint32_t L6208::L6208_ScaleWaveformSample(uint8_t sampleIndex)
+{
+  uint32_t sample;
+
+  sample = (uint32_t)RefMicroTable[sampleIndex];
+  sample *= devicePrm.vrefPwmPeriod;
+  sample >>= (uint32_t)L6208_SINE_WAVEFORM_POWER_OF_TWO_MAX_VALUE;
+  
+  sample *= (uint32_t)devicePrm.curTorqueScaler; // torque val (%)
+  sample /= (uint32_t)100;
+  
+  return sample;
+}
+
+/******************************************************//**
+ * @brief Compute the micro stepping waveform sample table samples with the
+ * current selected torque and pwm period
+ * @retval None
+ **********************************************************/
+void L6208::L6208_ScaleWaveformTable(void)
+{
+  uint8_t index;
+  for(index=0; index<=L6208_USTEPS_PER_QUARTER_PERIOD; index++)
+  { 
+    /* Calculate the scaled sample and save its value into the waveform to update table */
+    updatedMicroTable[index] = (uint16_t)L6208_ScaleWaveformSample(index);
+  }
+}
+
+/******************************************************//**
+ * @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 L6208::L6208_SetDeviceParamsToGivenValues(l6208_init_t* pInitDevicePrm)
+{
+  memset(&devicePrm, 0, sizeof(devicePrm));
+  L6208_SetAcceleration(pInitDevicePrm->accelerationSps2);
+  L6208_SetDeceleration(pInitDevicePrm->decelerationSps2);
+  L6208_SetMaxSpeed(pInitDevicePrm->maxSpeedSps);
+  L6208_SetMinSpeed(L6208_MIN_SPEED);
+  devicePrm.accelTorque = pInitDevicePrm->accelTorque;
+  devicePrm.decelTorque = pInitDevicePrm->decelTorque;
+  devicePrm.runTorque = pInitDevicePrm->runTorque;
+  devicePrm.holdTorque = pInitDevicePrm->holdTorque;
+  /* Only once acceleration, deceleration, min speed and max speed have been */
+  /* initialized, set the step mode */
+  devicePrm.stepMode = pInitDevicePrm->stepMode;
+  L6208_SetDecayMode(pInitDevicePrm->decayMode);
+  devicePrm.moveDwellTime = pInitDevicePrm->moveDwellTime;
+  if (L6208_CONF_PARAM_AUTO_HIZ_STOP) L6208_SetSysFlag(pInitDevicePrm->autoHiZstop);
+  devicePrm.vrefPwmFreq = pInitDevicePrm->vrefPwmFreq;
+  devicePrm.vrefPwmPeriod = (uint16_t)((1000000<<8)/pInitDevicePrm->vrefPwmFreq);
+  /* Initialize current stepper state machine index  */
+  L6208_SetMotionState(INACTIVE);
+}
+
+/******************************************************//**
+ * @brief  Set the parameters of the device to predefined values
+ * Set GPIO according to these values
+ * from l6208_target_config.h
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetDeviceParamsToPredefinedValues(void)
+{
+  memset(&devicePrm, 0, sizeof(devicePrm));
+  L6208_SetAcceleration(L6208_CONF_PARAM_ACC_RATE);
+  L6208_SetDeceleration(L6208_CONF_PARAM_DEC_RATE);
+  L6208_SetMaxSpeed(L6208_CONF_PARAM_RUNNING_SPEED);
+  L6208_SetMinSpeed(L6208_MIN_SPEED);
+  devicePrm.accelTorque = L6208_CONF_PARAM_ACC_CURRENT;
+  devicePrm.decelTorque = L6208_CONF_PARAM_DEC_CURRENT;
+  devicePrm.runTorque = L6208_CONF_PARAM_RUNNING_CURRENT;
+  devicePrm.holdTorque = L6208_CONF_PARAM_HOLDING_CURRENT;
+  /* Only once acceleration, deceleration, min speed and max speed have been */
+  /* initialized, set the step mode */
+  devicePrm.stepMode = (motorStepMode_t) L6208_CONF_PARAM_STEP_MODE;
+  L6208_SetDecayMode(L6208_CONF_PARAM_DECAY_MODE);
+  devicePrm.moveDwellTime = L6208_CONF_PARAM_DWELL_TIME;
+  if (L6208_CONF_PARAM_AUTO_HIZ_STOP) L6208_SetSysFlag(HiZstop);
+  devicePrm.vrefPwmFreq = L6208_CONF_VREF_PWM_FREQUENCY;
+  devicePrm.vrefPwmPeriod = (uint16_t)((1000000<<8)/L6208_CONF_VREF_PWM_FREQUENCY);
+  /* Initialize current stepper state machine index  */
+  L6208_SetMotionState(INACTIVE);
+}
+
+/******************************************************//**
+ * @brief Set the number of micro stepping waveform samples to rescale
+ * @param[in] value number of micro stepping waveform samples 
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetMicrostepSample2Scale(uint8_t value)
+{
+  if(value > L6208_USTEPS_PER_QUARTER_PERIOD)
+  {
+    value = L6208_USTEPS_PER_QUARTER_PERIOD;  // clamp to maximum number of samples per period/4
+  }
+  devicePrm.uStepsample2scale = value;    
+}
+
+/******************************************************//**
+ * @brief Set the number of micro stepping waveform samples to update into scanning
+ * @param[in] value number of micro stepping waveform samples 
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetMicrostepSample2Update(uint8_t value)
+{
+  // clamp to maximum number of samples per period/4
+  if(value > L6208_USTEPS_PER_QUARTER_PERIOD)
+  {
+    value = L6208_USTEPS_PER_QUARTER_PERIOD;  
+  }
+  // copy the stepper acceleration rate
+  devicePrm.uStepsample2update = value;    
+}
+
+/******************************************************//**
+ * @brief Set the stepper state machine index
+ * @param[in] newMotionState
+ * @retval None
+ **********************************************************/
+void L6208::L6208_SetMotionState(motorState_t newMotionState)
+{
+  // sets the new stepper state machine index
+  devicePrm.motionState = newMotionState;    
+}
+
+/******************************************************//**
+ * @brief Set the user selected speed in step/tick
+ * @param[in] newSpeed speed value (step/s)
+ * @param[in] pSpeed pointer to the selected speed field
+ * @retval return FALSE if the speed is too low or too high
+ * or if the device is running in position mode, else TRUE
+ **********************************************************/
+bool L6208::L6208_SetSpeed(uint16_t newSpeed, uint32_t volatile *pSpeed)
+{
+  uint64_t tmp64;
+  uint32_t tmp32;
+
+  if (((L6208_IsSysFlag(running))&&(L6208_IsSysFlag(positionmode)))||\
+      (newSpeed < L6208_MIN_SPEED))
+  {
+    return FALSE;
+  }
+  tmp32 = (uint32_t)L6208_Board_TickGetFreq();
+  if (tmp32 < newSpeed)
+  {
+    return FALSE;
+  }
+  /* Compute the decimal number of microstep or step per tick */
+  /* Decimal part is on 32 bits */
+  tmp64 = (uint64_t)newSpeed << 32;
+  tmp64 /= ((uint64_t)tmp32);
+  /* set the running constant speed value (step/tick) */
+  *pSpeed = (uint32_t)((tmp64 & 0x00000000FFFFFFFF)>>8);
+  
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Set the bit/s of flags according to the specified mask
+ * @param[in] mask flag bit mask
+ * @retval None
+ **********************************************************/
+inline void L6208::L6208_SetSysFlag(uint32_t mask)
+{
+  devicePrm.flags |= mask;    
+}
+
+/******************************************************//**
+ * @brief Stepper motor start command
+ * @retval true on correct command execution
+ **********************************************************/
+bool L6208::L6208_StartMovement(void)
+{
+  uint32_t tmp;
+  if (L6208_IsSysFlag(running))
+  {
+    /* Motor is already running ==> quit */
+    return FALSE;    
+  }
+  if (!L6208_IsSysFlag(positionmode))
+  {
+    /* Set the VREFA and VREFB to the selected acc. torque */
+    L6208_VectorCalc(devicePrm.accelTorque);
+    
+    /* If the speed control mode is selected */
+    /* setup the motor acceleration for velocity mode driving */
+    L6208_SetMotionState(ACCELERATING);  
+  }
+  else
+  {  
+    /* if position control mode is selected, reset the current step counter  */
+    devicePrm.step = 0;    
+    if(devicePrm.uStepSample > 31)
+    {
+      /* check the micro stepping waveform sample index */
+      devicePrm.uStepSample = 0;
+    }
+    /* Set the position dwelling wait time */
+    /* compute number of ticks per millisecond */
+    tmp = (uint32_t)L6208_Board_TickGetFreq() / 1000;
+    /* Compute the dwelling time in ticks => dwellCounter (ticks) */
+    devicePrm.dwellCounter = tmp * (uint32_t)devicePrm.moveDwellTime;
+    if (devicePrm.positionTarget == 0)
+    {
+      /* if the position to go is 0 (no move) */
+      /* Set the deceleration torque */
+      L6208_VectorCalc(devicePrm.decelTorque); 
+      /* Set the dwelling delay state index */
+      L6208_SetMotionState(INDEX_DWELL);       
+    }
+    else
+    {
+      /* Set the VREFA and VREFB to the selected acc. torque */
+      L6208_VectorCalc(devicePrm.accelTorque);
+      /* go to the selected position */
+      L6208_Indexmodeinit();
+      L6208_SetMotionState(INDEX_ACCEL);
+    }
+  }
+  /* Sets the motor running flag */
+  L6208_SetSysFlag(running);
+  /* Start the VREFA and VREFB PWMs */
+  L6208_Board_VrefPwmStart(BRIDGE_A, devicePrm.vrefPwmPeriod);
+  L6208_Board_VrefPwmStart(BRIDGE_B, devicePrm.vrefPwmPeriod);
+  if (!(L6208_IsSysFlag(EN_A_set)))
+  {
+    /* Enable power bridges */
+    L6208_Enable();
+  }
+  /* Start the tick */
+  L6208_Board_TickStart(L6208::tickFreq);
+  
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Update the micro stepping waveform samples table with the
+ * values previously scaled with current selected torque and tick period
+ * @retval None
+ **********************************************************/
+void L6208::L6208_UpdateScanWaveformTable(void)
+{
+  uint8_t index;
+
+  for(index=0; index<=L6208_USTEPS_PER_QUARTER_PERIOD; index++)
+  {
+    microTable1[index] = updatedMicroTable[index];
+    microTable1[L6208_USTEPS_PER_QUARTER_PERIOD*2 - index] = microTable1[index];
+    microTable1[index + L6208_USTEPS_PER_QUARTER_PERIOD*2] = updatedMicroTable[index];
+  }
+  /* clear the number of samples to update */
+  L6208_SetMicrostepSample2Update(0); 
+}
+
+/******************************************************//**
+ * @brief Check if there are waveform samples to rescale and if so, perform the rescaling
+ * @retval None
+ **********************************************************/
+void L6208::L6208_UstepWaveformHandling(void)
+{
+  /* micro stepper waveform samples rescaling ... and updating */
+  uint8_t nbSamplesToRescale = L6208_GetMicrostepSample2Scale();
+  if(nbSamplesToRescale > 0)
+  { 
+    /* Current torque value has been changed, so recalculate the waveform table */
+    L6208_ScaleWaveformTable();
+    
+    /* Set the number of samples to update */
+    L6208_SetMicrostepSample2Update(L6208_USTEPS_PER_QUARTER_PERIOD);
+
+    /* Reset the number of samples to rescaled afer rescaling */
+    L6208_SetMicrostepSample2Scale(0);
+  }
+}
+
+/******************************************************//**
+ * @brief Set the current torque value (Vref)
+ * @param[in] newTorque Selected torque value
+ * @retval always TRUE
+ **********************************************************/
+bool L6208::L6208_VectorCalc(uint8_t newTorque)
+{
+  /* save current selected torque value */
+  devicePrm.curTorqueScaler = (uint16_t)newTorque;
+
+  if(!L6208_IsSysFlag(microstep))
+  {
+    /* full/half step mode or the motor is not running */
+    /* set the PWM duty cycle according to the current torque value (%). */
+    /* The TON value will be calculated inside the TIMx_PWM_duty_setup f(). */
+    L6208_VrefPwmComputePulseWidth(BRIDGE_A, devicePrm.curTorqueScaler, TRUE);
+    L6208_VrefPwmComputePulseWidth(BRIDGE_B, devicePrm.curTorqueScaler, TRUE);
+    devicePrm.vRefAVal = devicePrm.curTorqueScaler; // save current VREFA value
+    devicePrm.vRefBVal = devicePrm.curTorqueScaler; // save current VREFB value
+  }
+  else
+  { 
+    /* microstep mode */
+    if(L6208_IsSysFlag(running))
+    {
+      /* set the number of waveform sample to rescale according current selected */
+      /* torque value */
+      L6208_SetMicrostepSample2Scale(L6208_USTEPS_PER_QUARTER_PERIOD);
+    }
+    else
+    { 
+      /* micro stepping mode motor stopped */
+      L6208_ScaleWaveformTable();
+      L6208_UpdateScanWaveformTable();
+      /* Set the VREF timer PWM TON to update VREFA and VREFB */
+      L6208_VrefPwmComputePulseWidth(BRIDGE_A, pMicroTable2[devicePrm.uStepSample], FALSE);      
+      L6208_VrefPwmComputePulseWidth(BRIDGE_B, microTable1[devicePrm.uStepSample], FALSE);
+    }
+  }
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Compute the pulse width of VREFA or VREFB PWM
+ * @param[in] bridgeId
+ *            0 for BRIDGE_A
+ *            1 for BRIDGE_B
+ * @param[in] value pulse length in 1/256th of microsecond
+ * or PWM duty cycle: 0 - 100 %
+ * @param[in] valueIsPwmDutyCycle must be TRUE if value is a PWM duty cycle
+ * @retval FALSE if wrong timer handle is used, else TRUE
+ **********************************************************/
+bool L6208::L6208_VrefPwmComputePulseWidth(uint8_t bridgeId, uint16_t value, bool valueIsPwmDutyCycle)
+{
+  if(valueIsPwmDutyCycle)
+  {
+    if (value > 100) value = 100;
+    value = (uint16_t)(((uint32_t)devicePrm.vrefPwmPeriod * (uint32_t)value) / 100); 
+  }
+  if (bridgeId == 0)
+  {
+    devicePrm.vrefPwmPulseWidthTargetA = value;
+    devicePrm.vrefPwmPulseWidthToBeGeneratedA = 0;
+  } 
+  else if (bridgeId == 1)
+  {
+    devicePrm.vrefPwmPulseWidthTargetB = value;
+    devicePrm.vrefPwmPulseWidthToBeGeneratedB = 0;
+  }
+  else
+  {
+    return FALSE;
+  }
+  return TRUE;
+}
+
+/******************************************************//**
+ * @brief Update the pulse width of VREFA or VREFB PWM
+ * @param None
+ * @retval None
+ **********************************************************/
+void L6208::L6208_VrefPwmUpdatePulseWidth(void)
+{
+  uint16_t pulseWidthUs;
+  
+  devicePrm.vrefPwmPulseWidthToBeGeneratedA += devicePrm.vrefPwmPulseWidthTargetA;
+  pulseWidthUs = devicePrm.vrefPwmPulseWidthToBeGeneratedA>>8;
+  if (pulseWidthUs!=0)
+  {
+    L6208_Board_VrefPwmSetPulseWidthA(pulseWidthUs);
+    devicePrm.vrefPwmPulseWidthToBeGeneratedA -= (pulseWidthUs<<8);
+  }
+  else
+  {
+    L6208_Board_VrefPwmSetPulseWidthA(0);
+  }
+  
+  devicePrm.vrefPwmPulseWidthToBeGeneratedB += devicePrm.vrefPwmPulseWidthTargetB;
+  pulseWidthUs = devicePrm.vrefPwmPulseWidthToBeGeneratedB>>8;
+  if (pulseWidthUs!=0)
+  {
+    L6208_Board_VrefPwmSetPulseWidthB(pulseWidthUs);
+    devicePrm.vrefPwmPulseWidthToBeGeneratedB -= (pulseWidthUs<<8);
+  }
+  else
+  {
+    L6208_Board_VrefPwmSetPulseWidthB(0);
+  }
+}
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/l6208/L6208_config.h	Fri Mar 24 10:59:42 2017 +0100
@@ -0,0 +1,112 @@
+/******************************************************//**
+  * @file    L6208_config.h 
+  * @author  IPC Rennes
+  * @version V1.1.0
+  * @date    February 11th, 2016
+  * @brief   Predefines values for the L6208 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 __L6208_CONFIG_H
+#define __L6208_CONFIG_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/** @addtogroup L6208
+  * @{
+  */
+
+/** @addtogroup L6208_Exported_Constants
+  * @{
+  */
+
+/** @defgroup Predefined_L6208_Parameters_Values Predefined L6208 Parameters Values
+  * @{
+  */
+
+/// Acceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
+#define L6208_CONF_PARAM_ACC_RATE        (1000)
+
+/// Acceleration current torque in % (from 0 to 100)
+#define L6208_CONF_PARAM_ACC_CURRENT     (10)
+
+/// Deceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
+#define L6208_CONF_PARAM_DEC_RATE        (1000)
+
+/// Deceleration current torque in % (from 0 to 100)
+#define L6208_CONF_PARAM_DEC_CURRENT     (10)
+
+/// Running speed in step/s or (1/16)th step/s for microstep modes
+#define L6208_CONF_PARAM_RUNNING_SPEED   (1000)
+
+/// Running current torque in % (from 0 to 100)
+#define L6208_CONF_PARAM_RUNNING_CURRENT (10)
+
+/// Holding current torque in % (from 0 to 100)
+#define L6208_CONF_PARAM_HOLDING_CURRENT (10)
+
+/// Step mode via enum motorStepMode_t
+#define L6208_CONF_PARAM_STEP_MODE       (STEP_MODE_1_16)
+
+/// Decay mode via enum motorDecayMode_t
+#define L6208_CONF_PARAM_DECAY_MODE      (FAST_DECAY)
+
+/// Dwelling time in ms
+#define L6208_CONF_PARAM_DWELL_TIME      (0)
+
+/// Automatic HIZ STOP
+#define L6208_CONF_PARAM_AUTO_HIZ_STOP   (FALSE)
+
+/// VREFA and VREFB PWM frequency (Hz)
+#define L6208_CONF_VREF_PWM_FREQUENCY    (100000)
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif /* __L6208_CONFIG_H */
+
+/******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/l6208/L6208_def.h	Fri Mar 24 10:59:42 2017 +0100
@@ -0,0 +1,328 @@
+/******************************************************//**
+  * @file    L6208_def.h 
+  * @author  IPC Rennes
+  * @version V1.1.0
+  * @date    February 11th, 2016
+  * @brief   Header for l6208.c module
+  * @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 _L6208_H_INCLUDED
+#define _L6208_H_INCLUDED
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/* Includes ------------------------------------------------------------------*/
+#include "L6208_config.h"
+#include "motor_def.h" 
+
+/* Definitions ---------------------------------------------------------------*/
+
+/** @addtogroup Components
+ * @{
+ */
+    
+/** @defgroup L6208
+  * @{
+  */
+
+/** @defgroup L6208_Exported_Defines L6208 Exported Defines
+  * @{
+  */
+/// Current FW major version
+#define L6208_FW_MAJOR_VERSION (uint8_t)(1)
+/// Current FW minor version
+#define L6208_FW_MINOR_VERSION (uint8_t)(1)
+/// Current FW patch version
+#define L6208_FW_PATCH_VERSION (uint8_t)(0)
+/// Current FW version
+#define L6208_FW_VERSION       (uint32_t)((L6208_FW_MAJOR_VERSION<<16)|\
+                                          (L6208_FW_MINOR_VERSION<<8)|\
+                                          (L6208_FW_PATCH_VERSION))
+
+/// Exponent used to scale the sine function for the RefMicroTable
+#define L6208_SINE_WAVEFORM_POWER_OF_TWO_MAX_VALUE (15)
+
+/// Tick frequency (Hz)
+#define TIMER_TICK_FREQUENCY         (10000)
+
+/// MCU wait time after power bridges are enabled
+#define BRIDGE_TURN_ON_DELAY         (10)
+
+/// The maximum number of devices
+#define MAX_NUMBER_OF_DEVICES        (1)
+
+/// Max position
+#define L6208_MAX_POSITION           (0x7FFFFFFF)
+
+/// Min position
+#define L6208_MIN_POSITION           (0x80000000)
+
+/// Position range
+#define L6208_POSITION_RANGE         ((uint32_t)(L6208_MAX_POSITION -\
+                                                        L6208_MIN_POSITION))
+/// micro step samples per period/4 
+#define L6208_USTEPS_PER_QUARTER_PERIOD        (16)
+
+/// minimum speed
+#define L6208_MIN_SPEED                        (16)
+
+/// minimum acceleration and deceleration rate
+#define L6208_MIN_ACC_DEC_RATE                 (24)
+
+/// Mask for HiZ bit in motorDecayMode_t enum
+#define L6208_FAST_DECAY_MODE_MASK             (0x1)
+
+/// L6208 error base number
+#define L6208_ERROR_BASE                       (0x9000)
+/**
+  * @}
+  */
+
+/* Types ---------------------------------------------------------------------*/
+
+/** @defgroup L6208_Exported_Types L6208 Exported Types
+  * @{
+  */
+
+/** @defgroup Error_Types Error Types
+  * @{
+  */
+/// Errors
+typedef enum {
+  L6208_ERROR_SET_HOME         = L6208_ERROR_BASE,     /// Error while setting home position
+  L6208_ERROR_SET_MAX_SPEED    = L6208_ERROR_BASE + 1, /// Error while setting max speed
+  L6208_ERROR_SET_MIN_SPEED    = L6208_ERROR_BASE + 2, /// Error while setting min speed
+  L6208_ERROR_SET_ACCELERATION = L6208_ERROR_BASE + 3, /// Error while setting acceleration
+  L6208_ERROR_SET_DECELERATION = L6208_ERROR_BASE + 4, /// Error while setting decelaration
+  L6208_ERROR_MCU_OSC_CONFIG   = L6208_ERROR_BASE + 5, /// Error while configuring mcu oscillator
+  L6208_ERROR_MCU_CLOCK_CONFIG = L6208_ERROR_BASE + 6, /// Error while configuring mcu clock
+  L6208_ERROR_POSITION         = L6208_ERROR_BASE + 7, /// Unexpected current position (wrong number of steps)
+  L6208_ERROR_SPEED            = L6208_ERROR_BASE + 8, /// Unexpected current speed
+  L6208_ERROR_INIT             = L6208_ERROR_BASE + 9, /// Unexpected number of devices
+  L6208_ERROR_SET_DIRECTION    = L6208_ERROR_BASE + 10,/// Error while setting direction
+  L6208_ERROR_SET_STEP_MODE    = L6208_ERROR_BASE + 11,/// Attempt to set an unsupported step mode
+  L6208_ERROR_SET_PWM          = L6208_ERROR_BASE + 12,/// Error while setting a PWM parameter
+}errorTypes_t;
+/**
+  * @}
+  */
+
+/** @defgroup Device_Parameters Device Parameters
+  * @{
+  */
+/// Device Parameters Structure Type
+typedef struct
+{
+  /// dwelling waiting time counter (tick)
+  volatile uint32_t dwellCounter;
+  /// motor position indicator (tick)
+  uint32_t ticks;
+  /// LSByte copy of the previous position (tick)
+  uint8_t lsbOldTicks;
+  /// LSByte copy of the previous position (tick) ( micro stepping )
+  uint8_t lsbOldUSteppingTicks;
+  /// LSByte copy of the current position (tick)
+  uint8_t lsbTicks;
+  /// P1 = acceleration phase steps number (motor position control mode)
+  uint32_t positionTarget1;
+  /// P2 = constant speed steps number (motor position control mode)
+  uint32_t positionTarget2;
+  /// P3 = deceleration phase steps number (motor position control mode)
+  uint32_t positionTarget3;
+  /// P = total move distance in steps (motor position control mode)
+  uint32_t positionTarget;
+  /// absolute motor position in microsteps (motor position control mode)
+  volatile int32_t absolutePos;
+  /// mark position in microsteps (motor position control mode)
+  volatile int32_t markPos;
+  /// motor position in microsteps (motor position control mode)
+  volatile uint32_t step;
+  /// dwelling time after position got (ms)
+  volatile uint16_t moveDwellTime;
+  /// number of micro stepping waveform samples to be rescaled according to selected torque value
+  volatile uint8_t uStepsample2scale;
+  /// number of micro stepping waveform samples to be updated into the waveform scanning table  
+  volatile uint8_t uStepsample2update;
+  /// microstepping waveform sample index  
+  volatile uint8_t uStepSample;
+  /// system status flags
+  volatile uint32_t flags;
+  /// current stepper state machine index
+  volatile motorState_t motionState;
+  /// current step mode
+  volatile motorStepMode_t stepMode;
+  /// micro stepping waveform scanning sample index increment
+  uint8_t uStepInc;
+  /// frequency of the VREFA and VREFB PWM
+  uint32_t vrefPwmFreq;
+  /// period of the VREFA and VREFB PWM in 1/256th of a microsecond
+  uint16_t vrefPwmPeriod;
+  /// pulse width target of the VREFA PWM in 1/256th of a microsecond
+  volatile uint16_t vrefPwmPulseWidthTargetA;
+  /// pulse width target of the VREFB PWM in 1/256th of a microsecond
+  volatile uint16_t vrefPwmPulseWidthTargetB;
+  /// pulse width to be generated for VREFA PWM in 1/256th of a microsecond
+  volatile int16_t vrefPwmPulseWidthToBeGeneratedA;
+  /// pulse width to be generated for VREFB PWM in 1/256th of a microsecond
+  volatile int16_t vrefPwmPulseWidthToBeGeneratedB;
+  /// current selected torque value
+  volatile uint16_t curTorqueScaler;
+  /// selected VREFA value (%)
+  volatile uint16_t vRefAVal;
+  /// selected VREFB value (%)
+  volatile uint16_t vRefBVal;
+  /// 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;
+  /// acceleration (steps/s^2)
+  volatile uint16_t accelerationSps2;
+  /// deceleration (steps/s^2)
+  volatile uint16_t decelerationSps2;
+  /// acceleration (steps/tick^2)
+  volatile uint16_t accelerationSpt2;
+  /// deceleration (steps/tick^2)
+  volatile uint16_t decelerationSpt2;
+  /// maximum speed (steps/s)
+  volatile uint16_t maxSpeedSps;
+  /// minimum speed (steps/s)
+  volatile uint16_t minSpeedSps;
+  /// current speed (steps/s)
+  volatile uint16_t speedSps;
+  /// maximum speed (steps/tick)
+  volatile uint32_t maxSpeedSpt;
+  /// minimum speed (steps/tick)
+  volatile uint32_t minSpeedSpt;
+  /// current speed (steps/tick) 
+  volatile uint32_t speedSpt;
+}deviceParams_t;
+/**
+  * @}
+  */
+
+/// Motor driver initialization structure definition  
+typedef struct
+{
+  /// acceleration (steps/s^2)
+  uint16_t accelerationSps2;
+  /// acceleration phase torque value (%)
+  uint8_t accelTorque;
+  /// deceleration (steps/s^2)
+  uint16_t decelerationSps2;
+  /// deceleration phase torque value (%)
+  uint8_t decelTorque;
+  /// maximum speed (steps/s)
+  uint16_t maxSpeedSps;
+  /// constant speed phase torque value (%)
+  uint8_t runTorque;
+  /// holding phase torque value (%)
+  uint8_t holdTorque;
+  /// current step mode
+  motorStepMode_t stepMode;
+  /// current decay mode (SLOW_DECAY or FAST_DECAY)
+  motorDecayMode_t decayMode;
+  /// dwelling time after position got (ms)
+  uint16_t moveDwellTime;
+  /// automatic HiZ on stop
+  bool autoHiZstop;
+  /// frequency of the VREFA and VREFB PWM
+  uint32_t vrefPwmFreq;
+} l6208_init_t;
+/**
+  * @}
+  */
+
+/* Functions --------------------------------------------------------*/
+
+/** @defgroup MotorControl_Board_Linked_Functions MotorControl Board Linked Functions
+  * @{
+  */
+///Delay of the requested number of milliseconds
+extern void L6208_Board_Delay(uint32_t delay);
+///Enable Irq
+extern void L6208_Board_EnableIrq(void);
+///Disable Irq
+extern void L6208_Board_DisableIrq(void);
+//Initialize the VREFA or VREFB PWM
+extern bool L6208_Board_VrefPwmInit(uint8_t bridgeId, uint32_t pwmFreq);
+///Initialize the tick
+extern void L6208_Board_TickInit(void);
+///Release the reset pin 
+extern void L6208_Board_Releasereset(void);
+///Set the reset pin
+extern void L6208_Board_reset(void);
+///Set the control pin
+extern void L6208_Board_CONTROL_PIN_Set(void);
+///Reset the control pin
+extern void L6208_Board_CONTROL_PIN_reset(void);
+///Set the clock pin
+extern void L6208_Board_CLOCK_PIN_Set(void);
+///Reset the clock pin
+extern void L6208_Board_CLOCK_PIN_reset(void);
+///Set the half full pin
+extern void L6208_Board_HALF_FULL_PIN_Set(void);
+///Reset the half full pin
+extern void L6208_Board_HALF_FULL_PIN_reset(void);
+///Set the dir pin
+extern void L6208_Board_DIR_PIN_Set(void);
+///Reset the dir pin
+extern void L6208_Board_DIR_PIN_reset(void);
+///Enable the power bridges (leave the output bridges HiZ)
+extern void L6208_Board_enable(void);
+///Disable the power bridges (leave the output bridges HiZ)
+extern void L6208_Board_disable(void);
+/**
+  * @}
+  */
+
+  /**
+  * @}
+  */
+
+/**
+  * @}
+  */
+  
+#ifdef __cplusplus
+  }
+#endif
+
+#endif /* __L6208_H */
+
+/******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
--- a/Components/l6208/l6208.h	Fri Apr 29 14:58:30 2016 +0000
+++ b/Components/l6208/l6208.h	Fri Mar 24 10:59:42 2017 +0100
@@ -1,328 +1,1183 @@
-/******************************************************//**
-  * @file    l6208.h 
-  * @author  IPC Rennes
-  * @version V1.1.0
-  * @date    February 11th, 2016
-  * @brief   Header for l6208.c module
-  * @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    L6208.h
+ * @author  IPC Rennes
+ * @version V1.0.0
+ * @date    March 18th, 2016
+ * @brief   This file contains the class of a L6208 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 _L6208_H_INCLUDED
-#define _L6208_H_INCLUDED
 
-#ifdef __cplusplus
- extern "C" {
-#endif 
+#ifndef __L6208_CLASS_H
+#define __L6208_CLASS_H
+
 
 /* Includes ------------------------------------------------------------------*/
-#include "l6208_target_config.h"
-#include "motor.h" 
 
-/* Definitions ---------------------------------------------------------------*/
-
-/** @addtogroup Components
- * @{
- */
-    
-/** @defgroup L6208
-  * @{
-  */
-
-/** @defgroup L6208_Exported_Defines L6208 Exported Defines
-  * @{
-  */
-/// Current FW major version
-#define L6208_FW_MAJOR_VERSION (uint8_t)(1)
-/// Current FW minor version
-#define L6208_FW_MINOR_VERSION (uint8_t)(1)
-/// Current FW patch version
-#define L6208_FW_PATCH_VERSION (uint8_t)(0)
-/// Current FW version
-#define L6208_FW_VERSION       (uint32_t)((L6208_FW_MAJOR_VERSION<<16)|\
-                                          (L6208_FW_MINOR_VERSION<<8)|\
-                                          (L6208_FW_PATCH_VERSION))
-
-/// Exponent used to scale the sine function for the RefMicroTable
-#define L6208_SINE_WAVEFORM_POWER_OF_TWO_MAX_VALUE (15)
-
-/// Tick frequency (Hz)
-#define TIMER_TICK_FREQUENCY         (10000)
-
-/// MCU wait time after power bridges are enabled
-#define BRIDGE_TURN_ON_DELAY         (10)
-
-/// The maximum number of devices
-#define MAX_NUMBER_OF_DEVICES        (1)
-
-/// Max position
-#define L6208_MAX_POSITION           (0x7FFFFFFF)
-
-/// Min position
-#define L6208_MIN_POSITION           (0x80000000)
-
-/// Position range
-#define L6208_POSITION_RANGE         ((uint32_t)(L6208_MAX_POSITION -\
-                                                        L6208_MIN_POSITION))
-/// micro step samples per period/4 
-#define L6208_USTEPS_PER_QUARTER_PERIOD        (16)
-
-/// minimum speed
-#define L6208_MIN_SPEED                        (16)
-
-/// minimum acceleration and deceleration rate
-#define L6208_MIN_ACC_DEC_RATE                 (24)
-
-/// Mask for HiZ bit in motorDecayMode_t enum
-#define L6208_FAST_DECAY_MODE_MASK             (0x1)
-
-/// L6208 error base number
-#define L6208_ERROR_BASE                       (0x9000)
-/**
-  * @}
-  */
-
-/* Types ---------------------------------------------------------------------*/
-
-/** @defgroup L6208_Exported_Types L6208 Exported Types
-  * @{
-  */
-
-/** @defgroup Error_Types Error Types
-  * @{
-  */
-/// Errors
-typedef enum {
-  L6208_ERROR_SET_HOME         = L6208_ERROR_BASE,     /// Error while setting home position
-  L6208_ERROR_SET_MAX_SPEED    = L6208_ERROR_BASE + 1, /// Error while setting max speed
-  L6208_ERROR_SET_MIN_SPEED    = L6208_ERROR_BASE + 2, /// Error while setting min speed
-  L6208_ERROR_SET_ACCELERATION = L6208_ERROR_BASE + 3, /// Error while setting acceleration
-  L6208_ERROR_SET_DECELERATION = L6208_ERROR_BASE + 4, /// Error while setting decelaration
-  L6208_ERROR_MCU_OSC_CONFIG   = L6208_ERROR_BASE + 5, /// Error while configuring mcu oscillator
-  L6208_ERROR_MCU_CLOCK_CONFIG = L6208_ERROR_BASE + 6, /// Error while configuring mcu clock
-  L6208_ERROR_POSITION         = L6208_ERROR_BASE + 7, /// Unexpected current position (wrong number of steps)
-  L6208_ERROR_SPEED            = L6208_ERROR_BASE + 8, /// Unexpected current speed
-  L6208_ERROR_INIT             = L6208_ERROR_BASE + 9, /// Unexpected number of devices
-  L6208_ERROR_SET_DIRECTION    = L6208_ERROR_BASE + 10,/// Error while setting direction
-  L6208_ERROR_SET_STEP_MODE    = L6208_ERROR_BASE + 11,/// Attempt to set an unsupported step mode
-  L6208_ERROR_SET_PWM          = L6208_ERROR_BASE + 12,/// Error while setting a PWM parameter
-}errorTypes_t;
-/**
-  * @}
-  */
+/* ACTION 1 ------------------------------------------------------------------*
+ * Include here platform specific header files.                               *
+ *----------------------------------------------------------------------------*/        
+#include "mbed.h"
 
-/** @defgroup Device_Parameters Device Parameters
-  * @{
-  */
-/// Device Parameters Structure Type
-typedef struct
-{
-  /// dwelling waiting time counter (tick)
-  volatile uint32_t dwellCounter;
-  /// motor position indicator (tick)
-  uint32_t ticks;
-  /// LSByte copy of the previous position (tick)
-  uint8_t lsbOldTicks;
-  /// LSByte copy of the previous position (tick) ( micro stepping )
-  uint8_t lsbOldUSteppingTicks;
-  /// LSByte copy of the current position (tick)
-  uint8_t lsbTicks;
-  /// P1 = acceleration phase steps number (motor position control mode)
-  uint32_t positionTarget1;
-  /// P2 = constant speed steps number (motor position control mode)
-  uint32_t positionTarget2;
-  /// P3 = deceleration phase steps number (motor position control mode)
-  uint32_t positionTarget3;
-  /// P = total move distance in steps (motor position control mode)
-  uint32_t positionTarget;
-  /// absolute motor position in microsteps (motor position control mode)
-  volatile int32_t absolutePos;
-  /// mark position in microsteps (motor position control mode)
-  volatile int32_t markPos;
-  /// motor position in microsteps (motor position control mode)
-  volatile uint32_t step;
-  /// dwelling time after position got (ms)
-  volatile uint16_t moveDwellTime;
-  /// number of micro stepping waveform samples to be rescaled according to selected torque value
-  volatile uint8_t uStepsample2scale;
-  /// number of micro stepping waveform samples to be updated into the waveform scanning table  
-  volatile uint8_t uStepsample2update;
-  /// microstepping waveform sample index  
-  volatile uint8_t uStepSample;
-  /// system status flags
-  volatile uint32_t flags;
-  /// current stepper state machine index
-  volatile motorState_t motionState;
-  /// current step mode
-  volatile motorStepMode_t stepMode;
-  /// micro stepping waveform scanning sample index increment
-  uint8_t uStepInc;
-  /// frequency of the VREFA and VREFB PWM
-  uint32_t vrefPwmFreq;
-  /// period of the VREFA and VREFB PWM in 1/256th of a microsecond
-  uint16_t vrefPwmPeriod;
-  /// pulse width target of the VREFA PWM in 1/256th of a microsecond
-  volatile uint16_t vrefPwmPulseWidthTargetA;
-  /// pulse width target of the VREFB PWM in 1/256th of a microsecond
-  volatile uint16_t vrefPwmPulseWidthTargetB;
-  /// pulse width to be generated for VREFA PWM in 1/256th of a microsecond
-  volatile int16_t vrefPwmPulseWidthToBeGeneratedA;
-  /// pulse width to be generated for VREFB PWM in 1/256th of a microsecond
-  volatile int16_t vrefPwmPulseWidthToBeGeneratedB;
-  /// current selected torque value
-  volatile uint16_t curTorqueScaler;
-  /// selected VREFA value (%)
-  volatile uint16_t vRefAVal;
-  /// selected VREFB value (%)
-  volatile uint16_t vRefBVal;
-  /// 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;
-  /// acceleration (steps/s^2)
-  volatile uint16_t accelerationSps2;
-  /// deceleration (steps/s^2)
-  volatile uint16_t decelerationSps2;
-  /// acceleration (steps/tick^2)
-  volatile uint16_t accelerationSpt2;
-  /// deceleration (steps/tick^2)
-  volatile uint16_t decelerationSpt2;
-  /// maximum speed (steps/s)
-  volatile uint16_t maxSpeedSps;
-  /// minimum speed (steps/s)
-  volatile uint16_t minSpeedSps;
-  /// current speed (steps/s)
-  volatile uint16_t speedSps;
-  /// maximum speed (steps/tick)
-  volatile uint32_t maxSpeedSpt;
-  /// minimum speed (steps/tick)
-  volatile uint32_t minSpeedSpt;
-  /// current speed (steps/tick) 
-  volatile uint32_t speedSpt;
-}deviceParams_t;
-/**
-  * @}
-  */
+/* ACTION 2 ------------------------------------------------------------------*
+ * Include here component specific header files.                              *
+ *----------------------------------------------------------------------------*/        
+#include "L6208.h"
+/* ACTION 3 ------------------------------------------------------------------*
+ * Include here interface specific header files.                              *
+ *                                                                            *
+ * Example:                                                                   *
+ *   #include "HumiditySensor.h"                                              *
+ *   #include "TemperatureSensor.h"                                           *
+ *----------------------------------------------------------------------------*/
+#include "StepperMotor.h"
 
-/// Motor driver initialization structure definition  
-typedef struct
-{
-  /// acceleration (steps/s^2)
-  uint16_t accelerationSps2;
-  /// acceleration phase torque value (%)
-  uint8_t accelTorque;
-  /// deceleration (steps/s^2)
-  uint16_t decelerationSps2;
-  /// deceleration phase torque value (%)
-  uint8_t decelTorque;
-  /// maximum speed (steps/s)
-  uint16_t maxSpeedSps;
-  /// constant speed phase torque value (%)
-  uint8_t runTorque;
-  /// holding phase torque value (%)
-  uint8_t holdTorque;
-  /// current step mode
-  motorStepMode_t stepMode;
-  /// current decay mode (SLOW_DECAY or FAST_DECAY)
-  motorDecayMode_t decayMode;
-  /// dwelling time after position got (ms)
-  uint16_t moveDwellTime;
-  /// automatic HiZ on stop
-  bool autoHiZstop;
-  /// frequency of the VREFA and VREFB PWM
-  uint32_t vrefPwmFreq;
-} l6208_Init_t;
-/**
-  * @}
-  */
 
-/* Functions --------------------------------------------------------*/
-
-/** @defgroup MotorControl_Board_Linked_Functions MotorControl Board Linked Functions
-  * @{
-  */
-///Delay of the requested number of milliseconds
-extern void L6208_Board_Delay(uint32_t delay);
-///Enable Irq
-extern void L6208_Board_EnableIrq(void);
-///Disable Irq
-extern void L6208_Board_DisableIrq(void);
-//Initialize the VREFA or VREFB PWM
-extern bool L6208_Board_VrefPwmInit(uint8_t bridgeId, uint32_t pwmFreq);
-///Initialize the tick
-extern void L6208_Board_TickInit(void);
-///Release the reset pin 
-extern void L6208_Board_ReleaseReset(void);
-///Set the reset pin
-extern void L6208_Board_Reset(void);
-///Set the control pin
-extern void L6208_Board_CONTROL_PIN_Set(void);
-///Reset the control pin
-extern void L6208_Board_CONTROL_PIN_Reset(void);
-///Set the clock pin
-extern void L6208_Board_CLOCK_PIN_Set(void);
-///Reset the clock pin
-extern void L6208_Board_CLOCK_PIN_Reset(void);
-///Set the half full pin
-extern void L6208_Board_HALF_FULL_PIN_Set(void);
-///Reset the half full pin
-extern void L6208_Board_HALF_FULL_PIN_Reset(void);
-///Set the dir pin
-extern void L6208_Board_DIR_PIN_Set(void);
-///Reset the dir pin
-extern void L6208_Board_DIR_PIN_Reset(void);
-///Enable the power bridges (leave the output bridges HiZ)
-extern void L6208_Board_Enable(void);
-///Disable the power bridges (leave the output bridges HiZ)
-extern void L6208_Board_Disable(void);
-/**
-  * @}
-  */
-
-  /**
-  * @}
-  */
+/* Classes -------------------------------------------------------------------*/
 
 /**
-  * @}
-  */
-  
-#ifdef __cplusplus
-  }
-#endif
+ * @brief Class representing a L6208 component.
+ */
+class L6208 : public StepperMotor
+{
+public:
+    /*** Constructor and Destructor Methods ***/
+
+    /**
+     * @brief Constructor.
+     * @param flag_and_enable_pin   pin name of the EN pin of the component.
+     * @param reset_pin             pin name of the RESET pin of the component.
+     * @param direction_pin         pin name of the CW_CCW pin of the component.
+     * @param half_full_pin         pin name of the HALF_FULL pin of the component.
+     * @param control_pin           pin name of the CONTROL pin of the component.
+     * @param clock_pin             pin name of the CLOCK pin of the component.
+     * @param vrefA_pwm_pin         pin name of the PWM connected to the VREFA pin of the component.
+     * @param vrefB_pwm_pin         pin name of the PWM connected to the VREFB pin of the component.
+     */
+    L6208(PinName flag_and_enable_pin, PinName reset_pin, PinName direction_pin, PinName half_full_pin, PinName control_pin, PinName clock_pin, PinName vrefA_pwm_pin, PinName vrefB_pwm_pin) : StepperMotor(),
+                                                                                                                                                         flag_and_enable(flag_and_enable_pin),
+                                                                                                                                                         reset(reset_pin),
+                                                                                                                                                         direction(direction_pin),
+                                                                                                                                                         half_full(half_full_pin),
+                                                                                                                                                         control(control_pin),
+                                                                                                                                                         clock(clock_pin),
+                                                                                                                                                         vrefA_pwm(vrefA_pwm_pin),
+                                                                                                                                                         vrefB_pwm(vrefB_pwm_pin)
+    {
+        /* Checking stackability. */
+        if (numberOfDevices!=0)
+            error("Instantiation of the L6208 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;
+        deviceInstance = numberOfDevices++;
+        /* default tick frequency */
+        tickFreq = TIMER_TICK_FREQUENCY;
+        /* waveform microstepping PWM period sample array, 90 deg shifted */
+        pMicroTable2 = &(microTable1[16]);
+    }
+    
+    /**
+     * @brief Destructor.
+     */
+    virtual ~L6208(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) L6208_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) L6208_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) L6208_GetMotionState();
+    }
+
+    /**
+     * @brief  Getting the position.
+     * @param  None.
+     * @retval The position.
+     */
+    virtual signed int get_position(void)
+    {
+        return (signed int)L6208_GetPosition();
+    }
+
+    /**
+     * @brief  Getting the marked position.
+     * @param  None.
+     * @retval The marked position.
+     */
+    virtual signed int get_mark(void)
+    {
+        return (signed int)L6208_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)L6208_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)L6208_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)L6208_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)L6208_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)L6208_GetDeceleration();
+    }
+    
+    /**
+     * @brief  Getting the direction of rotation.
+     * @param  None.
+     * @retval The direction of rotation.
+     */
+    virtual direction_t get_direction(void)
+    {
+        if (L6208_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)
+    {
+        L6208_SetHome();
+    }
+
+    /**
+     * @brief  Setting the current position to be the marked position.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void set_mark(void)
+    {
+        L6208_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 L6208_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 L6208_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 L6208_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 set_deceleration(unsigned int deceleration)
+    {
+        if (deceleration <= 0xFFFF)
+        {
+            return L6208_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 L6208_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)
+    {
+        L6208_GoTo((int32_t)position);
+    }
+
+    /**
+     * @brief  Going to the home position.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void go_home(void)
+    {
+        L6208_GoHome();
+    }
+
+    /**
+     * @brief  Going to the marked position.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void go_mark(void)
+    {
+        L6208_GoMark();
+    }
+
+    /**
+     * @brief  Running the motor towards a specified direction.
+     * @param  direction The direction of rotation.
+     * @retval None.
+     */
+    virtual void run(direction_t direction)
+    {
+        L6208_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)
+    {
+        L6208_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)
+    {
+        L6208_SoftStop();
+    }
+
+    /**
+     * @brief  Stopping the motor through an immediate infinite deceleration.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void hard_stop(void)
+    {
+        L6208_HardStop();
+    }
+
+    /**
+     * @brief  Disabling the power bridge after performing a deceleration to zero.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void soft_hiz(void)
+    {
+        motorStopMode_t stopMode = L6208_GetStopMode();
+        if (stopMode==HIZ_MODE)
+        {
+            L6208_SoftStop();
+        }
+        else
+        {
+            L6208_SetStopMode(HIZ_MODE);
+            L6208_SoftStop();
+            L6208_SetStopMode(stopMode);
+        }
+    }
+
+    /**
+     * @brief  Disabling the power bridge immediately.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void hard_hiz(void)
+    {
+        L6208_HardHiZ();
+    }
+
+    /**
+     * @brief  Waiting while the motor is active.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void wait_while_active(void)
+    {
+        L6208_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))
+    {
+        L6208_AttachErrorHandler((void (*)(uint16_t error)) fptr);
+    }
+
+    /**
+     * @brief  Checks if the device is disabled or/and has an alarm flag set 
+     * by reading the EN pin position.
+     * @param  None.
+     * @retval One if the EN pin is low (the device is disabled or/and 
+     * has an alarm flag set), otherwise zero.
+     */
+    virtual unsigned int check_status_hw(void)
+    {
+        if (!flag_and_enable.read()) return 0x01;
+        else return 0x00;
+    }
+    
+    /**
+     * @brief  Disabling the device.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void disable(void)
+    {
+        L6208_Disable();
+    }
+    
+    /**
+     * @brief  Enabling the device.
+     * @param  None.
+     * @retval None.
+     */
+    virtual void enable(void)
+    {
+        L6208_Enable();
+    }
+    
+    /**
+     * @brief  Getting the motor decay mode.
+     * @param  None.
+     * @retval The motor decay mode.
+     */
+    virtual motorDecayMode_t get_decay_mode()
+    {
+         return L6208_get_decay_mode();
+    }
+    
+    /**
+     * @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 L6208_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) L6208_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) L6208_get_step_mode();
+    }
+    
+    /**
+     * @brief  Getting the motor stop mode.
+     * @param  None.
+     * @retval The motor stop mode.
+     */  
+    virtual motorStopMode_t get_stop_mode(void)
+    {
+      return L6208_GetStopMode();
+    }
+    
+    /**
+     * @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)
+    {
+        L6208_GoToDir((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD),(int32_t)position);
+    }
+
+    /**
+     * @brief  Release the L6208 reset (Reset pin set to high level).
+     * @param  None.
+     * @retval None.
+     */    
+    virtual void release_reset(void)
+    {
+        L6208_ReleaseReset();
+    }
 
-#endif /* __L6208_H */
+    /**
+     * @brief  Reset the device with current step mode, resets current speed,
+     * positions and microstep variables.
+     * @param  None.
+     * @retval None.
+     */    
+    virtual void reset(void)
+    {
+        L6208_Reset();
+    }
+    
+    /**
+     * @brief  Reset the L6208 (Reset pin set to low level).
+     * @param  None.
+     * @retval None.
+     */    
+    virtual void reset_device(void)
+    {
+        L6208_ResetDevice();
+    }
+   
+    /**
+     * @brief  Set the motor decay mode.
+     * @param  decayMode The desired decay mode (SLOW_DECAY or FAST_DECAY).
+     * @retval None.
+     */    
+    virtual void set_decay_mode(motorDecayMode_t decayMode)
+    {
+        L6208_SetDecayMode(decayMode);
+    }
+
+    /**
+     * @brief  Set the motor direction.
+     * @param  direction The desired direction.
+     * @retval None.
+     */
+    virtual void set_direction(direction_t direction)
+    { 
+        L6208_SetDirection((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD));
+    }
+
+    /**
+     * @brief  Set the frequency of the VREFA and VREFB PWM
+     * @param  frequency in Hz
+     * @retval None.
+     */  
+    virtual void set_freq_vref_pwm(uint32_t frequency)
+    {
+        L6208_VrefPwmSetFreq(frequency);
+    }
+
+    /**
+     * @brief  Set the motor stop mode.
+     * @param  stopMode The desired stop mode (HOLD_MODE or HIZ_MODE).
+     * @retval None.
+     */       
+    virtual void set_stop_mode(motorStopMode_t stopMode)
+    {
+        L6208_SetStopMode(stopMode);
+    }
+   
+    /*** 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))
+    {
+        flag_and_enable.mode(PullDown);
+        flag_and_enable.fall(fptr);
+    }
+    
+    /**
+     * @brief  Enabling the FLAG interrupt handling.
+     * @param  None.
+     * @retval None.
+     */
+    void enable_flag_irq(void)
+    {
+        flag_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 L6208_Init(void *init);
+    status_t L6208_ReadID(uint8_t *id);
+    void L6208_AttachErrorHandler(void (*callback)(uint16_t error));
+    void L6208_disable(void);
+    void L6208_ErrorHandler(uint16_t error);
+    void L6208_enable(void);
+    uint16_t L6208_GetAcceleration(void);
+    uint16_t L6208_GetCurrentSpeed(void);
+    uint16_t L6208_GetDeceleration(void);
+    motorDecayMode_t L6208_get_decay_mode(void);
+    motorDir_t L6208_GetDirection(void);
+    uint32_t L6208_GetFwVersion(void);
+    int32_t L6208_GetMark(void);
+    uint16_t L6208_GetMaxSpeed(void);
+    uint16_t L6208_GetMinSpeed(void);
+    motorState_t L6208_GetMotionState(void);
+    int32_t L6208_GetPosition(void);
+    motorStepMode_t L6208_get_step_mode(void);
+    motorStopMode_t L6208_GetStopMode(void);    
+    void L6208_GoHome(void);  
+    void L6208_GoMark(void);
+    void L6208_GoTo(int32_t targetPosition);
+    void L6208_GoToDir(motorDir_t direction, int32_t targetPosition);   
+    void L6208_HardHiZ(void);
+    void L6208_HardStop(void);
+    void L6208_Move(motorDir_t direction, uint32_t stepCount);
+    void L6208_Releasereset(void);
+    void L6208_reset(void);
+    void L6208_ResetDevice(void);  
+    void L6208_Run(motorDir_t direction);
+    bool L6208_SetAcceleration(uint16_t newAcc);
+    void L6208_SetDecayMode(motorDecayMode_t decayMode);
+    bool L6208_SetDeceleration(uint16_t newDec);
+    void L6208_SetDirection(motorDir_t direction);
+    void L6208_SetHome(void);
+    void L6208_SetMark(void);
+    bool L6208_SetMaxSpeed(uint16_t volatile newSpeed);
+    bool L6208_SetMinSpeed(uint16_t volatile newSpeed);    
+    bool L6208_SetStepMode(motorStepMode_t stepMode);
+    void L6208_SetStopMode(motorStopMode_t stopMode);    
+    bool L6208_SoftStop(void);
+    void L6208_TickHandler(void);
+    uint32_t L6208_VrefPwmGetFreq(void);
+    void L6208_VrefPwmSetFreq(uint32_t newFreq);
+    void L6208_WaitWhileActive(void);
+    
+    /*** Functions intended to be used only internally ***/
+    
+    void L6208_ClearSysFlag(uint32_t mask);
+    uint32_t L6208_ComputeNbAccOrDecSteps(uint16_t accOrDecRate);
+    uint16_t L6208_ConvertAcceDecelRateValue(uint16_t newAccOrDecRate);
+    void L6208_DoAccel(void);
+    void L6208_DoDecel(void);
+    void L6208_DoRun(void);
+    uint8_t L6208_GetMicrostepSample2Scale(void);
+    void L6208_Indexmodeinit(void);
+    bool L6208_IsSysFlag(uint32_t mask);
+    void L6208_ResetSteps(void);
+    uint32_t L6208_ScaleWaveformSample(uint8_t sampleIndex);
+    void L6208_ScaleWaveformTable(void);
+    void L6208_SetDeviceParamsToGivenValues(l6208_init_t* pInitDevicePrm);
+    void L6208_SetDeviceParamsToPredefinedValues(void);
+    void L6208_SetMicrostepSample2Scale(uint8_t value);
+    void L6208_SetMicrostepSample2Update(uint8_t value);
+    void L6208_SetMotionState(motorState_t newMotionState);
+    bool L6208_SetSpeed(uint16_t newSpeed, uint32_t volatile *pSpeed);
+    void L6208_SetSysFlag(uint32_t mask);
+    bool L6208_StartMovement(void);
+    void L6208_UpdateScanWaveformTable(void);
+    void L6208_UstepWaveformHandling(void);
+    bool L6208_VectorCalc(uint8_t newTorque);
+    bool L6208_VrefPwmComputePulseWidth(uint8_t bridgeId, uint16_t value, bool valueIsPwmDutyCycle);
+    void L6208_VrefPwmUpdatePulseWidth(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  Reset the clock pin.
+     * @param  None.
+     * @retval None.
+     */    
+    void L6208_Board_CLOCK_PIN_reset(void)
+    {
+        clock = 0;
+    }    
+    /**
+     * @brief  Set the clock pin.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_CLOCK_PIN_Set(void)
+    {
+        clock = 1;
+    }
+
+    /**
+     * @brief  Set the control pin.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_CONTROL_PIN_Set(void)
+    {
+        control = 1;
+    }
 
-/******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
+    /**
+     * @brief  Reset the control pin.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_CONTROL_PIN_reset(void)
+    {
+        control = 0;
+    }
+    
+    /**
+     * @brief  Making the CPU wait.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_Delay(uint32_t delay)
+    {
+        wait_ms(delay);
+    }
+    
+    /**
+     * @brief  Reset the dir pin.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_DIR_PIN_reset(void)
+    {
+        direction = 0;
+    }
+        
+    /**
+     * @brief  Set the dir pin.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_DIR_PIN_Set(void)
+    {
+        direction = 1;
+    }
+    
+    /**
+     * @brief  Disable the power bridges (leave the output bridges HiZ).
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_disable(void)
+    {
+        flag_and_enable.disable_irq();
+        flag_and_enable.mode(PullDown);
+    }
+
+    /**
+     * @brief  Disabling interrupts.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_DisableIrq(void)
+    {
+        __disable_irq();
+    }
+    
+    /**
+     * @brief  Enable the power bridges (leave the output bridges HiZ).
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_enable(void)
+    {     
+        flag_and_enable.mode(PullUp);
+        flag_and_enable.enable_irq();
+    }
+    
+    /**
+     * @brief  Enabling interrupts.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_EnableIrq(void)
+    {
+        __enable_irq();
+    }
+    
+    /**
+     * @brief  Reset the half full pin.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_HALF_FULL_PIN_reset(void)
+    {
+        half_full = 0;
+    }
+    
+    /**
+     * @brief  Set the half full pin.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_HALF_FULL_PIN_Set(void)
+    {
+        half_full = 1;
+    }
+
+    /**
+     * @brief  Initialising the the VREFA or VREFB PWM.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_VrefPwmInit(uint8_t bridgeId, uint32_t pwmFreq) {}
+        
+    /**
+     * @brief  Exit the device from reset mode.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_Releasereset(void)
+    {
+        reset = 1;
+    }
+
+    /**
+     * @brief  Put the device in reset mode.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_reset(void)
+    {
+        reset = 0;
+    }
+
+    /**
+     * @brief  Get the tick timer frequency in Hz.
+     * @param  None.
+     * @retval The tick timer frequency in Hz.
+     */    
+    uint32_t L6208_Board_TickGetFreq(void)
+    {
+       return TIMER_TICK_FREQUENCY;
+    }
+
+    /**
+     * @brief  Initialising the tick.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_TickInit(void) {}
+
+    /**
+     * @brief  Starting the tick timer, setting its frequency
+     * and attaching a tick handler function to it.
+     * @param  frequency the frequency of the tick.
+     * @retval None.
+     */
+    void L6208_Board_TickStart(uint16_t frequency)
+    {
+        /* Computing the period of the tick. */
+        double period = 1.0f / frequency;
+        
+        /* Attaching a tick handler function which updates */
+        /* the state machine every elapsed period time. */
+        ticker.attach(this, &L6208::L6208_TickHandler, period);
+    }
+
+    /**
+     * @brief  Stopping the tick.
+     * @param  None.
+     * @retval None.
+     */
+    void L6208_Board_TickStop(void)
+    {
+        ticker.detach();
+    }
+
+    /**
+     * @brief Set the pulse width of the VREFA PWM.
+     * @param[in] pulseWidthInUs pulse width of the PWM in microsecond.
+     * @retval None.
+     */     
+    void L6208_Board_VrefPwmSetPulseWidthA(uint8_t pulseWidthInUs)
+    {
+      vrefA_pwm.pulsewidth_us(pulseWidthInUs);
+    }
+ 
+    /**
+     * @brief Set the pulse width of the VREFB PWM.
+     * @param[in] pulseWidthInUs pulse width of the PWM in microsecond.
+     * @retval None.
+     */       
+    void L6208_Board_VrefPwmSetPulseWidthB(uint8_t pulseWidthInUs)
+    {
+      vrefB_pwm.pulsewidth_us(pulseWidthInUs);
+    }    
+    
+    /**
+     * @brief  Start the timer for the VREFA or VREFB PWM.
+     * @param[in] bridgeId
+     *            0 for BRIDGE_A
+     *            1 for BRIDGE_B
+     * @param[in] pwmPeriod period of the PWM used to generate the reference
+     * voltage for the bridge.
+     * @retval "true" in case of success, "false" otherwise.
+     * @note the unit is 1/256th of a microsecond. The VREFA PWM must be started
+     * before the VREFB PWM.
+     */   
+    bool L6208_Board_VrefPwmStart(uint8_t bridgeId, uint16_t pwmPeriod)
+    { 
+        pwmPeriod>>=8;
+        /* Setting the period and the duty-cycle of PWM. */
+        if (bridgeId == 0)
+        {
+            vrefA_pwm.period_us(pwmPeriod);         
+        }
+        else if (bridgeId == 1)
+        {
+            vrefB_pwm.period_us(pwmPeriod);
+        }
+        else return false;
+        return true;
+    }
+    
+    /**
+     * @brief  Stop the timer for the VREFA or VREFB PWM.
+     * @param[in] bridgeId
+     *            0 for BRIDGE_A
+     *            1 for BRIDGE_B
+     * @retval "true" in case of success, "false" otherwise.
+     */       
+    bool L6208_Board_VrefPwmStop(uint8_t bridgeId)
+    {
+        if (bridgeId == 0)
+        {
+            vrefA_pwm.period_us(0);
+        }
+        else if (bridgeId == 1)
+        {
+            vrefB_pwm.period_us(0);
+        }
+        else return false;
+        return true;
+    }
+
+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;                                           *
+     *------------------------------------------------------------------------*/
+    /* Flag Interrupt and chip enable. */
+    InterruptIn flag_and_enable;
+
+    /* ACTION 10 -------------------------------------------------------------*
+     * Declare here other pin related variables, if needed.                   *
+     *                                                                        *
+     * Example:                                                               *
+     *   + mbed:                                                              *
+     *     DigitalOut standby_reset;                                          *
+     *------------------------------------------------------------------------*/
+    /* RESET pin. */
+    DigitalOut reset;
+    /* CW_CCW pin. */
+    DigitalOut direction;
+    /* HALF_FULL pin */
+    DigitalOut half_full;
+    /* CONTROL pin */
+    DigitalOut control;
+    /* CLOCK pin */
+    DigitalOut clock;
+
+    /* Pulse Width Modulation pin for VREFA pin */
+    PwmOut vrefA_pwm;
+    /* Pulse Width Modulation pin for VREFA pin */
+    PwmOut vrefB_pwm;
+    
+    /* Timer for the tick */
+    Ticker ticker;
+    
+    /* 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 (*errorHandlerCallback)(uint16_t error);
+    deviceParams_t devicePrm;
+    uint8_t deviceInstance;
+    uint32_t tickFreq;
+    /// microstepping PWM period and torque scaled waveform samples array
+    uint16_t updatedMicroTable[L6208_USTEPS_PER_QUARTER_PERIOD+1];
+    /// waveform scanning microstepping PWM period sample arrays for VREFA wave
+    uint16_t microTable1[L6208_USTEPS_PER_QUARTER_PERIOD*3+1];
+    /// waveform scanning microstepping PWM period sample array for VREFB wave
+    uint16_t *pMicroTable2;
+
+    /* Static data. */
+    static uint8_t numberOfDevices;
+    static const uint16_t RefMicroTable[L6208_USTEPS_PER_QUARTER_PERIOD*3];
+
+public:
+
+    /* Static data. */
+    
+};
+
+#endif // __L6208_CLASS_H
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/l6208/l6208_class.cpp	Fri Apr 29 14:58:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1872 +0,0 @@
-/**
-  ******************************************************************************
-  * @file    l6208_class.cpp
-  * @author  IPC Rennes
-  * @version V1.1.0
-  * @date    February 11th, 2016
-  * @brief   L6208 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 "l6208_class.h"
-
-/* Definitions ---------------------------------------------------------------*/
-/// Bridge A
-#define BRIDGE_A                     (0)
-/// Bridge B
-#define BRIDGE_B                     (1)
-
-/// Bitmaps for system flags
-#define EN_A_set              0x00000001    ///< EN_A pin status
-#define HiZstop               0x00000002    ///< motor has to be left in HiZ after stopping
-#define busy                  0x00000004    ///< stepper position command executing flag
-#define running               0x00000008    ///< running motor flag
-#define velocitymode          0x00000010    ///< velocity controlled stepper motor
-#define positionmode          0x00000020    ///< position controlled stepper motor
-#define fullstep              0x00000040    ///< full step mode controlled    
-#define halfstep              0x00000080    ///< half step mode controlled    
-#define microstep             0x00000100    ///< micro step mode controlled
-#define forward               0x00000200    ///< forward running motor
-#define dir2change            0x00000400    ///< direction has to be changed while the motor is running
-#define fastdecaymode         0x00000800    ///< decay mode is fast
-#define wavestep              0x00001000    ///< wave step mode controlled
-
-/* Variables  ----------------------------------------------------------------*/
-/* Number of devices. */
-uint8_t L6208::numberOfDevices = 0;
-
-/// RefMicroTable values are 2^L6208_SINE_WAVEFORM_POWER_OF_TWO_MAX_VALUE*|sin(n/16*PI/2)|
-/// where n is the index in the table
-const uint16_t L6208::RefMicroTable[L6208_USTEPS_PER_QUARTER_PERIOD*3] =
-{
-  0,3212,6393,9512,12540,15447,18205,20788,23170,25330,27246,28899,30274,31357,32138,32610,
-  32768,32610,32138,31357,30274,28899,27246,25330,23170,20788,18205,15447,12540,9512,6393,3212,
-  0,3212,6393,9512,12540,15447,18205,20788,23170,25330,27246,28899,30274,31357,32138,32610
-};
-
-/* Methods -------------------------------------------------------------------*/
-/******************************************************//**
- * @brief Start the L6208 library
- * @param[in] pInit pointer to the initialization data
- * @retval COMPONENT_OK in case of success.
- **********************************************************/
-Status_t L6208::L6208_Init(void* pInit)
-{ 
-  if (pInit == NULL)
-  {
-    /* Set context variables to the predefined values from l6208_target_config.h */
-    /* Set GPIO according to these values */
-    L6208_SetDeviceParamsToPredefinedValues();
-  }
-  else
-  {
-    L6208_SetDeviceParamsToGivenValues((l6208_Init_t*) pInit);
-  }
-  
-  /* Initialise the PWMs */
-  L6208_Board_VrefPwmInit(BRIDGE_A, devicePrm.vrefPwmPeriod);
-  L6208_Board_VrefPwmInit(BRIDGE_B, devicePrm.vrefPwmPeriod);
-
-  /* Initialise the tick */
-  L6208_Board_TickInit();
-  
-  /* Reset L6208 */
-  L6208_ResetDevice();
-  
-  /* Align motor mechanical position to driver position */
-  L6208_Board_VrefPwmStart(BRIDGE_A, devicePrm.vrefPwmPeriod);
-  L6208_Board_VrefPwmStart(BRIDGE_B, devicePrm.vrefPwmPeriod);
-  //L6208_Enable();
-  
-  return COMPONENT_OK;
-}
-
-/**********************************************************
- * @brief Read id
- * @param id pointer to the identifier to be read.
- * @retval COMPONENT_OK in case of success.
- **********************************************************/
-Status_t L6208::L6208_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 L6208::L6208_AttachErrorHandler(void (*callback)(uint16_t error))
-{
-  errorHandlerCallback = (void (*)(uint16_t error)) callback;
-}
-
-/******************************************************//**
- * @brief Disable the power bridges (leave the output bridges HiZ)
- * @retval None
- **********************************************************/
-void L6208::L6208_Disable(void)
-{
-  L6208_Board_Disable();
-  L6208_ClearSysFlag(EN_A_set);
-}
-
-/******************************************************//**
- * @brief Error handler which calls the user callback (if defined)
- * @param[in] error Number of the error
- * @retval None
- **********************************************************/
-void L6208::L6208_ErrorHandler(uint16_t error)
-{
-  if (errorHandlerCallback != 0)
-  {
-    errorHandlerCallback(error);
-  }
-  else   
-  {
-    while(1)
-    {
-      /* Infinite loop */
-    }
-  }
-}
-
-/******************************************************//**
- * @brief Enable the power bridges
- * @retval None
- **********************************************************/
-void L6208::L6208_Enable(void)
-{
-  L6208_Board_Enable();
-  L6208_SetSysFlag(EN_A_set);
-}
-
-/******************************************************//**
- * @brief Get the stepper acceleration rate
- * in step/s^2 for full, half and wave modes
- * in microsteps/s^2 for microstep modes
- * @retval the stepper acceleration rate in step/s^2 or microstep/s^2
- * @note
- **********************************************************/
-uint16_t L6208::L6208_GetAcceleration(void)
-{
-    return devicePrm.accelerationSps2;
-}
-
-/******************************************************//**
- * @brief Get the current speed
- * in step/s for full, half and wave modes
- * in microsteps/s for microstep modes
- * @retval return the current speed in step/s or microstep/s
- * @note
- **********************************************************/
-uint16_t L6208::L6208_GetCurrentSpeed(void)
-{
-  uint64_t tmp64 = (uint64_t) devicePrm.speedSpt * L6208_Board_TickGetFreq();
-  
-  devicePrm.speedSps = (uint16_t)(tmp64 >> 23);
-  if (devicePrm.speedSps & 0x1)
-  {
-    devicePrm.speedSps = (devicePrm.speedSps >> 1) + 1;
-  }
-  else
-  {
-    devicePrm.speedSps = devicePrm.speedSps >> 1;
-  }
-  return devicePrm.speedSps;
-}
-
-/******************************************************//**
- * @brief Get the motor decay mode
- * @retval decay mode
- **********************************************************/
-motorDecayMode_t L6208::L6208_GetDecayMode(void)
-{
-  if (L6208_IsSysFlag(fastdecaymode)) return (FAST_DECAY);
-  else return (SLOW_DECAY);
-}
-
-/******************************************************//**
- * @brief Get the stepper deceleration rate
- * in step/s^2 for full, half and wave modes
- * in microsteps/s^2 for microstep modes
- * @retval the stepper deceleration rate in step/s^2 or microstep/s^2
- * @note
- **********************************************************/
-uint16_t L6208::L6208_GetDeceleration(void)
-{
-    return devicePrm.decelerationSps2;
-}
-
-/******************************************************//**
- * @brief Get the motor current direction
- * @retval direction
- **********************************************************/
-motorDir_t L6208::L6208_GetDirection(void)
-{
-  if (L6208_IsSysFlag(forward))
-  {
-    return FORWARD;
-  }
-  else
-  {
-    return BACKWARD;
-  }
-}
-
-/******************************************************//**
- * @brief Return the FW version.
- * @retval FW version
- **********************************************************/
-uint32_t L6208::L6208_GetFwVersion(void)
-{
-  return L6208_FW_VERSION;
-}
-
-/******************************************************//**
- * @brief Get the mark position (32b signed) 
- * @retval mark position
- **********************************************************/
-int32_t L6208::L6208_GetMark(void)
-{
-  return devicePrm.markPos;
-}
-
-/******************************************************//**
- * @brief Get the max speed
- * in step/s for full, half and wave modes
- * in microsteps/s for microstep modes
- * @retval return the max speed in step/s or microstep/s
- * @note
- **********************************************************/
-uint16_t L6208::L6208_GetMaxSpeed(void)
-{
-  return devicePrm.maxSpeedSps;
-}
-
-/******************************************************//**
- * @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 L6208::L6208_GetMinSpeed(void)
-{
-  return devicePrm.minSpeedSps;
-}
-
-/******************************************************//**
- * @brief Get the stepper state machine index
- * @retval one of the stepper state machine index in the motorState_t enum
- **********************************************************/
-motorState_t L6208::L6208_GetMotionState(void)
-{
-  // gets the new stepper state machine index
-  return devicePrm.motionState;    
-}
-
-/******************************************************//**
- * @brief Get the current position (32b signed) 
- * @retval current absoulte position
- **********************************************************/
-int32_t L6208::L6208_GetPosition(void)
-{
-  return devicePrm.absolutePos;
-}
-
-/******************************************************//**
- * @brief Get the motor step mode
- * @retval step mode
- **********************************************************/
-motorStepMode_t L6208::L6208_GetStepMode(void)
-{
-  return devicePrm.stepMode;
-}
-
-/******************************************************//**
- * @brief Get the selected stop mode
- * @retval the selected stop mode
- **********************************************************/
-motorStopMode_t L6208::L6208_GetStopMode(void)
-{
-  if (L6208_IsSysFlag(HiZstop) == FALSE)
-  {
-      return (HOLD_MODE);
-  }
-  else
-  {
-      return (HIZ_MODE);
-  }
-}
-
-/******************************************************//**
- * @brief Go to the home position
- * @retval None
- **********************************************************/
-void L6208::L6208_GoHome(void)
-{
-  L6208_GoTo(0);
-}
-
-/******************************************************//**
- * @brief Go to the Mark position
- * @retval None
- **********************************************************/
-void L6208::L6208_GoMark(void)
-{
-  L6208_GoTo(devicePrm.markPos);
-}
-
-/******************************************************//**
- * @brief Move the motor to the absolute position using the shortest path
- * @param[in] abs_pos 32 bit signed value position
- * @retval None
- * @note The position is at the resolution corresponding to the
- * selected step mode.
- * STEP_MODE_FULL or STEP_MODE_WAVE : 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 
- **********************************************************/
-void L6208::L6208_GoTo(int32_t abs_pos)
-{
-  uint32_t steps = 0;
-  
-  if(L6208_IsSysFlag(running))
-  {
-    L6208_HardStop();
-  }
-  
-  if (abs_pos > devicePrm.absolutePos)
-  {
-    steps = abs_pos - devicePrm.absolutePos;
-    if (steps < (L6208_POSITION_RANGE>>1))
-    {
-      L6208_Move(FORWARD, steps);
-    }
-    else
-    {
-      L6208_Move(BACKWARD, (L6208_POSITION_RANGE - steps));
-    }
-  }
-  else
-  {
-    steps = devicePrm.absolutePos - abs_pos;
-    if (steps < (L6208_POSITION_RANGE>>1))
-    {
-      L6208_Move(BACKWARD, steps);
-    }
-    else
-    {
-      L6208_Move(FORWARD, (L6208_POSITION_RANGE - steps));
-    }
-  }
-}
-
-/******************************************************//**
- * @brief Move the motor to the absolute position
- * @param[in] direction FORWARD or BACKWARD
- * @param[in] abs_pos 32 bit signed value position
- * @retval None
- * @note The position is at the resolution corresponding to the
- * selected step mode.
- * STEP_MODE_FULL or STEP_MODE_WAVE : 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 
- **********************************************************/
-void L6208::L6208_GoToDir(motorDir_t direction, int32_t abs_pos)
-{
-  uint32_t steps = 0;
-  
-  if(L6208_IsSysFlag(running))
-  {
-    L6208_HardStop();
-  }
-  
-  if (direction != BACKWARD)
-  {
-    if (abs_pos > devicePrm.absolutePos)
-    {
-      steps = abs_pos - devicePrm.absolutePos;
-    }
-    else
-    {
-      steps = L6208_POSITION_RANGE + (abs_pos - devicePrm.absolutePos);
-    }
-  }
-  else
-  {
-    if (abs_pos > devicePrm.absolutePos)
-    {
-      steps = L6208_POSITION_RANGE + (devicePrm.absolutePos - abs_pos);
-    }
-    else
-    {
-      steps = devicePrm.absolutePos - abs_pos;
-    }
-  }
-  L6208_Move(direction, steps);
-}
-
-/******************************************************//**
- * @brief Immediately stop the motor and disables the power bridges
- * @retval None
- **********************************************************/
-void L6208::L6208_HardHiZ(void)
-{
-  /* Disables power stage */
-  L6208_Disable();
-  
-  /* Sets inactive state */
-  L6208_SetMotionState(INACTIVE);
-  
-  /* Clears the running motor and the position */
-  L6208_ClearSysFlag(running);
- 
-  /* Disables PWMs */
-  L6208_Board_VrefPwmStop(BRIDGE_A);
-  L6208_Board_VrefPwmStop(BRIDGE_B);
-  
-  /* Disables tick timer */
-  L6208_Board_TickStop();
-}
-
-/******************************************************//**
- * @brief Immediately stop the motor and keeps holding torque
- * @retval None
- **********************************************************/
-void L6208::L6208_HardStop(void) 
-{
-  /* Sets inactive state */
-  L6208_SetMotionState(INACTIVE);
-  
-  /* Clears the running motor and the position */
-  L6208_ClearSysFlag(running);
-  L6208_VectorCalc(devicePrm.holdTorque);
-    
-  /* Disables tick timer */
-  L6208_Board_TickStop();
-}
-
-/******************************************************//**
- * @brief Move the motor by the specified number of steps
- * in the specified direction
- * @param[in] direction FORWARD or BACKWARD
- * @param[in] stepCount 32 bit unsigned step count
- * @retval None
- * @note The step count resolution is corresponding to the
- * selected step mode.
- * STEP_MODE_FULL or STEP_MODE_WAVE : 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 
- **********************************************************/
-void L6208::L6208_Move(motorDir_t direction, uint32_t stepCount)
-{
-  if(L6208_IsSysFlag(running))
-  {
-    L6208_HardStop();
-  }
-
-  /* clear the velocity driving mode flag */
-  L6208_ClearSysFlag(velocitymode);
-  
-  /* Set the indexing driving mode flag */
-  /* and the user command executing flag */
-  L6208_SetSysFlag(positionmode);
-  
-  /* store relative number of steps to move */
-  devicePrm.positionTarget = stepCount;
-
-  L6208_SetDirection(direction); 
-  
-  /* Motor activation */
-  L6208_StartMovement(); 
-}
-
-/******************************************************//**
- * @brief  Release the L6208 reset (Reset pin set to high level)
- * @retval None
- **********************************************************/
-void L6208::L6208_ReleaseReset(void)
-{ 
-  L6208_Board_ReleaseReset(); 
-}
-
-/******************************************************//**
- * @brief Reset the L6208 (Reset pin set to low level)
- * @retval None
- **********************************************************/
-void L6208::L6208_Reset(void)
-{
-  L6208_Board_Reset();
-}
-
-
-/******************************************************//**
- * @brief Call L6208_SetStepMode with current step mode, 
- * the L6208_SetStepMode function along with setting the step mode resets
- * the L6208 device
- * @retval None
- **********************************************************/
-void L6208::L6208_ResetDevice(void)
-{
-  L6208_SetStepMode(L6208_GetStepMode());
-}
-
-/******************************************************//**
- * @brief Run the motor in the specified direction
- * according to the speed profile defined by the minimum speed,
- * maximum speed, and acceleration parameters. 
- * The device accelerates from the minimum speed up to the maximum
- * speed by using the device acceleration.
- * @param[in] direction FORWARD or BACKWARD
- * @retval None
- **********************************************************/
-void L6208::L6208_Run(motorDir_t direction)
-{
-  if(L6208_IsSysFlag(running))
-  {
-    L6208_HardStop();
-  }
-  L6208_SetDirection(direction);
-  /* Clear the indexing driving mode flag */
-  L6208_ClearSysFlag(positionmode);
-  /* Set the velocity driving mode flag */
-  L6208_SetSysFlag(velocitymode);
-  /* Motor activation */
-  L6208_StartMovement(); 
-}
-
-/******************************************************//**
- * @brief Set the stepper acceleration rate
- * in step/s^2 and step/tick^2 for full, half and wave modes
- * in microsteps/s^2 and microsteps/tick^2 for microstep modes
- * @param[in] newAcc new acceleration rate in step/s^2 or microstep/s^2
- * @retval TRUE
- * @note
- **********************************************************/
-bool L6208::L6208_SetAcceleration(uint16_t newAcc)
-{
-  uint16_t newAccSpt2 = L6208_ConvertAcceDecelRateValue(newAcc);
-  if (newAccSpt2)
-  {
-    devicePrm.accelerationSps2 = newAcc;
-    devicePrm.accelerationSpt2 = newAccSpt2; 
-  }
-  else
-  {
-    L6208_ErrorHandler(L6208_ERROR_SET_ACCELERATION);
-  }
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Select the motor decay mode
- * @param[in] decayMode (SLOW_DECAY or FAST_DECAY)
- * @retval None
- **********************************************************/
-void L6208::L6208_SetDecayMode(motorDecayMode_t decayMode)
-{
-  if ((decayMode & L6208_FAST_DECAY_MODE_MASK) == L6208_FAST_DECAY_MODE_MASK)
-  {
-    L6208_Board_CONTROL_PIN_Set();
-    L6208_SetSysFlag(fastdecaymode);
-  }
-  else 
-  {
-    L6208_Board_CONTROL_PIN_Reset();
-    L6208_ClearSysFlag(fastdecaymode);
-  }
-}
-
-/******************************************************//**
- * @brief Set the stepper deceleration rate
- * in step/s^2 and step/tick^2 for full, half and wave modes
- * in microsteps/s^2 and microsteps/tick^2 for microstep modes
- * @param[in] newDec new deceleration rate in step/s^2 or microstep/s^2
- * @retval TRUE
- * @note
- **********************************************************/
-bool L6208::L6208_SetDeceleration(uint16_t newDec)
-{
-  uint16_t newDecSpt2 = L6208_ConvertAcceDecelRateValue(newDec);
-  if (newDecSpt2)
-  {
-    devicePrm.decelerationSps2 = newDec;
-    devicePrm.decelerationSpt2 = newDecSpt2;
-  }
-  else
-  {
-    L6208_ErrorHandler(L6208_ERROR_SET_DECELERATION);
-  }
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Specify the direction
- * @param[in] dir FORWARD or BACKWARD
- * @note In velocity mode a direction change forces the device to stop and 
- * then run in the new direction. In position mode, if the device is 
- * running, a direction change will generate an error.
- * @retval None
- **********************************************************/
-void L6208::L6208_SetDirection(motorDir_t dir)
-{
-  L6208_ClearSysFlag(dir2change);
-  if (dir == FORWARD)
-  {
-    if (!L6208_IsSysFlag(forward))
-    {
-      if (L6208_IsSysFlag(running))
-      {
-        /* motor is running */
-        if (L6208_IsSysFlag(positionmode))
-        {
-          L6208_ErrorHandler(L6208_ERROR_SET_DIRECTION);
-        }
-        else
-        {
-          /* set the rotation direction to change flag */
-          L6208_SetSysFlag(dir2change);
-        }
-      }
-      else /* the motor is stopped, cw direction selected */
-      {
-        L6208_SetSysFlag(forward);
-        L6208_Board_DIR_PIN_Set();
-      }
-    }
-  }
-  else
-  {
-    if (L6208_IsSysFlag(forward))
-   {
-      if (L6208_IsSysFlag(running))
-      {
-        /* motor is running */
-        if (L6208_IsSysFlag(positionmode))
-        {
-          L6208_ErrorHandler(L6208_ERROR_SET_DIRECTION);
-        }
-        else
-        {
-          /* set the rotation direction to change flag */
-          L6208_SetSysFlag(dir2change);
-        }
-      }
-      else /* the motor is stopped, ccw direction selected */
-      {
-        L6208_ClearSysFlag(forward);
-        L6208_Board_DIR_PIN_Reset();
-      }
-    }
-  }
-  if(L6208_IsSysFlag(dir2change))
-  {
-    L6208_VectorCalc(devicePrm.decelTorque);     
-    L6208_SetMotionState(DECELERATINGTOSTOP);  
-  }
-}
-
-/******************************************************//**
- * @brief Set current position to be the home position
- * @retval None
- **********************************************************/
-void L6208::L6208_SetHome(void)
-{
-  if (!L6208_IsSysFlag(running))
-  {
-      devicePrm.absolutePos = 0;
-  }
-  else
-  {
-      L6208_ErrorHandler(L6208_ERROR_SET_HOME);
-  }
-}
-
-/******************************************************//**
- * @brief Set current position to be the mark position 
- * @retval None
- **********************************************************/
-void L6208::L6208_SetMark(void)
-{
-  devicePrm.markPos = devicePrm.absolutePos;
-}
-
-/******************************************************//**
- * @brief Set the user selected maximum speed 
- * in step/s and step/tick for full, half and wave modes
- * in microsteps/s and microsteps/tick for microstep modes
- * @param[in] newSpeed speed value (step/s or microstep/s)
- * @retval TRUE
- * @note One microstep is 1/16 step
- **********************************************************/
-bool L6208::L6208_SetMaxSpeed(uint16_t newSpeed)
-{
-  if (L6208_SetSpeed(newSpeed, &devicePrm.maxSpeedSpt))
-  {
-    devicePrm.maxSpeedSps = newSpeed;
-  }
-  else
-  {
-    L6208_ErrorHandler(L6208_ERROR_SET_MAX_SPEED);
-  }
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Set the user selected minimum speed 
- * in step/s and step/tick for full, half and wave modes
- * in microsteps/s and microsteps/tick for microstep modes
- * @param[in] newSpeed speed value (step/s or microstep/s)
- * @retval TRUE
- * @note One microstep is 1/16 step
- **********************************************************/
-bool L6208::L6208_SetMinSpeed(uint16_t newSpeed)
-{
-  if (L6208_SetSpeed(newSpeed, &devicePrm.minSpeedSpt))
-  {
-    devicePrm.minSpeedSps = newSpeed;
-  }
-  else
-  {
-    L6208_ErrorHandler(L6208_ERROR_SET_MIN_SPEED);
-  }
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Set the step mode
- * @param[in] stepMode
- * @retval true if the command is successfully executed, else false
- * @note Every time the step mode is changed, the step state machine is reset
- **********************************************************/
-bool L6208::L6208_SetStepMode(motorStepMode_t stepMode)
-{
-  devicePrm.stepMode = stepMode;
-  L6208_ClearSysFlag(fullstep | halfstep | microstep | wavestep);
-  switch (stepMode)
-  {
-    case STEP_MODE_HALF:
-      /* Set the Half/Full pin low and Reset and the set the Half/Full pin high*/
-      L6208_Board_HALF_FULL_PIN_Reset(); 
-      L6208_Board_Reset();
-      L6208_Board_HALF_FULL_PIN_Set();
-      /* Set system flag */
-      L6208_SetSysFlag(halfstep);
-      break;
-    case STEP_MODE_FULL:
-       /* Set the Half/Full pin low and Reset */
-      L6208_Board_HALF_FULL_PIN_Reset(); 
-      L6208_Board_Reset();
-      /* Set system flag */
-      L6208_SetSysFlag(fullstep);
-      break;
-    case STEP_MODE_WAVE:
-      /* Set the Half/Full pin low and Reset and the set the Half/Full pin high*/
-      L6208_Board_CLOCK_PIN_Reset();
-      L6208_Board_HALF_FULL_PIN_Reset();
-      L6208_Board_Reset();
-      L6208_Board_CLOCK_PIN_Set();
-      L6208_Board_HALF_FULL_PIN_Set();
-      L6208_Board_Delay(2);
-      L6208_Board_CLOCK_PIN_Reset();
-      L6208_Board_Delay(2);
-      L6208_Board_HALF_FULL_PIN_Reset();
-      /* Set system flag */
-      L6208_SetSysFlag(wavestep);
-      break;
-      case STEP_MODE_1_4:
-      /* Set the Half/Full pin low and Reset */
-      L6208_Board_HALF_FULL_PIN_Reset();
-      L6208_Board_Reset();
-      /* Set system flag */
-      L6208_SetSysFlag(microstep);
-      devicePrm.uStepInc = 4;
-      break;
-    case STEP_MODE_1_8:
-      /* Set the Half/Full pin low and Reset */
-      L6208_Board_HALF_FULL_PIN_Reset();
-      L6208_Board_Reset();
-      /* Set system flag */
-      L6208_SetSysFlag(microstep);
-      devicePrm.uStepInc = 2;
-      break;
-      case STEP_MODE_1_16:
-      /* Set the Half/Full pin low and Reset */
-      L6208_Board_HALF_FULL_PIN_Reset();
-      L6208_Board_Reset();
-      /* Set system flag */
-      L6208_SetSysFlag(microstep);
-      devicePrm.uStepInc = 1;
-      break;
-    default:
-      return FALSE;
-    }
-  L6208_Board_Delay(2);
-  L6208_Board_ReleaseReset();
-  L6208_ResetSteps();
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Select the mode to stop the motor. When the motor
- * is stopped, if autoHiZ is TRUE, the power bridges are disabled
- * if autoHiZ is FALSE, the power bridges are kept enabled.
- * @param[in] stopMode HOLD_MODE to let power bridge enabled
- * @retval None
- **********************************************************/
-void L6208::L6208_SetStopMode(motorStopMode_t stopMode)
-{
-  if (stopMode == HOLD_MODE)
-  {
-    L6208_ClearSysFlag(HiZstop);
-  }
-  else
-  {
-    L6208_SetSysFlag(HiZstop);
-  }
-}
-
-/******************************************************//**
- * @brief  Stop the motor by using the device deceleration and set deceleration torque
- * @retval true if the command is successfully executed, else false
- * @note .
- **********************************************************/
-bool L6208::L6208_SoftStop(void)
-{   
-  L6208_VectorCalc(devicePrm.decelTorque);
-  L6208_SetMotionState(DECELERATINGTOSTOP);
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief  Handle the device state machine at each tick timer pulse end.
- * @retval None
- **********************************************************/
-void L6208::L6208_TickHandler(void)
-{
-  uint32_t locMaxSpeedSpt = devicePrm.maxSpeedSpt;
-  uint32_t locMinSpeedSpt = devicePrm.minSpeedSpt;
-  
-  /* Update state, target speed, acceleration and deceleration rates */
-  L6208_Board_CLOCK_PIN_Reset();
-    
-  switch(L6208_GetMotionState())
-  {
-    /* ============ Velocity control mode states ======================== */
-    case ACCELERATING:
-      /* velocity mode: acceleration phase */
-      /* Increase Speed and update position */
-      L6208_DoAccel();
-      if(locMaxSpeedSpt < devicePrm.speedSpt)
-      {  
-        /*Target speed reached */
-        devicePrm.speedSpt = locMaxSpeedSpt;
-        L6208_VectorCalc(devicePrm.runTorque); 
-        L6208_SetMotionState(STEADY);
-      }
-      break;
-    case STEADY:  
-      /* velocity mode: constant speed phase */
-      /* Update position */
-      L6208_DoRun();  
-      if(locMaxSpeedSpt != devicePrm.speedSpt)
-      { 
-        /* targeted speed  has changed */
-        if(locMaxSpeedSpt< devicePrm.speedSpt)
-        { 
-          /* Slow down the motor */
-          L6208_VectorCalc(devicePrm.decelTorque);     
-          L6208_SetMotionState(DECELERATING); 
-        }
-        else
-        { 
-          /* speed up the motor */
-          L6208_VectorCalc(devicePrm.accelTorque);     
-          L6208_SetMotionState(ACCELERATING);
-        }
-      }
-      break;
-    case DECELERATING:  
-      /* velocity mode: running motor deceleration phase */
-      /* Decrease Speed and update position */
-      L6208_DoDecel();  
-      if(locMaxSpeedSpt > devicePrm.speedSpt)
-      { 
-        /*Target speed reached but motor has still to be run*/
-        devicePrm.speedSpt = locMaxSpeedSpt;
-        L6208_VectorCalc(devicePrm.runTorque);   
-        L6208_SetMotionState(STEADY);  
-      }
-      break;
-    case DECELERATINGTOSTOP: 
-      /* velocity mode: decelerate to stopped phase */
-      /* Decrease current speed */
-      L6208_DoDecel();
-      if(devicePrm.speedSpt == locMinSpeedSpt)
-      { 
-        if (L6208_IsSysFlag(dir2change))
-        { 
-          L6208_ClearSysFlag(running);
-          /* Change direction */
-          if (L6208_IsSysFlag(forward))
-          {
-            /* switch to reverse rotation */
-            L6208_SetDirection(BACKWARD);
-          }
-          else
-          {
-            /* switch to forward rotation */
-            L6208_SetDirection(FORWARD);
-          }
-          L6208_SetSysFlag(running);
-          L6208_SetMotionState(ACCELERATING);
-          /* Set VRefA and VRefB to the selected acceleration torque */
-          L6208_VectorCalc(devicePrm.accelTorque);
-        }
-        else
-        {
-          if (L6208_IsSysFlag(HiZstop))
-          { 
-            L6208_HardHiZ();
-          }
-          else
-          {
-            L6208_HardStop();
-          }
-        }
-      }
-      break;
-    
-    /* ============ Position (indexed) control mode states ======================== */
-
-    case INDEX_ACCEL:
-      /*  position mode: acceleration state*/
-      
-      /* Increase Speed and update position */
-      L6208_DoAccel();  
-
-      if(devicePrm.positionTarget1 <= devicePrm.step)
-      { 
-        /* End of acceleration phase */
-        L6208_VectorCalc(devicePrm.runTorque); 
-        L6208_SetMotionState(INDEX_RUN);    
-      }
-      break;
-
-      case INDEX_RUN:   
-        /* position mode: constant speed phase */
-        
-        /* Update position */
-        L6208_DoRun();  
-
-        if(devicePrm.positionTarget2 <= devicePrm.step)
-        {  
-          /* reach position targeted for constant speed */
-          L6208_VectorCalc(devicePrm.decelTorque);   
-          L6208_SetMotionState(INDEX_DECEL); 
-        }
-        break;
-
-      case INDEX_DECEL: 
-        /* position mode: deceleration phase */
-        
-        /* Decrease Speed and update position */
-        L6208_DoDecel();  
-
-        if(devicePrm.positionTarget3 <= devicePrm.step)
-        {  
-          /* reach position targeted for deceleration phase */
-          /* the motor terminated its run */
-          /* the torque will be the deceleration one */
-          devicePrm.step = devicePrm.positionTarget3;
-          L6208_SetMotionState(INDEX_DWELL);   
-        }
-        break;
-
-      case INDEX_DWELL: 
-        /* position mode: dwelling state */
-        if(devicePrm.dwellCounter > 0)
-        {
-          /* decrease the dwelling wait tick counter */
-          devicePrm.dwellCounter--;
-        }
-        if(devicePrm.dwellCounter == 0)
-        { 
-          /* dwelling wait time is elapsed */
-          /* so stop the motor */
-          if (L6208_IsSysFlag(HiZstop))
-          { 
-            L6208_HardHiZ();
-          }
-          else
-          {
-            L6208_HardStop();
-          }
-        }
-        break;
-        
-    /* ============ stopped state ======================== */
-    case INACTIVE:
-    {
-      if(L6208_IsSysFlag(running))
-      {
-        /* clear the user move command executing  */
-        /* and the motor running flags */
-        L6208_ClearSysFlag(running);
-      }
-      break;
-    }
-    default:
-      break;
-  } /* switch(L6208_GetMotionState()) */
-  if(L6208_GetMotionState() != INACTIVE)
-  {
-    if (L6208_IsSysFlag(microstep))
-    { 
-      /* Microstep handling */     
-      switch(devicePrm.uStepInc)
-      {
-        default:
-        case 1:  
-          /* 1 microstep increment */
-          devicePrm.lsbTicks = (uint8_t)(devicePrm.ticks>>16);
-          break;
-
-        case 2:  
-          /* 2 microsteps increment */           
-          devicePrm.lsbTicks = (uint8_t)(devicePrm.ticks>>17);
-          break;
-
-        case 4:  
-          /* 4 microsteps increment */
-          devicePrm.lsbTicks = (uint8_t)(devicePrm.ticks>>18);
-          break;
-      }
-      devicePrm.lsbTicks &= 0x01;
-      if(devicePrm.lsbOldUSteppingTicks != devicePrm.lsbTicks)
-      { 
-        /*  waveform sample to update */
-        devicePrm.lsbOldUSteppingTicks = devicePrm.lsbTicks;
-        devicePrm.step++;
-        if(L6208_IsSysFlag(forward))
-        { 
-          /* the motor is going forward */
-          devicePrm.absolutePos++;
-          /* Reset the absolute motor position in step/microsteps */
-          /* Get next microstep sample */
-          devicePrm.uStepSample += devicePrm.uStepInc;  
-          if(devicePrm.uStepSample > 31)
-          {
-            devicePrm.uStepSample = 0;
-          }
-        }
-        else
-        { 
-         /* the motor is going backward */
-          devicePrm.absolutePos--;
-          if(devicePrm.uStepSample >= devicePrm.uStepInc)
-          {
-            /* Get previous microstep sample */
-            devicePrm.uStepSample -= devicePrm.uStepInc; 
-          }
-          else
-          {
-            devicePrm.uStepSample = 32 - devicePrm.uStepInc;
-          }
-        }
-        /* set the PWM to update VRefs */
-        L6208_VrefPwmComputePulseWidth(BRIDGE_A, pMicroTable2[devicePrm.uStepSample], FALSE);
-        L6208_VrefPwmComputePulseWidth(BRIDGE_B, microTable1[devicePrm.uStepSample], FALSE);
-        if(devicePrm.uStepsample2update > 0)
-        { 
-          /*  the waveform samples table has been recalculated 
-          so update the waveform scanning table */
-          L6208_UpdateScanWaveformTable();
-          devicePrm.uStepsample2update = 0;
-        }
-      }
-      /* Microstep: use the bit4 toggling as step clock */
-      /* this bit is used because there are 16 microstep samples per quarter period */
-      devicePrm.lsbTicks = (uint8_t)((devicePrm.uStepSample>>4) & 0x01);
-      if(devicePrm.lsbOldTicks != devicePrm.lsbTicks)
-      { 
-        /* the selected bit status changed ==> get the next motor step
-        save the current masked motor tick position for step setting scope ... */
-        devicePrm.lsbOldTicks = devicePrm.lsbTicks;
-        L6208_Board_CLOCK_PIN_Set();
-      }
-    }
-    else
-    {
-      /* Full and half step handling code */ 
-      if(!L6208_IsSysFlag(halfstep))
-      { 
-        /* Full step: use the bit 16 toggling as step clock */
-        devicePrm.lsbTicks = (uint8_t)((devicePrm.ticks>>16) & 0x00000001);
-      }
-      else
-      { 
-        /* half step: use the bit 15 toggling as step clock */
-        devicePrm.lsbTicks = (uint8_t)((devicePrm.ticks>>15) & 0x00000001);
-      }
-      if(devicePrm.lsbOldTicks != devicePrm.lsbTicks)
-      { 
-        /* the selected bit status changed ==> get the next motor step */
-        devicePrm.step++;
-        if(L6208_IsSysFlag(forward))
-        { 
-          /* the motor is going forward */
-          devicePrm.absolutePos++;
-        }
-        else
-        {
-          /* the motor is going backward */
-          devicePrm.absolutePos--;          
-        }
-        /* save the current masked motor tick position for step setting scope ... */
-        devicePrm.lsbOldTicks = devicePrm.lsbTicks;
-        L6208_Board_CLOCK_PIN_Set();
-      }
-    }
-  }
-  L6208_UstepWaveformHandling();
-  L6208_VrefPwmUpdatePulseWidth();
-}
-
-/******************************************************//**
- * @brief Get the frequency of VREFA and VREFB PWM
- * @retval the frequency of VREFA and VREFB PWM in Hz
- * @note
- **********************************************************/
-uint32_t L6208::L6208_VrefPwmGetFreq(void)
-{
-  return devicePrm.vrefPwmFreq;
-}
-
-/******************************************************//**
- * @brief Set the frequency of the VREFA and VREFB PWM
- * @param[in] newFreq in Hz
- * @retval None
- * @note
- **********************************************************/
-void L6208::L6208_VrefPwmSetFreq(uint32_t newFreq)
-{
-  devicePrm.vrefPwmFreq = newFreq;
-  /* Compute the pwm period in 1/256th of a microsecond */
-  devicePrm.vrefPwmPeriod = (uint16_t)((1000000<<8)/newFreq);
-  /* Re-Initialise the PWMs -----------------------------------------------------*/
-  L6208_Board_VrefPwmInit(BRIDGE_A, devicePrm.vrefPwmPeriod);
-  L6208_Board_VrefPwmInit(BRIDGE_B, devicePrm.vrefPwmPeriod);
-  /* Recompute the waveform samples according to the new PWM frequency */
-  L6208_ScaleWaveformTable();
-  /* Update the waveform scanning table */
-  L6208_UpdateScanWaveformTable();
-  if (L6208_IsSysFlag(running))
-  {
-    L6208_Board_VrefPwmStart(BRIDGE_A, devicePrm.vrefPwmPeriod);
-    L6208_Board_VrefPwmStart(BRIDGE_B, devicePrm.vrefPwmPeriod);
-  }
-}
-
-/******************************************************//**
- * @brief Lock while motor is running
- * @retval None
- **********************************************************/
-void L6208::L6208_WaitWhileActive(void)
-{
-  /* Wait while motor is running */
-  while (L6208_IsSysFlag(running));
-}
-
-/* ------------------------------------------------------------------------- */
-/* Private functions ------------------------------------------------------- */
-/* ------------------------------------------------------------------------- */
-/******************************************************//**
- * @brief Clear the bit/s of flags according to the specified mask
- * @param[in] mask flag bit mask
- * @retval None
- **********************************************************/
-inline void L6208::L6208_ClearSysFlag(uint32_t mask)
-{
-  devicePrm.flags &= ~mask;    
-}
-
-/******************************************************//**
- * @brief Compute the number of steps at the end of the accereration/deceleration phase
- * P = position in steps at the end of the acceleration/deceleration phase
- * T = acceleration/deceleration time in seconds
- * A =  acceleration/deceleration rate in steps per second per second (steps/sec^2)
- * V = peak velocity during acceleration/deceleration phase
- * V1 = average velocity during acceleration/deceleration phase
- * T = V/A
- * V1 = V/2
- * P = V1*T
- * P = V^2/2A
- * @param  accOrDecRate acceleration/deceleration rate in steps per second per second (steps/sec^2)
- * @retval end position or 0xFFFFFFFF on error 
- **********************************************************/
-uint32_t L6208::L6208_ComputeNbAccOrDecSteps(uint16_t accOrDecRate)
-{
-  uint32_t nbAccOrDecSteps;
-  uint32_t locMaxSpeedSps = (uint32_t)devicePrm.maxSpeedSps;
-  
-  if (L6208_IsSysFlag(microstep))
-  {
-    switch(devicePrm.uStepInc)
-    {
-      case 1:  
-        locMaxSpeedSps = (uint32_t)devicePrm.maxSpeedSps;
-        break;
-      case 2:            
-        locMaxSpeedSps = ((uint32_t)devicePrm.maxSpeedSps)>>1;
-        accOrDecRate >>= 1;
-        break;
-      case 4:  
-        locMaxSpeedSps = ((uint32_t)devicePrm.maxSpeedSps)>>2;
-        accOrDecRate >>= 2;
-        break;
-      default:
-        break;
-    }
-  }
-  else if (L6208_IsSysFlag(halfstep))
-  {
-    locMaxSpeedSps = ((uint32_t)devicePrm.maxSpeedSps)<<1;
-    accOrDecRate <<= 1;
-  }
-  
-  if(accOrDecRate == 0)
-  {
-    /* division by 0 error */
-    return 0xFFFFFFFF;
-  }
-  nbAccOrDecSteps = locMaxSpeedSps * locMaxSpeedSps;
-  nbAccOrDecSteps /= (uint32_t)accOrDecRate;
-  nbAccOrDecSteps /= 2;
-
-  return nbAccOrDecSteps;
-}
-
-/******************************************************//**
- * @brief Compute the acceleration/deceleration speed increment value
- * @param[in] newAccOrDecRate acceleration or deceleration value (steps/s^2) greater or equal than 24
- * @retval the speed (step/tick) increment value
- * LSB = 2^-24 step/tick^2 or 2^-20 microstep/tick^2
- * @note return 0 if the rate is too low or if the tick frequency is too small
- * or if the device is running in position mode
- **********************************************************/
-uint16_t L6208::L6208_ConvertAcceDecelRateValue(uint16_t newAccOrDecRate)
-{
-  uint64_t tmp64;
-  uint32_t tmp32;
-
-  if (((L6208_IsSysFlag(running))&&(L6208_IsSysFlag(positionmode)))||\
-      (newAccOrDecRate < L6208_MIN_ACC_DEC_RATE))
-  {
-    return 0;
-  } 
-  /* Compute (tick frequency)^2 */
-  tmp32 = (uint32_t)L6208_Board_TickGetFreq();
-  tmp32 *= tmp32;
-  /* Return 0 if the (tick frequency)^2 is too small */
-  if ( tmp32 < (uint32_t)newAccOrDecRate )
-  {
-    return 0;
-  } 
-  /* Compute the decimal number of microstep or step per tick^2 */
-  /* Decimal part is on 32 bits */
-  tmp64 = (uint64_t)newAccOrDecRate << 32;
-  tmp64 /= ((uint64_t)tmp32);
-
-  return (uint16_t)((tmp64 & 0x00000000FFFFFFFF)>>8);
-}
-
-/******************************************************//**
- * @brief Compute next position and speed according to the acceleration rate
- * @retval None
- **********************************************************/
-void L6208::L6208_DoAccel(void)
-{
-  /* Increase speed by acceleration rate */
-  uint32_t locAccelerationSpt2 = (uint32_t)devicePrm.accelerationSpt2;
-  uint32_t locMinSpeedSpt = devicePrm.minSpeedSpt;
-  if ((devicePrm.speedSpt + locAccelerationSpt2) < locMinSpeedSpt)
-  {
-    devicePrm.speedSpt = locMinSpeedSpt;
-  }
-  else
-  {
-    devicePrm.speedSpt += locAccelerationSpt2;
-  }
-  /* Compute next position */
-  L6208_DoRun();
-}
-
-/******************************************************//**
- * @brief Compute next position and speed according to the deceleration rate
- * @retval None
- **********************************************************/
-void L6208::L6208_DoDecel(void)
-{
-  /* Decrease current speed by deceleration rate */
-  uint32_t locDecelerationSpt2 = (uint32_t)devicePrm.decelerationSpt2;
-  uint32_t locMinSpeedSpt = devicePrm.minSpeedSpt;
-  if((devicePrm.speedSpt - locMinSpeedSpt) > (uint32_t)locDecelerationSpt2)  
-  {
-    devicePrm.speedSpt -= (uint32_t)locDecelerationSpt2;
-  }
-  else
-  {
-    /* Set minimum speed */
-    devicePrm.speedSpt = locMinSpeedSpt;
-  }
-  /* Compute next position */
-  L6208_DoRun(); 
-}
-
-/******************************************************//**
- * @brief Compute next position by adding current speed
- * @retval None
- **********************************************************/
-void L6208::L6208_DoRun(void)
-{
-  devicePrm.ticks += (devicePrm.speedSpt >> 8) & 0x0000FFFF;
-}
-
-/******************************************************//**
- * @brief Get number of samples to rescale
- * @retval uStepsample2scale the number of micro stepping waveform samples to rescale
- **********************************************************/
-uint8_t L6208::L6208_GetMicrostepSample2Scale(void)
-{
-  return devicePrm.uStepsample2scale;
-}
-
-/******************************************************//**
- * @brief  Initialize the system for position mode motor moving command
- *  P = total move distance in steps
- *  P1 = steps required to accel from 0 to V
- *  P2 = steps required to decel from V to 0
- *  V = peak velocity in steps per second (steps/sec)
- *  V1 = average velocity during accel or decel*
- *  A = required accel rate in steps per second per second (steps/sec2)
- *  D = required decel rate in steps per second per second (steps/sec2)
- *  T1 = acceleration time in seconds
- *  T2 = deceleration time in seconds*
- *
- *  1) T1 = V / A
- *  2) V1 = V / 2
- *  3) P1 = V1 T1
- *  Substituting 1 and 2 into 3 yields:
- *  4) P1 = V2 / 2A
- *  In the same manner we have:
- *  5) P2 = V2 / 2D
- *
- *  P1 = PD/(D+A)
- *
- *  \sa Application Note: AN2044  
- * @retval None
- **********************************************************/
-void L6208::L6208_Indexmodeinit(void)
-{
-  uint32_t tmpVal0;
-  uint32_t tmpVal1;
-  uint32_t locAccelSteps;
-  uint32_t locDecSteps;
-
-  /* calculate the number of steps to get the running speed */
-  locAccelSteps = L6208_ComputeNbAccOrDecSteps(devicePrm.accelerationSps2);
-  /* calculate the number of steps to get the motor stopped */
-  locDecSteps = L6208_ComputeNbAccOrDecSteps(devicePrm.decelerationSps2);
-  if(( locAccelSteps + locDecSteps ) > devicePrm.positionTarget)
-  { 
-    /* Triangular move needed */
-    /* accelsteps = P1 = PD/(D+A) */
-    tmpVal0 = devicePrm.positionTarget * devicePrm.decelerationSps2;
-    tmpVal1 = (uint32_t)devicePrm.decelerationSps2;
-    tmpVal1 += (uint32_t)devicePrm.accelerationSps2;
-    locAccelSteps = tmpVal0 / tmpVal1;
-    devicePrm.positionTarget1 = locAccelSteps;
-    devicePrm.positionTarget2 = devicePrm.positionTarget1 + 1;
-    devicePrm.positionTarget3 = devicePrm.positionTarget;
-    if(devicePrm.positionTarget1 == 0)
-    {
-      devicePrm.positionTarget1 = 1;
-    }
-  }
-  else
-  {  
-    /* trapezoidal move needed */
-    /* P1 = V^2/2A */
-    /* P2 = P - V^2/2D */
-    devicePrm.positionTarget1 = locAccelSteps;
-    devicePrm.positionTarget2 = devicePrm.positionTarget - locDecSteps;
-    devicePrm.positionTarget3 = devicePrm.positionTarget;
-  }
-  L6208_SetMotionState(INDEX_ACCEL);  
-}
-
-/******************************************************//**
- * @brief Check the bit/s of flags according to the specified mask
- * @param[in] mask flag bit mask
- * @retval TRUE if the bit of the mask are set
- **********************************************************/
-inline bool L6208::L6208_IsSysFlag(uint32_t mask)
-{
-  return (bool)((devicePrm.flags & mask) == mask);    
-}
-
-/******************************************************//**
- * @brief Stepper driver device step state reset subroutine
- * @retval None
- **********************************************************/
-void L6208::L6208_ResetSteps(void)
-{
-  devicePrm.speedSpt = 0;             // reset the current speed value
-  devicePrm.ticks = 0;                // reset the current ticks counter value
-  devicePrm.step = 0;                 // reset the current step counter value
-  devicePrm.lsbOldTicks = 0;          // reset copy of the previous position (tick)
-  devicePrm.lsbOldUSteppingTicks = 0; // reset copy of the previous position (tick) ( micro stepping )
-  devicePrm.lsbTicks = 0;             // reset copy of the current position (tick)
-  devicePrm.absolutePos = 0;          // reset the absolute motor position in step/microsteps
-  devicePrm.uStepSample = 0;          // reset the microstepping waveform sample index
-}
-
-/******************************************************//**
- * @brief Compute the specified micro stepping waveform sample with the
- * current selected torque and pwm period
- * @param[in] sampleIndex sample Index
- * @retval scaled sample value
- **********************************************************/
-uint32_t L6208::L6208_ScaleWaveformSample(uint8_t sampleIndex)
-{
-  uint32_t sample;
-
-  sample = (uint32_t)RefMicroTable[sampleIndex];
-  sample *= devicePrm.vrefPwmPeriod;
-  sample >>= (uint32_t)L6208_SINE_WAVEFORM_POWER_OF_TWO_MAX_VALUE;
-  
-  sample *= (uint32_t)devicePrm.curTorqueScaler; // torque val (%)
-  sample /= (uint32_t)100;
-  
-  return sample;
-}
-
-/******************************************************//**
- * @brief Compute the micro stepping waveform sample table samples with the
- * current selected torque and pwm period
- * @retval None
- **********************************************************/
-void L6208::L6208_ScaleWaveformTable(void)
-{
-  uint8_t index;
-  for(index=0; index<=L6208_USTEPS_PER_QUARTER_PERIOD; index++)
-  { 
-    /* Calculate the scaled sample and save its value into the waveform to update table */
-    updatedMicroTable[index] = (uint16_t)L6208_ScaleWaveformSample(index);
-  }
-}
-
-/******************************************************//**
- * @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 L6208::L6208_SetDeviceParamsToGivenValues(l6208_Init_t* pInitDevicePrm)
-{
-  memset(&devicePrm, 0, sizeof(devicePrm));
-  L6208_SetAcceleration(pInitDevicePrm->accelerationSps2);
-  L6208_SetDeceleration(pInitDevicePrm->decelerationSps2);
-  L6208_SetMaxSpeed(pInitDevicePrm->maxSpeedSps);
-  L6208_SetMinSpeed(L6208_MIN_SPEED);
-  devicePrm.accelTorque = pInitDevicePrm->accelTorque;
-  devicePrm.decelTorque = pInitDevicePrm->decelTorque;
-  devicePrm.runTorque = pInitDevicePrm->runTorque;
-  devicePrm.holdTorque = pInitDevicePrm->holdTorque;
-  /* Only once acceleration, deceleration, min speed and max speed have been */
-  /* initialized, set the step mode */
-  devicePrm.stepMode = pInitDevicePrm->stepMode;
-  L6208_SetDecayMode(pInitDevicePrm->decayMode);
-  devicePrm.moveDwellTime = pInitDevicePrm->moveDwellTime;
-  if (L6208_CONF_PARAM_AUTO_HIZ_STOP) L6208_SetSysFlag(pInitDevicePrm->autoHiZstop);
-  devicePrm.vrefPwmFreq = pInitDevicePrm->vrefPwmFreq;
-  devicePrm.vrefPwmPeriod = (uint16_t)((1000000<<8)/pInitDevicePrm->vrefPwmFreq);
-  /* Initialize current stepper state machine index  */
-  L6208_SetMotionState(INACTIVE);
-}
-
-/******************************************************//**
- * @brief  Set the parameters of the device to predefined values
- * Set GPIO according to these values
- * from l6208_target_config.h
- * @retval None
- **********************************************************/
-void L6208::L6208_SetDeviceParamsToPredefinedValues(void)
-{
-  memset(&devicePrm, 0, sizeof(devicePrm));
-  L6208_SetAcceleration(L6208_CONF_PARAM_ACC_RATE);
-  L6208_SetDeceleration(L6208_CONF_PARAM_DEC_RATE);
-  L6208_SetMaxSpeed(L6208_CONF_PARAM_RUNNING_SPEED);
-  L6208_SetMinSpeed(L6208_MIN_SPEED);
-  devicePrm.accelTorque = L6208_CONF_PARAM_ACC_CURRENT;
-  devicePrm.decelTorque = L6208_CONF_PARAM_DEC_CURRENT;
-  devicePrm.runTorque = L6208_CONF_PARAM_RUNNING_CURRENT;
-  devicePrm.holdTorque = L6208_CONF_PARAM_HOLDING_CURRENT;
-  /* Only once acceleration, deceleration, min speed and max speed have been */
-  /* initialized, set the step mode */
-  devicePrm.stepMode = (motorStepMode_t) L6208_CONF_PARAM_STEP_MODE;
-  L6208_SetDecayMode(L6208_CONF_PARAM_DECAY_MODE);
-  devicePrm.moveDwellTime = L6208_CONF_PARAM_DWELL_TIME;
-  if (L6208_CONF_PARAM_AUTO_HIZ_STOP) L6208_SetSysFlag(HiZstop);
-  devicePrm.vrefPwmFreq = L6208_CONF_VREF_PWM_FREQUENCY;
-  devicePrm.vrefPwmPeriod = (uint16_t)((1000000<<8)/L6208_CONF_VREF_PWM_FREQUENCY);
-  /* Initialize current stepper state machine index  */
-  L6208_SetMotionState(INACTIVE);
-}
-
-/******************************************************//**
- * @brief Set the number of micro stepping waveform samples to rescale
- * @param[in] value number of micro stepping waveform samples 
- * @retval None
- **********************************************************/
-void L6208::L6208_SetMicrostepSample2Scale(uint8_t value)
-{
-  if(value > L6208_USTEPS_PER_QUARTER_PERIOD)
-  {
-    value = L6208_USTEPS_PER_QUARTER_PERIOD;  // clamp to maximum number of samples per period/4
-  }
-  devicePrm.uStepsample2scale = value;    
-}
-
-/******************************************************//**
- * @brief Set the number of micro stepping waveform samples to update into scanning
- * @param[in] value number of micro stepping waveform samples 
- * @retval None
- **********************************************************/
-void L6208::L6208_SetMicrostepSample2Update(uint8_t value)
-{
-  // clamp to maximum number of samples per period/4
-  if(value > L6208_USTEPS_PER_QUARTER_PERIOD)
-  {
-    value = L6208_USTEPS_PER_QUARTER_PERIOD;  
-  }
-  // copy the stepper acceleration rate
-  devicePrm.uStepsample2update = value;    
-}
-
-/******************************************************//**
- * @brief Set the stepper state machine index
- * @param[in] newMotionState
- * @retval None
- **********************************************************/
-void L6208::L6208_SetMotionState(motorState_t newMotionState)
-{
-  // sets the new stepper state machine index
-  devicePrm.motionState = newMotionState;    
-}
-
-/******************************************************//**
- * @brief Set the user selected speed in step/tick
- * @param[in] newSpeed speed value (step/s)
- * @param[in] pSpeed pointer to the selected speed field
- * @retval return FALSE if the speed is too low or too high
- * or if the device is running in position mode, else TRUE
- **********************************************************/
-bool L6208::L6208_SetSpeed(uint16_t newSpeed, uint32_t volatile *pSpeed)
-{
-  uint64_t tmp64;
-  uint32_t tmp32;
-
-  if (((L6208_IsSysFlag(running))&&(L6208_IsSysFlag(positionmode)))||\
-      (newSpeed < L6208_MIN_SPEED))
-  {
-    return FALSE;
-  }
-  tmp32 = (uint32_t)L6208_Board_TickGetFreq();
-  if (tmp32 < newSpeed)
-  {
-    return FALSE;
-  }
-  /* Compute the decimal number of microstep or step per tick */
-  /* Decimal part is on 32 bits */
-  tmp64 = (uint64_t)newSpeed << 32;
-  tmp64 /= ((uint64_t)tmp32);
-  /* set the running constant speed value (step/tick) */
-  *pSpeed = (uint32_t)((tmp64 & 0x00000000FFFFFFFF)>>8);
-  
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Set the bit/s of flags according to the specified mask
- * @param[in] mask flag bit mask
- * @retval None
- **********************************************************/
-inline void L6208::L6208_SetSysFlag(uint32_t mask)
-{
-  devicePrm.flags |= mask;    
-}
-
-/******************************************************//**
- * @brief Stepper motor start command
- * @retval true on correct command execution
- **********************************************************/
-bool L6208::L6208_StartMovement(void)
-{
-  uint32_t tmp;
-  if (L6208_IsSysFlag(running))
-  {
-    /* Motor is already running ==> quit */
-    return FALSE;    
-  }
-  if (!L6208_IsSysFlag(positionmode))
-  {
-    /* Set the VREFA and VREFB to the selected acc. torque */
-    L6208_VectorCalc(devicePrm.accelTorque);
-    
-    /* If the speed control mode is selected */
-    /* setup the motor acceleration for velocity mode driving */
-    L6208_SetMotionState(ACCELERATING);  
-  }
-  else
-  {  
-    /* if position control mode is selected, reset the current step counter  */
-    devicePrm.step = 0;    
-    if(devicePrm.uStepSample > 31)
-    {
-      /* check the micro stepping waveform sample index */
-      devicePrm.uStepSample = 0;
-    }
-    /* Set the position dwelling wait time */
-    /* compute number of ticks per millisecond */
-    tmp = (uint32_t)L6208_Board_TickGetFreq() / 1000;
-    /* Compute the dwelling time in ticks => dwellCounter (ticks) */
-    devicePrm.dwellCounter = tmp * (uint32_t)devicePrm.moveDwellTime;
-    if (devicePrm.positionTarget == 0)
-    {
-      /* if the position to go is 0 (no move) */
-      /* Set the deceleration torque */
-      L6208_VectorCalc(devicePrm.decelTorque); 
-      /* Set the dwelling delay state index */
-      L6208_SetMotionState(INDEX_DWELL);       
-    }
-    else
-    {
-      /* Set the VREFA and VREFB to the selected acc. torque */
-      L6208_VectorCalc(devicePrm.accelTorque);
-      /* go to the selected position */
-      L6208_Indexmodeinit();
-      L6208_SetMotionState(INDEX_ACCEL);
-    }
-  }
-  /* Sets the motor running flag */
-  L6208_SetSysFlag(running);
-  /* Start the VREFA and VREFB PWMs */
-  L6208_Board_VrefPwmStart(BRIDGE_A, devicePrm.vrefPwmPeriod);
-  L6208_Board_VrefPwmStart(BRIDGE_B, devicePrm.vrefPwmPeriod);
-  if (!(L6208_IsSysFlag(EN_A_set)))
-  {
-    /* Enable power bridges */
-    L6208_Enable();
-  }
-  /* Start the tick */
-  L6208_Board_TickStart(L6208::tickFreq);
-  
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Update the micro stepping waveform samples table with the
- * values previously scaled with current selected torque and tick period
- * @retval None
- **********************************************************/
-void L6208::L6208_UpdateScanWaveformTable(void)
-{
-  uint8_t index;
-
-  for(index=0; index<=L6208_USTEPS_PER_QUARTER_PERIOD; index++)
-  {
-    microTable1[index] = updatedMicroTable[index];
-    microTable1[L6208_USTEPS_PER_QUARTER_PERIOD*2 - index] = microTable1[index];
-    microTable1[index + L6208_USTEPS_PER_QUARTER_PERIOD*2] = updatedMicroTable[index];
-  }
-  /* clear the number of samples to update */
-  L6208_SetMicrostepSample2Update(0); 
-}
-
-/******************************************************//**
- * @brief Check if there are waveform samples to rescale and if so, perform the rescaling
- * @retval None
- **********************************************************/
-void L6208::L6208_UstepWaveformHandling(void)
-{
-  /* micro stepper waveform samples rescaling ... and updating */
-  uint8_t nbSamplesToRescale = L6208_GetMicrostepSample2Scale();
-  if(nbSamplesToRescale > 0)
-  { 
-    /* Current torque value has been changed, so recalculate the waveform table */
-    L6208_ScaleWaveformTable();
-    
-    /* Set the number of samples to update */
-    L6208_SetMicrostepSample2Update(L6208_USTEPS_PER_QUARTER_PERIOD);
-
-    /* Reset the number of samples to rescaled afer rescaling */
-    L6208_SetMicrostepSample2Scale(0);
-  }
-}
-
-/******************************************************//**
- * @brief Set the current torque value (Vref)
- * @param[in] newTorque Selected torque value
- * @retval always TRUE
- **********************************************************/
-bool L6208::L6208_VectorCalc(uint8_t newTorque)
-{
-  /* save current selected torque value */
-  devicePrm.curTorqueScaler = (uint16_t)newTorque;
-
-  if(!L6208_IsSysFlag(microstep))
-  {
-    /* full/half step mode or the motor is not running */
-    /* set the PWM duty cycle according to the current torque value (%). */
-    /* The TON value will be calculated inside the TIMx_PWM_duty_setup f(). */
-    L6208_VrefPwmComputePulseWidth(BRIDGE_A, devicePrm.curTorqueScaler, TRUE);
-    L6208_VrefPwmComputePulseWidth(BRIDGE_B, devicePrm.curTorqueScaler, TRUE);
-    devicePrm.vRefAVal = devicePrm.curTorqueScaler; // save current VREFA value
-    devicePrm.vRefBVal = devicePrm.curTorqueScaler; // save current VREFB value
-  }
-  else
-  { 
-    /* microstep mode */
-    if(L6208_IsSysFlag(running))
-    {
-      /* set the number of waveform sample to rescale according current selected */
-      /* torque value */
-      L6208_SetMicrostepSample2Scale(L6208_USTEPS_PER_QUARTER_PERIOD);
-    }
-    else
-    { 
-      /* micro stepping mode motor stopped */
-      L6208_ScaleWaveformTable();
-      L6208_UpdateScanWaveformTable();
-      /* Set the VREF timer PWM TON to update VREFA and VREFB */
-      L6208_VrefPwmComputePulseWidth(BRIDGE_A, pMicroTable2[devicePrm.uStepSample], FALSE);      
-      L6208_VrefPwmComputePulseWidth(BRIDGE_B, microTable1[devicePrm.uStepSample], FALSE);
-    }
-  }
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Compute the pulse width of VREFA or VREFB PWM
- * @param[in] bridgeId
- *            0 for BRIDGE_A
- *            1 for BRIDGE_B
- * @param[in] value pulse length in 1/256th of microsecond
- * or PWM duty cycle: 0 - 100 %
- * @param[in] valueIsPwmDutyCycle must be TRUE if value is a PWM duty cycle
- * @retval FALSE if wrong timer handle is used, else TRUE
- **********************************************************/
-bool L6208::L6208_VrefPwmComputePulseWidth(uint8_t bridgeId, uint16_t value, bool valueIsPwmDutyCycle)
-{
-  if(valueIsPwmDutyCycle)
-  {
-    if (value > 100) value = 100;
-    value = (uint16_t)(((uint32_t)devicePrm.vrefPwmPeriod * (uint32_t)value) / 100); 
-  }
-  if (bridgeId == 0)
-  {
-    devicePrm.vrefPwmPulseWidthTargetA = value;
-    devicePrm.vrefPwmPulseWidthToBeGeneratedA = 0;
-  } 
-  else if (bridgeId == 1)
-  {
-    devicePrm.vrefPwmPulseWidthTargetB = value;
-    devicePrm.vrefPwmPulseWidthToBeGeneratedB = 0;
-  }
-  else
-  {
-    return FALSE;
-  }
-  return TRUE;
-}
-
-/******************************************************//**
- * @brief Update the pulse width of VREFA or VREFB PWM
- * @param None
- * @retval None
- **********************************************************/
-void L6208::L6208_VrefPwmUpdatePulseWidth(void)
-{
-  uint16_t pulseWidthUs;
-  
-  devicePrm.vrefPwmPulseWidthToBeGeneratedA += devicePrm.vrefPwmPulseWidthTargetA;
-  pulseWidthUs = devicePrm.vrefPwmPulseWidthToBeGeneratedA>>8;
-  if (pulseWidthUs!=0)
-  {
-    L6208_Board_VrefPwmSetPulseWidthA(pulseWidthUs);
-    devicePrm.vrefPwmPulseWidthToBeGeneratedA -= (pulseWidthUs<<8);
-  }
-  else
-  {
-    L6208_Board_VrefPwmSetPulseWidthA(0);
-  }
-  
-  devicePrm.vrefPwmPulseWidthToBeGeneratedB += devicePrm.vrefPwmPulseWidthTargetB;
-  pulseWidthUs = devicePrm.vrefPwmPulseWidthToBeGeneratedB>>8;
-  if (pulseWidthUs!=0)
-  {
-    L6208_Board_VrefPwmSetPulseWidthB(pulseWidthUs);
-    devicePrm.vrefPwmPulseWidthToBeGeneratedB -= (pulseWidthUs<<8);
-  }
-  else
-  {
-    L6208_Board_VrefPwmSetPulseWidthB(0);
-  }
-}
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/l6208/l6208_class.h	Fri Apr 29 14:58:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1183 +0,0 @@
-/**
- ******************************************************************************
- * @file    l6208_class.h
- * @author  IPC Rennes
- * @version V1.0.0
- * @date    March 18th, 2016
- * @brief   This file contains the class of a L6208 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 __L6208_CLASS_H
-#define __L6208_CLASS_H
-
-
-/* Includes ------------------------------------------------------------------*/
-
-/* ACTION 1 ------------------------------------------------------------------*
- * Include here platform specific header files.                               *
- *----------------------------------------------------------------------------*/        
-#include "mbed.h"
-
-/* ACTION 2 ------------------------------------------------------------------*
- * Include here component specific header files.                              *
- *----------------------------------------------------------------------------*/        
-#include "l6208.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 L6208 component.
- */
-class L6208 : public StepperMotor
-{
-public:
-    /*** Constructor and Destructor Methods ***/
-
-    /**
-     * @brief Constructor.
-     * @param flag_and_enable_pin   pin name of the EN pin of the component.
-     * @param reset_pin             pin name of the RESET pin of the component.
-     * @param direction_pin         pin name of the CW_CCW pin of the component.
-     * @param half_full_pin         pin name of the HALF_FULL pin of the component.
-     * @param control_pin           pin name of the CONTROL pin of the component.
-     * @param clock_pin             pin name of the CLOCK pin of the component.
-     * @param vrefA_pwm_pin         pin name of the PWM connected to the VREFA pin of the component.
-     * @param vrefB_pwm_pin         pin name of the PWM connected to the VREFB pin of the component.
-     */
-    L6208(PinName flag_and_enable_pin, PinName reset_pin, PinName direction_pin, PinName half_full_pin, PinName control_pin, PinName clock_pin, PinName vrefA_pwm_pin, PinName vrefB_pwm_pin) : StepperMotor(),
-                                                                                                                                                         flag_and_enable(flag_and_enable_pin),
-                                                                                                                                                         reset(reset_pin),
-                                                                                                                                                         direction(direction_pin),
-                                                                                                                                                         half_full(half_full_pin),
-                                                                                                                                                         control(control_pin),
-                                                                                                                                                         clock(clock_pin),
-                                                                                                                                                         vrefA_pwm(vrefA_pwm_pin),
-                                                                                                                                                         vrefB_pwm(vrefB_pwm_pin)
-    {
-        /* Checking stackability. */
-        if (numberOfDevices!=0)
-            error("Instantiation of the L6208 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;
-        deviceInstance = numberOfDevices++;
-        /* default tick frequency */
-        tickFreq = TIMER_TICK_FREQUENCY;
-        /* waveform microstepping PWM period sample array, 90 deg shifted */
-        pMicroTable2 = &(microTable1[16]);
-    }
-    
-    /**
-     * @brief Destructor.
-     */
-    virtual ~L6208(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) L6208_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) L6208_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) L6208_GetMotionState();
-    }
-
-    /**
-     * @brief  Getting the position.
-     * @param  None.
-     * @retval The position.
-     */
-    virtual signed int GetPosition(void)
-    {
-        return (signed int)L6208_GetPosition();
-    }
-
-    /**
-     * @brief  Getting the marked position.
-     * @param  None.
-     * @retval The marked position.
-     */
-    virtual signed int GetMark(void)
-    {
-        return (signed int)L6208_GetMark();
-    }
-
-    /**
-     * @brief  Getting the current speed in pps.
-     * @param  None.
-     * @retval The current speed in pps.
-     */
-    virtual unsigned int GetSpeed(void)
-    {
-        return (unsigned int)L6208_GetCurrentSpeed();
-    }
-
-    /**
-     * @brief  Getting the maximum speed in pps.
-     * @param  None.
-     * @retval The maximum speed in pps.
-     */
-    virtual unsigned int GetMaxSpeed(void)
-    {
-        return (unsigned int)L6208_GetMaxSpeed();
-    }
-
-    /**
-     * @brief  Getting the minimum speed in pps.
-     * @param  None.
-     * @retval The minimum speed in pps.
-     */
-    virtual unsigned int GetMinSpeed(void)
-    {
-        return (unsigned int)L6208_GetMinSpeed();
-    }
-
-    /**
-     * @brief  Getting the acceleration in pps^2.
-     * @param  None.
-     * @retval The acceleration in pps^2.
-     */
-    virtual unsigned int GetAcceleration(void)
-    {
-        return (unsigned int)L6208_GetAcceleration();
-    }
-
-    /**
-     * @brief  Getting the deceleration in pps^2.
-     * @param  None.
-     * @retval The deceleration in pps^2.
-     */
-    virtual unsigned int GetDeceleration(void)
-    {
-        return (unsigned int)L6208_GetDeceleration();
-    }
-    
-    /**
-     * @brief  Getting the direction of rotation.
-     * @param  None.
-     * @retval The direction of rotation.
-     */
-    virtual direction_t GetDirection(void)
-    {
-        if (L6208_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)
-    {
-        L6208_SetHome();
-    }
-
-    /**
-     * @brief  Setting the current position to be the marked position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SetMark(void)
-    {
-        L6208_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 L6208_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 L6208_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 L6208_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 L6208_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 L6208_SetStepMode((motorStepMode_t) step_mode);
-    }
-
-    /**
-     * @brief  Going to a specified position.
-     * @param  position The desired position.
-     * @retval None.
-     */
-    virtual void GoTo(signed int position)
-    {
-        L6208_GoTo((int32_t)position);
-    }
-
-    /**
-     * @brief  Going to the home position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void GoHome(void)
-    {
-        L6208_GoHome();
-    }
-
-    /**
-     * @brief  Going to the marked position.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void GoMark(void)
-    {
-        L6208_GoMark();
-    }
-
-    /**
-     * @brief  Running the motor towards a specified direction.
-     * @param  direction The direction of rotation.
-     * @retval None.
-     */
-    virtual void Run(direction_t direction)
-    {
-        L6208_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)
-    {
-        L6208_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)
-    {
-        L6208_SoftStop();
-    }
-
-    /**
-     * @brief  Stopping the motor through an immediate infinite deceleration.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void HardStop(void)
-    {
-        L6208_HardStop();
-    }
-
-    /**
-     * @brief  Disabling the power bridge after performing a deceleration to zero.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void SoftHiZ(void)
-    {
-        motorStopMode_t stopMode = L6208_GetStopMode();
-        if (stopMode==HIZ_MODE)
-        {
-            L6208_SoftStop();
-        }
-        else
-        {
-            L6208_SetStopMode(HIZ_MODE);
-            L6208_SoftStop();
-            L6208_SetStopMode(stopMode);
-        }
-    }
-
-    /**
-     * @brief  Disabling the power bridge immediately.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void HardHiZ(void)
-    {
-        L6208_HardHiZ();
-    }
-
-    /**
-     * @brief  Waiting while the motor is active.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void WaitWhileActive(void)
-    {
-        L6208_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))
-    {
-        L6208_AttachErrorHandler((void (*)(uint16_t error)) fptr);
-    }
-
-    /**
-     * @brief  Checks if the device is disabled or/and has an alarm flag set 
-     * by reading the EN pin position.
-     * @param  None.
-     * @retval One if the EN pin is low (the device is disabled or/and 
-     * has an alarm flag set), otherwise zero.
-     */
-    virtual unsigned int CheckStatusHw(void)
-    {
-        if (!flag_and_enable.read()) return 0x01;
-        else return 0x00;
-    }
-    
-    /**
-     * @brief  Disabling the device.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void Disable(void)
-    {
-        L6208_Disable();
-    }
-    
-    /**
-     * @brief  Enabling the device.
-     * @param  None.
-     * @retval None.
-     */
-    virtual void Enable(void)
-    {
-        L6208_Enable();
-    }
-    
-    /**
-     * @brief  Getting the motor decay mode.
-     * @param  None.
-     * @retval The motor decay mode.
-     */
-    virtual motorDecayMode_t GetDecayMode()
-    {
-         return L6208_GetDecayMode();
-    }
-    
-    /**
-     * @brief  Set the frequency of the VREFA and VREFB PWM
-     * @param  frequency in Hz
-     * @retval None.
-     */  
-    virtual uint32_t GetFreqVrefPwm(void)
-    {
-        return L6208_VrefPwmGetFreq();
-    }    
-    
-    /**
-     * @brief  Getting the version of the firmware.
-     * @param  None.
-     * @retval The version of the firmware.
-     */
-    virtual unsigned int GetFwVersion(void)
-    {
-        return (unsigned int) L6208_GetFwVersion();
-    }
-    
-    /**
-     * @brief  Getting the motor step mode.
-     * @param  None.
-     * @retval The motor step mode.
-     */
-    virtual step_mode_t GetStepMode(void)
-    {
-      return (step_mode_t) L6208_GetStepMode();
-    }
-    
-    /**
-     * @brief  Getting the motor stop mode.
-     * @param  None.
-     * @retval The motor stop mode.
-     */  
-    virtual motorStopMode_t GetStopMode(void)
-    {
-      return L6208_GetStopMode();
-    }
-    
-    /**
-     * @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)
-    {
-        L6208_GoToDir((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD),(int32_t)position);
-    }
-
-    /**
-     * @brief  Release the L6208 reset (Reset pin set to high level).
-     * @param  None.
-     * @retval None.
-     */    
-    virtual void ReleaseReset(void)
-    {
-        L6208_ReleaseReset();
-    }
-
-    /**
-     * @brief  Reset the device with current step mode, resets current speed,
-     * positions and microstep variables.
-     * @param  None.
-     * @retval None.
-     */    
-    virtual void Reset(void)
-    {
-        L6208_Reset();
-    }
-    
-    /**
-     * @brief  Reset the L6208 (Reset pin set to low level).
-     * @param  None.
-     * @retval None.
-     */    
-    virtual void ResetDevice(void)
-    {
-        L6208_ResetDevice();
-    }
-   
-    /**
-     * @brief  Set the motor decay mode.
-     * @param  decayMode The desired decay mode (SLOW_DECAY or FAST_DECAY).
-     * @retval None.
-     */    
-    virtual void SetDecayMode(motorDecayMode_t decayMode)
-    {
-        L6208_SetDecayMode(decayMode);
-    }
-
-    /**
-     * @brief  Set the motor direction.
-     * @param  direction The desired direction.
-     * @retval None.
-     */
-    virtual void SetDirection(direction_t direction)
-    { 
-        L6208_SetDirection((motorDir_t) (direction == StepperMotor::FWD ? FORWARD : BACKWARD));
-    }
-
-    /**
-     * @brief  Set the frequency of the VREFA and VREFB PWM
-     * @param  frequency in Hz
-     * @retval None.
-     */  
-    virtual void SetFreqVrefPwm(uint32_t frequency)
-    {
-        L6208_VrefPwmSetFreq(frequency);
-    }
-
-    /**
-     * @brief  Set the motor stop mode.
-     * @param  stopMode The desired stop mode (HOLD_MODE or HIZ_MODE).
-     * @retval None.
-     */       
-    virtual void SetStopMode(motorStopMode_t stopMode)
-    {
-        L6208_SetStopMode(stopMode);
-    }
-   
-    /*** 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))
-    {
-        flag_and_enable.mode(PullDown);
-        flag_and_enable.fall(fptr);
-    }
-    
-    /**
-     * @brief  Enabling the FLAG interrupt handling.
-     * @param  None.
-     * @retval None.
-     */
-    void EnableFlagIRQ(void)
-    {
-        flag_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 L6208_Init(void *init);
-    Status_t L6208_ReadID(uint8_t *id);
-    void L6208_AttachErrorHandler(void (*callback)(uint16_t error));
-    void L6208_Disable(void);
-    void L6208_ErrorHandler(uint16_t error);
-    void L6208_Enable(void);
-    uint16_t L6208_GetAcceleration(void);
-    uint16_t L6208_GetCurrentSpeed(void);
-    uint16_t L6208_GetDeceleration(void);
-    motorDecayMode_t L6208_GetDecayMode(void);
-    motorDir_t L6208_GetDirection(void);
-    uint32_t L6208_GetFwVersion(void);
-    int32_t L6208_GetMark(void);
-    uint16_t L6208_GetMaxSpeed(void);
-    uint16_t L6208_GetMinSpeed(void);
-    motorState_t L6208_GetMotionState(void);
-    int32_t L6208_GetPosition(void);
-    motorStepMode_t L6208_GetStepMode(void);
-    motorStopMode_t L6208_GetStopMode(void);    
-    void L6208_GoHome(void);  
-    void L6208_GoMark(void);
-    void L6208_GoTo(int32_t targetPosition);
-    void L6208_GoToDir(motorDir_t direction, int32_t targetPosition);   
-    void L6208_HardHiZ(void);
-    void L6208_HardStop(void);
-    void L6208_Move(motorDir_t direction, uint32_t stepCount);
-    void L6208_ReleaseReset(void);
-    void L6208_Reset(void);
-    void L6208_ResetDevice(void);  
-    void L6208_Run(motorDir_t direction);
-    bool L6208_SetAcceleration(uint16_t newAcc);
-    void L6208_SetDecayMode(motorDecayMode_t decayMode);
-    bool L6208_SetDeceleration(uint16_t newDec);
-    void L6208_SetDirection(motorDir_t direction);
-    void L6208_SetHome(void);
-    void L6208_SetMark(void);
-    bool L6208_SetMaxSpeed(uint16_t volatile newSpeed);
-    bool L6208_SetMinSpeed(uint16_t volatile newSpeed);    
-    bool L6208_SetStepMode(motorStepMode_t stepMode);
-    void L6208_SetStopMode(motorStopMode_t stopMode);    
-    bool L6208_SoftStop(void);
-    void L6208_TickHandler(void);
-    uint32_t L6208_VrefPwmGetFreq(void);
-    void L6208_VrefPwmSetFreq(uint32_t newFreq);
-    void L6208_WaitWhileActive(void);
-    
-    /*** Functions intended to be used only internally ***/
-    
-    void L6208_ClearSysFlag(uint32_t mask);
-    uint32_t L6208_ComputeNbAccOrDecSteps(uint16_t accOrDecRate);
-    uint16_t L6208_ConvertAcceDecelRateValue(uint16_t newAccOrDecRate);
-    void L6208_DoAccel(void);
-    void L6208_DoDecel(void);
-    void L6208_DoRun(void);
-    uint8_t L6208_GetMicrostepSample2Scale(void);
-    void L6208_Indexmodeinit(void);
-    bool L6208_IsSysFlag(uint32_t mask);
-    void L6208_ResetSteps(void);
-    uint32_t L6208_ScaleWaveformSample(uint8_t sampleIndex);
-    void L6208_ScaleWaveformTable(void);
-    void L6208_SetDeviceParamsToGivenValues(l6208_Init_t* pInitDevicePrm);
-    void L6208_SetDeviceParamsToPredefinedValues(void);
-    void L6208_SetMicrostepSample2Scale(uint8_t value);
-    void L6208_SetMicrostepSample2Update(uint8_t value);
-    void L6208_SetMotionState(motorState_t newMotionState);
-    bool L6208_SetSpeed(uint16_t newSpeed, uint32_t volatile *pSpeed);
-    void L6208_SetSysFlag(uint32_t mask);
-    bool L6208_StartMovement(void);
-    void L6208_UpdateScanWaveformTable(void);
-    void L6208_UstepWaveformHandling(void);
-    bool L6208_VectorCalc(uint8_t newTorque);
-    bool L6208_VrefPwmComputePulseWidth(uint8_t bridgeId, uint16_t value, bool valueIsPwmDutyCycle);
-    void L6208_VrefPwmUpdatePulseWidth(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  Reset the clock pin.
-     * @param  None.
-     * @retval None.
-     */    
-    void L6208_Board_CLOCK_PIN_Reset(void)
-    {
-        clock = 0;
-    }    
-    /**
-     * @brief  Set the clock pin.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_CLOCK_PIN_Set(void)
-    {
-        clock = 1;
-    }
-
-    /**
-     * @brief  Set the control pin.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_CONTROL_PIN_Set(void)
-    {
-        control = 1;
-    }
-
-    /**
-     * @brief  Reset the control pin.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_CONTROL_PIN_Reset(void)
-    {
-        control = 0;
-    }
-    
-    /**
-     * @brief  Making the CPU wait.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_Delay(uint32_t delay)
-    {
-        wait_ms(delay);
-    }
-    
-    /**
-     * @brief  Reset the dir pin.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_DIR_PIN_Reset(void)
-    {
-        direction = 0;
-    }
-        
-    /**
-     * @brief  Set the dir pin.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_DIR_PIN_Set(void)
-    {
-        direction = 1;
-    }
-    
-    /**
-     * @brief  Disable the power bridges (leave the output bridges HiZ).
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_Disable(void)
-    {
-        flag_and_enable.disable_irq();
-        flag_and_enable.mode(PullDown);
-    }
-
-    /**
-     * @brief  Disabling interrupts.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_DisableIrq(void)
-    {
-        __disable_irq();
-    }
-    
-    /**
-     * @brief  Enable the power bridges (leave the output bridges HiZ).
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_Enable(void)
-    {     
-        flag_and_enable.mode(PullUp);
-        flag_and_enable.enable_irq();
-    }
-    
-    /**
-     * @brief  Enabling interrupts.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_EnableIrq(void)
-    {
-        __enable_irq();
-    }
-    
-    /**
-     * @brief  Reset the half full pin.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_HALF_FULL_PIN_Reset(void)
-    {
-        half_full = 0;
-    }
-    
-    /**
-     * @brief  Set the half full pin.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_HALF_FULL_PIN_Set(void)
-    {
-        half_full = 1;
-    }
-
-    /**
-     * @brief  Initialising the the VREFA or VREFB PWM.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_VrefPwmInit(uint8_t bridgeId, uint32_t pwmFreq) {}
-        
-    /**
-     * @brief  Exit the device from reset mode.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_ReleaseReset(void)
-    {
-        reset = 1;
-    }
-
-    /**
-     * @brief  Put the device in reset mode.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_Reset(void)
-    {
-        reset = 0;
-    }
-
-    /**
-     * @brief  Get the tick timer frequency in Hz.
-     * @param  None.
-     * @retval The tick timer frequency in Hz.
-     */    
-    uint32_t L6208_Board_TickGetFreq(void)
-    {
-       return TIMER_TICK_FREQUENCY;
-    }
-
-    /**
-     * @brief  Initialising the tick.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_TickInit(void) {}
-
-    /**
-     * @brief  Starting the tick timer, setting its frequency
-     * and attaching a tick handler function to it.
-     * @param  frequency the frequency of the tick.
-     * @retval None.
-     */
-    void L6208_Board_TickStart(uint16_t frequency)
-    {
-        /* Computing the period of the tick. */
-        double period = 1.0f / frequency;
-        
-        /* Attaching a tick handler function which updates */
-        /* the state machine every elapsed period time. */
-        ticker.attach(this, &L6208::L6208_TickHandler, period);
-    }
-
-    /**
-     * @brief  Stopping the tick.
-     * @param  None.
-     * @retval None.
-     */
-    void L6208_Board_TickStop(void)
-    {
-        ticker.detach();
-    }
-
-    /**
-     * @brief Set the pulse width of the VREFA PWM.
-     * @param[in] pulseWidthInUs pulse width of the PWM in microsecond.
-     * @retval None.
-     */     
-    void L6208_Board_VrefPwmSetPulseWidthA(uint8_t pulseWidthInUs)
-    {
-      vrefA_pwm.pulsewidth_us(pulseWidthInUs);
-    }
- 
-    /**
-     * @brief Set the pulse width of the VREFB PWM.
-     * @param[in] pulseWidthInUs pulse width of the PWM in microsecond.
-     * @retval None.
-     */       
-    void L6208_Board_VrefPwmSetPulseWidthB(uint8_t pulseWidthInUs)
-    {
-      vrefB_pwm.pulsewidth_us(pulseWidthInUs);
-    }    
-    
-    /**
-     * @brief  Start the timer for the VREFA or VREFB PWM.
-     * @param[in] bridgeId
-     *            0 for BRIDGE_A
-     *            1 for BRIDGE_B
-     * @param[in] pwmPeriod period of the PWM used to generate the reference
-     * voltage for the bridge.
-     * @retval "true" in case of success, "false" otherwise.
-     * @note the unit is 1/256th of a microsecond. The VREFA PWM must be started
-     * before the VREFB PWM.
-     */   
-    bool L6208_Board_VrefPwmStart(uint8_t bridgeId, uint16_t pwmPeriod)
-    { 
-        pwmPeriod>>=8;
-        /* Setting the period and the duty-cycle of PWM. */
-        if (bridgeId == 0)
-        {
-            vrefA_pwm.period_us(pwmPeriod);         
-        }
-        else if (bridgeId == 1)
-        {
-            vrefB_pwm.period_us(pwmPeriod);
-        }
-        else return false;
-        return true;
-    }
-    
-    /**
-     * @brief  Stop the timer for the VREFA or VREFB PWM.
-     * @param[in] bridgeId
-     *            0 for BRIDGE_A
-     *            1 for BRIDGE_B
-     * @retval "true" in case of success, "false" otherwise.
-     */       
-    bool L6208_Board_VrefPwmStop(uint8_t bridgeId)
-    {
-        if (bridgeId == 0)
-        {
-            vrefA_pwm.period_us(0);
-        }
-        else if (bridgeId == 1)
-        {
-            vrefB_pwm.period_us(0);
-        }
-        else return false;
-        return true;
-    }
-
-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;                                           *
-     *------------------------------------------------------------------------*/
-    /* Flag Interrupt and chip enable. */
-    InterruptIn flag_and_enable;
-
-    /* ACTION 10 -------------------------------------------------------------*
-     * Declare here other pin related variables, if needed.                   *
-     *                                                                        *
-     * Example:                                                               *
-     *   + mbed:                                                              *
-     *     DigitalOut standby_reset;                                          *
-     *------------------------------------------------------------------------*/
-    /* RESET pin. */
-    DigitalOut reset;
-    /* CW_CCW pin. */
-    DigitalOut direction;
-    /* HALF_FULL pin */
-    DigitalOut half_full;
-    /* CONTROL pin */
-    DigitalOut control;
-    /* CLOCK pin */
-    DigitalOut clock;
-
-    /* Pulse Width Modulation pin for VREFA pin */
-    PwmOut vrefA_pwm;
-    /* Pulse Width Modulation pin for VREFA pin */
-    PwmOut vrefB_pwm;
-    
-    /* Timer for the tick */
-    Ticker ticker;
-    
-    /* 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 (*errorHandlerCallback)(uint16_t error);
-    deviceParams_t devicePrm;
-    uint8_t deviceInstance;
-    uint32_t tickFreq;
-    /// microstepping PWM period and torque scaled waveform samples array
-    uint16_t updatedMicroTable[L6208_USTEPS_PER_QUARTER_PERIOD+1];
-    /// waveform scanning microstepping PWM period sample arrays for VREFA wave
-    uint16_t microTable1[L6208_USTEPS_PER_QUARTER_PERIOD*3+1];
-    /// waveform scanning microstepping PWM period sample array for VREFB wave
-    uint16_t *pMicroTable2;
-
-    /* Static data. */
-    static uint8_t numberOfDevices;
-    static const uint16_t RefMicroTable[L6208_USTEPS_PER_QUARTER_PERIOD*3];
-
-public:
-
-    /* Static data. */
-    
-};
-
-#endif // __L6208_CLASS_H
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/l6208/l6208_target_config.h	Fri Apr 29 14:58:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/******************************************************//**
-  * @file    l6208_target_config.h 
-  * @author  IPC Rennes
-  * @version V1.1.0
-  * @date    February 11th, 2016
-  * @brief   Predefines values for the L6208 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 __L6208_TARGET_CONFIG_H
-#define __L6208_TARGET_CONFIG_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif 
-
-/** @addtogroup L6208
-  * @{
-  */
-
-/** @addtogroup L6208_Exported_Constants
-  * @{
-  */
-
-/** @defgroup Predefined_L6208_Parameters_Values Predefined L6208 Parameters Values
-  * @{
-  */
-
-/// Acceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
-#define L6208_CONF_PARAM_ACC_RATE        (1000)
-
-/// Acceleration current torque in % (from 0 to 100)
-#define L6208_CONF_PARAM_ACC_CURRENT     (10)
-
-/// Deceleration rate in step/s^2 or (1/16)th step/s^2 for microstep modes
-#define L6208_CONF_PARAM_DEC_RATE        (1000)
-
-/// Deceleration current torque in % (from 0 to 100)
-#define L6208_CONF_PARAM_DEC_CURRENT     (10)
-
-/// Running speed in step/s or (1/16)th step/s for microstep modes
-#define L6208_CONF_PARAM_RUNNING_SPEED   (1000)
-
-/// Running current torque in % (from 0 to 100)
-#define L6208_CONF_PARAM_RUNNING_CURRENT (10)
-
-/// Holding current torque in % (from 0 to 100)
-#define L6208_CONF_PARAM_HOLDING_CURRENT (10)
-
-/// Step mode via enum motorStepMode_t
-#define L6208_CONF_PARAM_STEP_MODE       (STEP_MODE_1_16)
-
-/// Decay mode via enum motorDecayMode_t
-#define L6208_CONF_PARAM_DECAY_MODE      (FAST_DECAY)
-
-/// Dwelling time in ms
-#define L6208_CONF_PARAM_DWELL_TIME      (0)
-
-/// Automatic HIZ STOP
-#define L6208_CONF_PARAM_AUTO_HIZ_STOP   (FALSE)
-
-/// VREFA and VREFB PWM frequency (Hz)
-#define L6208_CONF_VREF_PWM_FREQUENCY    (100000)
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif /* __L6208_TARGET_CONFIG_H */
-
-/******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ST_INTERFACES.lib	Fri Mar 24 10:59:42 2017 +0100
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/ST_INTERFACES/#8f70f7159316