motor board library

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Dependents:   selfbalansingcar

Fork of X_NUCLEO_IHM02A1 by ST

Files at this revision

API Documentation at this revision

Comitter:
Davidroid
Date:
Thu Jan 14 10:00:31 2016 +0000
Parent:
10:aa68441705b2
Child:
12:a942d51c488b
Commit message:
+ <INTERFACE>_InitTypeDef moved to <COMPONENT>_InitTypeDef.

Changed in this revision

BSP/x_nucleo_ihm02a1_class.cpp Show annotated file Show diff for this revision Revisions of this file
BSP/x_nucleo_ihm02a1_class.h Show annotated file Show diff for this revision Revisions of this file
Components/Common/microstepping_motor.h Show annotated file Show diff for this revision Revisions of this file
Components/Interfaces/StepperMotor_class.h Show annotated file Show diff for this revision Revisions of this file
Components/l6470/l6470.h Show annotated file Show diff for this revision Revisions of this file
Components/l6470/l6470_class.cpp Show annotated file Show diff for this revision Revisions of this file
Components/l6470/l6470_class.h Show annotated file Show diff for this revision Revisions of this file
--- a/BSP/x_nucleo_ihm02a1_class.cpp	Mon Jan 04 16:10:54 2016 +0000
+++ b/BSP/x_nucleo_ihm02a1_class.cpp	Thu Jan 14 10:00:31 2016 +0000
@@ -70,7 +70,7 @@
  * @param ssel          pin name of the SSEL pin of the SPI device to be used for communication.
  * @param spi           SPI device to be used for communication.
  */
