hi
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_IHM02A1 by
Components/L6470/L6470_def.h@25:e7bdebda3c3b, 2018-02-01 (annotated)
- Committer:
- barry210110
- Date:
- Thu Feb 01 07:31:24 2018 +0000
- Revision:
- 25:e7bdebda3c3b
- Parent:
- 23:cf489f2ab072
hi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 1 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 2 | ****************************************************************************** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 3 | * @file L6470_def.h |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 4 | * @date 01/10/2014 12:00:00 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 5 | * @brief This file contains definitions, exported variables and function |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 6 | * prototypes related to the L6470. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 7 | ****************************************************************************** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 8 | * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 9 | * COPYRIGHT(c) 2014 STMicroelectronics |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 10 | * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 11 | * Redistribution and use in source and binary forms, with or without modification, |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 12 | * are permitted provided that the following conditions are met: |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 13 | * 1. Redistributions of source code must retain the above copyright notice, |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 14 | * this list of conditions and the following disclaimer. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 16 | * this list of conditions and the following disclaimer in the documentation |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 17 | * and/or other materials provided with the distribution. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 19 | * may be used to endorse or promote products derived from this software |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 20 | * without specific prior written permission. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 21 | * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 32 | * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 33 | ****************************************************************************** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 34 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 35 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 36 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 37 | /* Define to prevent recursive inclusion -------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 38 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 39 | #ifndef __L6470_H |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 40 | #define __L6470_H |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 41 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 42 | #ifdef __cplusplus |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 43 | extern "C" { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 44 | #endif |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 45 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 46 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 47 | /* Includes ------------------------------------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 48 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 49 | #include "../Common/microstepping_motor_def.h" |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 50 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 51 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 52 | /* Definitions ---------------------------------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 53 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 54 | /** @addtogroup BSP |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 55 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 56 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 57 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 58 | /** @addtogroup Components |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 59 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 60 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 61 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 62 | /** @addtogroup L6470 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 63 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 64 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 65 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 66 | /** @defgroup L6470_Exported_Defines L6470_Exported_Defines |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 67 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 68 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 69 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 70 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 71 | * @defgroup L6470_Exported_Constants |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 72 | * @brief L6470 Exported Constants. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 73 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 74 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 75 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 76 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 77 | * @defgroup L6470_Register_Max_Values |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 78 | * @brief Maximum values for L6470 registers. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 79 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 80 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 81 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 82 | #define L6470_MAX_POSITION (0x1FFFFF) //!< Max position |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 83 | #define L6470_MIN_POSITION (-(0x200000)) //!< Min position |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 84 | #define L6470_POSITION_RANGE ((uint32_t)(L6470_MAX_POSITION - L6470_MIN_POSITION)) //!< Position range |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 85 | #define L6470_MAX_SPEED (0xFFFFF) //!< max value of SPEED |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 86 | #define L6470_MAX_ACC (0xFFF) //!< max value of ACC |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 87 | #define L6470_MAX_DEC (0xFFF) //!< max value of DEC |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 88 | #define L6470_MAX_MAX_SPEED (0x3FF) //!< max value of MAX_SPEED |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 89 | #define L6470_MAX_MIN_SPEED (0xFFF) //!< max value of MIN_SPEED |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 90 | #define L6470_MAX_FS_SPD (0x3FF) //!< max value of FS_SPD |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 91 | #define L6470_MAX_INT_SPEED (0x3FFF) //!< max value of INT_SPEED |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 92 | #define L6470_MAX_ST_SLP (0xFF) //!< max value of ST_SLP |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 93 | #define L6470_MAX_FN_SLP_ACC (0xFF) //!< max value of FN_SLP_ACC |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 94 | #define L6470_MAX_FN_SLP_DEC (0xFF) //!< max value of FN_SLP_DEC |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 95 | #define L6470_MAX_OCD_TH (0xF) //!< max value of OCD_TH |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 96 | #define L6470_MAX_STALL_TH (0x7F) //!< max value of STALL_TH |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 97 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 98 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 99 | * @} |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 100 | */ /* End of L6470_Register_Max_Values */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 101 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 102 | #define L6470REGIDSIZE 25 //!< Max number of identifiers of L6470 Registers |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 103 | #define L6470APPCMDIDSIZE 19 //!< Max number of identifiers of L6470 Application Commands |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 104 | #define L6470DIRIDSIZE 2 //!< Max number of identifiers of L6470 directions |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 105 | #define L6470ACTIDSIZE 2 //!< Max number of identifiers of actions to perform about ABS_POS register |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 106 | #define L6470MAXSPICMDBYTESIZE 4 //!< Max number of byte to send via SPI to perform an application command |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 107 | #define L6470DAISYCHAINSIZE 2 //!< Max number of identifiers of L6470 in daisy chain configuration |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 108 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 109 | #define L6470_MAX_SPEED_VALUE ((float)15610) //!< max value for the speed in step/s |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 110 | #define L6470_MAX_ACC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 111 | #define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 112 | #define L6470_MAX_DEC_VALUE ((float)59590) //!< max value for the acceleration in step/s^2 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 113 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 114 | #define OCD_TH_STEP ((float)375) //!< Minimum step for OCD_TH register in mAmpere |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 115 | #define STALL_TH_STEP ((float)31.25) //!< Minimum step for STALL_TH register in mAmpere |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 116 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 117 | #define L6470_ACC_CONV ((float)0.068719) //!< Conversion factor for acceleration value from step/s^2 to the right value |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 118 | #define L6470_DEC_CONV ((float)0.068719) //!< Conversion factor for deceleration value from step/s^2 to the right value |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 119 | #define L6470_MAXSPEED_CONV ((float)0.065536) //!< Conversion factor for max speed value from step/s to the right value |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 120 | #define L6470_MINSPEED_CONV ((float)4.194304) //!< Conversion factor for min speed value from step/s to the right value |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 121 | #define L6470_SPEED_CONV ((float)67.108864) //!< Conversion factor for speed value from step/s to the right value |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 122 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 123 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 124 | /* Types ---------------------------------------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 125 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 126 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 127 | * @addtogroup BSP |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 128 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 129 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 130 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 131 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 132 | * @addtogroup Components |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 133 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 134 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 135 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 136 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 137 | * @defgroup L6470 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 138 | * @brief Tools to manage the L6470 Stepper Motor Driver. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 139 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 140 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 141 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 142 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 143 | * @defgroup L6470_Exported_Types |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 144 | * @brief L6470 Exported Types. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 145 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 146 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 147 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 148 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 149 | * @brief The structure to store some features of the L6470 Registers. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 150 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 151 | typedef struct { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 152 | uint8_t Address; //!< Register Address |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 153 | uint8_t Name[12]; //!< Register Name |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 154 | uint8_t LengthBit; //!< Register Length in bits |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 155 | uint8_t LengthByte; //!< Register Length in bytes |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 156 | uint32_t ResetValue; //!< Register Reset Value |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 157 | } sL6470_Register_t; |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 158 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 159 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 160 | * @brief The structure to store some features of the L6470 Application Commands. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 161 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 162 | typedef struct { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 163 | uint8_t Mnemonic[12]; //!< AppCmd Mnemonic |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 164 | uint8_t BinaryCode; //!< AppCmd Binary Code |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 165 | uint8_t NrOfParameters; //!< AppCmd number of needed parameters |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 166 | } sL6470_ApplicationCommand_t; |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 167 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 168 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 169 | * @brief The structure to store some features about the L6470 Motor Direction. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 170 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 171 | typedef struct { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 172 | uint8_t Mnemonic[8]; //!< L6470 Direction Mnemonic |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 173 | uint8_t BinaryCode; //!< L6470 Direction Binary Code |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 174 | } sL6470_Direction_t; |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 175 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 176 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 177 | * @brief The structure to store some features about the action taken with the L6470 ABS_POS register. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 178 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 179 | typedef struct { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 180 | uint8_t Mnemonic[4]; //!< ACT Mnemonic |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 181 | uint8_t BinaryCode; //!< ACT Binary Code |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 182 | } sL6470_ACT_t; |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 183 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 184 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 185 | * @brief The structure used to store the identifier of the L6470 application |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 186 | * command and its the needed parameters. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 187 | * @note The data stored into this structure will be used to fill the matrix |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 188 | * used by SPI to send the command to the L6470. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 189 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 190 | typedef struct { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 191 | eL6470_AppCmdId_t L6470_AppCmdId; //!< The identifier of the actual L6470 Application Command |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 192 | uint32_t p1; //!< The 1st parameter if needed |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 193 | uint32_t p2; //!< The 2nd parameter if needed |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 194 | uint32_t p3; //!< The 3rd parameter if needed |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 195 | } sL6470_AppCmdPkg_t; |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 196 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 197 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 198 | * @} |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 199 | */ /* End of L6470_Exported_Types */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 200 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 201 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 202 | * @brief L6470 driver initialization structure definition. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 203 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 204 | /* ACTION --------------------------------------------------------------------* |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 205 | * Declare here the component's initialization structure, if any, one * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 206 | * variable per line without initialization. * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 207 | * * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 208 | * Example: * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 209 | * typedef struct * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 210 | * { * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 211 | * int frequency; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 212 | * int update_mode; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 213 | * } COMPONENT_Init_t; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 214 | *----------------------------------------------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 215 | typedef struct |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 216 | { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 217 | float motorvoltage; //!< motor supply voltage in V |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 218 | float fullstepsperrevolution; //!< min number of steps per revolution for the motor |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 219 | float phasecurrent; //!< max motor phase voltage in A |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 220 | float phasevoltage; //!< max motor phase voltage in V |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 221 | float speed; //!< motor initial speed [step/s] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 222 | float acc; //!< motor acceleration [step/s^2] (comment for infinite acceleration mode) |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 223 | float dec; //!< motor deceleration [step/s^2] (comment for infinite deceleration mode) |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 224 | float maxspeed; //!< motor maximum speed [step/s] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 225 | float minspeed; //!< motor minimum speed [step/s] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 226 | float fsspd; //!< motor full-step speed threshold [step/s] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 227 | float kvalhold; //!< holding kval [V] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 228 | float kvalrun; //!< constant speed kval [V] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 229 | float kvalacc; //!< acceleration starting kval [V] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 230 | float kvaldec; //!< deceleration starting kval [V] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 231 | float intspeed; //!< intersect speed for bemf compensation curve slope changing [step/s] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 232 | float stslp; //!< start slope [s/step] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 233 | float fnslpacc; //!< acceleration final slope [s/step] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 234 | float fnslpdec; //!< deceleration final slope [s/step] |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 235 | uint8_t kterm; //!< thermal compensation factor (range [0, 15]) |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 236 | float ocdth; //!< ocd threshold [ma] (range [375 ma, 6000 ma]) |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 237 | float stallth; //!< stall threshold [ma] (range [31.25 ma, 4000 ma]) |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 238 | uint8_t step_sel; //!< step mode selection |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 239 | uint8_t alarmen; //!< alarm conditions enable |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 240 | uint16_t config; //!< ic configuration |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 241 | } L6470_init_t; |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 242 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 243 | /** |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 244 | * @brief L6470 driver data structure definition. |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 245 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 246 | /* ACTION --------------------------------------------------------------------* |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 247 | * Declare here the structure of component's data, if any, one variable per * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 248 | * line without initialization. * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 249 | * * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 250 | * Example: * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 251 | * typedef struct * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 252 | * { * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 253 | * int T0_out; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 254 | * int T1_out; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 255 | * float T0_degC; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 256 | * float T1_degC; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 257 | * } COMPONENT_Data_t; * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 258 | *----------------------------------------------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 259 | typedef struct |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 260 | { |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 261 | uint8_t L6470_Id; //!< The L6470 identifier inside the daisy chain |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 262 | sL6470_Register_t *L6470_Register; //[L6470REGIDSIZE]; //!< Array whose elements are a structure in which store information about the L6470 Registers (the address, the names, the length in bits, the reset value) |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 263 | sL6470_ApplicationCommand_t *L6470_ApplicationCommand; //[L6470APPCMDIDSIZE]; //!< Array whose elements are a structure in which store information about the L6470 Application Commands (the mnemonic name, the number of needed parameters, the related funtion to call) |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 264 | sL6470_Direction_t *L6470_Direction; //[L6470DIRIDSIZE]; //!< The mnemonic names for the L6470 direction |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 265 | sL6470_ACT_t *L6470_ACT; //[L6470ACTIDSIZE]; //!< Action taken about ABS_POS register |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 266 | sL6470_AppCmdPkg_t L6470_AppCmdPkg[L6470DAISYCHAINSIZE]; //!< To store the identifier of the actual L6470 application command and its the needed parameters |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 267 | uint8_t L6470_DaisyChainSpiTxStruct[L6470MAXSPICMDBYTESIZE][L6470DAISYCHAINSIZE]; //!< To store the matrix that contains the command data that are going to be sent by SPI to the L6470 daisy chain |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 268 | uint8_t L6470_DaisyChainSpiRxStruct[L6470MAXSPICMDBYTESIZE][L6470DAISYCHAINSIZE]; //!< To store the matrix that contains the received data by SPI from the L6470 daisy chain |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 269 | 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 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 270 | sL6470_StatusRegister_t L6470_StatusRegister; //!< To store the received L6470_StatusRegister |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 271 | sL6470_StatusRegister_t *pL6470_StatusRegister; /* = &L6470_StatusRegister; */ //!< Pointer to the L6470_StatusRegister variable |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 272 | } L6470_Data_t; |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 273 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 274 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 275 | /* Functions -----------------------------------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 276 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 277 | /** @addtogroup BSP |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 278 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 279 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 280 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 281 | /** @addtogroup Components |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 282 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 283 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 284 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 285 | /** @addtogroup L6470 |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 286 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 287 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 288 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 289 | /** @defgroup L6470_Imported_Functions L6470_Imported_Functions |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 290 | * @{ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 291 | */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 292 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 293 | /* ACTION --------------------------------------------------------------------* |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 294 | * Declare here extern platform-dependent APIs you might need (e.g.: I/O and * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 295 | * interrupt related functions), and implement them in a glue-logic file on * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 296 | * the target environment, for example within the "x_nucleo_board.c" file. * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 297 | * E.g.: * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 298 | * extern status_t COMPONENT_IO_Init (void *handle); * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 299 | * extern status_t COMPONENT_IO_Read (handle, buf, regadd, bytes); * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 300 | * extern status_t COMPONENT_IO_Write(handle, buf, regadd, bytes); * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 301 | * extern void COMPONENT_IO_ITConfig(void); * |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 302 | *----------------------------------------------------------------------------*/ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 303 | extern void L6470_DISABLE(void); |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 304 | extern void L6470_ENABLE(void); |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 305 | extern void L6470_nCS_LOW(void); |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 306 | extern void L6470_nCS_HIGH(void); |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 307 | extern void L6470_SPI_Communication(uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 308 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 309 | #ifdef __cplusplus |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 310 | } |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 311 | #endif |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 312 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 313 | #endif /* __L6470_H */ |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 314 | |
davide.aliprandi@st.com | 22:ba7f4131a5e0 | 315 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |