Library used to control ST Nucleo Evaluation board IHM12A1, based on STSPIN240 low voltage dual brush DC motor control driver.

Dependencies:   ST_INTERFACES

Dependents:   motori prova_motore SchedamotoriIHM12A1 prova_motore_duck ... more

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

Brush DC Motor Control Library

Library to handle the X-NUCLEO-IHM12A1 Motor Control Expansion Board based on the STSPIN240 component.

It allows a complete management of the STSPIN240, a low voltage dual brush DC driver, by providing a complete APIs.

The key features of the library are :

  • Configuration of the STSPIN240 (bridges input and enabling signals)
  • Flag interrupt handling (overcurrent and thermal alarms reporting)
  • Handling of up to two bidirectional Brush DC motors
  • Nucleo and expansion board configuration (GPIOs, PWMs, IRQs…)

To use the STSPIN240 driver library, the user first has to call its initialization method which:

  • Setups the required GPIOs to handle the bridges enable pins, the FLAG interrupt which reports overcurrent detection or thermal protection.
  • Loads the driver parameters with initial values configured by the user or with their predefined values from “stspin240_250_target_config.h”, in order to program the PWMs frequency of the bridges inputs, the number of brush DC motors.

Once the initialization is done, the user can modify the driver parameters by calling specific functions to change the numbers of motors or the PWMs frequency.

The user can also write callback functions and attach them to:

  • The flag interrupt handler depending on the actions he wants to perform when an overcurrent or a thermal alarm is reported.
  • The Error handler which is called by the library when it reports an error.

Then, the user can drive the different brush DC motors by requesting to run in a specified direction and by changing the maximal speed. When a motor is requested to run, the corresponding bridge is automatically enabled.

A motion command can be stopped at any moment:

  • Either by a hard stop which immediately stops the motor.
  • Or by a hardHiz command which immediately stops the motor and disables the bridge which is used by the motor.

The library also provides functions to disable or enable the bridges independently from the run or stop commands.

Arduino Connector Compatibility Warning

Using the X-NUCLEO-IHM12A1 expansion board with the NUCLEO-F429ZI requires adopting the following patch:

  • to connect with a wire the PB_3 Nucleo pin to the PWMB expansion board pin.


Board configuration for HelloWorld_IHM12A1 example

/media/uploads/Manu_L/x_nucleo_ihm12a1.jpg

Files at this revision

API Documentation at this revision

Comitter:
Davidroid
Date:
Fri Mar 24 14:06:00 2017 +0000
Parent:
3:b0128df93d26
Child:
5:e5b95641e7d4
Commit message:
Typos corrected.

Changed in this revision