-X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(MICROSTEPPING_MOTOR_InitTypeDef *init_0, MICROSTEPPING_MOTOR_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, DevSPI *spi) : dev_spi(spi)
+X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(L6470_InitTypeDef *init_0, L6470_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, DevSPI *spi) : dev_spi(spi)
 {
     /* Checking stackability. */
     if (!(number_of_boards < EXPBRD_MOUNTED_NR_MAX))
@@ -111,7 +111,7 @@
  * @param miso          pin name of the MISO pin of the SPI device to be used for communication.
  * @param sclk          pin name of the SCLK pin of the SPI device to be used for communication.
  */
-X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(MICROSTEPPING_MOTOR_InitTypeDef *init_0, MICROSTEPPING_MOTOR_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, PinName mosi, PinName miso, PinName sclk)
+X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(L6470_InitTypeDef *init_0, L6470_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, PinName mosi, PinName miso, PinName sclk)
 {
     /* Checking stackability. */
     if (!(number_of_boards < EXPBRD_MOUNTED_NR_MAX))
--- a/BSP/x_nucleo_ihm02a1_class.h	Mon Jan 04 16:10:54 2016 +0000
+++ b/BSP/x_nucleo_ihm02a1_class.h	Thu Jan 14 10:00:31 2016 +0000
@@ -86,7 +86,7 @@
      * @param ssel          pin name of the SSEL pin of the SPI device to be used for communication.
      * @param spi           SPI device to be used for communication.
      */
-    X_NUCLEO_IHM02A1(MICROSTEPPING_MOTOR_InitTypeDef *init_0, MICROSTEPPING_MOTOR_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, DevSPI *spi);
+    X_NUCLEO_IHM02A1(L6470_InitTypeDef *init_0, L6470_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, DevSPI *spi);
 
     /**
      * @brief Constructor.
@@ -100,7 +100,7 @@
      * @param miso          pin name of the MISO pin of the SPI device to be used for communication.
      * @param sclk          pin name of the SCLK pin of the SPI device to be used for communication.
      */
-    X_NUCLEO_IHM02A1(MICROSTEPPING_MOTOR_InitTypeDef *init_0, MICROSTEPPING_MOTOR_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, PinName mosi, PinName miso, PinName sclk);
+    X_NUCLEO_IHM02A1(L6470_InitTypeDef *init_0, L6470_InitTypeDef *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, PinName mosi, PinName miso, PinName sclk);
 
     /**
      * @brief Destructor.
@@ -198,7 +198,7 @@
     L6470 *components[L6470DAISYCHAINSIZE];
     
     /* Components' initialization. */
-    MICROSTEPPING_MOTOR_InitTypeDef *init_components[L6470DAISYCHAINSIZE];
+    L6470_InitTypeDef *init_components[L6470DAISYCHAINSIZE];
 
     /* Results of prepared actions. */
     uint32_t results[L6470DAISYCHAINSIZE];
--- a/Components/Common/microstepping_motor.h	Mon Jan 04 16:10:54 2016 +0000
+++ b/Components/Common/microstepping_motor.h	Thu Jan 14 10:00:31 2016 +0000
@@ -274,37 +274,6 @@
 } sL6470_StatusRegister_t;
 
 /**
-  * @brief  Motor Parameter Data  
-  */ 
-typedef struct
-{
-  float     motorvoltage;           //!< motor supply voltage in V
-  float     fullstepsperrevolution; //!< min number of steps per revolution for the motor
-  float     phasecurrent;           //!< max motor phase voltage in A
-  float     phasevoltage;           //!< max motor phase voltage in V
-  float     speed;                  //!< motor initial speed [step/s]
-  float     acc;                    //!< motor acceleration [step/s^2] (comment for infinite acceleration mode)
-  float     dec;                    //!< motor deceleration [step/s^2] (comment for infinite deceleration mode)
-  float     maxspeed;               //!< motor maximum speed [step/s]
-  float     minspeed;               //!< motor minimum speed [step/s]
-  float     fsspd;                  //!< motor full-step speed threshold [step/s]
-  float     kvalhold;               //!< holding kval [V]
-  float     kvalrun;                //!< constant speed kval [V]
-  float     kvalacc;                //!< acceleration starting kval [V]
-  float     kvaldec;                //!< deceleration starting kval [V]
-  float     intspeed;               //!< intersect speed for bemf compensation curve slope changing [step/s]
-  float     stslp;                  //!< start slope [s/step]
-  float     fnslpacc;               //!< acceleration final slope [s/step]
-  float     fnslpdec;               //!< deceleration final slope [s/step]
-  uint8_t   kterm;                  //!< thermal compensation factor (range [0, 15])
-  float     ocdth;                  //!< ocd threshold [ma] (range [375 ma, 6000 ma])
-  float     stallth;                //!< stall threshold [ma] (range [31.25 ma, 4000 ma])
-  uint8_t   step_sel;               //!< step mode selection
-  uint8_t   alarmen;                //!< alarm conditions enable
-  uint16_t  config;                 //!< ic configuration
-} MICROSTEPPING_MOTOR_InitTypeDef;
-
-/**
   * @brief Stepper Motor Registers
   */
 typedef struct
@@ -350,11 +319,11 @@
    * specified exactly in the given way.                                    *
    *                                                                        *
    * Example:                                                               *
-   *   DrvStatusTypeDef (*Init)(void *handle, INTERFACE_InitTypeDef *init); *
+   *   DrvStatusTypeDef (*Init)(void *handle, void *init);                  *
    *   DrvStatusTypeDef (*ReadID)(void *handle, uint8_t *id);               *
    *------------------------------------------------------------------------*/
   /* Generic */
-  DrvStatusTypeDef (*Init)(void *handle, MICROSTEPPING_MOTOR_InitTypeDef *init);
+  DrvStatusTypeDef (*Init)(void *handle, void *init);
   DrvStatusTypeDef (*ReadID)(void *handle, uint8_t *id);
   
   /* ACTION ----------------------------------------------------------------*
@@ -466,7 +435,6 @@
 typedef struct __StepperMotorDriver_HandleTypeDef
 {
   uint8_t DaisyChainPosition;
-  void (*Config)(MICROSTEPPING_MOTOR_InitTypeDef*);
   MICROSTEPPING_MOTOR_DrvVTableTypeDef *Command;
 } StepperMotorDriverHandle_t;
 
@@ -476,7 +444,6 @@
 typedef struct __StepperMotorBoard_HandleTypeDef
 {
   uint8_t StackedPosition;
-  void (*Config)(MICROSTEPPING_MOTOR_InitTypeDef*);
   MICROSTEPPING_MOTOR_EB_DrvVTableTypeDef *Command;
   StepperMotorDriverHandle_t *StepperMotorDriverHandle[2];
   uint8_t (*Select)(uint8_t);
--- a/Components/Interfaces/StepperMotor_class.h	Mon Jan 04 16:10:54 2016 +0000
+++ b/Components/Interfaces/StepperMotor_class.h	Thu Jan 14 10:00:31 2016 +0000
@@ -76,7 +76,7 @@
      * @param  parameter The parameter's identifier (or its register address).
      * @retval The parameter's value.
      */
-    virtual unsigned int GetParameter(unsigned int parameter) = 0;
+    virtual float GetParameter(unsigned int parameter) = 0;
 
     /**
      * @brief  Getting the position.
@@ -140,7 +140,7 @@
      * @param  value The parameter's value.
      * @retval None.
      */
-    virtual void SetParameter(unsigned int parameter, unsigned int value) = 0;
+    virtual void SetParameter(unsigned int parameter, float value) = 0;
 
     /**
      * @brief  Setting the current position to be the home position.
--- a/Components/l6470/l6470.h	Mon Jan 04 16:10:54 2016 +0000
+++ b/Components/l6470/l6470.h	Thu Jan 14 10:00:31 2016 +0000
@@ -174,7 +174,38 @@
 
 
 /** 
-  * @brief  L6470 driver data structure definition.
+  * @brief  L6470 driver initialization structure definition.
+  */ 
+typedef struct
+{
+  float     motorvoltage;           //!< motor supply voltage in V
+  float     fullstepsperrevolution; //!< min number of steps per revolution for the motor
+  float     phasecurrent;           //!< max motor phase voltage in A
+  float     phasevoltage;           //!< max motor phase voltage in V
+  float     speed;                  //!< motor initial speed [step/s]
+  float     acc;                    //!< motor acceleration [step/s^2] (comment for infinite acceleration mode)
+  float     dec;                    //!< motor deceleration [step/s^2] (comment for infinite deceleration mode)
+  float     maxspeed;               //!< motor maximum speed [step/s]
+  float     minspeed;               //!< motor minimum speed [step/s]
+  float     fsspd;                  //!< motor full-step speed threshold [step/s]
+  float     kvalhold;               //!< holding kval [V]
+  float     kvalrun;                //!< constant speed kval [V]
+  float     kvalacc;                //!< acceleration starting kval [V]
+  float     kvaldec;                //!< deceleration starting kval [V]
+  float     intspeed;               //!< intersect speed for bemf compensation curve slope changing [step/s]
+  float     stslp;                  //!< start slope [s/step]
+  float     fnslpacc;               //!< acceleration final slope [s/step]
+  float     fnslpdec;               //!< deceleration final slope [s/step]
+  uint8_t   kterm;                  //!< thermal compensation factor (range [0, 15])
+  float     ocdth;                  //!< ocd threshold [ma] (range [375 ma, 6000 ma])
+  float     stallth;                //!< stall threshold [ma] (range [31.25 ma, 4000 ma])
+  uint8_t   step_sel;               //!< step mode selection
+  uint8_t   alarmen;                //!< alarm conditions enable
+  uint16_t  config;                 //!< ic configuration
+} L6470_InitTypeDef;
+
+/** 
+  * @brief L6470 driver data structure definition.
   */ 
 /* ACTION --------------------------------------------------------------------*
  * Declare here the structure of component's data, if any, one variable per   *
--- a/Components/l6470/l6470_class.cpp	Mon Jan 04 16:10:54 2016 +0000
+++ b/Components/l6470/l6470_class.cpp	Thu Jan 14 10:00:31 2016 +0000
@@ -1446,7 +1446,7 @@
   * @param  StepperMotorDriverHandle_t* The pointer to the stepper motor driver handle structure.
   * @param  MotorParameterData_t* The pointer to the related parameter data structure.
   */
-DrvStatusTypeDef L6470::L6470_Config(MICROSTEPPING_MOTOR_InitTypeDef *MotorParameterData)
+DrvStatusTypeDef L6470::L6470_Config(L6470_InitTypeDef *MotorParameterData)
 {
   /* Disable the L6470. */
   L6470_DISABLE();
--- a/Components/l6470/l6470_class.h	Mon Jan 04 16:10:54 2016 +0000
+++ b/Components/l6470/l6470_class.h	Thu Jan 14 10:00:31 2016 +0000
@@ -170,7 +170,7 @@
      */
     virtual int Init(void *init)
     {
-        return (int) L6470_Config((MICROSTEPPING_MOTOR_InitTypeDef *) init);
+        return (int) L6470_Config((L6470_InitTypeDef *) init);
     }
 
     /**
@@ -198,9 +198,9 @@
      * @param  parameter The parameter's identifier (or its register address).
      * @retval The parameter's value.
      */
-    virtual unsigned int GetParameter(unsigned int parameter)
+    virtual float GetParameter(unsigned int parameter)
     {
-        return (unsigned int) L6470_GetParam((eL6470_RegId_t) parameter);
+        return (float) L6470_GetParam((eL6470_RegId_t) parameter);
     }
 
     /**
@@ -289,7 +289,7 @@
      * @param  value The parameter's value.
      * @retval None.
      */
-    virtual void SetParameter(unsigned int parameter, unsigned int value)
+    virtual void SetParameter(unsigned int parameter, float value)
     {
         L6470_SetParam((eL6470_RegId_t) parameter, (uint32_t) value);
     }
@@ -1086,7 +1086,7 @@
      */
     void AttachFlagIRQ(void (*fptr)(void))
     {
-        flag_irq.rise(fptr);
+        flag_irq.fall(fptr);
     }
     
     /**
@@ -1116,7 +1116,7 @@
      */
     void AttachBusyIRQ(void (*fptr)(void))
     {
-        busy_irq.rise(fptr);
+        busy_irq.fall(fptr);
     }
     
     /**
@@ -1185,7 +1185,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(MICROSTEPPING_MOTOR_InitTypeDef *MotorParameterData);
+    DrvStatusTypeDef L6470_Config(L6470_InitTypeDef *MotorParameterData);
     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);