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:
13:25a579b9b7c3
Child:
15:31785d1acd4b
--- a/Components/l6470/l6470_class.h	Tue Jan 19 16:07:00 2016 +0000
+++ b/Components/l6470/l6470_class.h	Tue Feb 09 16:01:30 2016 +0000
@@ -57,12 +57,12 @@
 
 /* ACTION 1 ------------------------------------------------------------------*
  * Include here platform specific header files.                               *
- *----------------------------------------------------------------------------*/        
+ *----------------------------------------------------------------------------*/
 #include "mbed.h"
 #include "DevSPI.h"
 /* ACTION 2 ------------------------------------------------------------------*
  * Include here component specific header files.                              *
- *----------------------------------------------------------------------------*/        
+ *----------------------------------------------------------------------------*/
 #include "l6470.h"
 /* ACTION 3 ------------------------------------------------------------------*
  * Include here interface specific header files.                              *
@@ -76,7 +76,8 @@
 
 /* Classes -------------------------------------------------------------------*/
 
-/** Class representing a L6470 component.
+/**
+ * @brief Class representing a L6470 component.
  */
 class L6470 : public StepperMotor
 {
@@ -153,9 +154,9 @@
      *     table's functions, if any (2).                                     *
      *                                                                        *
      * Example:                                                               *
-     *   virtual int GetValue(float *pData) //(1)                             *
+     *   virtual int GetValue(float *f)  //(1)                                *
      *   {                                                                    *
-     *     return COMPONENT_GetValue(float *pfData);                          *
+     *     return COMPONENT_GetValue(float *f);                               *
      *   }                                                                    *
      *                                                                        *
      *   virtual int EnableFeature(void) //(2)                                *
@@ -1054,11 +1055,11 @@
      * 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.                 *
+     *     InterruptIn feature_irq(pin);           //Interrupt object.        *
+     *     feature_irq.fall(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.       *
@@ -1066,7 +1067,7 @@
      * Example (mbed):                                                        *
      *   void AttachFeatureIRQ(void (*fptr) (void))                           *
      *   {                                                                    *
-     *     feature_irq.rise(fptr);                                            *
+     *     feature_irq.fall(fptr);                                            *
      *   }                                                                    *
      *                                                                        *
      *   void EnableFeatureIRQ(void)                                          *
@@ -1155,9 +1156,9 @@
      *     source files but not pointed by the component's virtual table (3). *
      *                                                                        *
      * Example:                                                               *
-     *   DrvStatusTypeDef COMPONENT_GetValue(float* pfData); //(1)            *
-     *   DrvStatusTypeDef COMPONENT_EnableFeature(void);     //(2)            *
-     *   DrvStatusTypeDef COMPONENT_ComputeAverage(void);    //(3)            *
+     *   Status_t COMPONENT_GetValue(float *f);   //(1)                       *
+     *   Status_t COMPONENT_EnableFeature(void);  //(2)                       *
+     *   Status_t COMPONENT_ComputeAverage(void); //(3)                       *
      *------------------------------------------------------------------------*/
     int32_t  L6470_AbsPos_2_Position(uint32_t AbsPos);
     uint32_t L6470_Position_2_AbsPos(int32_t Position);
@@ -1185,7 +1186,7 @@
     uint8_t  L6470_mA_2_OcdTh(float mA);
     float    L6470_StallTh_2_mA(uint8_t StallTh);
     uint8_t  L6470_mA_2_StallTh(float mA);
-    DrvStatusTypeDef L6470_Config(void *init);
+    Status_t L6470_Config(void *init);
     void     L6470_SetParam(eL6470_RegId_t L6470_RegId, uint32_t Value);
     uint32_t L6470_GetParam(eL6470_RegId_t L6470_RegId);
     void     L6470_Run(eL6470_DirId_t L6470_DirId, uint32_t Speed);
@@ -1254,7 +1255,7 @@
      * @param[in]  NumBytesToRead number of bytes to read.
      * @retval     COMPONENT_OK in case of success, COMPONENT_ERROR otherwise.
      */
-    DrvStatusTypeDef Read(uint8_t* pBuffer, uint16_t NumBytesToRead)
+    Status_t Read(uint8_t* pBuffer, uint16_t NumBytesToRead)
     {
         if (dev_spi.spi_read(pBuffer, ssel, NumBytesToRead) != 0)
             return COMPONENT_ERROR;
@@ -1267,7 +1268,7 @@
      * @param[in]  NumBytesToWrite number of bytes to write.
      * @retval     COMPONENT_OK in case of success, COMPONENT_ERROR otherwise.
      */
-    DrvStatusTypeDef Write(uint8_t* pBuffer, uint16_t NumBytesToWrite)
+    Status_t Write(uint8_t* pBuffer, uint16_t NumBytesToWrite)
     {
         if (dev_spi.spi_write(pBuffer, ssel, NumBytesToWrite) != 0)
             return COMPONENT_ERROR;
@@ -1281,7 +1282,7 @@
      * @param[in]  NumBytes number of bytes to read and write.
      * @retval     COMPONENT_OK in case of success, COMPONENT_ERROR otherwise.
      */
-    DrvStatusTypeDef ReadWrite(uint8_t* pBufferToRead, uint8_t* pBufferToWrite, uint16_t NumBytes)
+    Status_t ReadWrite(uint8_t* pBufferToRead, uint8_t* pBufferToWrite, uint16_t NumBytes)
     {
         if (dev_spi.spi_read_write(pBufferToRead, pBufferToWrite, ssel, NumBytes) != 0)
             return COMPONENT_ERROR;
@@ -1398,6 +1399,6 @@
     static uint8_t L6470_DaisyChainSpiRxStruct[L6470MAXSPICMDBYTESIZE][L6470DAISYCHAINSIZE];
 };
 
-#endif // __L6470_CLASS_H
+#endif /* __L6470_CLASS_H */
 
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/