Components/STSpin240_250/STSpin240_250.cpp Show annotated file Show diff for this revision Revisions of this file
Components/STSpin240_250/STSpin240_250.h Show annotated file Show diff for this revision Revisions of this file
Components/STSpin240_250/STSpin240_250_config.h Show annotated file Show diff for this revision Revisions of this file
Components/STSpin240_250/STSpin240_250_def.h Show annotated file Show diff for this revision Revisions of this file
Components/stspin240_250/STSpin240_250.cpp Show diff for this revision Revisions of this file
Components/stspin240_250/STSpin240_250_config.h Show diff for this revision Revisions of this file
Components/stspin240_250/STSpin240_250_def.h Show diff for this revision Revisions of this file
Components/stspin240_250/stspin240_250.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/STSpin240_250/STSpin240_250.cpp	Fri Mar 24 14:06:00 2017 +0000
@@ -0,0 +1,664 @@
+/**
+ ******************************************************************************
+ * @file    STSpin240_250.cpp
+ * @author  IPC Rennes
+ * @version V1.0.0
+ * @date    April 25th, 2016
+ * @brief   STSpin240 motor driver (Dual brush DC motors)
+ * @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 "STSpin240_250.h"
+
+/* Definitions ---------------------------------------------------------------*/
+
+/* Error: Access a motor index greater than the one of the current brigde configuration */
+#define STSPIN240_250_ERROR_1   (0xC001)
+/* Error: Use of a bridgeId greater than BRIDGE_B */
+#define STSPIN240_250_ERROR_2   (0xC002)    
+
+/* Maximum frequency of the PWMs in Hz */
+#define STSPIN240_250_MAX_PWM_FREQ   (100000)
+
+/* Minimum frequency of the PWMs in Hz */
+#define STSPIN240_250_MIN_PWM_FREQ   (2)
+
+/* Bridge A */
+#define BRIDGE_A         (0)
+
+/* Bridge B */
+#define BRIDGE_B         (1)
+    
+/* PWM id for PWM_A */
+#define PWM_A         (0)
+
+/* PWM id for PWM_B */
+#define PWM_B         (1)
+
+/* PWM id for PWM_REF */
+#define PWM_REF       (2)    
+
+/* Variables  ----------------------------------------------------------------*/
+
+/* Number of devices. */
+uint8_t STSpin240_250::numberOfDevices = 0;
+uint8_t STSpin240_250::arrayNbMaxMotorsByConfig[2] = {1,2};
+/* Methods -------------------------------------------------------------------*/
+
+/**********************************************************
+ * @brief Starts the STSpin240_250 library
+ * @param[in] pInit pointer to the initialization data
+ * @retval COMPONENT_OK in case of success.
+ **********************************************************/
+status_t STSpin240_250::STSpin240_250_Init(void* pInit)
+{ 
+    /* Standby-reset deactivation */
+    STSpin240_250_Board_ReleaseReset();
+    
+    /* Let a delay after reset */
+    STSpin240_250_Board_Delay(1);
+    
+    if (pInit == 0)
+    {
+        // Set all registers to their predefined values 
+        // from powerstep01_target_config.h 
+        STSpin240_250_SetDeviceParamsToPredefinedValues();
+    }
+    else
+    {
+        STSpin240_250_SetDeviceParamsToGivenValues((STSpin240_250_init_t *)pInit);
+    }
+    
+    /* Initialise input PWM of bridges*/
+    STSpin240_250_SetDualFullBridgeconfig(device_prm.dualBridgeEnabled);
+    
+    return COMPONENT_OK;
+}
+
+/**********************************************************
+ * @brief Read id
+ * @param[in] id pointer to the identifier to be read.
+ * @retval COMPONENT_OK in case of success.
+ **********************************************************/
+status_t STSpin240_250::STSpin240_250_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 STSpin240_250::STSpin240_250_AttachErrorHandler(void (*callback)(uint16_t error))
+{
+    errorHandlerCallback = (void (*)(uint16_t error)) callback;
+}
+
+
+/******************************************************//**
+ * @brief Disable the specified bridge
+ * @param[in] bridgeId (from 0 for bridge A to 1 for bridge B)
+ * @retval None
+ * @note  Bridge A and bridge B share the same enable pin. 
+ * When bridge A is disabled, bridge B is disabled and 
+ * reversely
+ **********************************************************/
+void STSpin240_250::STSpin240_250_DisableBridge(uint8_t bridgeId)
+{
+    STSpin240_250_Board_DisableBridge();
+    device_prm.bridgeEnabled[BRIDGE_A] = FALSE;
+    device_prm.bridgeEnabled[BRIDGE_B] = FALSE;
+}
+
+/******************************************************//**
+ * @brief Enable the specified bridge
+ * @param[in] bridgeId (from 0 for bridge A to 1 for bridge B)
+ * @retval None
+ * @note  Bridge A and bridge B share the same enable pin. 
+ * When bridge A is enabled, bridge B is enabled and 
+ * reversely
+ **********************************************************/
+void STSpin240_250::STSpin240_250_EnableBridge(uint8_t bridgeId)
+{
+    device_prm.bridgeEnabled[BRIDGE_A] = TRUE;
+    device_prm.bridgeEnabled[BRIDGE_B] = TRUE;  
+    STSpin240_250_Board_EnableBridge(1);
+}
+
+/**********************************************************
+ * @brief Error handler which calls the user callback (if defined)
+ * @param[in] error Number of the error
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_ErrorHandler(uint16_t error)
+{
+    if (errorHandlerCallback != 0)
+    {
+    (void) errorHandlerCallback(error);
+    }
+    else   
+    {
+    /* Aborting the program. */
+    exit(EXIT_FAILURE);
+    }
+}
+
+/******************************************************//**
+ * @brief  Get the PWM frequency of the specified bridge 
+ * @param[in] bridgeId 0 for bridge A, 1 for bridge B
+ * @retval Freq in Hz
+ **********************************************************/
+uint32_t STSpin240_250::STSpin240_250_GetBridgeInputPwmFreq(uint8_t bridgeId)
+{                                                  
+  if (bridgeId > BRIDGE_B)
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_2);
+  }    
+  
+  return (device_prm.bridgePwmFreq[(bridgeId << 1)]);
+}
+
+/******************************************************//**
+ * @brief  Get the status of the bridge enabling of the corresponding bridge
+ * @param[in] bridgeId from 0 for bridge A to 1 for bridge B
+ * @retval State of the Enable&Fault pin (shared for bridge A and B)
+  **********************************************************/
+uint16_t STSpin240_250::STSpin240_250_GetBridgeStatus(void)
+{
+    uint16_t status = STSpin240_250_Board_GetFaultPinState();
+  
+    return (status);
+}
+
+/******************************************************//**
+ * @brief  Returns the current speed of the specified motor
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @retval current speed in % from 0 to 100
+ **********************************************************/
+uint16_t STSpin240_250::STSpin240_250_GetCurrentSpeed(uint8_t motorId)
+{
+  uint16_t speed = 0;
+
+  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }
+  else if (device_prm.motionState[motorId] != INACTIVE)
+  {
+    speed = device_prm.speed[motorId];
+  }   
+  return (speed); 
+}
+
+/******************************************************//**
+ * @brief Returns the device state
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @retval State (STEADY or INACTIVE)
+ **********************************************************/
+motorState_t STSpin240_250::STSpin240_250_GetDeviceState(uint8_t motorId)
+{
+  motorState_t state =  INACTIVE;
+
+  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }
+  else
+  {
+    state =  device_prm.motionState[motorId];
+  }
+  return (state);      
+}
+
+/******************************************************//**
+ * @brief Get the motor current direction
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @retval direction
+ **********************************************************/
+motorDir_t STSpin240_250::STSpin240_250_GetDirection(uint8_t motorId)
+{
+  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }
+  
+  return device_prm.direction[motorId];
+}
+
+/******************************************************//**
+ * @brief Returns the FW version of the library
+ * @retval STSPIN240_250_FW_VERSION
+ **********************************************************/
+uint32_t STSpin240_250::STSpin240_250_GetFwVersion(void)
+{
+  return (STSPIN240_250_FW_VERSION);
+}
+
+
+/******************************************************//**
+ * @brief  Return the duty cycle of PWM used for REF 
+ * @param[in] refId 0 is the only supported id for STSpin240 or 
+ * STSpin250
+ * @retval duty cycle in % (from 0 to 100)
+ **********************************************************/
+uint8_t STSpin240_250::STSpin240_250_GetRefPwmDc(uint8_t refId)
+{                                                  
+  uint32_t duty = 0;
+  
+  if (duty == 0)
+  {
+    duty = device_prm.refPwmDc;
+  }
+  return (duty);
+}
+
+/******************************************************//**
+ * @brief  Return the frequency of PWM used for REF 
+ * @param[in] refId 0 is the only supported id for STSpin240 or 
+ * STSpin250
+ * @retval Frequency in Hz
+ **********************************************************/
+uint32_t STSpin240_250::STSpin240_250_GetRefPwmFreq(uint8_t refId)
+{                                                  
+  uint32_t freq = 0;
+  
+  if (refId == 0)
+  {
+    freq = device_prm.refPwmFreq;
+  }
+  return (freq);
+}
+
+/******************************************************//**
+ * @brief  Immediatly stops the motor and disable the power bridge
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @retval None
+ * @note  As all motors uses the same power bridge, the 
+ * power bridge will be disable only if all motors are
+ * stopped
+ **********************************************************/
+void STSpin240_250::STSpin240_250_HardHiz(uint8_t motorId) 
+{
+   if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }
+  else
+  {
+    if (device_prm.bridgeEnabled[motorId] != FALSE)
+    {
+      /* Only disable bridges if dual bridge mode is disabled or */
+      /* if all motors are inactive as there are sharing the same power stage */
+      if ((device_prm.dualBridgeEnabled == 0)||
+          ((motorId == 0)&&(device_prm.motionState[1] == INACTIVE))||
+          ((motorId == 1)&&(device_prm.motionState[0] == INACTIVE)))
+      {  
+        /* Disable the bridge */
+        STSpin240_250_DisableBridge(motorId);
+      }
+    }
+    /* Disable the PWM */
+    STSpin240_250_HardStop(motorId);
+  }
+}
+
+/******************************************************//**
+ * @brief  Stops the motor without disabling the bridge
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @retval none
+ **********************************************************/
+void STSpin240_250::STSpin240_250_HardStop(uint8_t motorId)
+{   
+  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }
+  else if (device_prm.motionState[motorId] != INACTIVE)
+  {
+    /* Disable corresponding PWM */
+    STSpin240_250_Board_PwmStop(motorId);
+
+    /* Set inactive state */
+    device_prm.motionState[motorId] = INACTIVE;
+  }  
+}
+
+/******************************************************//**
+ * @brief Release reset (exit standby mode)
+ * @param[in] deviceId (from 0 to MAX_NUMBER_OF_DEVICES -1)
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_ReleaseReset(void)
+{
+  STSpin240_250_Board_ReleaseReset();
+  
+  /* Start PWM used for REF pin */
+  STSpin240_250_Board_PwmSetFreq(PWM_REF, device_prm.refPwmFreq,device_prm.refPwmDc);          
+}
+
+/******************************************************//**
+ * @brief Reset (enter standby mode)
+ * @param[in] deviceId (from 0 to MAX_NUMBER_OF_DEVICES -1)
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_Reset(void)
+{
+  uint8_t loop;
+  for (loop = 0; loop < STSPIN240_250_NB_MAX_MOTORS; loop++)
+  {
+    /* Stop motor if needed*/
+    if (device_prm.motionState[loop] != INACTIVE) 
+    {
+      STSpin240_250_HardStop(loop);
+    }
+    /* Disable bridge if needed */
+    if (device_prm.bridgeEnabled[loop] != FALSE) 
+    {
+      STSpin240_250_DisableBridge(loop);
+    }    
+  }
+  
+  /* Stop PWM used for REF pin */
+  STSpin240_250_Board_PwmStop(PWM_REF);
+  
+  /* Reset the STBY/RESET pin */
+  STSpin240_250_Board_Reset();
+}
+
+/******************************************************//**
+ * @brief  Runs the motor
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @param[in] direction FORWARD or BACKWARD
+ * @retval None
+ * @note  For unidirectionnal motor, direction parameter has 
+ * no effect
+ **********************************************************/
+void STSpin240_250::STSpin240_250_Run(uint8_t motorId, motorDir_t direction)
+{
+  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }  
+  else if ((device_prm.motionState[motorId] == INACTIVE) ||
+           (device_prm.direction[motorId] != direction))
+  {
+    
+    /* Release reset if required */
+    if (STSpin240_250_GetResetState() == 0)
+    {
+      STSpin240_250_ReleaseReset();
+    }
+    
+    /* Eventually deactivate motor */
+    if (device_prm.motionState[motorId] != INACTIVE) 
+    {
+      STSpin240_250_HardStop(motorId);
+    }
+
+    /* Set direction */
+    STSpin240_250_SetDirection(motorId, direction);
+
+    /* Switch to steady state */
+    device_prm.motionState[motorId] = STEADY;
+   
+    /* Enable bridge */
+    if (device_prm.bridgeEnabled[motorId] == FALSE)
+    {
+      STSpin240_250_EnableBridge(motorId);
+    }
+    /* Set PWM */
+    STSpin240_250_Board_PwmSetFreq(motorId, device_prm.bridgePwmFreq[motorId],device_prm.speed[motorId]);          
+  }
+}
+
+/******************************************************//**
+ * @brief  Changes the PWM frequency of the bridge input
+ * @param[in] bridgeId 0 for bridge A, 1 for bridge B
+ * @param[in] newFreq in Hz
+ * @retval None
+ * @note 1)The PWM is only enabled when the motor is requested
+ * to run.
+ * 2) If the two bridges share the same timer, their frequency
+ * has to be the same
+ * 3) If the two bridges share the same timer, the frequency
+ * is updated on the fly is there is only one motor running
+ * on the targeted bridge.
+ **********************************************************/
+void STSpin240_250::STSpin240_250_SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq)
+{                                                  
+  if (bridgeId > BRIDGE_B)
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_2);
+  }  
+  
+  if (newFreq > STSPIN240_250_MAX_PWM_FREQ)
+  {
+    newFreq = STSPIN240_250_MAX_PWM_FREQ;
+  }
+ 
+  device_prm.bridgePwmFreq[bridgeId] = newFreq;
+  
+  if (device_prm.motionState[bridgeId] != INACTIVE)
+  {
+    STSpin240_250_Board_PwmSetFreq(bridgeId, device_prm.bridgePwmFreq[bridgeId],device_prm.speed[bridgeId]);          
+  }
+}
+
+/******************************************************//**
+ * @brief  Specifies the direction 
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @param[in] dir FORWARD or BACKWARD
+ * @note The direction change is only applied if the device 
+ * is in INACTIVE state. To change direction while motor is 
+ * running, use the run function
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_SetDirection(uint8_t motorId, motorDir_t dir)
+{
+   if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }  
+  else if (device_prm.motionState[motorId] == INACTIVE)
+  {
+    STSpin240_250_Board_SetDirectionGpio(motorId, dir);
+    device_prm.direction[motorId] = dir;
+  }
+}
+
+/******************************************************//**
+ * @brief Set the dual bridge configuration mode
+ * @param[in] enable 0 to disable, 
+ *                   1 to enable (not supported by STSPIN250)
+ * @retval None
+  **********************************************************/
+void STSpin240_250::STSpin240_250_SetDualFullBridgeconfig(uint8_t enable)
+{
+  device_prm.dualBridgeEnabled = enable;
+
+  /* Check reset pin state*/
+  if (STSpin240_250_GetResetState() != 0)
+  {
+    STSpin240_250_Reset();
+    STSpin240_250_ReleaseReset();
+  }
+}
+
+/******************************************************//**
+ * @brief  Changes the max speed of the specified device
+ * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
+ * @param[in] newMaxSpeed in % from 0 to 100
+ * @retval true if the command is successfully executed, else false
+ **********************************************************/
+bool STSpin240_250::STSpin240_250_SetMaxSpeed(uint8_t motorId, uint16_t newMaxSpeed)
+{                                                  
+  bool cmdExecuted = FALSE;
+
+  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
+  {
+    STSpin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
+  }
+  else
+  {
+    device_prm.speed[motorId] = newMaxSpeed;
+    if (device_prm.motionState[motorId] != INACTIVE)
+    {
+      /* Set PWM frequency*/
+      STSpin240_250_Board_PwmSetFreq(motorId, device_prm.bridgePwmFreq[motorId],device_prm.speed[motorId]);          
+    }
+    cmdExecuted = TRUE;
+  }
+  return cmdExecuted;
+}      
+
+/******************************************************//**
+ * @brief  Changes the duty cycle of the PWM used for REF 
+ * @param[in] refId 0 is the only supported id for STSpin240 or 
+ * STSpin250
+ * @param[in] newDc new duty cycle from 0 to 100
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_SetRefPwmDc(uint8_t refId, uint8_t newDc)
+{                                                  
+  if (newDc > 100)
+  {
+    newDc = 100;
+  }
+ 
+  device_prm.refPwmDc = newDc;
+  
+  if (STSpin240_250_GetResetState() != 0)
+  {
+    /* Immediatly set the PWM frequency  for ref if chip is not in reset */
+    STSpin240_250_Board_PwmSetFreq(PWM_REF, device_prm.refPwmFreq,device_prm.refPwmDc);          
+  }
+}
+
+/******************************************************//**
+ * @brief  Changes the frequency of PWM used for REF 
+ * @param[in] refId 0 is the only supported id for STSpin240 or 
+ * STSpin250
+ * @param[in] newFreq in Hz
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_SetRefPwmFreq(uint8_t refId, uint32_t newFreq)
+{
+  if (newFreq > STSPIN240_250_MAX_PWM_FREQ)
+  {
+    newFreq = STSPIN240_250_MAX_PWM_FREQ;
+  }
+ 
+  device_prm.refPwmFreq = newFreq;
+  
+  if (STSpin240_250_GetResetState() != 0)
+  {
+    /* Immediatly set the PWM frequency  for ref if chip is not in reset */
+    STSpin240_250_Board_PwmSetFreq(PWM_REF, device_prm.refPwmFreq,device_prm.refPwmDc);            
+  }
+} 
+
+
+/******************************************************//**
+ * @brief  Get the status of the bridge enabling of the corresponding bridge
+ * @retval State of the Enable&Fault pin (shared for bridge A and B)
+  **********************************************************/
+uint8_t STSpin240_250::STSpin240_250_GetResetState(void)
+{
+  uint8_t status = STSpin240_250_Board_GetResetPinState();
+  
+  return (status);
+}
+
+/******************************************************//**
+ * @brief  Set the parameters of the device to values of pInitPrm structure
+ * @param[in] deviceId (from 0 to MAX_NUMBER_OF_DEVICES -1)
+ * @param pInitPrm pointer to a structure containing the initial device parameters 
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_SetDeviceParamsToGivenValues(STSpin240_250_init_t *pInitPrm)
+{
+  uint32_t i;
+
+  device_prm.dualBridgeEnabled = pInitPrm->dualBridgeEnabled;
+
+  device_prm.bridgePwmFreq[BRIDGE_A] = pInitPrm->bridgePwmFreq[BRIDGE_A];
+  device_prm.bridgePwmFreq[BRIDGE_B] = pInitPrm->bridgePwmFreq[BRIDGE_B];;
+
+  device_prm.refPwmFreq = pInitPrm->refPwmFreq;
+  device_prm.refPwmDc = pInitPrm->refPwmDc;
+  
+  for (i = 0; i < MAX_NUMBER_OF_BRUSH_DC_MOTORS; i++)
+  {
+    device_prm.speed[i] = 100;
+    device_prm.direction[i] = FORWARD;
+    device_prm.motionState[i] = INACTIVE;
+  }
+  for (i = 0; i < STSPIN240_250_NB_BRIDGES; i++)
+  {  
+    device_prm.bridgeEnabled[i] = FALSE;
+  }  
+}
+/******************************************************//**
+ * @brief  Sets the parameters of the device to predefined values
+ * from STSpin240_250_target_config.h
+ * @retval None
+ **********************************************************/
+void STSpin240_250::STSpin240_250_SetDeviceParamsToPredefinedValues(void)
+{
+  uint32_t i;
+
+  device_prm.dualBridgeEnabled = STSPIN240_250_CONF_PARAM_DUAL_BRIDGE_ENABLING;
+
+  device_prm.bridgePwmFreq[BRIDGE_A] = STSPIN240_250_CONF_PARAM_FREQ_PWM_A;
+  device_prm.bridgePwmFreq[BRIDGE_B] = STSPIN240_250_CONF_PARAM_FREQ_PWM_B;
+
+  device_prm.refPwmFreq = STSPIN240_250_CONF_PARAM_FREQ_PWM_REF;
+  device_prm.refPwmDc = STSPIN240_250_CONF_PARAM_DC_PWM_REF;
+  
+  for (i = 0; i < MAX_NUMBER_OF_BRUSH_DC_MOTORS; i++)
+  {
+    device_prm.speed[i] = 100;
+    device_prm.direction[i] = FORWARD;
+    device_prm.motionState[i] = INACTIVE;
+  }
+  for (i = 0; i < STSPIN240_250_NB_BRIDGES; i++)
+  {  
+    device_prm.bridgeEnabled[i] = FALSE;
+  }
+}
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/STSpin240_250/STSpin240_250.h	Fri Mar 24 14:06:00 2017 +0000
@@ -0,0 +1,786 @@
+/**
+ ******************************************************************************
+ * @file    STSpin240_250.h
+ * @author  IPC Rennes
+ * @version V1.0.0
+ * @date    April 20th, 2016
+ * @brief   This file contains the class of a STSpin240_250 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 __STSPIN240_250_CLASS_H
+#define __STSPIN240_250_CLASS_H
+
+
+/* Includes ------------------------------------------------------------------*/
+
+/* ACTION 1 ------------------------------------------------------------------*
+ * Include here platform specific header files.                               *
+ *----------------------------------------------------------------------------*/        
+#include "mbed.h"
+/* ACTION 2 ------------------------------------------------------------------*
+ * Include here component specific header files.                              *
+ *----------------------------------------------------------------------------*/        
+#include "STSpin240_250_def.h"
+/* ACTION 3 ------------------------------------------------------------------*
+ * Include here interface specific header files.                              *
+ *                                                                            *
+ * Example:                                                                   *
+ *   #include "HumiditySensor.h"                                              *
+ *   #include "TemperatureSensor.h"                                           *
+ *----------------------------------------------------------------------------*/
+#include "BDCMotor.h"
+
+/* Defines -------------------------------------------------------------------*/
+
+/* MCU wait time in ms after power bridges are enabled */
+#define BRIDGE_TURN_ON_DELAY    (1)
+
+/* MCU wait time in ms after exit standby mode */
+#define EXIT_STANDBY_MODE_DELAY    (1)
+
+/* Classes -------------------------------------------------------------------*/
+
+
+/**
+ * @brief Class representing a STSpin240_250 component.
+ */
+class STSpin240_250 : public BDCMotor
+{
+public:
+
+    /*** Constructor and Destructor Methods ***/
+
+    /**
+     * @brief Constructor.
+     * @param flag_and_enable_pin   pin name of the EN pin of the component.
+     * @param standby_reset_pin     pin name of the STBY\RST pin of the component.
+     * @param pwmA_pin              pin name for the PWM input for bridge A
+     * @param pwmB_pin              pin name for the PWM input for bridge B
+     * @param dirA_pin              pin name for the direction pinfor bridge A
+     * @param dirB_pin              pin name for the direction pinfor bridge B
+     */
+    STSpin240_250(PinName flag_and_enable_pin, PinName standby_reset_pin, PinName dirA_pin, PinName dirB_pin, PinName pwmA_pin, PinName pwmB_pin, PinName pwmRef_pin) : BDCMotor(), flag_and_enable(flag_and_enable_pin), standby_reset(standby_reset_pin), dirA(dirA_pin), dirB(dirB_pin), pwmA(pwmA_pin), pwmB(pwmB_pin), pwmRef(pwmRef_pin)
+    { 
+        /* Checking stackability. */
+        if (!(numberOfDevices < MAX_NUMBER_OF_DEVICES))
+            error("Instantiation of the Stpin240_250 component failed: it can be stacked up to %d times.\r\n", MAX_NUMBER_OF_DEVICES);
+
+        /* 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++;
+    }
+    
+    /**
+     * @brief Destructor.
+     */
+    virtual ~STSpin240_250(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) STSpin240_250_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) STSpin240_250_ReadId((uint8_t *) id);
+    }
+
+    /**
+     * @brief Public functions inherited from the BCDMotor Class
+     */
+
+    /**
+     * @brief  Disabling the specified bridge.
+     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
+     * @retval None.
+     */
+    virtual void disable_bridge(unsigned int bridgeId) 
+    {
+        STSpin240_250_DisableBridge(bridgeId);
+    }
+     
+    /**
+     * @brief  Enabling the specified bridge.
+     * @param  bridgeId from 0 for bridge A to 1 for bridge B
+     * @retval None.
+     */
+    virtual void enable_bridge(unsigned int bridgeId)
+    {
+        STSpin240_250_EnableBridge(bridgeId);
+    }
+     
+    /**
+     * @brief  Getting the PWM frequency of the specified bridge;
+     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
+     * @retval The frequency in Hz of the specified bridge input PWM.
+     */
+    virtual unsigned int get_bridge_input_pwm_freq(unsigned int bridgeId)
+    {
+        return (unsigned int) STSpin240_250_GetBridgeInputPwmFreq(bridgeId);
+    }
+    
+    /**
+     * @brief  Getting the bridge status.
+     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
+     * @retval The status.
+     */
+    virtual unsigned int get_bridge_status(unsigned int bridgeId)
+    {
+        return (unsigned int) STSpin240_250_GetBridgeStatus();
+    }
+
+    /**
+     * @brief  Getting the device State. 
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
+     * @retval The device state (STEADY or INACTIVE)
+     */
+    virtual unsigned int get_device_state(unsigned int motorId)
+    {
+        return (motorState_t) STSpin240_250_GetDeviceState(motorId);
+    }
+   
+    /**
+     * @brief  Getting the current speed in % of the specified motor.
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
+     * @retval The current speed in %.
+     */
+    virtual unsigned int get_speed(unsigned int motorId)
+    {
+        return (unsigned int) STSpin240_250_GetCurrentSpeed(motorId);
+    }
+    
+    /**
+     * @brief  Stopping the motor and disabling the power bridge immediately.
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
+     * @retval None.
+     */
+    virtual void hard_hiz(unsigned int motorId)
+    {
+       STSpin240_250_HardHiz(motorId);
+    }
+    
+    /**
+     * @brief  Stopping the motor immediately.
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
+     * @retval None.
+     */
+    virtual void hard_stop(unsigned int motorId)
+    {
+       STSpin240_250_HardStop(motorId);
+    }
+
+    /**
+     * @brief  Running the motor.
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
+     * @param  direction The direction of rotation.
+     * @retval None.
+     */
+    virtual void run(unsigned int motorId, direction_t direction) 
+    {
+       STSpin240_250_Run(motorId, (motorDir_t) direction);
+    }
+    
+    /**
+     * @brief  Setting the PWM frequency of the specified bridge.
+     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
+     * @param  frequency of the PWM in Hz
+     * @retval None.
+     */
+    virtual void set_bridge_input_pwm_freq(unsigned int bridgeId, unsigned int frequency)
+    {
+        STSpin240_250_SetBridgeInputPwmFreq(bridgeId, frequency);
+    }
+        
+    /**
+     * @brief  Setting the dual bridge configuration mode.
+     * @param  configuration. The bridge configuration.
+     * @retval None.
+     */
+    virtual void set_dual_full_bridge_config(unsigned int configuration)
+    {
+        STSpin240_250_SetDualFullBridgeconfig(configuration);
+    }
+
+    /**
+     * @brief  Setting the speed in %.
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
+     * @param  speed The new speed in %.
+     * @retval "true" in case of success, "false" otherwise.
+     */
+    virtual bool set_speed(unsigned int motorId, unsigned int speed)
+    {
+        return (bool) STSpin240_250_SetMaxSpeed(motorId, speed);
+    }
+
+    /**
+     * @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))
+    {
+        STSpin240_250_AttachErrorHandler((void (*)(uint16_t error)) fptr);
+    }
+    
+    /**
+     * @brief  Getting the motor current direction.
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
+     * @retval direction The direction of rotation.
+     */
+    virtual direction_t get_direction(unsigned int motorId)
+    {
+        return (direction_t) STSpin240_250_GetDirection(motorId);
+    }
+
+    /**
+     * @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) STSpin240_250_GetFwVersion();
+    }
+
+    /**
+     * @brief  Getting the duty cycle of the PWM used for REF.
+     * @param  refId Id of the reference PWM signal.
+     * @retval duty cycle in % (from 0 to 100)
+     */
+    virtual unsigned int get_ref_pwm_dc(unsigned int refId)
+    {
+        return (unsigned int) STSpin240_250_GetRefPwmDc(refId);
+    }
+    
+    /**
+     * @brief  Getting the frequency of the PWM used for REF.
+     * @param  refId Id of the reference PWM signal.
+     * @retval frequency in Hz.
+     */
+    virtual unsigned int get_ref_pwm_freq(unsigned int refId)
+    {
+        return (unsigned int) STSpin240_250_GetRefPwmFreq(refId);
+    }
+    
+    /**
+     * @brief  Releasing the reset (exiting standby mode).
+     * @param  None.
+     * @retval None.
+     */
+    virtual void release_reset(void)
+    {
+       STSpin240_250_ReleaseReset();
+    }
+    
+    /**
+     * @brief  Reseting (entering standby mode).
+     * @param  None.
+     * @retval None.
+     */
+    virtual void reset(void)
+    {
+       STSpin240_250_Reset();
+    }
+        
+    /**
+     * @brief  Setting the direction of rotation of the firmware.
+     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
+     * @param direction The direction of rotation.
+     * @retval None
+     */
+    virtual void set_direction(unsigned int motorId, direction_t direction)
+    {
+       STSpin240_250_SetDirection(motorId, (motorDir_t) direction);
+    }
+
+    /**
+     * @brief  Setting the duty cycle of the PWM used for REF.
+     * @param  refId Id of the reference PWM signal.
+     * @param  newDc new duty cycle from 0 to 100
+     * @retval None.
+     */
+    virtual void set_ref_pwm_dc(unsigned int refId, unsigned int newDc)
+    {
+        STSpin240_250_SetRefPwmDc(refId, newDc);
+    }
+    
+    /**
+     * @brief  Setting the frequency of the PWM used for REF.
+     * @param  refId Id of the reference PWM signal.
+     * @param  frequency in Hz.
+     * @retval None.
+     */
+    virtual void set_ref_pwm_freq(unsigned int refId, unsigned int frequency)
+    {
+        STSpin240_250_SetRefPwmFreq(refId, frequency);
+    }
+
+    /**
+     * @brief Public static functions
+     */    
+    static uint8_t get_nb_devices(void)
+    {
+        return numberOfDevices;
+    }
+
+    /*** 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();
+    }
+    
+    /**
+     * @brief  Disabling the FLAG interrupt handling.
+     * @param  None.
+     * @retval None.
+     */
+    void disable_flag_irq(void)
+    {
+        flag_and_enable.disable_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 STSpin240_250_Init(void *init);
+    status_t STSpin240_250_ReadId(uint8_t *id);
+    void STSpin240_250_AttachErrorHandler(void (*callback)(uint16_t error));
+    void STSpin240_250_DisableBridge(uint8_t bridgeId);
+    void STSpin240_250_EnableBridge(uint8_t bridgeId);
+    void STSpin240_250_ErrorHandler(uint16_t error);
+    uint32_t STSpin240_250_GetBridgeInputPwmFreq(uint8_t bridgeId);
+    uint16_t STSpin240_250_GetBridgeStatus(void);
+    uint16_t STSpin240_250_GetCurrentSpeed(uint8_t motorId);
+    motorState_t STSpin240_250_GetDeviceState(uint8_t motorId); 
+    motorDir_t STSpin240_250_GetDirection(uint8_t motorId); 
+    uint32_t STSpin240_250_GetFwVersion(void);  
+    uint8_t STSpin240_250_GetRefPwmDc(uint8_t refId);    
+    uint32_t STSpin240_250_GetRefPwmFreq(uint8_t refId);
+    void STSpin240_250_HardHiz(uint8_t motorId); 
+    void STSpin240_250_HardStop(uint8_t motorId); 
+    void STSpin240_250_ReleaseReset(void);  
+    void STSpin240_250_Reset(void);
+    void STSpin240_250_Run(uint8_t motorId, motorDir_t direction); 
+    void STSpin240_250_SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq); 
+    void STSpin240_250_SetDirection(uint8_t motorId, motorDir_t dir); 
+    void STSpin240_250_SetDualFullBridgeconfig(uint8_t enable);         
+    bool STSpin240_250_SetMaxSpeed(uint8_t motorId,uint16_t newMaxSpeed);
+    void STSpin240_250_SetRefPwmDc(uint8_t refId, uint8_t newDc);   
+    void STSpin240_250_SetRefPwmFreq(uint8_t refId, uint32_t newFreq);  
+
+    /**
+     * @brief Functions to initialize the registers
+     */
+    void STSpin240_250_SetDeviceParamsToGivenValues(STSpin240_250_init_t *pInitPrm);
+    void STSpin240_250_SetDeviceParamsToPredefinedValues(void);
+    
+    /**
+     * @brief  Get the state of the standby/reset pin
+     */
+    uint8_t STSpin240_250_GetResetState(void);
+   
+    /*** Component's I/O Methods ***/
+
+    /* ACTION 8 --------------------------------------------------------------*
+     * Implement here other I/O methods beyond those already implemented      *
+     * above, which are declared extern within the component's header file.   *
+     *------------------------------------------------------------------------*/
+    /**
+     * @brief  Making the CPU wait.
+     * @param  None.
+     * @retval None.
+     */
+    void STSpin240_250_Board_Delay(uint32_t delay)
+    {
+        wait_ms(delay);
+    }
+
+    /**
+     * @brief  Disable bridge.
+     * @param  None.
+     * @retval None.
+     */  
+    void STSpin240_250_Board_DisableBridge(void) 
+    {
+        flag_and_enable.disable_irq();
+        flag_and_enable.mode(PullDown);        
+    }
+
+    /**
+     * @brief  Enable bridge.
+     * @param  addDelay if different from 0, a delay is added after bridge activation..
+     * @retval None.
+     */  
+    void STSpin240_250_Board_EnableBridge(uint8_t addDelay) 
+    {
+        flag_and_enable.mode(PullUp);
+        if (addDelay)
+        {
+            STSpin240_250_Board_Delay(BRIDGE_TURN_ON_DELAY);
+        }
+        flag_and_enable.enable_irq();       
+    }  
+
+    /** 
+     * @brief  Get the status of the reset Pin.
+     * @param  None.
+     * @retval None.
+     */  
+    uint16_t STSpin240_250_Board_GetResetPinState(void) 
+    {
+        return((uint16_t)flag_and_enable.read());
+    }
+
+    /**
+     * @brief  Get the status of the flag and enable Pin.
+     * @param  None.
+     * @retval None.
+     */  
+    uint16_t STSpin240_250_Board_GetFaultPinState(void) 
+    {
+        return((uint16_t)flag_and_enable.read());
+    }
+    
+     /**
+     * @brief  Deinitialising the PWM.
+     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
+     * @retval None.
+     */
+     void STSpin240_250_Board_PwmDeInit(uint8_t pwmId)
+     {
+        
+     }
+        
+     /**
+     * @brief  Initialising the PWM.
+     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
+     * @param  onlyChannel.
+     * @retval None.
+     */
+    void STSpin240_250_Board_PwmInit(uint8_t pwmId, uint8_t onlyChannel) 
+    {
+        
+    }
+
+    /**
+     * @brief  Setting the frequency of PWM.
+     *         The frequency of bridge A and B controls directly the speed of the device.
+     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
+     * @param  newFreq frequency to apply in Hz.
+     * @param  duty Duty cycle to use from 0 to 100.
+     * @retval None.
+     */
+    void STSpin240_250_Board_PwmSetFreq(int8_t pwmId, uint32_t newFreq, uint8_t duty)
+    {
+        /* Computing the period of PWM. */
+        double period = 1.0f / newFreq;
+        
+        switch (pwmId)
+        {
+            case 0:
+            default:
+                /* Setting the period and the duty-cycle of PWM A. */
+                pwmA.period(period);
+                pwmA.write((float)(duty / 100.0f));
+            break;
+            case 1:
+                /* Setting the period and the duty-cycle of PWM B. */
+                pwmB.period(period);
+                pwmB.write((float)(duty / 100.0f));
+            break;
+            case 2:
+                /* Setting the period and the duty-cycle of PWM Ref. */
+                pwmRef.period(period);    
+                pwmRef.write((float)(duty / 100.0f));
+            break;           
+        }
+    }
+
+    /**
+     * @brief  Stopping the PWM.
+     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
+     * @retval None.
+     */
+    void STSpin240_250_Board_PwmStop(uint8_t pwmId)
+    {
+        switch (pwmId)
+        {
+            case 0:
+            default:
+                pwmA.write(0.0f);
+            break;
+            case 1:
+                pwmB.write(0.0f);
+            break;
+            case 2:
+                pwmRef.write(0.0f);
+            break;
+        }
+    }
+
+    /**
+     * @brief  Putting the device in standby mode.
+     * @param  None.
+     * @retval None.
+     */
+    void STSpin240_250_Board_ReleaseReset(void)
+    {
+        standby_reset = 1;
+        STSpin240_250_Board_Delay(EXIT_STANDBY_MODE_DELAY);
+    }
+
+    /**
+     * @brief  Putting the device in reset mode.
+     * @param  None.
+     * @retval None.
+     */
+    void STSpin240_250_Board_Reset(void)
+    {
+        standby_reset = 0;
+    }
+
+    /**
+     * @brief  Setting the direction of rotation.
+     * @param  bridgeId 0 for bridge A, 1 for bridge B.
+     * @param  gpioState direction of rotation: "1" for forward, "0" for backward.
+     * @retval None.
+     */
+    void STSpin240_250_Board_SetDirectionGpio(uint8_t bridgeId, uint8_t gpioState)
+    {
+      if (bridgeId == 0)
+      {
+        dirA = gpioState;
+      }
+      else
+      {
+        dirB = gpioState;
+      }
+    }
+
+    /*** 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. */
+    InterruptIn flag_and_enable;
+
+    /* ACTION 10 -------------------------------------------------------------*
+     * Declare here other pin related variables, if needed.                   *
+     *                                                                        *
+     * Example:                                                               *
+     *   + mbed:                                                              *
+     *     DigitalOut standby_reset;                                          *
+     *------------------------------------------------------------------------*/
+    /* Standby/reset pin. */
+    DigitalOut standby_reset;
+
+    /* Direction pin of bridge A. */
+    DigitalOut dirA;
+
+    /* Direction pin of bridge B. */
+    DigitalOut dirB;
+
+    /* Pulse Width Modulation pin for bridge A input. */
+    PwmOut pwmA;
+    
+    /* Pulse Width Modulation pin for bridge A input. */
+    PwmOut pwmB;
+
+    /* Pulse Width Modulation pin for Ref signal. */
+    PwmOut pwmRef;
+    
+    /* ACTION 11 -------------------------------------------------------------*
+     * Declare here communication related variables, if needed.               *
+     *                                                                        *
+     * Example:                                                               *
+     *   + mbed:                                                              *
+     *     DigitalOut ssel;                                                   *
+     *     DevSPI &dev_spi;                                                   *
+     *------------------------------------------------------------------------*/
+
+    /* 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 device_prm;
+    uint8_t deviceInstance;
+
+    
+    /* Static data. */
+    static uint8_t numberOfDevices;
+    static uint8_t arrayNbMaxMotorsByConfig[2];
+    
+public:
+
+    /* Static data. */
+    
+};
+
+#endif // __STSPIN240_250_CLASS_H
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/STSpin240_250/STSpin240_250_config.h	Fri Mar 24 14:06:00 2017 +0000
@@ -0,0 +1,100 @@
+/**************************************************************************//**
+  * @file    STSpin240_250_config.h
+  * @author  IPC Rennes
+  * @version V1.0.0
+  * @date    February 10, 2016
+  * @brief   Predefines values for the Stspin240 or Stspin250 parameters
+  * and for the devices parameters
+  * @note    (C) COPYRIGHT 2016 STMicroelectronics
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STSPIN240_250_CONFIG_H
+#define __STSPIN240_250_CONFIG_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/** @addtogroup STSPIN240_250
+  * @{
+  */   
+
+/** @addtogroup STSPIN240_250_Exported_Defines STSPIN240_250 Exported Defines
+  * @{
+  */   
+   
+/** @defgroup Predefined_STSPIN240_250_Parameters_Values Predefined STSPIN240_250 Parameters Values
+  * @{
+  */   
+
+/// The maximum number of Stspin240 or Stspin250 devices 
+#define MAX_NUMBER_OF_DEVICES                 (1)
+   
+/// The maximum number of Brush DC motors connected to the Stspin240 or Stspin250
+#define MAX_NUMBER_OF_BRUSH_DC_MOTORS                    (2)
+
+/// Frequency of PWM of Input Bridge A in Hz up to 100000Hz
+#define STSPIN240_250_CONF_PARAM_FREQ_PWM_A  (20000)
+
+/// Frequency of PWM of Input Bridge B in Hz up to 100000Hz
+/// On the X-NUCLEO-IHM01A12 expansion board the PWM_A and PWM_B
+/// share the same timer, so the frequency must be the same     
+#define STSPIN240_250_CONF_PARAM_FREQ_PWM_B  (20000)
+       
+/// Frequency of PWM used for Ref pinin Hz up to 100000Hz
+#define STSPIN240_250_CONF_PARAM_FREQ_PWM_REF  (20000)
+
+/// Duty cycle of PWM used for Ref pin (from 0 to 100)
+#define STSPIN240_250_CONF_PARAM_DC_PWM_REF  (50)   
+    
+/// Dual Bridge configuration  (0 for mono, 1 for dual brush dc (STSPIN240 only)
+#define STSPIN240_250_CONF_PARAM_DUAL_BRIDGE_ENABLING    (0)
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif /* __STSPIN240_250_CONFIG_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Components/STSpin240_250/STSpin240_250_def.h	Fri Mar 24 14:06:00 2017 +0000
@@ -0,0 +1,243 @@
+/**
+ ******************************************************************************
+  * @file    STSpin240_250_def.h 
+  * @author  IPC Rennes
+  * @version V1.0.0
+  * @date    February 10, 2016
+  * @brief   Header for STSpin240 (low voltage dual brush DC motor driver) and 
+  *          STSpin250 driver (low voltage  brush DC motor driver)
+  * @note    (C) COPYRIGHT 2016 STMicroelectronics
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STSPIN240_250_H
+#define __STSPIN240_250_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/* Includes ------------------------------------------------------------------*/
+#include "STSpin240_250_config.h"
+#include "motor_def.h"   
+   
+/* Definitions ---------------------------------------------------------------*/
+
+/** @addtogroup Components
+  * @{
+  */   
+   
+/** @defgroup STSPIN240_250 STSPIN240_250
+  * @{
+  */   
+   
+/** @defgroup STSPIN240_250_Exported_Defines STSPIN240_250 Exported Defines
+  * @{
+  */   
+
+/// Current FW version
+   
+/// Current FW major version
+#define STSPIN240_250_FW_MAJOR_VERSION (uint8_t)(1)
+/// Current FW minor version
+#define STSPIN240_250_FW_MINOR_VERSION (uint8_t)(0)
+/// Current FW patch version
+#define STSPIN240_250_FW_PATCH_VERSION (uint8_t)(0)
+/// Current FW version
+#define STSPIN240_250_FW_VERSION (uint32_t)((STSPIN240_250_FW_MAJOR_VERSION<<16)|\
+                                            (STSPIN240_250_FW_MINOR_VERSION<<8)|\
+                                            (STSPIN240_250_FW_PATCH_VERSION))   
+
+///Max number of Brush DC motors
+#define STSPIN240_250_NB_MAX_MOTORS (2)
+///Number of Bridges
+#define STSPIN240_250_NB_BRIDGES (2)
+    
+    /**
+  * @}
+  */
+     
+/* Types ---------------------------------------------------------------------*/
+
+/** @defgroup STSPIN240_250_Exported_Types STSPIN240_250 Exported Types
+  * @{
+  */   
+
+
+/** @defgroup Device_Parameters Device Parameters
+  * @{
+  */
+
+/// Device Parameters Structure Type
+typedef struct {
+    /// Pwm frequency of the bridge input
+    uint32_t bridgePwmFreq[STSPIN240_250_NB_BRIDGES];      
+    /// Pwm frequency of the ref pin
+    uint32_t refPwmFreq;      
+    /// Pwm Duty Cycle of the ref pin
+    uint8_t refPwmDc;      
+    /// Speed% (from 0 to 100) of the corresponding motor
+     uint16_t speed[STSPIN240_250_NB_MAX_MOTORS];  
+    /// FORWARD or BACKWARD direction of the motors
+    motorDir_t direction[STSPIN240_250_NB_MAX_MOTORS];                 
+    /// Current State of the motors
+     motorState_t motionState[STSPIN240_250_NB_MAX_MOTORS];       
+    /// Current State of the bridges
+    bool bridgeEnabled[STSPIN240_250_NB_BRIDGES];    
+    /// Enabling of a dual bridge configuration
+    bool dualBridgeEnabled;    
+}deviceParams_t; 
+
+/**
+  * @}
+  */
+
+
+
+/** @defgroup STSpin240_250_Initialization_Structure STSpin240_250 Initialization Structure
+  * @{
+  */
+/* ACTION --------------------------------------------------------------------*
+ * Declare here the component's initialization structure, if any, one         *
+ * variable per line without initialization.                                  *
+ *                                                                            *
+ * Example:                                                                   *
+ *   typedef struct                                                           *
+ *   {                                                                        *
+ *     int frequency;                                                         *
+ *     int update_mode;                                                       *
+ *   } COMPONENT_init_t;                                                      *
+ *----------------------------------------------------------------------------*/  
+typedef struct {
+  /* Frequency of the bridge PWMs in Hz up to 100000Hz */
+  uint32_t bridgePwmFreq[STSPIN240_250_NB_BRIDGES];
+  /* Frequency of the PWM used for Ref pin in Hz up to 100000Hz */
+  uint32_t refPwmFreq; 
+  /* Duty cycle of the PWM used for Ref pin in % (0..100) */
+  uint8_t refPwmDc;
+  /* Dual Bridge configuration  (0 for mono, 1 for dual brush dc (STSPIN240 only) */
+  bool dualBridgeEnabled;
+} STSpin240_250_init_t;
+
+/**
+  * @}
+  */
+
+/** 
+ * @brief  Powerstep01 driver data structure definition.
+ */ 
+/* ACTION --------------------------------------------------------------------*
+ * Declare here the structure of component's data, if any, one variable per   *
+ * line without initialization.                                               *
+ *                                                                            *
+ * Example:                                                                   *
+ *   typedef struct                                                           *
+ *   {                                                                        *
+ *       int T0_out;                                                          *
+ *       int T1_out;                                                          *
+ *       float T0_degC;                                                       *
+ *       float T1_degC;                                                       *
+ *   } COMPONENT_Data_t;                                                      *
+ *----------------------------------------------------------------------------*/
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/* Functions -----------------------------------------------------------------*/
+
+
+/** @defgroup STSPIN240_250_Board_Linked_Functions STSPIN240_250 Board Linked Functions
+  * @{
+  */  
+
+/* ACTION --------------------------------------------------------------------*
+ * Declare here extern platform-dependent APIs you might need (e.g.: I/O and  *
+ * interrupt related functions), and implement them in a glue-logic file on   *
+ * the target environment, for example within the "x_nucleo_board.c" file.    *
+ * E.g.:                                                                      *
+ *   extern status_t COMPONENT_IO_Init (void *handle);                        *
+ *   extern status_t COMPONENT_IO_Read (handle, buf, regadd, bytes);          *
+ *   extern status_t COMPONENT_IO_Write(handle, buf, regadd, bytes);          *
+ *   extern void     COMPONENT_IO_ITConfig(void);                             *
+ *----------------------------------------------------------------------------*/
+    
+///Delay of the requested number of milliseconds
+extern void STSpin240_250_Board_Delay(void *handle, uint32_t delay);         
+///Disable the bridges
+extern void STSpin240_250_Board_DisableBridge(void *handle);     
+///Enable the specified bridge
+extern void STSpin240_250_Board_EnableBridge(void *handle, uint8_t addDelay);      
+//Get the status of the flag and enable Pin
+extern uint8_t STSpin240_250_Board_GetFaultPinState(void *handle);
+//Get the status of the reset Pin
+extern uint8_t STSpin240_250_Board_GetResetPinState(void *handle);
+///Set Briges Inputs PWM frequency and start it
+extern void STSpin240_250_Board_PwmSetFreq(void *handle, uint8_t pwmId, uint32_t newFreq, uint8_t duty); 
+///Deinitialise the PWM of the specified bridge input
+extern void STSpin240_250_Board_PwmDeInit(void *handle, uint8_t pwmId);
+///init the PWM of the specified bridge input
+extern void STSpin240_250_Board_PwmInit(void *handle, uint8_t pwmId, uint8_t onlyChannel);    
+///Stop the PWM of the specified brigde input
+extern void STSpin240_250_Board_PwmStop(void *handle, uint8_t pwmId);
+///Release the reset pin of the STSpin240 or STSpin250
+extern void STSpin240_250_Board_ReleaseReset(void *handle, uint8_t deviceId); 
+///Reset the STSpin240 or STSpin250
+extern void STSpin240_250_Board_Reset(void *handle, uint8_t deviceId);  
+///Set direction of the specified bridge
+extern void STSpin240_250_Board_SetDirectionGpio(void *handle, uint8_t bridgeId, uint8_t gpioState); 
+
+
+/**
+  * @}
+  */
+
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif /* #ifndef __STSPIN240_250_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/stspin240_250/STSpin240_250.cpp	Fri Mar 24 10:59:30 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,664 +0,0 @@
-/**
- ******************************************************************************
- * @file    STSpin240_250.cpp
- * @author  IPC Rennes
- * @version V1.0.0
- * @date    April 25th, 2016
- * @brief   Stspin240 motor driver (Dual brush DC motors)
- * @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 "STSpin240_250.h"
-
-/* Definitions ---------------------------------------------------------------*/
-
-/* Error: Access a motor index greater than the one of the current brigde configuration */
-#define STSPIN240_250_ERROR_1   (0xC001)
-/* Error: Use of a bridgeId greater than BRIDGE_B */
-#define STSPIN240_250_ERROR_2   (0xC002)    
-
-/* Maximum frequency of the PWMs in Hz */
-#define STSPIN240_250_MAX_PWM_FREQ   (100000)
-
-/* Minimum frequency of the PWMs in Hz */
-#define STSPIN240_250_MIN_PWM_FREQ   (2)
-
-/* Bridge A */
-#define BRIDGE_A         (0)
-
-/* Bridge B */
-#define BRIDGE_B         (1)
-    
-/* PWM id for PWM_A */
-#define PWM_A         (0)
-
-/* PWM id for PWM_B */
-#define PWM_B         (1)
-
-/* PWM id for PWM_REF */
-#define PWM_REF       (2)    
-
-/* Variables  ----------------------------------------------------------------*/
-
-/* Number of devices. */
-uint8_t STSpin240_250::numberOfDevices = 0;
-uint8_t STSpin240_250::arrayNbMaxMotorsByConfig[2] = {1,2};
-/* Methods -------------------------------------------------------------------*/
-
-/**********************************************************
- * @brief Starts the STSpin240_250 library
- * @param[in] pInit pointer to the initialization data
- * @retval COMPONENT_OK in case of success.
- **********************************************************/
-status_t STSpin240_250::Stspin240_250_Init(void* pInit)
-{ 
-    /* Standby-reset deactivation */
-    Stspin240_250_Board_ReleaseReset();
-    
-    /* Let a delay after reset */
-    Stspin240_250_Board_Delay(1);
-    
-    if (pInit == 0)
-    {
-        // Set all registers to their predefined values 
-        // from powerstep01_target_config.h 
-        Stspin240_250_SetDeviceParamsToPredefinedValues();
-    }
-    else
-    {
-        Stspin240_250_SetDeviceParamsToGivenValues((Stspin240_250_init_t *)pInit);
-    }
-    
-    /* Initialise input PWM of bridges*/
-    Stspin240_250_SetDualFullBridgeconfig(device_prm.dualBridgeEnabled);
-    
-    return COMPONENT_OK;
-}
-
-/**********************************************************
- * @brief Read id
- * @param[in] id pointer to the identifier to be read.
- * @retval COMPONENT_OK in case of success.
- **********************************************************/
-status_t STSpin240_250::Stspin240_250_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 STSpin240_250::Stspin240_250_AttachErrorHandler(void (*callback)(uint16_t error))
-{
-    errorHandlerCallback = (void (*)(uint16_t error)) callback;
-}
-
-
-/******************************************************//**
- * @brief Disable the specified bridge
- * @param[in] bridgeId (from 0 for bridge A to 1 for bridge B)
- * @retval None
- * @note  Bridge A and bridge B share the same enable pin. 
- * When bridge A is disabled, bridge B is disabled and 
- * reversely
- **********************************************************/
-void STSpin240_250::Stspin240_250_DisableBridge(uint8_t bridgeId)
-{
-    Stspin240_250_Board_DisableBridge();
-    device_prm.bridgeEnabled[BRIDGE_A] = FALSE;
-    device_prm.bridgeEnabled[BRIDGE_B] = FALSE;
-}
-
-/******************************************************//**
- * @brief Enable the specified bridge
- * @param[in] bridgeId (from 0 for bridge A to 1 for bridge B)
- * @retval None
- * @note  Bridge A and bridge B share the same enable pin. 
- * When bridge A is enabled, bridge B is enabled and 
- * reversely
- **********************************************************/
-void STSpin240_250::Stspin240_250_EnableBridge(uint8_t bridgeId)
-{
-    device_prm.bridgeEnabled[BRIDGE_A] = TRUE;
-    device_prm.bridgeEnabled[BRIDGE_B] = TRUE;  
-    Stspin240_250_Board_EnableBridge(1);
-}
-
-/**********************************************************
- * @brief Error handler which calls the user callback (if defined)
- * @param[in] error Number of the error
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_ErrorHandler(uint16_t error)
-{
-    if (errorHandlerCallback != 0)
-    {
-    (void) errorHandlerCallback(error);
-    }
-    else   
-    {
-    /* Aborting the program. */
-    exit(EXIT_FAILURE);
-    }
-}
-
-/******************************************************//**
- * @brief  Get the PWM frequency of the specified bridge 
- * @param[in] bridgeId 0 for bridge A, 1 for bridge B
- * @retval Freq in Hz
- **********************************************************/
-uint32_t STSpin240_250::Stspin240_250_GetBridgeInputPwmFreq(uint8_t bridgeId)
-{                                                  
-  if (bridgeId > BRIDGE_B)
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_2);
-  }    
-  
-  return (device_prm.bridgePwmFreq[(bridgeId << 1)]);
-}
-
-/******************************************************//**
- * @brief  Get the status of the bridge enabling of the corresponding bridge
- * @param[in] bridgeId from 0 for bridge A to 1 for bridge B
- * @retval State of the Enable&Fault pin (shared for bridge A and B)
-  **********************************************************/
-uint16_t STSpin240_250::Stspin240_250_GetBridgeStatus(void)
-{
-    uint16_t status = Stspin240_250_Board_GetFaultPinState();
-  
-    return (status);
-}
-
-/******************************************************//**
- * @brief  Returns the current speed of the specified motor
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @retval current speed in % from 0 to 100
- **********************************************************/
-uint16_t STSpin240_250::Stspin240_250_GetCurrentSpeed(uint8_t motorId)
-{
-  uint16_t speed = 0;
-
-  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }
-  else if (device_prm.motionState[motorId] != INACTIVE)
-  {
-    speed = device_prm.speed[motorId];
-  }   
-  return (speed); 
-}
-
-/******************************************************//**
- * @brief Returns the device state
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @retval State (STEADY or INACTIVE)
- **********************************************************/
-motorState_t STSpin240_250::Stspin240_250_get_device_state(uint8_t motorId)
-{
-  motorState_t state =  INACTIVE;
-
-  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }
-  else
-  {
-    state =  device_prm.motionState[motorId];
-  }
-  return (state);      
-}
-
-/******************************************************//**
- * @brief Get the motor current direction
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @retval direction
- **********************************************************/
-motorDir_t STSpin240_250::Stspin240_250_GetDirection(uint8_t motorId)
-{
-  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }
-  
-  return device_prm.direction[motorId];
-}
-
-/******************************************************//**
- * @brief Returns the FW version of the library
- * @retval STSPIN240_250_FW_VERSION
- **********************************************************/
-uint32_t STSpin240_250::Stspin240_250_GetFwVersion(void)
-{
-  return (STSPIN240_250_FW_VERSION);
-}
-
-
-/******************************************************//**
- * @brief  Return the duty cycle of PWM used for REF 
- * @param[in] refId 0 is the only supported id for Stspin240 or 
- * Stspin250
- * @retval duty cycle in % (from 0 to 100)
- **********************************************************/
-uint8_t STSpin240_250::Stspin240_250_GetRefPwmDc(uint8_t refId)
-{                                                  
-  uint32_t duty = 0;
-  
-  if (duty == 0)
-  {
-    duty = device_prm.refPwmDc;
-  }
-  return (duty);
-}
-
-/******************************************************//**
- * @brief  Return the frequency of PWM used for REF 
- * @param[in] refId 0 is the only supported id for Stspin240 or 
- * Stspin250
- * @retval Frequency in Hz
- **********************************************************/
-uint32_t STSpin240_250::Stspin240_250_GetRefPwmFreq(uint8_t refId)
-{                                                  
-  uint32_t freq = 0;
-  
-  if (refId == 0)
-  {
-    freq = device_prm.refPwmFreq;
-  }
-  return (freq);
-}
-
-/******************************************************//**
- * @brief  Immediatly stops the motor and disable the power bridge
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @retval None
- * @note  As all motors uses the same power bridge, the 
- * power bridge will be disable only if all motors are
- * stopped
- **********************************************************/
-void STSpin240_250::Stspin240_250_HardHiz(uint8_t motorId) 
-{
-   if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }
-  else
-  {
-    if (device_prm.bridgeEnabled[motorId] != FALSE)
-    {
-      /* Only disable bridges if dual bridge mode is disabled or */
-      /* if all motors are inactive as there are sharing the same power stage */
-      if ((device_prm.dualBridgeEnabled == 0)||
-          ((motorId == 0)&&(device_prm.motionState[1] == INACTIVE))||
-          ((motorId == 1)&&(device_prm.motionState[0] == INACTIVE)))
-      {  
-        /* Disable the bridge */
-        Stspin240_250_DisableBridge(motorId);
-      }
-    }
-    /* Disable the PWM */
-    Stspin240_250_HardStop(motorId);
-  }
-}
-
-/******************************************************//**
- * @brief  Stops the motor without disabling the bridge
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @retval none
- **********************************************************/
-void STSpin240_250::Stspin240_250_HardStop(uint8_t motorId)
-{   
-  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }
-  else if (device_prm.motionState[motorId] != INACTIVE)
-  {
-    /* Disable corresponding PWM */
-    Stspin240_250_Board_PwmStop(motorId);
-
-    /* Set inactive state */
-    device_prm.motionState[motorId] = INACTIVE;
-  }  
-}
-
-/******************************************************//**
- * @brief Release reset (exit standby mode)
- * @param[in] deviceId (from 0 to MAX_NUMBER_OF_DEVICES -1)
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_Releasereset(void)
-{
-  Stspin240_250_Board_ReleaseReset();
-  
-  /* Start PWM used for REF pin */
-  Stspin240_250_Board_PwmSetFreq(PWM_REF, device_prm.refPwmFreq,device_prm.refPwmDc);          
-}
-
-/******************************************************//**
- * @brief Reset (enter standby mode)
- * @param[in] deviceId (from 0 to MAX_NUMBER_OF_DEVICES -1)
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_reset(void)
-{
-  uint8_t loop;
-  for (loop = 0; loop < STSPIN240_250_NB_MAX_MOTORS; loop++)
-  {
-    /* Stop motor if needed*/
-    if (device_prm.motionState[loop] != INACTIVE) 
-    {
-      Stspin240_250_HardStop(loop);
-    }
-    /* Disable bridge if needed */
-    if (device_prm.bridgeEnabled[loop] != FALSE) 
-    {
-      Stspin240_250_DisableBridge(loop);
-    }    
-  }
-  
-  /* Stop PWM used for REF pin */
-  Stspin240_250_Board_PwmStop(PWM_REF);
-  
-  /* Reset the STBY/RESET pin */
-  Stspin240_250_Board_Reset();
-}
-
-/******************************************************//**
- * @brief  Runs the motor
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @param[in] direction FORWARD or BACKWARD
- * @retval None
- * @note  For unidirectionnal motor, direction parameter has 
- * no effect
- **********************************************************/
-void STSpin240_250::Stspin240_250_Run(uint8_t motorId, motorDir_t direction)
-{
-  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }  
-  else if ((device_prm.motionState[motorId] == INACTIVE) ||
-           (device_prm.direction[motorId] != direction))
-  {
-    
-    /* Release reset if required */
-    if (Stspin240_250_GetResetState() == 0)
-    {
-      Stspin240_250_ReleaseReset();
-    }
-    
-    /* Eventually deactivate motor */
-    if (device_prm.motionState[motorId] != INACTIVE) 
-    {
-      Stspin240_250_HardStop(motorId);
-    }
-
-    /* Set direction */
-    Stspin240_250_SetDirection(motorId, direction);
-
-    /* Switch to steady state */
-    device_prm.motionState[motorId] = STEADY;
-   
-    /* Enable bridge */
-    if (device_prm.bridgeEnabled[motorId] == FALSE)
-    {
-      Stspin240_250_EnableBridge(motorId);
-    }
-    /* Set PWM */
-    Stspin240_250_Board_PwmSetFreq(motorId, device_prm.bridgePwmFreq[motorId],device_prm.speed[motorId]);          
-  }
-}
-
-/******************************************************//**
- * @brief  Changes the PWM frequency of the bridge input
- * @param[in] bridgeId 0 for bridge A, 1 for bridge B
- * @param[in] newFreq in Hz
- * @retval None
- * @note 1)The PWM is only enabled when the motor is requested
- * to run.
- * 2) If the two bridges share the same timer, their frequency
- * has to be the same
- * 3) If the two bridges share the same timer, the frequency
- * is updated on the fly is there is only one motor running
- * on the targeted bridge.
- **********************************************************/
-void STSpin240_250::Stspin240_250_SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq)
-{                                                  
-  if (bridgeId > BRIDGE_B)
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_2);
-  }  
-  
-  if (newFreq > STSPIN240_250_MAX_PWM_FREQ)
-  {
-    newFreq = STSPIN240_250_MAX_PWM_FREQ;
-  }
- 
-  device_prm.bridgePwmFreq[bridgeId] = newFreq;
-  
-  if (device_prm.motionState[bridgeId] != INACTIVE)
-  {
-    Stspin240_250_Board_PwmSetFreq(bridgeId, device_prm.bridgePwmFreq[bridgeId],device_prm.speed[bridgeId]);          
-  }
-}
-
-/******************************************************//**
- * @brief  Specifies the direction 
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @param[in] dir FORWARD or BACKWARD
- * @note The direction change is only applied if the device 
- * is in INACTIVE state. To change direction while motor is 
- * running, use the run function
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_SetDirection(uint8_t motorId, motorDir_t dir)
-{
-   if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }  
-  else if (device_prm.motionState[motorId] == INACTIVE)
-  {
-    Stspin240_250_Board_SetDirectionGpio(motorId, dir);
-    device_prm.direction[motorId] = dir;
-  }
-}
-
-/******************************************************//**
- * @brief Set the dual bridge configuration mode
- * @param[in] enable 0 to disable, 
- *                   1 to enable (not supported by STSPIN250)
- * @retval None
-  **********************************************************/
-void STSpin240_250::Stspin240_250_SetDualFullBridgeconfig(uint8_t enable)
-{
-  device_prm.dualBridgeEnabled = enable;
-
-  /* Check reset pin state*/
-  if (Stspin240_250_GetResetState() != 0)
-  {
-    Stspin240_250_Reset();
-    Stspin240_250_ReleaseReset();
-  }
-}
-
-/******************************************************//**
- * @brief  Changes the max speed of the specified device
- * @param[in] motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1) 
- * @param[in] newMaxSpeed in % from 0 to 100
- * @retval true if the command is successfully executed, else false
- **********************************************************/
-bool STSpin240_250::Stspin240_250_SetMaxSpeed(uint8_t motorId, uint16_t newMaxSpeed)
-{                                                  
-  bool cmdExecuted = FALSE;
-
-  if (motorId >= arrayNbMaxMotorsByConfig[device_prm.dualBridgeEnabled])
-  {
-    Stspin240_250_ErrorHandler(STSPIN240_250_ERROR_1);
-  }
-  else
-  {
-    device_prm.speed[motorId] = newMaxSpeed;
-    if (device_prm.motionState[motorId] != INACTIVE)
-    {
-      /* Set PWM frequency*/
-      Stspin240_250_Board_PwmSetFreq(motorId, device_prm.bridgePwmFreq[motorId],device_prm.speed[motorId]);          
-    }
-    cmdExecuted = TRUE;
-  }
-  return cmdExecuted;
-}      
-
-/******************************************************//**
- * @brief  Changes the duty cycle of the PWM used for REF 
- * @param[in] refId 0 is the only supported id for Stspin240 or 
- * Stspin250
- * @param[in] newDc new duty cycle from 0 to 100
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_SetRefPwmDc(uint8_t refId, uint8_t newDc)
-{                                                  
-  if (newDc > 100)
-  {
-    newDc = 100;
-  }
- 
-  device_prm.refPwmDc = newDc;
-  
-  if (Stspin240_250_GetResetState() != 0)
-  {
-    /* Immediatly set the PWM frequency  for ref if chip is not in reset */
-    Stspin240_250_Board_PwmSetFreq(PWM_REF, device_prm.refPwmFreq,device_prm.refPwmDc);          
-  }
-}
-
-/******************************************************//**
- * @brief  Changes the frequency of PWM used for REF 
- * @param[in] refId 0 is the only supported id for Stspin240 or 
- * Stspin250
- * @param[in] newFreq in Hz
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_SetRefPwmFreq(uint8_t refId, uint32_t newFreq)
-{
-  if (newFreq > STSPIN240_250_MAX_PWM_FREQ)
-  {
-    newFreq = STSPIN240_250_MAX_PWM_FREQ;
-  }
- 
-  device_prm.refPwmFreq = newFreq;
-  
-  if (Stspin240_250_GetResetState() != 0)
-  {
-    /* Immediatly set the PWM frequency  for ref if chip is not in reset */
-    Stspin240_250_Board_PwmSetFreq(PWM_REF, device_prm.refPwmFreq,device_prm.refPwmDc);            
-  }
-} 
-
-
-/******************************************************//**
- * @brief  Get the status of the bridge enabling of the corresponding bridge
- * @retval State of the Enable&Fault pin (shared for bridge A and B)
-  **********************************************************/
-uint8_t STSpin240_250::Stspin240_250_GetResetState(void)
-{
-  uint8_t status = Stspin240_250_Board_GetResetPinState();
-  
-  return (status);
-}
-
-/******************************************************//**
- * @brief  Set the parameters of the device to values of pInitPrm structure
- * @param[in] deviceId (from 0 to MAX_NUMBER_OF_DEVICES -1)
- * @param pInitPrm pointer to a structure containing the initial device parameters 
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_SetDeviceParamsToGivenValues(Stspin240_250_init_t *pInitPrm)
-{
-  uint32_t i;
-
-  device_prm.dualBridgeEnabled = pInitPrm->dualBridgeEnabled;
-
-  device_prm.bridgePwmFreq[BRIDGE_A] = pInitPrm->bridgePwmFreq[BRIDGE_A];
-  device_prm.bridgePwmFreq[BRIDGE_B] = pInitPrm->bridgePwmFreq[BRIDGE_B];;
-
-  device_prm.refPwmFreq = pInitPrm->refPwmFreq;
-  device_prm.refPwmDc = pInitPrm->refPwmDc;
-  
-  for (i = 0; i < MAX_NUMBER_OF_BRUSH_DC_MOTORS; i++)
-  {
-    device_prm.speed[i] = 100;
-    device_prm.direction[i] = FORWARD;
-    device_prm.motionState[i] = INACTIVE;
-  }
-  for (i = 0; i < STSPIN240_250_NB_BRIDGES; i++)
-  {  
-    device_prm.bridgeEnabled[i] = FALSE;
-  }  
-}
-/******************************************************//**
- * @brief  Sets the parameters of the device to predefined values
- * from stspin240_250_target_config.h
- * @retval None
- **********************************************************/
-void STSpin240_250::Stspin240_250_SetDeviceParamsToPredefinedValues(void)
-{
-  uint32_t i;
-
-  device_prm.dualBridgeEnabled = STSPIN240_250_CONF_PARAM_DUAL_BRIDGE_ENABLING;
-
-  device_prm.bridgePwmFreq[BRIDGE_A] = STSPIN240_250_CONF_PARAM_FREQ_PWM_A;
-  device_prm.bridgePwmFreq[BRIDGE_B] = STSPIN240_250_CONF_PARAM_FREQ_PWM_B;
-
-  device_prm.refPwmFreq = STSPIN240_250_CONF_PARAM_FREQ_PWM_REF;
-  device_prm.refPwmDc = STSPIN240_250_CONF_PARAM_DC_PWM_REF;
-  
-  for (i = 0; i < MAX_NUMBER_OF_BRUSH_DC_MOTORS; i++)
-  {
-    device_prm.speed[i] = 100;
-    device_prm.direction[i] = FORWARD;
-    device_prm.motionState[i] = INACTIVE;
-  }
-  for (i = 0; i < STSPIN240_250_NB_BRIDGES; i++)
-  {  
-    device_prm.bridgeEnabled[i] = FALSE;
-  }
-}
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/stspin240_250/STSpin240_250_config.h	Fri Mar 24 10:59:30 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/**************************************************************************//**
-  * @file    STSpin240_250_config.h
-  * @author  IPC Rennes
-  * @version V1.0.0
-  * @date    February 10, 2016
-  * @brief   Predefines values for the Stspin240 or Stspin250 parameters
-  * and for the devices parameters
-  * @note    (C) COPYRIGHT 2016 STMicroelectronics
-  ******************************************************************************
-  * @attention
-  *
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STSPIN240_250_CONFIG_H
-#define __STSPIN240_250_CONFIG_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif 
-
-/** @addtogroup STSPIN240_250
-  * @{
-  */   
-
-/** @addtogroup STSPIN240_250_Exported_Defines STSPIN240_250 Exported Defines
-  * @{
-  */   
-   
-/** @defgroup Predefined_STSPIN240_250_Parameters_Values Predefined STSPIN240_250 Parameters Values
-  * @{
-  */   
-
-/// The maximum number of Stspin240 or Stspin250 devices 
-#define MAX_NUMBER_OF_DEVICES                 (1)
-   
-/// The maximum number of Brush DC motors connected to the Stspin240 or Stspin250
-#define MAX_NUMBER_OF_BRUSH_DC_MOTORS                    (2)
-
-/// Frequency of PWM of Input Bridge A in Hz up to 100000Hz
-#define STSPIN240_250_CONF_PARAM_FREQ_PWM_A  (20000)
-
-/// Frequency of PWM of Input Bridge B in Hz up to 100000Hz
-/// On the X-NUCLEO-IHM01A12 expansion board the PWM_A and PWM_B
-/// share the same timer, so the frequency must be the same     
-#define STSPIN240_250_CONF_PARAM_FREQ_PWM_B  (20000)
-       
-/// Frequency of PWM used for Ref pinin Hz up to 100000Hz
-#define STSPIN240_250_CONF_PARAM_FREQ_PWM_REF  (20000)
-
-/// Duty cycle of PWM used for Ref pin (from 0 to 100)
-#define STSPIN240_250_CONF_PARAM_DC_PWM_REF  (50)   
-    
-/// Dual Bridge configuration  (0 for mono, 1 for dual brush dc (STSPIN240 only)
-#define STSPIN240_250_CONF_PARAM_DUAL_BRIDGE_ENABLING    (0)
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif /* __STSPIN240_250_CONFIG_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\ No newline at end of file
--- a/Components/stspin240_250/STSpin240_250_def.h	Fri Mar 24 10:59:30 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,243 +0,0 @@
-/**
- ******************************************************************************
-  * @file    STSpin240_250_def.h 
-  * @author  IPC Rennes
-  * @version V1.0.0
-  * @date    February 10, 2016
-  * @brief   Header for Stspin240 (low voltage dual brush DC motor driver) and 
-  *          Stspin250 driver (low voltage  brush DC motor driver)
-  * @note    (C) COPYRIGHT 2016 STMicroelectronics
-  ******************************************************************************
-  * @attention
-  *
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STSPIN240_250_H
-#define __STSPIN240_250_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif 
-
-/* Includes ------------------------------------------------------------------*/
-#include "STSpin240_250_config.h"
-#include "motor_def.h"   
-   
-/* Definitions ---------------------------------------------------------------*/
-
-/** @addtogroup Components
-  * @{
-  */   
-   
-/** @defgroup STSPIN240_250 STSPIN240_250
-  * @{
-  */   
-   
-/** @defgroup STSPIN240_250_Exported_Defines STSPIN240_250 Exported Defines
-  * @{
-  */   
-
-/// Current FW version
-   
-/// Current FW major version
-#define STSPIN240_250_FW_MAJOR_VERSION (uint8_t)(1)
-/// Current FW minor version
-#define STSPIN240_250_FW_MINOR_VERSION (uint8_t)(0)
-/// Current FW patch version
-#define STSPIN240_250_FW_PATCH_VERSION (uint8_t)(0)
-/// Current FW version
-#define STSPIN240_250_FW_VERSION (uint32_t)((STSPIN240_250_FW_MAJOR_VERSION<<16)|\
-                                            (STSPIN240_250_FW_MINOR_VERSION<<8)|\
-                                            (STSPIN240_250_FW_PATCH_VERSION))   
-
-///Max number of Brush DC motors
-#define STSPIN240_250_NB_MAX_MOTORS (2)
-///Number of Bridges
-#define STSPIN240_250_NB_BRIDGES (2)
-    
-    /**
-  * @}
-  */
-     
-/* Types ---------------------------------------------------------------------*/
-
-/** @defgroup STSPIN240_250_Exported_Types STSPIN240_250 Exported Types
-  * @{
-  */   
-
-
-/** @defgroup Device_Parameters Device Parameters
-  * @{
-  */
-
-/// Device Parameters Structure Type
-typedef struct {
-    /// Pwm frequency of the bridge input
-    uint32_t bridgePwmFreq[STSPIN240_250_NB_BRIDGES];      
-    /// Pwm frequency of the ref pin
-    uint32_t refPwmFreq;      
-    /// Pwm Duty Cycle of the ref pin
-    uint8_t refPwmDc;      
-    /// Speed% (from 0 to 100) of the corresponding motor
-     uint16_t speed[STSPIN240_250_NB_MAX_MOTORS];  
-    /// FORWARD or BACKWARD direction of the motors
-    motorDir_t direction[STSPIN240_250_NB_MAX_MOTORS];                 
-    /// Current State of the motors
-     motorState_t motionState[STSPIN240_250_NB_MAX_MOTORS];       
-    /// Current State of the bridges
-    bool bridgeEnabled[STSPIN240_250_NB_BRIDGES];    
-    /// Enabling of a dual bridge configuration
-    bool dualBridgeEnabled;    
-}deviceParams_t; 
-
-/**
-  * @}
-  */
-
-
-
-/** @defgroup Stspin240_250_Initialization_Structure Stspin240_250 Initialization Structure
-  * @{
-  */
-/* ACTION --------------------------------------------------------------------*
- * Declare here the component's initialization structure, if any, one         *
- * variable per line without initialization.                                  *
- *                                                                            *
- * Example:                                                                   *
- *   typedef struct                                                           *
- *   {                                                                        *
- *     int frequency;                                                         *
- *     int update_mode;                                                       *
- *   } COMPONENT_init_t;                                                      *
- *----------------------------------------------------------------------------*/  
-typedef struct {
-  /* Frequency of the bridge PWMs in Hz up to 100000Hz */
-  uint32_t bridgePwmFreq[STSPIN240_250_NB_BRIDGES];
-  /* Frequency of the PWM used for Ref pin in Hz up to 100000Hz */
-  uint32_t refPwmFreq; 
-  /* Duty cycle of the PWM used for Ref pin in % (0..100) */
-  uint8_t refPwmDc;
-  /* Dual Bridge configuration  (0 for mono, 1 for dual brush dc (STSPIN240 only) */
-  bool dualBridgeEnabled;
-} Stspin240_250_init_t;
-
-/**
-  * @}
-  */
-
-/** 
- * @brief  Powerstep01 driver data structure definition.
- */ 
-/* ACTION --------------------------------------------------------------------*
- * Declare here the structure of component's data, if any, one variable per   *
- * line without initialization.                                               *
- *                                                                            *
- * Example:                                                                   *
- *   typedef struct                                                           *
- *   {                                                                        *
- *       int T0_out;                                                          *
- *       int T1_out;                                                          *
- *       float T0_degC;                                                       *
- *       float T1_degC;                                                       *
- *   } COMPONENT_Data_t;                                                      *
- *----------------------------------------------------------------------------*/
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-/* Functions -----------------------------------------------------------------*/
-
-
-/** @defgroup STSPIN240_250_Board_Linked_Functions STSPIN240_250 Board Linked Functions
-  * @{
-  */  
-
-/* ACTION --------------------------------------------------------------------*
- * Declare here extern platform-dependent APIs you might need (e.g.: I/O and  *
- * interrupt related functions), and implement them in a glue-logic file on   *
- * the target environment, for example within the "x_nucleo_board.c" file.    *
- * E.g.:                                                                      *
- *   extern status_t COMPONENT_IO_Init (void *handle);                        *
- *   extern status_t COMPONENT_IO_Read (handle, buf, regadd, bytes);          *
- *   extern status_t COMPONENT_IO_Write(handle, buf, regadd, bytes);          *
- *   extern void     COMPONENT_IO_ITConfig(void);                             *
- *----------------------------------------------------------------------------*/
-    
-///Delay of the requested number of milliseconds
-extern void Stspin240_250_Board_Delay(void *handle, uint32_t delay);         
-///Disable the bridges
-extern void Stspin240_250_Board_DisableBridge(void *handle);     
-///Enable the specified bridge
-extern void Stspin240_250_Board_EnableBridge(void *handle, uint8_t addDelay);      
-//Get the status of the flag and enable Pin
-extern uint8_t Stspin240_250_Board_GetFaultPinState(void *handle);
-//Get the status of the reset Pin
-extern uint8_t Stspin240_250_Board_GetResetPinState(void *handle);
-///Set Briges Inputs PWM frequency and start it
-extern void Stspin240_250_Board_PwmSetFreq(void *handle, uint8_t pwmId, uint32_t newFreq, uint8_t duty); 
-///Deinitialise the PWM of the specified bridge input
-extern void Stspin240_250_Board_PwmDeInit(void *handle, uint8_t pwmId);
-///init the PWM of the specified bridge input
-extern void Stspin240_250_Board_PwmInit(void *handle, uint8_t pwmId, uint8_t onlyChannel);    
-///Stop the PWM of the specified brigde input
-extern void Stspin240_250_Board_PwmStop(void *handle, uint8_t pwmId);
-///Release the reset pin of the Stspin240 or Stspin250
-extern void Stspin240_250_Board_ReleaseReset(void *handle, uint8_t deviceId); 
-///Reset the Stspin240 or Stspin250
-extern void Stspin240_250_Board_Reset(void *handle, uint8_t deviceId);  
-///Set direction of the specified bridge
-extern void Stspin240_250_Board_SetDirectionGpio(void *handle, uint8_t bridgeId, uint8_t gpioState); 
-
-
-/**
-  * @}
-  */
-
-
-/**
-  * @}
-  */
-
-/**
-  * @}
-  */
-
-#ifdef __cplusplus
-  }
-#endif
-
-#endif /* #ifndef __STSPIN240_250_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/Components/stspin240_250/stspin240_250.h	Fri Mar 24 10:59:30 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,786 +0,0 @@
-/**
- ******************************************************************************
- * @file    STSpin240_250.h
- * @author  IPC Rennes
- * @version V1.0.0
- * @date    April 20th, 2016
- * @brief   This file contains the class of a Stspin240_250 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 __STSPIN240_250_CLASS_H
-#define __STSPIN240_250_CLASS_H
-
-
-/* Includes ------------------------------------------------------------------*/
-
-/* ACTION 1 ------------------------------------------------------------------*
- * Include here platform specific header files.                               *
- *----------------------------------------------------------------------------*/        
-#include "mbed.h"
-/* ACTION 2 ------------------------------------------------------------------*
- * Include here component specific header files.                              *
- *----------------------------------------------------------------------------*/        
-#include "STSpin240_250.h"
-/* ACTION 3 ------------------------------------------------------------------*
- * Include here interface specific header files.                              *
- *                                                                            *
- * Example:                                                                   *
- *   #include "HumiditySensor.h"                                              *
- *   #include "TemperatureSensor.h"                                           *
- *----------------------------------------------------------------------------*/
-#include "BDCMotor.h"
-
-/* Defines -------------------------------------------------------------------*/
-
-/* MCU wait time in ms after power bridges are enabled */
-#define BRIDGE_TURN_ON_DELAY    (1)
-
-/* MCU wait time in ms after exit standby mode */
-#define EXIT_STANDBY_MODE_DELAY    (1)
-
-/* Classes -------------------------------------------------------------------*/
-
-
-/**
- * @brief Class representing a Stspin240_250 component.
- */
-class STSpin240_250 : public BDCMotor
-{
-public:
-
-    /*** Constructor and Destructor Methods ***/
-
-    /**
-     * @brief Constructor.
-     * @param flag_and_enable_pin   pin name of the EN pin of the component.
-     * @param standby_reset_pin     pin name of the STBY\RST pin of the component.
-     * @param pwmA_pin              pin name for the PWM input for bridge A
-     * @param pwmB_pin              pin name for the PWM input for bridge B
-     * @param dirA_pin              pin name for the direction pinfor bridge A
-     * @param dirB_pin              pin name for the direction pinfor bridge B
-     */
-    STSpin240_250(PinName flag_and_enable_pin, PinName standby_reset_pin, PinName dirA_pin, PinName dirB_pin, PinName pwmA_pin, PinName pwmB_pin, PinName pwmRef_pin) : BDCMotor(), flag_and_enable(flag_and_enable_pin), standby_reset(standby_reset_pin), dirA(dirA_pin), dirB(dirB_pin), pwmA(pwmA_pin), pwmB(pwmB_pin), pwmRef(pwmRef_pin)
-    { 
-        /* Checking stackability. */
-        if (!(numberOfDevices < MAX_NUMBER_OF_DEVICES))
-            error("Instantiation of the Stpin240_250 component failed: it can be stacked up to %d times.\r\n", MAX_NUMBER_OF_DEVICES);
-
-        /* 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++;
-    }
-    
-    /**
-     * @brief Destructor.
-     */
-    virtual ~STSpin240_250(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) Stspin240_250_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) Stspin240_250_ReadId((uint8_t *) id);
-    }
-
-    /**
-     * @brief Public functions inherited from the BCDMotor Class
-     */
-
-    /**
-     * @brief  Disabling the specified bridge.
-     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
-     * @retval None.
-     */
-    virtual void disable_bridge(unsigned int bridgeId) 
-    {
-        Stspin240_250_DisableBridge(bridgeId);
-    }
-     
-    /**
-     * @brief  Enabling the specified bridge.
-     * @param  bridgeId from 0 for bridge A to 1 for bridge B
-     * @retval None.
-     */
-    virtual void enable_bridge(unsigned int bridgeId)
-    {
-        Stspin240_250_EnableBridge(bridgeId);
-    }
-     
-    /**
-     * @brief  Getting the PWM frequency of the specified bridge;
-     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
-     * @retval The frequency in Hz of the specified bridge input PWM.
-     */
-    virtual unsigned int get_bridge_input_pwm_freq(unsigned int bridgeId)
-    {
-        return (unsigned int) Stspin240_250_GetBridgeInputPwmFreq(bridgeId);
-    }
-    
-    /**
-     * @brief  Getting the bridge status.
-     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
-     * @retval The status.
-     */
-    virtual unsigned int get_bridge_status(unsigned int bridgeId)
-    {
-        return (unsigned int) Stspin240_250_GetBridgeStatus();
-    }
-
-    /**
-     * @brief  Getting the device State. 
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
-     * @retval The device state (STEADY or INACTIVE)
-     */
-    virtual motorState_t get_device_state(unsigned int motorId)
-    {
-        return (motorState_t) Stspin240_250_get_device_state(motorId);
-    }
-   
-    /**
-     * @brief  Getting the current speed in % of the specified motor.
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
-     * @retval The current speed in %.
-     */
-    virtual unsigned int get_speed(unsigned int motorId)
-    {
-        return (unsigned int) Stspin240_250_GetCurrentSpeed(motorId);
-    }
-    
-    /**
-     * @brief  Stopping the motor and disabling the power bridge immediately.
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
-     * @retval None.
-     */
-    virtual void hard_hiz(unsigned int motorId)
-    {
-       Stspin240_250_HardHiz(motorId);
-    }
-    
-    /**
-     * @brief  Stopping the motor immediately.
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1). 
-     * @retval None.
-     */
-    virtual void hard_stop(unsigned int motorId)
-    {
-       Stspin240_250_HardStop(motorId);
-    }
-
-    /**
-     * @brief  Running the motor.
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
-     * @param  direction The direction of rotation.
-     * @retval None.
-     */
-    virtual void run(unsigned int motorId, direction_t direction) 
-    {
-       Stspin240_250_Run(motorId, (motorDir_t) direction);
-    }
-    
-    /**
-     * @brief  Setting the PWM frequency of the specified bridge.
-     * @param  bridgeId from 0 for bridge A to 1 for bridge B.
-     * @param  frequency of the PWM in Hz
-     * @retval None.
-     */
-    virtual void set_bridge_input_pwm_freq(unsigned int bridgeId, unsigned int frequency)
-    {
-        Stspin240_250_SetBridgeInputPwmFreq(bridgeId, frequency);
-    }
-        
-    /**
-     * @brief  Setting the dual bridge configuration mode.
-     * @param  configuration. The bridge configuration.
-     * @retval None.
-     */
-    virtual void set_dual_full_bridge_config(unsigned int configuration)
-    {
-        Stspin240_250_SetDualFullBridgeconfig(configuration);
-    }
-
-    /**
-     * @brief  Setting the speed in %.
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
-     * @param  speed The new speed in %.
-     * @retval "true" in case of success, "false" otherwise.
-     */
-    virtual bool set_speed(unsigned int motorId, unsigned int speed)
-    {
-        return (bool) Stspin240_250_SetMaxSpeed(motorId, speed);
-    }
-
-    /**
-     * @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))
-    {
-        Stspin240_250_AttachErrorHandler((void (*)(uint16_t error)) fptr);
-    }
-    
-    /**
-     * @brief  Getting the motor current direction.
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
-     * @retval direction The direction of rotation.
-     */
-    virtual direction_t get_direction(unsigned int motorId)
-    {
-        return (direction_t) Stspin240_250_GetDirection(motorId);
-    }
-
-    /**
-     * @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) Stspin240_250_GetFwVersion();
-    }
-
-    /**
-     * @brief  Getting the duty cycle of the PWM used for REF.
-     * @param  refId Id of the reference PWM signal.
-     * @retval duty cycle in % (from 0 to 100)
-     */
-    virtual unsigned int get_ref_pwm_dc(unsigned int refId)
-    {
-        return (unsigned int) Stspin240_250_GetRefPwmDc(refId);
-    }
-    
-    /**
-     * @brief  Getting the frequency of the PWM used for REF.
-     * @param  refId Id of the reference PWM signal.
-     * @retval frequency in Hz.
-     */
-    virtual unsigned int get_ref_pwm_freq(unsigned int refId)
-    {
-        return (unsigned int) Stspin240_250_GetRefPwmFreq(refId);
-    }
-    
-    /**
-     * @brief  Releasing the reset (exiting standby mode).
-     * @param  None.
-     * @retval None.
-     */
-    virtual void release_reset(void)
-    {
-       Stspin240_250_ReleaseReset();
-    }
-    
-    /**
-     * @brief  Reseting (entering standby mode).
-     * @param  None.
-     * @retval None.
-     */
-    virtual void reset(void)
-    {
-       Stspin240_250_Reset();
-    }
-        
-    /**
-     * @brief  Setting the direction of rotation of the firmware.
-     * @param  motorId from 0 to (MAX_NUMBER_OF_BRUSH_DC_MOTORS - 1).
-     * @param direction The direction of rotation.
-     * @retval None
-     */
-    virtual void set_direction(unsigned int motorId, direction_t direction)
-    {
-       Stspin240_250_SetDirection(motorId, (motorDir_t) direction);
-    }
-
-    /**
-     * @brief  Setting the duty cycle of the PWM used for REF.
-     * @param  refId Id of the reference PWM signal.
-     * @param  newDc new duty cycle from 0 to 100
-     * @retval None.
-     */
-    virtual void set_ref_pwm_dc(unsigned int refId, unsigned int newDc)
-    {
-        Stspin240_250_SetRefPwmDc(refId, newDc);
-    }
-    
-    /**
-     * @brief  Setting the frequency of the PWM used for REF.
-     * @param  refId Id of the reference PWM signal.
-     * @param  frequency in Hz.
-     * @retval None.
-     */
-    virtual void set_ref_pwm_freq(unsigned int refId, unsigned int frequency)
-    {
-        Stspin240_250_SetRefPwmFreq(refId, frequency);
-    }
-
-    /**
-     * @brief Public static functions
-     */    
-    static uint8_t get_nb_devices(void)
-    {
-        return numberOfDevices;
-    }
-
-    /*** 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();
-    }
-    
-    /**
-     * @brief  Disabling the FLAG interrupt handling.
-     * @param  None.
-     * @retval None.
-     */
-    void disable_flag_irq(void)
-    {
-        flag_and_enable.disable_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 Stspin240_250_Init(void *init);
-    status_t Stspin240_250_ReadId(uint8_t *id);
-    void Stspin240_250_AttachErrorHandler(void (*callback)(uint16_t error));
-    void Stspin240_250_DisableBridge(uint8_t bridgeId);
-    void Stspin240_250_EnableBridge(uint8_t bridgeId);
-    void Stspin240_250_ErrorHandler(uint16_t error);
-    uint32_t Stspin240_250_GetBridgeInputPwmFreq(uint8_t bridgeId);
-    uint16_t Stspin240_250_GetBridgeStatus(void);
-    uint16_t Stspin240_250_GetCurrentSpeed(uint8_t motorId);
-    motorState_t Stspin240_250_get_device_state(uint8_t motorId); 
-    motorDir_t Stspin240_250_GetDirection(uint8_t motorId); 
-    uint32_t Stspin240_250_GetFwVersion(void);  
-    uint8_t Stspin240_250_GetRefPwmDc(uint8_t refId);    
-    uint32_t Stspin240_250_GetRefPwmFreq(uint8_t refId);
-    void Stspin240_250_HardHiz(uint8_t motorId); 
-    void Stspin240_250_HardStop(uint8_t motorId); 
-    void Stspin240_250_Releasereset(void);  
-    void Stspin240_250_reset(void);
-    void Stspin240_250_Run(uint8_t motorId, motorDir_t direction); 
-    void Stspin240_250_SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq); 
-    void Stspin240_250_SetDirection(uint8_t motorId, motorDir_t dir); 
-    void Stspin240_250_SetDualFullBridgeconfig(uint8_t enable);         
-    bool Stspin240_250_SetMaxSpeed(uint8_t motorId,uint16_t newMaxSpeed);
-    void Stspin240_250_SetRefPwmDc(uint8_t refId, uint8_t newDc);   
-    void Stspin240_250_SetRefPwmFreq(uint8_t refId, uint32_t newFreq);  
-
-    /**
-     * @brief Functions to initialize the registers
-     */
-    void Stspin240_250_SetDeviceParamsToGivenValues(Stspin240_250_init_t *pInitPrm);
-    void Stspin240_250_SetDeviceParamsToPredefinedValues(void);
-    
-    /**
-     * @brief  Get the state of the standby/reset pin
-     */
-    uint8_t Stspin240_250_GetResetState(void);
-   
-    /*** Component's I/O Methods ***/
-
-    /* ACTION 8 --------------------------------------------------------------*
-     * Implement here other I/O methods beyond those already implemented      *
-     * above, which are declared extern within the component's header file.   *
-     *------------------------------------------------------------------------*/
-    /**
-     * @brief  Making the CPU wait.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin240_250_Board_Delay(uint32_t delay)
-    {
-        wait_ms(delay);
-    }
-
-    /**
-     * @brief  Disable bridge.
-     * @param  None.
-     * @retval None.
-     */  
-    void Stspin240_250_Board_DisableBridge(void) 
-    {
-        flag_and_enable.disable_irq();
-        flag_and_enable.mode(PullDown);        
-    }
-
-    /**
-     * @brief  Enable bridge.
-     * @param  addDelay if different from 0, a delay is added after bridge activation..
-     * @retval None.
-     */  
-    void Stspin240_250_Board_EnableBridge(uint8_t addDelay) 
-    {
-        flag_and_enable.mode(PullUp);
-        if (addDelay)
-        {
-            Stspin240_250_Board_Delay(BRIDGE_TURN_ON_DELAY);
-        }
-        flag_and_enable.enable_irq();       
-    }  
-
-    /** 
-     * @brief  Get the status of the reset Pin.
-     * @param  None.
-     * @retval None.
-     */  
-    uint16_t Stspin240_250_Board_GetResetPinState(void) 
-    {
-        return((uint16_t)flag_and_enable.read());
-    }
-
-    /**
-     * @brief  Get the status of the flag and enable Pin.
-     * @param  None.
-     * @retval None.
-     */  
-    uint16_t Stspin240_250_Board_GetFaultPinState(void) 
-    {
-        return((uint16_t)flag_and_enable.read());
-    }
-    
-     /**
-     * @brief  Deinitialising the PWM.
-     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
-     * @retval None.
-     */
-     void Stspin240_250_Board_PwmDeInit(uint8_t pwmId)
-     {
-        
-     }
-        
-     /**
-     * @brief  Initialising the PWM.
-     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
-     * @param  onlyChannel.
-     * @retval None.
-     */
-    void Stspin240_250_Board_PwmInit(uint8_t pwmId, uint8_t onlyChannel) 
-    {
-        
-    }
-
-    /**
-     * @brief  Setting the frequency of PWM.
-     *         The frequency of bridge A and B controls directly the speed of the device.
-     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
-     * @param  newFreq frequency to apply in Hz.
-     * @param  duty Duty cycle to use from 0 to 100.
-     * @retval None.
-     */
-    void Stspin240_250_Board_PwmSetFreq(int8_t pwmId, uint32_t newFreq, uint8_t duty)
-    {
-        /* Computing the period of PWM. */
-        double period = 1.0f / newFreq;
-        
-        switch (pwmId)
-        {
-            case 0:
-            default:
-                /* Setting the period and the duty-cycle of PWM A. */
-                pwmA.period(period);
-                pwmA.write((float)(duty / 100.0f));
-            break;
-            case 1:
-                /* Setting the period and the duty-cycle of PWM B. */
-                pwmB.period(period);
-                pwmB.write((float)(duty / 100.0f));
-            break;
-            case 2:
-                /* Setting the period and the duty-cycle of PWM Ref. */
-                pwmRef.period(period);    
-                pwmRef.write((float)(duty / 100.0f));
-            break;           
-        }
-    }
-
-    /**
-     * @brief  Stopping the PWM.
-     * @param  pwmId 0 for bridge A PWM, 1 for bridge B PWM, 2 for REF PWM.
-     * @retval None.
-     */
-    void Stspin240_250_Board_PwmStop(uint8_t pwmId)
-    {
-        switch (pwmId)
-        {
-            case 0:
-            default:
-                pwmA.write(0.0f);
-            break;
-            case 1:
-                pwmB.write(0.0f);
-            break;
-            case 2:
-                pwmRef.write(0.0f);
-            break;
-        }
-    }
-
-    /**
-     * @brief  Putting the device in standby mode.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin240_250_Board_Releasereset(void)
-    {
-        standby_reset = 1;
-        Stspin240_250_Board_Delay(EXIT_STANDBY_MODE_DELAY);
-    }
-
-    /**
-     * @brief  Putting the device in reset mode.
-     * @param  None.
-     * @retval None.
-     */
-    void Stspin240_250_Board_reset(void)
-    {
-        standby_reset = 0;
-    }
-
-    /**
-     * @brief  Setting the direction of rotation.
-     * @param  bridgeId 0 for bridge A, 1 for bridge B.
-     * @param  gpioState direction of rotation: "1" for forward, "0" for backward.
-     * @retval None.
-     */
-    void Stspin240_250_Board_SetDirectionGpio(uint8_t bridgeId, uint8_t gpioState)
-    {
-      if (bridgeId == 0)
-      {
-        dirA = gpioState;
-      }
-      else
-      {
-        dirB = gpioState;
-      }
-    }
-
-    /*** 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. */
-    InterruptIn flag_and_enable;
-
-    /* ACTION 10 -------------------------------------------------------------*
-     * Declare here other pin related variables, if needed.                   *
-     *                                                                        *
-     * Example:                                                               *
-     *   + mbed:                                                              *
-     *     DigitalOut standby_reset;                                          *
-     *------------------------------------------------------------------------*/
-    /* Standby/reset pin. */
-    DigitalOut standby_reset;
-
-    /* Direction pin of bridge A. */
-    DigitalOut dirA;
-
-    /* Direction pin of bridge B. */
-    DigitalOut dirB;
-
-    /* Pulse Width Modulation pin for bridge A input. */
-    PwmOut pwmA;
-    
-    /* Pulse Width Modulation pin for bridge A input. */
-    PwmOut pwmB;
-
-    /* Pulse Width Modulation pin for Ref signal. */
-    PwmOut pwmRef;
-    
-    /* ACTION 11 -------------------------------------------------------------*
-     * Declare here communication related variables, if needed.               *
-     *                                                                        *
-     * Example:                                                               *
-     *   + mbed:                                                              *
-     *     DigitalOut ssel;                                                   *
-     *     DevSPI &dev_spi;                                                   *
-     *------------------------------------------------------------------------*/
-
-    /* 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 device_prm;
-    uint8_t deviceInstance;
-
-    
-    /* Static data. */
-    static uint8_t numberOfDevices;
-    static uint8_t arrayNbMaxMotorsByConfig[2];
-    
-public:
-
-    /* Static data. */
-    
-};
-
-#endif // __STSPIN240_250_CLASS_H
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
--- a/ST_INTERFACES.lib	Fri Mar 24 10:59:30 2017 +0100
+++ b/ST_INTERFACES.lib	Fri Mar 24 14:06:00 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ST/code/ST_INTERFACES/#8f70f7159316
+https://developer.mbed.org/teams/ST/code/ST_INTERFACES/#d3c9b33b992c