Controlls of IHM01A1 by Joystick shield

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_IHM01A1 by ST

Files at this revision

API Documentation at this revision

Comitter:
Davidroid
Date:
Fri Oct 16 13:30:06 2015 +0000
Parent:
0:2887415a46cd
Child:
2:de6d31fa3709
Child:
4:83a1eb397a65
Commit message:
+ Removed Timer Serivce Routine's flag and restored direct callback.; + Restored "L6474_WaitWhileActive()" function.;

Changed in this revision

Components/Common/motor.h Show annotated file Show diff for this revision Revisions of this file
Components/Interfaces/Motor_class.h Show annotated file Show diff for this revision Revisions of this file
Components/l6474/l6474.h Show annotated file Show diff for this revision Revisions of this file
Components/l6474/l6474_class.cpp Show annotated file Show diff for this revision Revisions of this file
Components/l6474/l6474_class.h Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_COMMON.lib Show annotated file Show diff for this revision Revisions of this file
--- a/Components/Common/motor.h	Wed Oct 14 15:12:18 2015 +0000
+++ b/Components/Common/motor.h	Fri Oct 16 13:30:06 2015 +0000
@@ -72,7 +72,7 @@
 #define TRUE  (1)
 #endif
 
-   /**
+/**
   * @}
   */
    
@@ -80,11 +80,6 @@
   * @{
   */
 
-   /** @defgroup Motor_Boolean_Type
-  * @{
-  */
-///bool Type
-//typedef uint8_t bool;
 /**
   * @}
   */   
@@ -97,6 +92,7 @@
   BACKWARD = 0,
   FORWARD = 1
 } motorDir_t;
+
 /**
   * @}
   */
@@ -298,6 +294,8 @@
   bool (*SoftStop)(void *handle); 
   /// Function pointer to StepClockHandler
   void (*StepClockHandler)(void *handle);  
+  /// Function pointer to WaitWhileActive
+  void (*WaitWhileActive)(void *handle);
   /// Function pointer to CmdDisable
   void (*CmdDisable)(void *handle); 
   /// Function pointer to CmdEnable
--- a/Components/Interfaces/Motor_class.h	Wed Oct 14 15:12:18 2015 +0000
+++ b/Components/Interfaces/Motor_class.h	Fri Oct 16 13:30:06 2015 +0000
@@ -78,41 +78,42 @@
      * Example:                                                               *
      *    virtual int GetValue(float *pfData) = 0;                            *
      *------------------------------------------------------------------------*/
-    virtual uint16_t GetAcceleration (void) = 0;
-    virtual uint16_t GetCurrentSpeed (void) = 0;
-    virtual uint16_t GetDeceleration (void) = 0;
-    virtual motorState_t GetDeviceState (void) = 0;
-    virtual uint8_t GetFwVersion (void) = 0;
-    virtual int32_t GetMark (void) = 0;
-    virtual uint16_t GetMaxSpeed (void) = 0;
-    virtual uint16_t GetMinSpeed (void) = 0;
-    virtual int32_t GetPosition (void) = 0;
-    virtual void GoHome (void) = 0;
-    virtual void GoMark (void) = 0;
-    virtual void GoTo (int32_t targetPosition) = 0;
-    virtual void HardStop (void) = 0;
-    virtual void Move (motorDir_t direction, uint32_t stepCount) = 0;
-    virtual void Run (motorDir_t direction) = 0;
-    virtual bool SetAcceleration (uint16_t newAcc) = 0;
-    virtual bool SetDeceleration (uint16_t newDec) = 0;
-    virtual void SetHome (void) = 0;
-    virtual void SetMark (void) = 0;
-    virtual bool SetMaxSpeed (uint16_t newMaxSpeed) = 0;
-    virtual bool SetMinSpeed (uint16_t newMinSpeed) = 0;
-    virtual bool SoftStop (void) = 0;
-    virtual void StepClockHandler (void) = 0;
-    virtual void CmdDisable (void) = 0;
-    virtual void CmdEnable (void) = 0;
-    virtual uint32_t CmdGetParam (uint32_t param) = 0;
-    virtual uint16_t CmdGetStatus (void) = 0;
-    virtual void CmdNop (void) = 0;
-    virtual void CmdSetParam (uint32_t param, uint32_t value) = 0;
-    virtual uint16_t ReadStatusRegister (void) = 0;
-    virtual void ReleaseReset (void) = 0;
-    virtual void Reset (void) = 0;
-    virtual void SelectStepMode (motorStepMode_t stepMod) = 0;
-    virtual void SetDirection (motorDir_t direction) = 0;
-    virtual void ErrorHandler (uint16_t error) = 0;
+    virtual uint16_t GetAcceleration(void) = 0;
+    virtual uint16_t GetCurrentSpeed(void) = 0;
+    virtual uint16_t GetDeceleration(void) = 0;
+    virtual motorState_t GetDeviceState(void) = 0;
+    virtual uint8_t GetFwVersion(void) = 0;
+    virtual int32_t GetMark(void) = 0;
+    virtual uint16_t GetMaxSpeed(void) = 0;
+    virtual uint16_t GetMinSpeed(void) = 0;
+    virtual int32_t GetPosition(void) = 0;
+    virtual void GoHome(void) = 0;
+    virtual void GoMark(void) = 0;
+    virtual void GoTo(int32_t targetPosition) = 0;
+    virtual void HardStop(void) = 0;
+    virtual void Move(motorDir_t direction, uint32_t stepCount) = 0;
+    virtual void Run(motorDir_t direction) = 0;
+    virtual bool SetAcceleration(uint16_t newAcc) = 0;
+    virtual bool SetDeceleration(uint16_t newDec) = 0;
+    virtual void SetHome(void) = 0;
+    virtual void SetMark(void) = 0;
+    virtual bool SetMaxSpeed(uint16_t newMaxSpeed) = 0;
+    virtual bool SetMinSpeed(uint16_t newMinSpeed) = 0;
+    virtual bool SoftStop(void) = 0;
+    virtual void StepClockHandler(void) = 0;
+    virtual void WaitWhileActive(void) = 0;
+    virtual void CmdDisable(void) = 0;
+    virtual void CmdEnable(void) = 0;
+    virtual uint32_t CmdGetParam(uint32_t param) = 0;
+    virtual uint16_t CmdGetStatus(void) = 0;
+    virtual void CmdNop(void) = 0;
+    virtual void CmdSetParam(uint32_t param, uint32_t value) = 0;
+    virtual uint16_t ReadStatusRegister(void) = 0;
+    virtual void ReleaseReset(void) = 0;
+    virtual void Reset(void) = 0;
+    virtual void SelectStepMode(motorStepMode_t stepMod) = 0;
+    virtual void SetDirection(motorDir_t direction) = 0;
+    virtual void ErrorHandler(uint16_t error) = 0;
 };
 
 #endif /* __MOTOR_CLASS_H */
