Library to handle the X_NUCLEO_IHM02A1 Motor Control Expansion Board based on the L6470 component.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_IHM02A1 ConcorsoFinal HelloWorld_IHM02A1_mbedOS HelloWorld_IHM02A1-Serialinterpreter ... more

Fork of X_NUCLEO_IHM02A1 by ST Expansion SW Team

Motor Control Library

Introduction

Library to handle the X-NUCLEO-IHM02A1 Motor Control Expansion Board based on the the L6470 component.

Daisy-Chain Configuration

The two L6470 components mounted on this board are connected in daisy-chain configuration. This board can be stacked up to four times so that the eight L6470 components will be connected two-by-two in daisy-chain configuration.

Concerning the SSEL pin of the SPI communication, each expansion board must be in one of the following configuration:

  • SB_23 resistor connected only: SSEL on pin A2;
  • SB_7 resistor connected only: SSEL on pin D2;
  • SB_8 resistor connected only: SSEL on pin D10;
  • SB_9 resistor connected only: SSEL on pin D5.

Arduino Connector Compatibility Warning

X-NUCLEO-IHM02A1 is Arduino compatible with one exception: instead of using D13 pin to drive the SPI clock, it uses D3 pin, hence the default configuration for this library is with the SPI clock on D3 pin.

To be fully Arduino compatible the following patch is required:

  • to remove the SB34 resistor;
  • to solder the SB12 resistor.

Alternatively, you can route the Nucleo board’s D13 pin directly to the expansion board’s D3 pin with a wire. In case you patch your expansion board or route the pin, the SPI clock will be driven on D13 pin rather than on D3 pin, and you have also to initialize the sclk PinName variable with D13 rather than D3. This patch is known to be required, for example, on the following boards: NUCLEO-F103RB, NUCLEO-F302RB, NUCLEO-F411RE, and NUCLEO-F429ZI.

If you use D13 pin for the SPI clock, please be aware that on STM32 Nucleo boards you may not drive the LED, otherwise you will get a conflict: the LED on STM32 Nucleo boards is connected to the D13 pin.

Example Applications

Revision:
14:e614697ebf34
Parent:
12:a942d51c488b
Child:
15:31785d1acd4b
--- a/Components/l6470/l6470_class.cpp	Tue Jan 19 16:07:00 2016 +0000
+++ b/Components/l6470/l6470_class.cpp	Tue Feb 09 16:01:30 2016 +0000
@@ -1,37 +1,37 @@
 /**
-  ******************************************************************************
-  * @file       l6470_class.cpp
-  * @date       01/10/2014 12:00:00
-  * @brief      This file provides set of firmware functions to manage the
-  *             L6470.
-  ******************************************************************************
-  *
-  * COPYRIGHT(c) 2014 STMicroelectronics
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
+ ******************************************************************************
+ * @file       l6470_class.cpp
+ * @date       01/10/2014 12:00:00
+ * @brief      This file provides set of firmware functions to manage the
+ *             L6470.
+ ******************************************************************************
+ *
+ * COPYRIGHT(c) 2014 STMicroelectronics
+ *
+ * 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.
+ *
+ ******************************************************************************
+ */
 
 
 /* Generated with Stm32CubeTOO -----------------------------------------------*/
@@ -52,66 +52,7 @@
 #include "l6470.h"
 
 
-/* Methods -------------------------------------------------------------------*/
-
-/**
-  * @defgroup   L6470_Conversion_Functions
-  * @brief      The following functions act just on one driver inside the L6470
-  *             daisy chain. The command is immediately sent.
-  * @{
-  */
-
-/* End of L6470_Conversion_Functions */
-
-/**
-  * @defgroup   L6470_AppCMDs
-  * @brief      The following functions act just on one driver inside the L6470
-  *             daisy chain. The command is immediately sent.
-  * @{
-  */
-
-/* End of L6470_AppCMDs */
-
-/**
-  * @defgroup L6470_AppCMDs_ToBePrepared
-  * @brief  The following functions act just on one driver inside the L6470 daisy
-  *         chain. The command is prepared and not sent. To send the application
-  *         commands already prepared for the addressed L6470 drivers you have to
-  *         use @ref L6470_PerformPreparedApplicationCommand.
-  * @{
-  */
-
-/* End of L6470_AppCMDs_ToBePrepared */
-
-/**
-  * @defgroup L6470_Private_Functions
-  * @brief    L6470 Private Functions.
-  * @{
-  */
-
-/* End of L6470_Private_Functions */
-
-
-/**
-  * @addtogroup BSP
-  * @{
-  */
-
-/**
-  * @addtogroup Components
-  * @{
-  */
-
-/**
-  * @addtogroup L6470
-  * @{
-  */
-    
-/**
-  * @defgroup   L6470_Private_Constants
-  * @brief      L6470 Private Constants.
-  * @{
-  */
+/* Variables -----------------------------------------------------------------*/
 
 /* Number of instantiated devices on an expansion board. */
 uint8_t L6470::number_of_devices = 0;
@@ -214,6 +155,9 @@
   * @{
   */
 
+
+/* Methods -------------------------------------------------------------------*/
+
 /**
   * @brief  Reset the structure used to store the identifier of the L6470
   *         application command and its the needed parameters.
@@ -1071,7 +1015,7 @@
   */
 void L6470::L6470_PrepareSetParam(eL6470_RegId_t L6470_RegId, uint32_t Value)
 {
-    L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SETPARAM_ID, L6470_RegId, Value, 0);
+  L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SETPARAM_ID, L6470_RegId, Value, 0);
 }
 
 /**
@@ -1087,7 +1031,7 @@
   */
 void L6470::L6470_PrepareGetParam(eL6470_RegId_t L6470_RegId)
 {
-    L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GETPARAM_ID, L6470_RegId, 0, 0);
+  L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GETPARAM_ID, L6470_RegId, 0, 0);
 }
 
 /**
@@ -1445,7 +1389,7 @@
   * @brief  Configures the L6470 registers.
   * @param  init The pointer to the initialization structure.
   */
-DrvStatusTypeDef L6470::L6470_Config(void *init)
+Status_t L6470::L6470_Config(void *init)
 {
   /* Disable the L6470. */
   L6470_DISABLE();
@@ -1460,7 +1404,7 @@
   GetStatus();
 
   /* Prepare the 'Register' field of StepperMotorDriverHandle */
-  L6470_InitTypeDef *MotorParameterData = (L6470_InitTypeDef *) init;
+  L6470_Init_t *MotorParameterData = (L6470_Init_t *) init;
   StepperMotorRegister.ACC = L6470_Step_s2_2_Acc(MotorParameterData->acc);
   StepperMotorRegister.DEC = L6470_Step_s2_2_Dec(MotorParameterData->dec);
   StepperMotorRegister.MAX_SPEED = L6470_Step_s_2_MaxSpeed(MotorParameterData->maxspeed);