Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_IHM02A1 by
Diff: Components/l6470/l6470.h
- Revision:
- 14:e614697ebf34
- Parent:
- 11:1aca63b2f034
- Child:
- 16:0d5be428b264
--- a/Components/l6470/l6470.h Tue Jan 19 16:07:00 2016 +0000
+++ b/Components/l6470/l6470.h Tue Feb 09 16:01:30 2016 +0000
@@ -1,39 +1,41 @@
/**
- ******************************************************************************
- * @file L6470.h
- * @date 01/10/2014 12:00:00
- * @brief This file contains definitions, exported variables and function
- * prototypes related to 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.h
+ * @date 01/10/2014 12:00:00
+ * @brief This file contains definitions, exported variables and function
+ * prototypes related to 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.
+ *
+ ******************************************************************************
+ */
+
/* Define to prevent recursive inclusion -------------------------------------*/
+
#ifndef __L6470_H
#define __L6470_H
@@ -41,9 +43,86 @@
extern "C" {
#endif
+
/* Includes ------------------------------------------------------------------*/
+
#include "microstepping_motor.h"
+
+/* Definitions ---------------------------------------------------------------*/
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Components
+ * @{
+ */
+
+/** @addtogroup L6470
+ * @{
+ */
+
+/** @defgroup L6470_Exported_Defines L6470_Exported_Defines
+ * @{
+ */
+
+/**
+ * @defgroup L6470_Exported_Constants
+ * @brief L6470 Exported Constants.
+ * @{
+ */
+
+/**
+ * @defgroup L6470_Register_Max_Values
+ * @brief Maximum values for L6470 registers.
+ * @{
+ */
+
+#define L6470_MAX_POSITION (0x1FFFFF) //!< Max position
+#define L6470_MIN_POSITION (-(0x200000)) //!< Min position
+#define L6470_POSITION_RANGE ((uint32_t)(L6470_MAX_POSITION - L6470_MIN_POSITION)) //!< Position range
+#define L6470_MAX_SPEED (0xFFFFF) //!< max value of SPEED
+#define L6470_MAX_ACC (0xFFF) //!< max value of ACC
+#define L6470_MAX_DEC (0xFFF) //!< max value of DEC
+#define L6470_MAX_MAX_SPEED (0x3FF) //!< max value of MAX_SPEED
+#define L6470_MAX_MIN_SPEED (0xFFF) //!< max value of MIN_SPEED
+#define L6470_MAX_FS_SPD (0x3FF) //!< max value of FS_SPD
+#define L6470_MAX_INT_SPEED (0x3FFF) //!< max value of INT_SPEED
+#define L6470_MAX_ST_SLP (0xFF) //!< max value of ST_SLP
+#define L6470_MAX_FN_SLP_ACC (0xFF) //!< max value of FN_SLP_ACC
+#define L6470_MAX_FN_SLP_DEC (0xFF) //!< max value of FN_SLP_DEC
+#define L6470_MAX_OCD_TH (0xF) //!< max value of OCD_TH
+#define L6470_MAX_STALL_TH (0x7F) //!< max value of STALL_TH
+
+/**
+ * @}
+ */ /* End of L6470_Register_Max_Values */
+
+#define L6470REGIDSIZE 25 //!< Max number of identifiers of L6470 Registers
+#define L6470APPCMDIDSIZE 19 //!< Max number of identifiers of L6470 Application Commands
+#define L6470DIRIDSIZE 2 //!< Max number of identifiers of L6470 directions
+#define L6470ACTIDSIZE 2 //!< Max number of identifiers of actions to perform about ABS_POS register
+#define L6470MAXSPICMDBYTESIZE 4 //!< Max number of byte to send via SPI to perform an application command
+#define L6470DAISYCHAINSIZE 2 //!< Max number of identifiers of L6470 in daisy chain configuration
+
+#define L6470_MAX_SPEED_VALUE ((float)15610) //!< max value for the speed in step/s
+#define L6470_MAX_ACC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
+#define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
+#define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
+
+#define OCD_TH_STEP ((float)375) //!< Minimum step for OCD_TH register in mAmpere
+#define STALL_TH_STEP ((float)31.25) //!< Minimum step for STALL_TH register in mAmpere
+
+#define L6470_ACC_CONV ((float)0.068719) //!< Conversion factor for acceleration value from step/s^2 to the right value
+#define L6470_DEC_CONV ((float)0.068719) //!< Conversion factor for deceleration value from step/s^2 to the right value
+#define L6470_MAXSPEED_CONV ((float)0.065536) //!< Conversion factor for max speed value from step/s to the right value
+#define L6470_MINSPEED_CONV ((float)4.194304) //!< Conversion factor for min speed value from step/s to the right value
+#define L6470_SPEED_CONV ((float)67.108864) //!< Conversion factor for speed value from step/s to the right value
+
+
+/* Types ---------------------------------------------------------------------*/
+
/**
* @addtogroup BSP
* @{
@@ -119,63 +198,20 @@
* @}
*/ /* End of L6470_Exported_Types */
-/**
- * @defgroup L6470_Exported_Constants
- * @brief L6470 Exported Constants.
- * @{
- */
-
-/**
- * @defgroup L6470_Register_Max_Values
- * @brief Maximum values for L6470 registers.
- * @{
- */
-
-#define L6470_MAX_POSITION (0x1FFFFF) //!< Max position
-#define L6470_MIN_POSITION (-(0x200000)) //!< Min position
-#define L6470_POSITION_RANGE ((uint32_t)(L6470_MAX_POSITION - L6470_MIN_POSITION)) //!< Position range
-#define L6470_MAX_SPEED (0xFFFFF) //!< max value of SPEED
-#define L6470_MAX_ACC (0xFFF) //!< max value of ACC
-#define L6470_MAX_DEC (0xFFF) //!< max value of DEC
-#define L6470_MAX_MAX_SPEED (0x3FF) //!< max value of MAX_SPEED
-#define L6470_MAX_MIN_SPEED (0xFFF) //!< max value of MIN_SPEED
-#define L6470_MAX_FS_SPD (0x3FF) //!< max value of FS_SPD
-#define L6470_MAX_INT_SPEED (0x3FFF) //!< max value of INT_SPEED
-#define L6470_MAX_ST_SLP (0xFF) //!< max value of ST_SLP
-#define L6470_MAX_FN_SLP_ACC (0xFF) //!< max value of FN_SLP_ACC
-#define L6470_MAX_FN_SLP_DEC (0xFF) //!< max value of FN_SLP_DEC
-#define L6470_MAX_OCD_TH (0xF) //!< max value of OCD_TH
-#define L6470_MAX_STALL_TH (0x7F) //!< max value of STALL_TH
-
-/**
- * @}
- */ /* End of L6470_Register_Max_Values */
-
-#define L6470REGIDSIZE 25 //!< Max number of identifiers of L6470 Registers
-#define L6470APPCMDIDSIZE 19 //!< Max number of identifiers of L6470 Application Commands
-#define L6470DIRIDSIZE 2 //!< Max number of identifiers of L6470 directions
-#define L6470ACTIDSIZE 2 //!< Max number of identifiers of actions to perform about ABS_POS register
-#define L6470MAXSPICMDBYTESIZE 4 //!< Max number of byte to send via SPI to perform an application command
-#define L6470DAISYCHAINSIZE 2 //!< Max number of identifiers of L6470 in daisy chain configuration
-
-#define L6470_MAX_SPEED_VALUE ((float)15610) //!< max value for the speed in step/s
-#define L6470_MAX_ACC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
-#define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
-#define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2
-
-#define OCD_TH_STEP ((float)375) //!< Minimum step for OCD_TH register in mAmpere
-#define STALL_TH_STEP ((float)31.25) //!< Minimum step for STALL_TH register in mAmpere
-
-#define L6470_ACC_CONV ((float)0.068719) //!< Conversion factor for acceleration value from step/s^2 to the right value
-#define L6470_DEC_CONV ((float)0.068719) //!< Conversion factor for deceleration value from step/s^2 to the right value
-#define L6470_MAXSPEED_CONV ((float)0.065536) //!< Conversion factor for max speed value from step/s to the right value
-#define L6470_MINSPEED_CONV ((float)4.194304) //!< Conversion factor for min speed value from step/s to the right value
-#define L6470_SPEED_CONV ((float)67.108864) //!< Conversion factor for speed value from step/s to the right value
-
-
/**
- * @brief L6470 driver initialization structure definition.
- */
+ * @brief L6470 driver initialization structure definition.
+ */
+/* 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
{
float motorvoltage; //!< motor supply voltage in V
@@ -202,11 +238,11 @@
uint8_t step_sel; //!< step mode selection
uint8_t alarmen; //!< alarm conditions enable
uint16_t config; //!< ic configuration
-} L6470_InitTypeDef;
+} L6470_Init_t;
/**
- * @brief L6470 driver data structure definition.
- */
+ * @brief L6470 driver data structure definition.
+ */
/* ACTION --------------------------------------------------------------------*
* Declare here the structure of component's data, if any, one variable per *
* line without initialization. *
@@ -218,8 +254,8 @@
* int T1_out; *
* float T0_degC; *
* float T1_degC; *
- * } COMPONENT_DrvDataTypeDef; *
- * ---------------------------------------------------------------------------*/
+ * } COMPONENT_Data_t; *
+ *----------------------------------------------------------------------------*/
typedef struct
{
uint8_t L6470_Id; //!< The L6470 identifier inside the daisy chain
@@ -233,7 +269,7 @@
eFlagStatus_t L6470_DaisyChain_HalfPrepared; /* = ZERO_F; */ //!< Boolean variable used when more than one L6470 into the daisy chain is going to be addressed for commanding
sL6470_StatusRegister_t L6470_StatusRegister; //!< To store the received L6470_StatusRegister
sL6470_StatusRegister_t *pL6470_StatusRegister; /* = &L6470_StatusRegister; */ //!< Pointer to the L6470_StatusRegister variable
-} L6470_DrvDataTypeDef;
+} L6470_Data_t;
/* Functions -----------------------------------------------------------------*/
@@ -250,15 +286,19 @@
* @{
*/
-/** @defgroup L6470_IO_Functions L6470_IO_Functions
+/** @defgroup L6470_Imported_Functions L6470_Imported_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.: *
- * extern DrvStatusTypeDef COMPONENT_IO_Read (handle, buf, regadd, bytes); *
- * extern DrvStatusTypeDef COMPONENT_IO_Write(handle, buf, regadd, bytes); *
+ * 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); *
*----------------------------------------------------------------------------*/
extern void L6470_DISABLE(void);
extern void L6470_ENABLE(void);
@@ -266,22 +306,6 @@
extern void L6470_nCS_HIGH(void);
extern void L6470_SPI_Communication(uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
-/**
- * @}
- */ /* End of L6470_Exported_Variables */
-
-/**
- * @}
- */ /* End of L6470 */
-
-/**
- * @}
- */ /* End of Components */
-
-/**
- * @}
- */ /* End of BSP */
-
#ifdef __cplusplus
}
#endif