--- a/Components/l6474/l6474.h	Wed Oct 14 15:12:18 2015 +0000
+++ b/Components/l6474/l6474.h	Fri Oct 16 13:30:06 2015 +0000
@@ -455,30 +455,24 @@
 } L6474_DrvDataTypeDef;
 
 
-/* Functions -----------------------------------------------------------------*/
+/* Exported functions --------------------------------------------------------*/
 
-/** @addtogroup BSP
- * @{
- */
-
-/** @addtogroup Components
- * @{
- */
+/** @defgroup L6474_Exported_Functions
+  * @{
+  */   
 
-/** @addtogroup L6474
- * @{
- */
-
-/** @defgroup L6474_IO_Functions L6474_IO_Functions
- * @{
- */
 /* ACTION --------------------------------------------------------------------*
- * Declare here extern I/O functions you need and implemented them in a glue  *
- * logic file on the target environment, for example within the expansion     *
- * board "*.c" file. E.g.:                                                    *
+ * Declare here extern I/O and interrupt related functions you might need,    *
+ * and implemented then in a glue logic file on the target environment, for   *
+ * example within the "x_nucleo_<board>.c" file., e.g.:                       *
+ *   extern DrvStatusTypeDef COMPONENT_IO_Init (void *handle);                *
  *   extern DrvStatusTypeDef COMPONENT_IO_Read (handle, buf, regadd, bytes);  *
  *   extern DrvStatusTypeDef COMPONENT_IO_Write(handle, buf, regadd, bytes);  *
+ *   extern void COMPONENT_IO_ITConfig(void);                                 *
  *----------------------------------------------------------------------------*/
+/** @defgroup MotorControl_Board_Linked_Functions
+  * @{
+  */   
 ///Delay of the requested number of milliseconds
 extern void L6474_Delay(void *handle, uint32_t delay);     
 ///Enable Irq
--- a/Components/l6474/l6474_class.cpp	Wed Oct 14 15:12:18 2015 +0000
+++ b/Components/l6474/l6474_class.cpp	Fri Oct 16 13:30:06 2015 +0000
@@ -45,7 +45,7 @@
     Repository:       http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
     Branch/Trunk/Tag: trunk
     Based on:         X-CUBE-SPN1/trunk/Drivers/BSP/Components/l6474/l6474.c
-    Revision:         0
+    Revision:         :0
 */
 
 
@@ -54,8 +54,8 @@
 #include "l6474_class.h"
 #include "l6474.h"
 
-
-/* Private constants ---------------------------------------------------------*/
+    
+/* Private constants ---------------------------------------------------------*/    
 
 /// Error while initialising the SPI
 #define L6474_ERROR_0   (0x8000)   
@@ -78,7 +78,7 @@
 uint8_t L6474::numberOfDevices = 0;
 
 
-/* Private function prototypes -----------------------------------------------*/
+/* Methods -------------------------------------------------------------------*/
 
 /******************************************************//**
  * @brief  Attaches a user callback to the error Handler.
@@ -144,7 +144,7 @@
  **********************************************************/
 DrvStatusTypeDef L6474::L6474_ReadID(uint8_t *id)
 {
-  *id = type;
+  *id = deviceInstance;
 
   return COMPONENT_OK;
 }
@@ -514,6 +514,16 @@
 }
 
 /******************************************************//**
+ * @brief  Locks until the device state becomes Inactive
+ * @retval None
+ **********************************************************/
+void L6474::L6474_WaitWhileActive(void)
+{
+  /* Wait while motor is running */
+  while (L6474_GetDeviceState() != INACTIVE);
+}
+
+/******************************************************//**
  * @brief  Issue the Disable command to the L6474 of the specified device
  * @retval None
  **********************************************************/
--- a/Components/l6474/l6474_class.h	Wed Oct 14 15:12:18 2015 +0000
+++ b/Components/l6474/l6474_class.h	Fri Oct 16 13:30:06 2015 +0000
@@ -76,11 +76,6 @@
 #include "../Interfaces/Motor_class.h"
 
 
-/* Functions -----------------------------------------------------------------*/
-
-extern void PWMCallback(void);
-
-
 /* Classes -------------------------------------------------------------------*/
 
 /** Class representing a L6474 component.
@@ -290,6 +285,11 @@
         L6474_StepClockHandler();
     }
 
+    virtual void WaitWhileActive(void)
+    {
+        L6474_WaitWhileActive();
+    }
+
     virtual void CmdDisable(void)
     {
         L6474_CmdDisable();
@@ -403,41 +403,42 @@
      *   DrvStatusTypeDef COMPONENT_EnableFeature(void);     //(2)            *
      *   DrvStatusTypeDef COMPONENT_ComputeAverage(void);    //(3)            *
      *------------------------------------------------------------------------*/
-    void L6474_AttachErrorHandler(void (*callback)(uint16_t error));   //Attach a user callback to the error handler
-    void L6474_AttachFlagInterrupt(void (*callback)(void));            //Attach a user callback to the flag Interrupt
-    DrvStatusTypeDef L6474_Init(MOTOR_InitTypeDef *init);              //Start the L6474 library
-    DrvStatusTypeDef L6474_ReadID(uint8_t *id);                        //Read Id to get driver instance
-    uint16_t L6474_GetAcceleration(void);                              //Return the acceleration in pps^2
-    uint16_t L6474_GetCurrentSpeed(void);                              //Return the current speed in pps
-    uint16_t L6474_GetDeceleration(void);                              //Return the deceleration in pps^2
-    motorState_t L6474_GetDeviceState(void);                           //Return the device state
-    uint8_t L6474_GetFwVersion(void);                                  //Return the FW version
-    int32_t L6474_GetMark(void);                                       //Return the mark position 
-    uint16_t L6474_GetMaxSpeed(void);                                  //Return the max speed in pps
-    uint16_t L6474_GetMinSpeed(void);                                  //Return the min speed in pps
-    int32_t L6474_GetPosition(void);                                   //Return the ABS_POSITION (32b signed)
-    void L6474_GoHome(void);                                           //Move to the home position
-    void L6474_GoMark(void);                                           //Move to the Mark position
-    void L6474_GoTo(int32_t targetPosition);                           //Go to the specified position
-    void L6474_HardStop(void);                                         //Stop the motor and disable the power bridge
-    void L6474_Move(motorDir_t direction, uint32_t stepCount);         //Move the motor of the specified number of steps
-    void L6474_Run(motorDir_t direction);                              //Run the motor 
-    bool L6474_SetAcceleration(uint16_t newAcc);                       //Set the acceleration in pps^2
-    bool L6474_SetDeceleration(uint16_t newDec);                       //Set the deceleration in pps^2
-    void L6474_SetHome(void);                                          //Set current position to be the home position
-    void L6474_SetMark(void);                                          //Set current position to be the Markposition
-    bool L6474_SetMaxSpeed(uint16_t newMaxSpeed);                      //Set the max speed in pps
-    bool L6474_SetMinSpeed(uint16_t newMinSpeed);                      //Set the min speed in pps   
-    bool L6474_SoftStop(void);                                         //Progressively stops the motor 
-    void L6474_CmdDisable(void);                                       //Send the L6474_DISABLE command
-    void L6474_CmdEnable(void);                                        //Send the L6474_ENABLE command
-    uint32_t L6474_CmdGetParam(uint32_t param);                        //Send the L6474_GET_PARAM command
-    uint16_t L6474_CmdGetStatus(void);                                 //Send the L6474_GET_STATUS command
-    void L6474_CmdNop(void);                                           //Send the L6474_NOP command
-    void L6474_CmdSetParam(uint32_t param, uint32_t value);            //Send the L6474_SET_PARAM command
-    uint16_t L6474_ReadStatusRegister(void);                           //Read the L6474_STATUS register without clearing the flags
-    void L6474_SelectStepMode(motorStepMode_t stepMod);                //Step mode selection
-    void L6474_SetDirection(motorDir_t direction);                     //Set the L6474 direction pin
+    void L6474_AttachErrorHandler(void (*callback)(uint16_t error)); //Attach a user callback to the error handler
+    void L6474_AttachFlagInterrupt(void (*callback)(void));          //Attach a user callback to the flag Interrupt
+    DrvStatusTypeDef L6474_Init(MOTOR_InitTypeDef *init);            //Start the L6474 library
+    DrvStatusTypeDef L6474_ReadID(uint8_t *id);                      //Read Id to get driver instance
+    uint16_t L6474_GetAcceleration(void);                            //Return the acceleration in pps^2
+    uint16_t L6474_GetCurrentSpeed(void);                            //Return the current speed in pps
+    uint16_t L6474_GetDeceleration(void);                            //Return the deceleration in pps^2
+    motorState_t L6474_GetDeviceState(void);                         //Return the device state
+    uint8_t L6474_GetFwVersion(void);                                //Return the FW version
+    int32_t L6474_GetMark(void);                                     //Return the mark position 
+    uint16_t L6474_GetMaxSpeed(void);                                //Return the max speed in pps
+    uint16_t L6474_GetMinSpeed(void);                                //Return the min speed in pps
+    int32_t L6474_GetPosition(void);                                 //Return the ABS_POSITION (32b signed)
+    void L6474_GoHome(void);                                         //Move to the home position
+    void L6474_GoMark(void);                                         //Move to the Mark position
+    void L6474_GoTo(int32_t targetPosition);                         //Go to the specified position
+    void L6474_HardStop(void);                                       //Stop the motor and disable the power bridge
+    void L6474_Move(motorDir_t direction, uint32_t stepCount);       //Move the motor of the specified number of steps
+    void L6474_Run(motorDir_t direction);                            //Run the motor 
+    bool L6474_SetAcceleration(uint16_t newAcc);                     //Set the acceleration in pps^2
+    bool L6474_SetDeceleration(uint16_t newDec);                     //Set the deceleration in pps^2
+    void L6474_SetHome(void);                                        //Set current position to be the home position
+    void L6474_SetMark(void);                                        //Set current position to be the Markposition
+    bool L6474_SetMaxSpeed(uint16_t newMaxSpeed);                    //Set the max speed in pps
+    bool L6474_SetMinSpeed(uint16_t newMinSpeed);                    //Set the min speed in pps   
+    bool L6474_SoftStop(void);                                       //Progressively stops the motor 
+    void L6474_WaitWhileActive(void);                                //Wait for the device state becomes Inactive
+    void L6474_CmdDisable(void);                                     //Send the L6474_DISABLE command
+    void L6474_CmdEnable(void);                                      //Send the L6474_ENABLE command
+    uint32_t L6474_CmdGetParam(uint32_t param);                      //Send the L6474_GET_PARAM command
+    uint16_t L6474_CmdGetStatus(void);                               //Send the L6474_GET_STATUS command
+    void L6474_CmdNop(void);                                         //Send the L6474_NOP command
+    void L6474_CmdSetParam(uint32_t param, uint32_t value);          //Send the L6474_SET_PARAM command
+    uint16_t L6474_ReadStatusRegister(void);                         //Read the L6474_STATUS register without clearing the flags
+    void L6474_SelectStepMode(motorStepMode_t stepMod);              //Step mode selection
+    void L6474_SetDirection(motorDir_t direction);                   //Set the L6474 direction pin
     void L6474_ApplySpeed(uint16_t newSpeed);
     void L6474_ComputeSpeedProfile(uint32_t nbSteps);
     int32_t L6474_ConvertPosition(uint32_t abs_position_reg); 
@@ -536,7 +537,7 @@
         double period = 1.0f / newFreq;
         pwm.period(period);
         pwm.write(0.5f);
-        ticker.attach(&PWMCallback, period);
+        ticker.attach(this, &L6474::L6474_StepClockHandler, period);
     }
 
     /*
--- a/X_NUCLEO_COMMON.lib	Wed Oct 14 15:12:18 2015 +0000
+++ b/X_NUCLEO_COMMON.lib	Fri Oct 16 13:30:06 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/ST/code/X_NUCLEO_COMMON/#1f35e8bf427b
+http://developer.mbed.org/teams/ST/code/X_NUCLEO_COMMON/#da29b5403ca1