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

Committer:
Davidroid
Date:
Wed Dec 09 15:00:35 2015 +0000
Revision:
6:c62aa608a493
Parent:
2:3ed992ffeada
Child:
7:3bb27256c3ed
+ Correction of a typo.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Davidroid 0:92706998571a 1 /**
Davidroid 0:92706998571a 2 ******************************************************************************
Davidroid 2:3ed992ffeada 3 * @file l6470_class.cpp
Davidroid 0:92706998571a 4 * @date 01/10/2014 12:00:00
Davidroid 0:92706998571a 5 * @brief This file provides set of firmware functions to manage the
Davidroid 0:92706998571a 6 * L6470.
Davidroid 0:92706998571a 7 ******************************************************************************
Davidroid 0:92706998571a 8 *
Davidroid 0:92706998571a 9 * COPYRIGHT(c) 2014 STMicroelectronics
Davidroid 0:92706998571a 10 *
Davidroid 0:92706998571a 11 * Redistribution and use in source and binary forms, with or without modification,
Davidroid 0:92706998571a 12 * are permitted provided that the following conditions are met:
Davidroid 0:92706998571a 13 * 1. Redistributions of source code must retain the above copyright notice,
Davidroid 0:92706998571a 14 * this list of conditions and the following disclaimer.
Davidroid 0:92706998571a 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
Davidroid 0:92706998571a 16 * this list of conditions and the following disclaimer in the documentation
Davidroid 0:92706998571a 17 * and/or other materials provided with the distribution.
Davidroid 0:92706998571a 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Davidroid 0:92706998571a 19 * may be used to endorse or promote products derived from this software
Davidroid 0:92706998571a 20 * without specific prior written permission.
Davidroid 0:92706998571a 21 *
Davidroid 0:92706998571a 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Davidroid 0:92706998571a 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Davidroid 0:92706998571a 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Davidroid 0:92706998571a 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Davidroid 0:92706998571a 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Davidroid 0:92706998571a 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Davidroid 0:92706998571a 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Davidroid 0:92706998571a 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Davidroid 0:92706998571a 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Davidroid 0:92706998571a 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Davidroid 0:92706998571a 32 *
Davidroid 0:92706998571a 33 ******************************************************************************
Davidroid 0:92706998571a 34 */
Davidroid 0:92706998571a 35
Davidroid 0:92706998571a 36
Davidroid 0:92706998571a 37 /* Generated with Stm32CubeTOO -----------------------------------------------*/
Davidroid 0:92706998571a 38
Davidroid 0:92706998571a 39
Davidroid 0:92706998571a 40 /* Revision ------------------------------------------------------------------*/
Davidroid 0:92706998571a 41 /*
Davidroid 0:92706998571a 42 Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
Davidroid 0:92706998571a 43 Branch/Trunk/Tag: trunk
Davidroid 0:92706998571a 44 Based on: X-CUBE-SPN2/trunk/Drivers/BSP/Components/L6470/L6470.c
Davidroid 6:c62aa608a493 45 Revision: 0
Davidroid 0:92706998571a 46 */
Davidroid 0:92706998571a 47
Davidroid 0:92706998571a 48
Davidroid 0:92706998571a 49 /* Includes ------------------------------------------------------------------*/
Davidroid 0:92706998571a 50
Davidroid 0:92706998571a 51 #include "l6470_class.h"
Davidroid 0:92706998571a 52 #include "l6470.h"
Davidroid 0:92706998571a 53
Davidroid 0:92706998571a 54
Davidroid 0:92706998571a 55 /* Definitions ---------------------------------------------------------------*/
Davidroid 0:92706998571a 56
Davidroid 0:92706998571a 57 /**
Davidroid 0:92706998571a 58 * @defgroup L6470_Private_Macros
Davidroid 0:92706998571a 59 * @brief L6470 Private Macros.
Davidroid 0:92706998571a 60 * @{
Davidroid 0:92706998571a 61 */
Davidroid 0:92706998571a 62 //#define _DELAY(TDISCS) for(delay_cnt=0; delay_cnt<20; delay_cnt++) __NOP() //!<Simply deselect time delay for SPI nCS
Davidroid 0:92706998571a 63 /* End of L6470_Private_Macros */
Davidroid 0:92706998571a 64
Davidroid 0:92706998571a 65
Davidroid 0:92706998571a 66 /* Methods -------------------------------------------------------------------*/
Davidroid 0:92706998571a 67
Davidroid 0:92706998571a 68 /**
Davidroid 0:92706998571a 69 * @defgroup L6470_Conversion_Functions
Davidroid 0:92706998571a 70 * @brief The following functions act just on one driver inside the L6470
Davidroid 0:92706998571a 71 * daisy chain. The command is immediately sent.
Davidroid 0:92706998571a 72 * @{
Davidroid 0:92706998571a 73 */
Davidroid 0:92706998571a 74
Davidroid 0:92706998571a 75 /* End of L6470_Conversion_Functions */
Davidroid 0:92706998571a 76
Davidroid 0:92706998571a 77 /**
Davidroid 0:92706998571a 78 * @defgroup L6470_AppCMDs
Davidroid 0:92706998571a 79 * @brief The following functions act just on one driver inside the L6470
Davidroid 0:92706998571a 80 * daisy chain. The command is immediately sent.
Davidroid 0:92706998571a 81 * @{
Davidroid 0:92706998571a 82 */
Davidroid 0:92706998571a 83
Davidroid 0:92706998571a 84 /* End of L6470_AppCMDs */
Davidroid 0:92706998571a 85
Davidroid 0:92706998571a 86 /**
Davidroid 0:92706998571a 87 * @defgroup L6470_AppCMDs_ToBePrepared
Davidroid 0:92706998571a 88 * @brief The following functions act just on one driver inside the L6470 daisy
Davidroid 0:92706998571a 89 * chain. The command is prepared and not sent. To send the application
Davidroid 0:92706998571a 90 * commands already prepared for the addressed L6470 drivers you have to
Davidroid 0:92706998571a 91 * use @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 92 * @{
Davidroid 0:92706998571a 93 */
Davidroid 0:92706998571a 94
Davidroid 0:92706998571a 95 /* End of L6470_AppCMDs_ToBePrepared */
Davidroid 0:92706998571a 96
Davidroid 0:92706998571a 97 /**
Davidroid 0:92706998571a 98 * @defgroup L6470_Private_Functions
Davidroid 0:92706998571a 99 * @brief L6470 Private Functions.
Davidroid 0:92706998571a 100 * @{
Davidroid 0:92706998571a 101 */
Davidroid 0:92706998571a 102
Davidroid 0:92706998571a 103 /* End of L6470_Private_Functions */
Davidroid 0:92706998571a 104
Davidroid 0:92706998571a 105
Davidroid 0:92706998571a 106 /**
Davidroid 0:92706998571a 107 * @addtogroup BSP
Davidroid 0:92706998571a 108 * @{
Davidroid 0:92706998571a 109 */
Davidroid 0:92706998571a 110
Davidroid 0:92706998571a 111 /**
Davidroid 0:92706998571a 112 * @addtogroup Components
Davidroid 0:92706998571a 113 * @{
Davidroid 0:92706998571a 114 */
Davidroid 0:92706998571a 115
Davidroid 0:92706998571a 116 /**
Davidroid 0:92706998571a 117 * @addtogroup L6470
Davidroid 0:92706998571a 118 * @{
Davidroid 0:92706998571a 119 */
Davidroid 0:92706998571a 120
Davidroid 0:92706998571a 121 /**
Davidroid 0:92706998571a 122 * @defgroup L6470_Private_Constants
Davidroid 0:92706998571a 123 * @brief L6470 Private Constants.
Davidroid 0:92706998571a 124 * @{
Davidroid 0:92706998571a 125 */
Davidroid 0:92706998571a 126
Davidroid 0:92706998571a 127 /* Number of instantiated devices on an expansion board. */
Davidroid 0:92706998571a 128 uint8_t L6470::number_of_devices = 0;
Davidroid 0:92706998571a 129
Davidroid 0:92706998571a 130 /* SPI Transmission for Daisy-Chain Configuration. */
Davidroid 0:92706998571a 131 eFlagStatus_t L6470::L6470_DaisyChain_HalfPrepared;
Davidroid 0:92706998571a 132 sL6470_AppCmdPkg_t L6470::L6470_AppCmdPkg[L6470DAISYCHAINSIZE];
Davidroid 0:92706998571a 133 uint8_t L6470::L6470_DaisyChainSpiTxStruct[L6470MAXSPICMDBYTESIZE][L6470DAISYCHAINSIZE];
Davidroid 0:92706998571a 134 uint8_t L6470::L6470_DaisyChainSpiRxStruct[L6470MAXSPICMDBYTESIZE][L6470DAISYCHAINSIZE];
Davidroid 0:92706998571a 135
Davidroid 0:92706998571a 136 /**
Davidroid 0:92706998571a 137 * @brief Array whose elements are a structure in which store information about
Davidroid 0:92706998571a 138 * the L6470 Registers (the address, the names, the length in bits, the
Davidroid 0:92706998571a 139 * reset value)
Davidroid 0:92706998571a 140 */
Davidroid 0:92706998571a 141 const sL6470_Register_t L6470::_L6470_Register[L6470REGIDSIZE] = {
Davidroid 0:92706998571a 142 {0x01 , "ABS_POS", 22, 3, 0x000000}, //!< Current position
Davidroid 0:92706998571a 143 {0x02 , "EL_POS", 9, 2, 0x000}, //!< Electrical position
Davidroid 0:92706998571a 144 {0x03 , "MARK", 22, 3, 0x000000}, //!< Mark position
Davidroid 0:92706998571a 145 {0x04 , "SPEED", 20, 3, 0x0000}, //!< Current speed
Davidroid 0:92706998571a 146 {0x05 , "ACC", 12, 2, 0x08A}, //!< Acceleration
Davidroid 0:92706998571a 147 {0x06 , "DEC", 12, 2, 0x08A}, //!< Deceleration
Davidroid 0:92706998571a 148 {0x07 , "MAX_SPEED", 10, 2, 0x041}, //!< Maximum speed
Davidroid 0:92706998571a 149 {0x08 , "MIN_SPEED", 13, 2, 0x000}, //!< Minimum speed
Davidroid 0:92706998571a 150 {0x15 , "FS_SPD", 10, 2, 0x027}, //!< Full-step speed
Davidroid 0:92706998571a 151 {0x09 , "KVAL_HOLD", 8, 1, 0x29}, //!< Holding KVAL
Davidroid 0:92706998571a 152 {0x0A , "KVAL_RUN", 8, 1, 0x29}, //!< Constant speed KVAL
Davidroid 0:92706998571a 153 {0x0B , "KVAL_ACC", 8, 1, 0x29}, //!< Acceleration starting KVAL
Davidroid 0:92706998571a 154 {0x0C , "KVAL_DEC", 8, 1, 0x29}, //!< Deceleration starting KVAL
Davidroid 0:92706998571a 155 {0x0D , "INT_SPEED", 14, 2, 0x0408}, //!< Intersect speed
Davidroid 0:92706998571a 156 {0x0E , "ST_SLP", 8, 1, 0x19}, //!< Start slope
Davidroid 0:92706998571a 157 {0x0F , "FN_SLP_ACC", 8, 1, 0x29}, //!< Acceleration final slope
Davidroid 0:92706998571a 158 {0x10 , "FN_SLP_DEC", 8, 1, 0x29}, //!< Deceleration final slope
Davidroid 0:92706998571a 159 {0x11 , "K_THERM", 4, 1, 0x0}, //!< Thermal compensation factor
Davidroid 0:92706998571a 160 {0x12 , "ADC_OUT", 5, 1, 0x00}, //!< ADC output, (the reset value is according to startup conditions)
Davidroid 0:92706998571a 161 {0x13 , "OCD_TH", 4, 1, 0x8}, //!< OCD threshold
Davidroid 0:92706998571a 162 {0x14 , "STALL_TH", 7, 1, 0x40}, //!< STALL threshold
Davidroid 0:92706998571a 163 {0x16 , "STEP_MODE", 8, 1, 0x7}, //!< Step mode
Davidroid 0:92706998571a 164 {0x17 , "ALARM_EN", 8, 1, 0xFF}, //!< Alarm enable
Davidroid 0:92706998571a 165 {0x18 , "CONFIG", 16, 2, 0x2E88}, //!< IC configuration
Davidroid 0:92706998571a 166 {0x19 , "STATUS", 16, 2, 0x0000} //!< Status, (the reset value is according to startup conditions)
Davidroid 0:92706998571a 167 };
Davidroid 0:92706998571a 168
Davidroid 0:92706998571a 169 /**
Davidroid 0:92706998571a 170 * @brief Array whose elements are a structure in which store information about
Davidroid 0:92706998571a 171 * the L6470 Application Commands (the mnemonic name, the number of
Davidroid 0:92706998571a 172 * needed parameters, the related funtion to call)
Davidroid 0:92706998571a 173 */
Davidroid 0:92706998571a 174 const sL6470_ApplicationCommand_t L6470::_L6470_ApplicationCommand[L6470APPCMDIDSIZE] = {
Davidroid 0:92706998571a 175 {"NOP", 0x00, 0},
Davidroid 0:92706998571a 176 {"SETPARAM", 0x00, 2},
Davidroid 0:92706998571a 177 {"GETPARAM", 0x20, 1},
Davidroid 0:92706998571a 178 {"RUN", 0x50, 2},
Davidroid 0:92706998571a 179 {"STEPCLOCK", 0x58, 1},
Davidroid 0:92706998571a 180 {"MOVE", 0x40, 2},
Davidroid 0:92706998571a 181 {"GOTO", 0x60, 1},
Davidroid 0:92706998571a 182 {"GOTO_DIR", 0x68, 2},
Davidroid 0:92706998571a 183 {"GOUNTIL", 0x82, 3},
Davidroid 0:92706998571a 184 {"RELEASESW", 0x92, 2},
Davidroid 0:92706998571a 185 {"GOHOME", 0x70, 0},
Davidroid 0:92706998571a 186 {"GOMARK", 0x78, 0},
Davidroid 0:92706998571a 187 {"RESETPOS", 0xD8, 0},
Davidroid 0:92706998571a 188 {"RESETDEVICE", 0xC0, 0},
Davidroid 0:92706998571a 189 {"SOFTSTOP", 0xB0, 0},
Davidroid 0:92706998571a 190 {"HARDSTOP", 0xB8, 0},
Davidroid 0:92706998571a 191 {"SOFTHIZ", 0xA0, 0},
Davidroid 0:92706998571a 192 {"HARDHIZ", 0xA8, 0},
Davidroid 0:92706998571a 193 {"GETSTATUS", 0xD0, 0}
Davidroid 0:92706998571a 194 };
Davidroid 0:92706998571a 195
Davidroid 0:92706998571a 196 /**
Davidroid 0:92706998571a 197 * @brief The mnemonic names for the L6470 direction
Davidroid 0:92706998571a 198 */
Davidroid 0:92706998571a 199 const sL6470_Direction_t L6470::_L6470_Direction[L6470DIRIDSIZE] = {
Davidroid 0:92706998571a 200 {"REV", 0x00}, //!< Reverse direction
Davidroid 0:92706998571a 201 {"FWD", 0x01} //!< Forward direction
Davidroid 0:92706998571a 202 };
Davidroid 0:92706998571a 203
Davidroid 0:92706998571a 204 /**
Davidroid 0:92706998571a 205 * @brief Action taken about ABS_POS register
Davidroid 0:92706998571a 206 */
Davidroid 0:92706998571a 207 const sL6470_ACT_t L6470::_L6470_ACT[L6470ACTIDSIZE] = {
Davidroid 0:92706998571a 208 {"RST", 0x00}, //!< ABS_POS register is reset
Davidroid 0:92706998571a 209 {"CPY", 0x01} //!< ABS_POS register value is copied into the MARK register
Davidroid 0:92706998571a 210 };
Davidroid 0:92706998571a 211
Davidroid 0:92706998571a 212 /* End of L6470_Private_Constants */
Davidroid 0:92706998571a 213
Davidroid 0:92706998571a 214 /**
Davidroid 0:92706998571a 215 * @defgroup L6470_Private_Variables
Davidroid 0:92706998571a 216 * @brief L6470 Private Variables.
Davidroid 0:92706998571a 217 * @{
Davidroid 0:92706998571a 218 */
Davidroid 0:92706998571a 219
Davidroid 0:92706998571a 220 /* End of L6470_Private_Variables */
Davidroid 0:92706998571a 221
Davidroid 0:92706998571a 222
Davidroid 0:92706998571a 223 /**
Davidroid 0:92706998571a 224 * @addtogroup L6470_Private_Functions
Davidroid 0:92706998571a 225 * @{
Davidroid 0:92706998571a 226 */
Davidroid 0:92706998571a 227
Davidroid 0:92706998571a 228 /**
Davidroid 0:92706998571a 229 * @brief Reset the structure used to store the identifier of the L6470
Davidroid 0:92706998571a 230 * application command and its the needed parameters.
Davidroid 0:92706998571a 231 * @param pL6470_AppCmdPkg The structure to be reset.
Davidroid 0:92706998571a 232 */
Davidroid 0:92706998571a 233 void L6470::L6470_ResetAppCmdPkg(sL6470_AppCmdPkg_t* pL6470_AppCmdPkg)
Davidroid 0:92706998571a 234 {
Davidroid 0:92706998571a 235 uint8_t id;
Davidroid 0:92706998571a 236
Davidroid 0:92706998571a 237 for(id=0; id<L6470DAISYCHAINSIZE; id++)
Davidroid 0:92706998571a 238 {
Davidroid 0:92706998571a 239 (pL6470_AppCmdPkg+id)->L6470_AppCmdId=(eL6470_AppCmdId_t)0;
Davidroid 0:92706998571a 240 (pL6470_AppCmdPkg+id)->p1=0;
Davidroid 0:92706998571a 241 (pL6470_AppCmdPkg+id)->p2=0;
Davidroid 0:92706998571a 242 (pL6470_AppCmdPkg+id)->p3=0;
Davidroid 0:92706998571a 243 }
Davidroid 0:92706998571a 244 }
Davidroid 0:92706998571a 245
Davidroid 0:92706998571a 246 /**
Davidroid 0:92706998571a 247 * @brief Fill the structure used to store the identifier of the L6470
Davidroid 0:92706998571a 248 * application command and its the needed parameters.
Davidroid 0:92706998571a 249 * @param L6470_Id The identifier of the L6470 target inside the daisy chain.
Davidroid 0:92706998571a 250 * @param pL6470_AppCmdPkg The structure to be filled.
Davidroid 0:92706998571a 251 * @param L6470_AppCmdId The identifier of the L6470 application command to be sent.
Davidroid 0:92706998571a 252 * @param p1 The 1st parameter (if it is not needed it will be not considered).
Davidroid 0:92706998571a 253 * @param p2 The 2nd parameter (if it is not needed it will be not considered).
Davidroid 0:92706998571a 254 * @param p3 The 3rd parameter (if it is not needed it will be not considered).
Davidroid 0:92706998571a 255 */
Davidroid 0:92706998571a 256 void L6470::L6470_FillAppCmdPkg(sL6470_AppCmdPkg_t* pL6470_AppCmdPkg, eL6470_AppCmdId_t L6470_AppCmdId, uint32_t p1, uint32_t p2, uint32_t p3)
Davidroid 0:92706998571a 257 {
Davidroid 0:92706998571a 258 (pL6470_AppCmdPkg+L6470_Id)->L6470_AppCmdId = L6470_AppCmdId;
Davidroid 0:92706998571a 259 (pL6470_AppCmdPkg+L6470_Id)->p1 = p1;
Davidroid 0:92706998571a 260 (pL6470_AppCmdPkg+L6470_Id)->p2 = p2;
Davidroid 0:92706998571a 261 (pL6470_AppCmdPkg+L6470_Id)->p3 = p3;
Davidroid 0:92706998571a 262 }
Davidroid 0:92706998571a 263
Davidroid 0:92706998571a 264 /**
Davidroid 0:92706998571a 265 * @brief This function will fill the column of the L6470_AppCmdPkg related
Davidroid 0:92706998571a 266 * the L6470 to be addressed inside the daisy chain.
Davidroid 0:92706998571a 267 *
Davidroid 0:92706998571a 268 * @param L6470_Id The identifier of the L6470 target inside the daisy chain.
Davidroid 0:92706998571a 269 * @param pL6470_AppCmdPkg Pointer to the sL6470_AppCmdPkg_t to be filled.
Davidroid 0:92706998571a 270 * @param L6470_AppCmdId The identifier of the L6470 application command to be sent.
Davidroid 0:92706998571a 271 * @param p1 The 1st parameter (if it is not needed it will be not considered).
Davidroid 0:92706998571a 272 * @param p2 The 2nd parameter (if it is not needed it will be not considered).
Davidroid 0:92706998571a 273 * @param p3 The 3rd parameter (if it is not needed it will be not considered).
Davidroid 0:92706998571a 274 */
Davidroid 0:92706998571a 275 void L6470::L6470_PrepareAppCmdPkg(sL6470_AppCmdPkg_t* pL6470_AppCmdPkg, eL6470_AppCmdId_t L6470_AppCmdId, uint32_t p1, uint32_t p2, uint32_t p3)
Davidroid 0:92706998571a 276 {
Davidroid 0:92706998571a 277 if(!L6470_DaisyChain_HalfPrepared)
Davidroid 0:92706998571a 278 {
Davidroid 0:92706998571a 279 L6470_DaisyChain_HalfPrepared = ONE_F; /* To avoid to delete the previous entered command */
Davidroid 0:92706998571a 280 L6470_ResetAppCmdPkg(pL6470_AppCmdPkg);
Davidroid 0:92706998571a 281 }
Davidroid 0:92706998571a 282
Davidroid 0:92706998571a 283 L6470_FillAppCmdPkg(pL6470_AppCmdPkg, L6470_AppCmdId, p1, p2, p3);
Davidroid 0:92706998571a 284 }
Davidroid 0:92706998571a 285
Davidroid 0:92706998571a 286 /**
Davidroid 0:92706998571a 287 * @brief This function will translate the data inside the L6470_AppCmdPkg into
Davidroid 0:92706998571a 288 * the right data to be sent via SPI to the L6470 daisy chain.
Davidroid 0:92706998571a 289 *
Davidroid 0:92706998571a 290 * @param pL6470_AppCmdPkg Pointer to the sL6470_AppCmdPkg_t to be filled.
Davidroid 0:92706998571a 291 * @param pL6470_DaisyChainSpiTxStruct Pointer to the structure used by SPI to send the commands.
Davidroid 0:92706998571a 292 */
Davidroid 0:92706998571a 293 void L6470::L6470_PrepareDaisyChainCommand(sL6470_AppCmdPkg_t* pL6470_AppCmdPkg, uint8_t* pL6470_DaisyChainSpiTxStruct)
Davidroid 0:92706998571a 294 {
Davidroid 0:92706998571a 295 uint8_t PkgId;
Davidroid 0:92706998571a 296 uint8_t PARAMLengthBytes; /* The number of bytes related to the numeric value for the addressed register */
Davidroid 0:92706998571a 297 uint8_t spibyte;
Davidroid 0:92706998571a 298
Davidroid 0:92706998571a 299 /* Reset the structure used to send the command to the L6470 Daisy Chain through the SPI */
Davidroid 0:92706998571a 300 uint8_t i = 0;
Davidroid 0:92706998571a 301 for(spibyte=0;spibyte<L6470MAXSPICMDBYTESIZE;spibyte++)
Davidroid 0:92706998571a 302 for(PkgId=0; PkgId<L6470DAISYCHAINSIZE; PkgId++)
Davidroid 0:92706998571a 303 *(pL6470_DaisyChainSpiTxStruct+(i++)) = 0x00;
Davidroid 0:92706998571a 304
Davidroid 0:92706998571a 305 for(PkgId=0; PkgId<L6470DAISYCHAINSIZE; PkgId++)
Davidroid 0:92706998571a 306 {
Davidroid 0:92706998571a 307 /* Build the 1st bytes to transmit with the binary code of the command */
Davidroid 0:92706998571a 308 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) = (L6470_ApplicationCommand[(pL6470_AppCmdPkg+PkgId)->L6470_AppCmdId].BinaryCode);
Davidroid 0:92706998571a 309
Davidroid 0:92706998571a 310 /* Perform the related L6470_AppCmdId */
Davidroid 0:92706998571a 311 switch((pL6470_AppCmdPkg+PkgId)->L6470_AppCmdId)
Davidroid 0:92706998571a 312 {
Davidroid 0:92706998571a 313 case L6470_NOP_ID:
Davidroid 0:92706998571a 314 break;
Davidroid 0:92706998571a 315 case L6470_SETPARAM_ID:
Davidroid 0:92706998571a 316 /* Build the 1st bytes to transmit (PARAM) */
Davidroid 0:92706998571a 317 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Register[((pL6470_AppCmdPkg+PkgId)->p1)].Address);
Davidroid 0:92706998571a 318
Davidroid 0:92706998571a 319 /* The length, in byte, of this register (PARAM) is... */
Davidroid 0:92706998571a 320 PARAMLengthBytes = L6470_Register[((pL6470_AppCmdPkg+PkgId)->p1)].LengthByte;
Davidroid 0:92706998571a 321
Davidroid 0:92706998571a 322 /* Build the others bytes to transmit (VALUE) */
Davidroid 0:92706998571a 323 for (spibyte=1; spibyte<(PARAMLengthBytes+1); spibyte++)
Davidroid 0:92706998571a 324 {
Davidroid 0:92706998571a 325 *(pL6470_DaisyChainSpiTxStruct+((spibyte*L6470DAISYCHAINSIZE)+PkgId)) = (uint8_t)(((pL6470_AppCmdPkg+PkgId)->p2) >> (8*(PARAMLengthBytes-spibyte)));
Davidroid 0:92706998571a 326 }
Davidroid 0:92706998571a 327 break;
Davidroid 0:92706998571a 328 case L6470_GETPARAM_ID:
Davidroid 0:92706998571a 329 /* Build the 1st bytes to transmit (PARAM) */
Davidroid 0:92706998571a 330 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Register[((pL6470_AppCmdPkg+PkgId)->p1)].Address);
Davidroid 0:92706998571a 331 break;
Davidroid 0:92706998571a 332 case L6470_RUN_ID:
Davidroid 0:92706998571a 333 /* Build the 1st bytes to transmit (DIR) */
Davidroid 0:92706998571a 334 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Direction[((pL6470_AppCmdPkg+PkgId)->p1)].BinaryCode);
Davidroid 0:92706998571a 335
Davidroid 0:92706998571a 336 /* Build the others bytes to transmit (SPD) */
Davidroid 0:92706998571a 337 for (spibyte=1; spibyte<(3+1); spibyte++)
Davidroid 0:92706998571a 338 {
Davidroid 0:92706998571a 339 *(pL6470_DaisyChainSpiTxStruct+((spibyte*L6470DAISYCHAINSIZE)+PkgId)) = (uint8_t)(((pL6470_AppCmdPkg+PkgId)->p2) >> (8*(3-spibyte)));
Davidroid 0:92706998571a 340 }
Davidroid 0:92706998571a 341 break;
Davidroid 0:92706998571a 342 case L6470_STEPCLOCK_ID:
Davidroid 0:92706998571a 343 /* Build the 1st bytes to transmit (DIR) */
Davidroid 0:92706998571a 344 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Direction[((pL6470_AppCmdPkg+PkgId)->p1)].BinaryCode);
Davidroid 0:92706998571a 345 break;
Davidroid 0:92706998571a 346 case L6470_MOVE_ID:
Davidroid 0:92706998571a 347 /* Build the 1st bytes to transmit (DIR) */
Davidroid 0:92706998571a 348 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Direction[((pL6470_AppCmdPkg+PkgId)->p1)].BinaryCode);
Davidroid 0:92706998571a 349
Davidroid 0:92706998571a 350 /* Build the others bytes to transmit (N_STEP) */
Davidroid 0:92706998571a 351 for (spibyte=1; spibyte<(3+1); spibyte++)
Davidroid 0:92706998571a 352 {
Davidroid 0:92706998571a 353 *(pL6470_DaisyChainSpiTxStruct+((spibyte*L6470DAISYCHAINSIZE)+PkgId)) = (uint8_t)(((pL6470_AppCmdPkg+PkgId)->p2) >> (8*(3-spibyte)));
Davidroid 0:92706998571a 354 }
Davidroid 0:92706998571a 355 break;
Davidroid 0:92706998571a 356 case L6470_GOTO_ID:
Davidroid 0:92706998571a 357 /* Build the others bytes to transmit (ABS_POS) */
Davidroid 0:92706998571a 358 for (spibyte=1; spibyte<(3+1); spibyte++)
Davidroid 0:92706998571a 359 {
Davidroid 0:92706998571a 360 *(pL6470_DaisyChainSpiTxStruct+((spibyte*L6470DAISYCHAINSIZE)+PkgId)) = (uint8_t)(((pL6470_AppCmdPkg+PkgId)->p1) >> (8*(3-spibyte)));
Davidroid 0:92706998571a 361 }
Davidroid 0:92706998571a 362 break;
Davidroid 0:92706998571a 363 case L6470_GOTODIR_ID:
Davidroid 0:92706998571a 364 /* Build the 1st bytes to transmit (DIR) */
Davidroid 0:92706998571a 365 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Direction[((pL6470_AppCmdPkg+PkgId)->p1)].BinaryCode);
Davidroid 0:92706998571a 366
Davidroid 0:92706998571a 367 /* Build the others bytes to transmit (ABS_POS) */
Davidroid 0:92706998571a 368 for (spibyte=1; spibyte<(3+1); spibyte++)
Davidroid 0:92706998571a 369 {
Davidroid 0:92706998571a 370 *(pL6470_DaisyChainSpiTxStruct+((spibyte*L6470DAISYCHAINSIZE)+PkgId)) = (uint8_t)(((pL6470_AppCmdPkg+PkgId)->p2) >> (8*(3-spibyte)));
Davidroid 0:92706998571a 371 }
Davidroid 0:92706998571a 372 break;
Davidroid 0:92706998571a 373 case L6470_GOUNTIL_ID:
Davidroid 0:92706998571a 374 /* Build the 1st bytes to transmit (ACT) */
Davidroid 0:92706998571a 375 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= ((L6470_ACT[((pL6470_AppCmdPkg+PkgId)->p1)].BinaryCode)<<3);
Davidroid 0:92706998571a 376 /* Build the 1st bytes to transmit (DIR) */
Davidroid 0:92706998571a 377 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Direction[((pL6470_AppCmdPkg+PkgId)->p2)].BinaryCode);
Davidroid 0:92706998571a 378
Davidroid 0:92706998571a 379 /* Build the others bytes to transmit (SPD) */
Davidroid 0:92706998571a 380 for (spibyte=1; spibyte<(3+1); spibyte++)
Davidroid 0:92706998571a 381 {
Davidroid 0:92706998571a 382 *(pL6470_DaisyChainSpiTxStruct+((spibyte*L6470DAISYCHAINSIZE)+PkgId)) = (uint8_t)(((pL6470_AppCmdPkg+PkgId)->p3) >> (8*(3-spibyte)));
Davidroid 0:92706998571a 383 }
Davidroid 0:92706998571a 384 break;
Davidroid 0:92706998571a 385 case L6470_RELEASESW_ID:
Davidroid 0:92706998571a 386 /* Build the 1st bytes to transmit (ACT) */
Davidroid 0:92706998571a 387 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= ((L6470_ACT[((pL6470_AppCmdPkg+PkgId)->p1)].BinaryCode)<<3);
Davidroid 0:92706998571a 388 /* Build the 1st bytes to transmit (DIR) */
Davidroid 0:92706998571a 389 *(pL6470_DaisyChainSpiTxStruct+((0*L6470DAISYCHAINSIZE)+PkgId)) |= (L6470_Direction[((pL6470_AppCmdPkg+PkgId)->p2)].BinaryCode);
Davidroid 0:92706998571a 390 break;
Davidroid 0:92706998571a 391 case L6470_GOHOME_ID:
Davidroid 0:92706998571a 392 break;
Davidroid 0:92706998571a 393 case L6470_GOMARK_ID:
Davidroid 0:92706998571a 394 break;
Davidroid 0:92706998571a 395 case L6470_RESETPOS_ID:
Davidroid 0:92706998571a 396 break;
Davidroid 0:92706998571a 397 case L6470_RESETDEVICE_ID:
Davidroid 0:92706998571a 398 break;
Davidroid 0:92706998571a 399 case L6470_SOFTSTOP_ID:
Davidroid 0:92706998571a 400 break;
Davidroid 0:92706998571a 401 case L6470_HARDSTOP_ID:
Davidroid 0:92706998571a 402 break;
Davidroid 0:92706998571a 403 case L6470_SOFTHIZ_ID:
Davidroid 0:92706998571a 404 break;
Davidroid 0:92706998571a 405 case L6470_HARDHIZ_ID:
Davidroid 0:92706998571a 406 break;
Davidroid 0:92706998571a 407 case L6470_GETSTATUS_ID:
Davidroid 0:92706998571a 408 break;
Davidroid 0:92706998571a 409 }
Davidroid 0:92706998571a 410 }
Davidroid 0:92706998571a 411 }
Davidroid 0:92706998571a 412
Davidroid 0:92706998571a 413 /* End of L6470_Private_Functions */
Davidroid 0:92706998571a 414
Davidroid 0:92706998571a 415 /**
Davidroid 0:92706998571a 416 * @addtogroup L6470_Exported_Functions
Davidroid 0:92706998571a 417 * @{
Davidroid 0:92706998571a 418 */
Davidroid 0:92706998571a 419
Davidroid 0:92706998571a 420 /**
Davidroid 0:92706998571a 421 * @addtogroup L6470_Conversion_Functions
Davidroid 0:92706998571a 422 * @brief The following functions act just on one driver inside the L6470
Davidroid 0:92706998571a 423 * daisy chain. The command is immediately sent.
Davidroid 0:92706998571a 424 * @{
Davidroid 0:92706998571a 425 */
Davidroid 0:92706998571a 426
Davidroid 0:92706998571a 427 /**
Davidroid 0:92706998571a 428 * @brief Convert the absolute position as 2's complement format into the signed number.
Davidroid 0:92706998571a 429 *
Davidroid 0:92706998571a 430 * @param AbsPos The absolute position in the range from [-(2^21)] to [+(2^21)-1].
Davidroid 0:92706998571a 431 * @retval Position The position as signed number.
Davidroid 0:92706998571a 432 */
Davidroid 0:92706998571a 433 int32_t L6470::L6470_AbsPos_2_Position(uint32_t AbsPos)
Davidroid 0:92706998571a 434 {
Davidroid 0:92706998571a 435 if (AbsPos > L6470_MAX_POSITION)
Davidroid 0:92706998571a 436 return (AbsPos - (L6470_POSITION_RANGE + 1));
Davidroid 0:92706998571a 437 else
Davidroid 0:92706998571a 438 return AbsPos;
Davidroid 0:92706998571a 439 }
Davidroid 0:92706998571a 440
Davidroid 0:92706998571a 441 /**
Davidroid 0:92706998571a 442 * @brief Convert the position as signed number into absolute position as 2's complement format.
Davidroid 0:92706998571a 443 *
Davidroid 0:92706998571a 444 * @param Position The position as signed number.
Davidroid 0:92706998571a 445 * @retval AbsPos The absolute position in the range from [-(2^21)] to [+(2^21)-1].
Davidroid 0:92706998571a 446 */
Davidroid 0:92706998571a 447 uint32_t L6470::L6470_Position_2_AbsPos(int32_t Position)
Davidroid 0:92706998571a 448 {
Davidroid 0:92706998571a 449 if ((Position >= 0) && (Position <= L6470_MAX_POSITION))
Davidroid 0:92706998571a 450 return Position;
Davidroid 0:92706998571a 451 else
Davidroid 0:92706998571a 452 {
Davidroid 0:92706998571a 453 if ((Position >= L6470_MIN_POSITION) && (Position < 0))
Davidroid 0:92706998571a 454 return (Position + (L6470_POSITION_RANGE + 1));
Davidroid 0:92706998571a 455 else
Davidroid 0:92706998571a 456 return (L6470_POSITION_RANGE + 1); // OVF
Davidroid 0:92706998571a 457 }
Davidroid 0:92706998571a 458 }
Davidroid 0:92706998571a 459
Davidroid 0:92706998571a 460 /**
Davidroid 0:92706998571a 461 * @brief Convert the SPEED register value into step/s.
Davidroid 0:92706998571a 462 *
Davidroid 0:92706998571a 463 * @param Speed The SPEED register value.
Davidroid 0:92706998571a 464 * @retval step/s The speed as step/s.
Davidroid 0:92706998571a 465 */
Davidroid 0:92706998571a 466 float L6470::L6470_Speed_2_Step_s(uint32_t Speed)
Davidroid 0:92706998571a 467 {
Davidroid 0:92706998571a 468 return (Speed * ((float)14.9012e-3));
Davidroid 0:92706998571a 469 }
Davidroid 0:92706998571a 470
Davidroid 0:92706998571a 471 /**
Davidroid 0:92706998571a 472 * @brief Convert the speed as step/s into a right value for SPEED register.
Davidroid 0:92706998571a 473 *
Davidroid 0:92706998571a 474 * @param step/s The speed as step/s.
Davidroid 0:92706998571a 475 * @retval Speed The SPEED register value.
Davidroid 0:92706998571a 476 */
Davidroid 0:92706998571a 477 uint32_t L6470::L6470_Step_s_2_Speed(float Step_s)
Davidroid 0:92706998571a 478 {
Davidroid 0:92706998571a 479 if (Step_s <= (L6470_MAX_SPEED * ((float)14.9012e-3)))
Davidroid 0:92706998571a 480 return (uint32_t)(Step_s / ((float)14.9012e-3));
Davidroid 0:92706998571a 481 else
Davidroid 0:92706998571a 482 return 0; // Warning
Davidroid 0:92706998571a 483 }
Davidroid 0:92706998571a 484
Davidroid 0:92706998571a 485 /**
Davidroid 0:92706998571a 486 * @brief Convert the ACC register value into step/(s^2).
Davidroid 0:92706998571a 487 *
Davidroid 0:92706998571a 488 * @param Acc The ACC register value.
Davidroid 0:92706998571a 489 * @retval step/(s^2) The acceleration as step/(s^2).
Davidroid 0:92706998571a 490 */
Davidroid 0:92706998571a 491 float L6470::L6470_Acc_2_Step_s2(uint16_t Acc)
Davidroid 0:92706998571a 492 {
Davidroid 0:92706998571a 493 if (Acc <= L6470_MAX_ACC)
Davidroid 0:92706998571a 494 return (Acc * ((float)1.4552e1));
Davidroid 0:92706998571a 495 else
Davidroid 0:92706998571a 496 return 0; // Warning
Davidroid 0:92706998571a 497 }
Davidroid 0:92706998571a 498
Davidroid 0:92706998571a 499 /**
Davidroid 0:92706998571a 500 * @brief Convert the acceleartion as step/(s^2) into a right value for ACC register.
Davidroid 0:92706998571a 501 *
Davidroid 0:92706998571a 502 * @param step/(s^2) The acceleration as step/(s^2).
Davidroid 0:92706998571a 503 * @retval Acc The ACC register value.
Davidroid 0:92706998571a 504 */
Davidroid 0:92706998571a 505 uint16_t L6470::L6470_Step_s2_2_Acc(float Step_s2)
Davidroid 0:92706998571a 506 {
Davidroid 0:92706998571a 507 if (Step_s2 <= (L6470_MAX_ACC * ((float)1.4552e1)))
Davidroid 0:92706998571a 508 return (uint16_t)(Step_s2 / ((float)1.4552e1));
Davidroid 0:92706998571a 509 else
Davidroid 0:92706998571a 510 return 0; // Warning
Davidroid 0:92706998571a 511 }
Davidroid 0:92706998571a 512
Davidroid 0:92706998571a 513 /**
Davidroid 0:92706998571a 514 * @brief Convert the DEC register value into step/(s^2).
Davidroid 0:92706998571a 515 *
Davidroid 0:92706998571a 516 * @param Dec The DEC register value.
Davidroid 0:92706998571a 517 * @retval step/(s^2) The deceleration as step/(s^2).
Davidroid 0:92706998571a 518 */
Davidroid 0:92706998571a 519 float L6470::L6470_Dec_2_Step_s2(uint16_t Dec)
Davidroid 0:92706998571a 520 {
Davidroid 0:92706998571a 521 if (Dec <= L6470_MAX_DEC)
Davidroid 0:92706998571a 522 return (Dec * ((float)1.4552e1));
Davidroid 0:92706998571a 523 else
Davidroid 0:92706998571a 524 return 0; // Warning
Davidroid 0:92706998571a 525 }
Davidroid 0:92706998571a 526
Davidroid 0:92706998571a 527 /**
Davidroid 0:92706998571a 528 * @brief Convert the deceleration as step/(s^2) into a right value for DEC register.
Davidroid 0:92706998571a 529 *
Davidroid 0:92706998571a 530 * @param step/(s^2) The deceleration as step/(s^2).
Davidroid 0:92706998571a 531 * @retval Dec The DEC register value.
Davidroid 0:92706998571a 532 */
Davidroid 0:92706998571a 533 uint16_t L6470::L6470_Step_s2_2_Dec(float Step_s2)
Davidroid 0:92706998571a 534 {
Davidroid 0:92706998571a 535 if (Step_s2 <= (L6470_MAX_DEC * ((float)1.4552e1)))
Davidroid 0:92706998571a 536 return (uint16_t)(Step_s2 / ((float)1.4552e1));
Davidroid 0:92706998571a 537 else
Davidroid 0:92706998571a 538 return 0; // Warning
Davidroid 0:92706998571a 539 }
Davidroid 0:92706998571a 540
Davidroid 0:92706998571a 541 /**
Davidroid 0:92706998571a 542 * @brief Convert the MAX_SPEED register value into step/s.
Davidroid 0:92706998571a 543 *
Davidroid 0:92706998571a 544 * @param MaxSpeed The MAX_SPEED register value.
Davidroid 0:92706998571a 545 * @retval step/s The max speed as step/s.
Davidroid 0:92706998571a 546 */
Davidroid 0:92706998571a 547 float L6470::L6470_MaxSpeed_2_Step_s(uint16_t MaxSpeed)
Davidroid 0:92706998571a 548 {
Davidroid 0:92706998571a 549 if (MaxSpeed <= L6470_MAX_MAX_SPEED)
Davidroid 0:92706998571a 550 return (MaxSpeed * ((float)15.2588));
Davidroid 0:92706998571a 551 else
Davidroid 0:92706998571a 552 return 0; // Warning
Davidroid 0:92706998571a 553 }
Davidroid 0:92706998571a 554
Davidroid 0:92706998571a 555 /**
Davidroid 0:92706998571a 556 * @brief Convert the max speed as step/s into a right value for MAX_SPEED register.
Davidroid 0:92706998571a 557 *
Davidroid 0:92706998571a 558 * @param step/s The max speed as step/s.
Davidroid 0:92706998571a 559 * @retval MaxSpeed The MAX_SPEED register value.
Davidroid 0:92706998571a 560 */
Davidroid 0:92706998571a 561 uint16_t L6470::L6470_Step_s_2_MaxSpeed(float Step_s)
Davidroid 0:92706998571a 562 {
Davidroid 0:92706998571a 563 if (Step_s <= (L6470_MAX_MAX_SPEED * ((float)15.2588)))
Davidroid 0:92706998571a 564 return (uint16_t)(Step_s / ((float)15.2588));
Davidroid 0:92706998571a 565 else
Davidroid 0:92706998571a 566 return 0; // Warning
Davidroid 0:92706998571a 567 }
Davidroid 0:92706998571a 568
Davidroid 0:92706998571a 569 /**
Davidroid 0:92706998571a 570 * @brief Convert the MIN_SPEED register value into step/s.
Davidroid 0:92706998571a 571 *
Davidroid 0:92706998571a 572 * @param MinSpeed The MIN_SPEED register value.
Davidroid 0:92706998571a 573 * @retval step/s The min speed as step/s.
Davidroid 0:92706998571a 574 */
Davidroid 0:92706998571a 575 float L6470::L6470_MinSpeed_2_Step_s(uint16_t MinSpeed)
Davidroid 0:92706998571a 576 {
Davidroid 0:92706998571a 577 if (MinSpeed <= L6470_MAX_MIN_SPEED)
Davidroid 0:92706998571a 578 return (MinSpeed * ((float)238.4186e-3));
Davidroid 0:92706998571a 579 else
Davidroid 0:92706998571a 580 return 0; // Warning
Davidroid 0:92706998571a 581 }
Davidroid 0:92706998571a 582
Davidroid 0:92706998571a 583 /**
Davidroid 0:92706998571a 584 * @brief Convert the min speed as step/s into a right value for MIN_SPEED register.
Davidroid 0:92706998571a 585 *
Davidroid 0:92706998571a 586 * @param step/s The min speed as step/s.
Davidroid 0:92706998571a 587 * @retval MinSpeed The MIN_SPEED register value.
Davidroid 0:92706998571a 588 */
Davidroid 0:92706998571a 589 uint16_t L6470::L6470_Step_s_2_MinSpeed(float Step_s)
Davidroid 0:92706998571a 590 {
Davidroid 0:92706998571a 591 if (Step_s <= (L6470_MAX_MIN_SPEED * ((float)238.4186e-3)))
Davidroid 0:92706998571a 592 return (uint16_t)(Step_s / ((float)238.4186e-3));
Davidroid 0:92706998571a 593 else
Davidroid 0:92706998571a 594 return 0; // Warning
Davidroid 0:92706998571a 595 }
Davidroid 0:92706998571a 596
Davidroid 0:92706998571a 597 /**
Davidroid 0:92706998571a 598 * @brief Convert the FS_SPD register value into step/s.
Davidroid 0:92706998571a 599 *
Davidroid 0:92706998571a 600 * @param FsSpd The FS_SPD register value.
Davidroid 0:92706998571a 601 * @retval step/s The full-step speed as step/s.
Davidroid 0:92706998571a 602 */
Davidroid 0:92706998571a 603 float L6470::L6470_FsSpd_2_Step_s(uint16_t FsSpd)
Davidroid 0:92706998571a 604 {
Davidroid 0:92706998571a 605 if (FsSpd <= L6470_MAX_FS_SPD)
Davidroid 0:92706998571a 606 return ((FsSpd+0.5) * ((float)15.25));
Davidroid 0:92706998571a 607 else
Davidroid 0:92706998571a 608 return 0; // Warning
Davidroid 0:92706998571a 609 }
Davidroid 0:92706998571a 610
Davidroid 0:92706998571a 611 /**
Davidroid 0:92706998571a 612 * @brief Convert the full-step speed as step/s into a right value for FS_SPD register.
Davidroid 0:92706998571a 613 *
Davidroid 0:92706998571a 614 * @param step/s The full-step speed as step/s.
Davidroid 0:92706998571a 615 * @retval FsSpd The FS_SPD register value.
Davidroid 0:92706998571a 616 */
Davidroid 0:92706998571a 617 uint16_t L6470::L6470_Step_s_2_FsSpd(float Step_s)
Davidroid 0:92706998571a 618 {
Davidroid 0:92706998571a 619 if (Step_s <= ((L6470_MAX_FS_SPD+0.5) * ((float)15.25)))
Davidroid 0:92706998571a 620 return (uint16_t)((float)(Step_s / ((float)15.25)) - (float)0.5);
Davidroid 0:92706998571a 621 else
Davidroid 0:92706998571a 622 return 0; // Warning
Davidroid 0:92706998571a 623 }
Davidroid 0:92706998571a 624
Davidroid 0:92706998571a 625 /**
Davidroid 0:92706998571a 626 * @brief Convert the INT_SPEED register value into step/s.
Davidroid 0:92706998571a 627 *
Davidroid 0:92706998571a 628 * @param IntSpeed The INT_SPEED register value.
Davidroid 0:92706998571a 629 * @retval step/s The intersect speed as step/s.
Davidroid 0:92706998571a 630 */
Davidroid 0:92706998571a 631 float L6470::L6470_IntSpeed_2_Step_s(uint16_t IntSpeed)
Davidroid 0:92706998571a 632 {
Davidroid 0:92706998571a 633 if (IntSpeed <= L6470_MAX_INT_SPEED)
Davidroid 0:92706998571a 634 return (IntSpeed * ((float)59.6046e-3));
Davidroid 0:92706998571a 635 else
Davidroid 0:92706998571a 636 return 0; // Warning
Davidroid 0:92706998571a 637 }
Davidroid 0:92706998571a 638
Davidroid 0:92706998571a 639 /**
Davidroid 0:92706998571a 640 * @brief Convert the intersect speed as step/s into a right value for INT_SPEED register.
Davidroid 0:92706998571a 641 *
Davidroid 0:92706998571a 642 * @param step/s The full-step speed as step/s.
Davidroid 0:92706998571a 643 * @retval FsSpd The FS_SPD register value.
Davidroid 0:92706998571a 644 */
Davidroid 0:92706998571a 645 uint16_t L6470::L6470_Step_s_2_IntSpeed(float Step_s)
Davidroid 0:92706998571a 646 {
Davidroid 0:92706998571a 647 if (Step_s <= (L6470_MAX_INT_SPEED * ((float)59.6046e-3)))
Davidroid 0:92706998571a 648 return (uint16_t)(Step_s / ((float)59.6046e-3));
Davidroid 0:92706998571a 649 else
Davidroid 0:92706998571a 650 return 0; // Warning
Davidroid 0:92706998571a 651 }
Davidroid 0:92706998571a 652
Davidroid 0:92706998571a 653 /**
Davidroid 0:92706998571a 654 * @brief Convert the ST_SLP register value into s/step.
Davidroid 0:92706998571a 655 *
Davidroid 0:92706998571a 656 * @param StartSlope The ST_SLP register value.
Davidroid 0:92706998571a 657 * @retval s/step The start slope as s/step.
Davidroid 0:92706998571a 658 */
Davidroid 0:92706998571a 659 float L6470::L6470_StSlp_2_s_Step(uint8_t StSlp)
Davidroid 0:92706998571a 660 {
Davidroid 0:92706998571a 661 // if (StSlp <= L6470_MAX_ST_SLP)
Davidroid 0:92706998571a 662 return (StSlp * ((float)1.5686e-5));
Davidroid 0:92706998571a 663 // else
Davidroid 0:92706998571a 664 // return 0; // Warning
Davidroid 0:92706998571a 665 }
Davidroid 0:92706998571a 666
Davidroid 0:92706998571a 667 /**
Davidroid 0:92706998571a 668 * @brief Convert the intersect speed as step/s into a right value for INT_SPEED register.
Davidroid 0:92706998571a 669 *
Davidroid 0:92706998571a 670 * @param step/s The full-step speed as step/s.
Davidroid 0:92706998571a 671 * @retval FsSpd The FS_SPD register value.
Davidroid 0:92706998571a 672 */
Davidroid 0:92706998571a 673 uint8_t L6470::L6470_s_Step_2_StSlp(float s_Step)
Davidroid 0:92706998571a 674 {
Davidroid 0:92706998571a 675 if (s_Step <= (L6470_MAX_ST_SLP * ((float)1.5686e-5)))
Davidroid 0:92706998571a 676 return (uint8_t)(s_Step / ((float)1.5686e-5));
Davidroid 0:92706998571a 677 else
Davidroid 0:92706998571a 678 return 0; // Warning
Davidroid 0:92706998571a 679 }
Davidroid 0:92706998571a 680
Davidroid 0:92706998571a 681 /**
Davidroid 0:92706998571a 682 * @brief Convert the INT_SPEED register value into step/s.
Davidroid 0:92706998571a 683 *
Davidroid 0:92706998571a 684 * @param IntSpeed The INT_SPEED register value.
Davidroid 0:92706998571a 685 * @retval step/s The intersect speed as step/s.
Davidroid 0:92706998571a 686 */
Davidroid 0:92706998571a 687 float L6470::L6470_FnSlpAcc_2_s_Step(uint8_t FnSlpAcc)
Davidroid 0:92706998571a 688 {
Davidroid 0:92706998571a 689 // if (FnSlpAcc <= L6470_MAX_FN_SLP_ACC)
Davidroid 0:92706998571a 690 return (FnSlpAcc * ((float)1.5686e-5));
Davidroid 0:92706998571a 691 // else
Davidroid 0:92706998571a 692 // return 0; // Warning
Davidroid 0:92706998571a 693 }
Davidroid 0:92706998571a 694
Davidroid 0:92706998571a 695 /**
Davidroid 0:92706998571a 696 * @brief Convert the intersect speed as step/s into a right value for INT_SPEED register.
Davidroid 0:92706998571a 697 *
Davidroid 0:92706998571a 698 * @param step/s The full-step speed as step/s.
Davidroid 0:92706998571a 699 * @retval FsSpd The FS_SPD register value.
Davidroid 0:92706998571a 700 */
Davidroid 0:92706998571a 701 uint8_t L6470::L6470_s_Step_2_FnSlpAcc(float s_Step)
Davidroid 0:92706998571a 702 {
Davidroid 0:92706998571a 703 if (s_Step <= (L6470_MAX_FN_SLP_ACC * ((float)1.5686e-5)))
Davidroid 0:92706998571a 704 return (uint8_t)(s_Step / ((float)1.5686e-5));
Davidroid 0:92706998571a 705 else
Davidroid 0:92706998571a 706 return 0; // Warning
Davidroid 0:92706998571a 707 }
Davidroid 0:92706998571a 708
Davidroid 0:92706998571a 709 /**
Davidroid 0:92706998571a 710 * @brief Convert the INT_SPEED register value into step/s.
Davidroid 0:92706998571a 711 *
Davidroid 0:92706998571a 712 * @param IntSpeed The INT_SPEED register value.
Davidroid 0:92706998571a 713 * @retval step/s The intersect speed as step/s.
Davidroid 0:92706998571a 714 */
Davidroid 0:92706998571a 715 float L6470::L6470_FnSlpDec_2_s_Step(uint8_t FnSlpDec)
Davidroid 0:92706998571a 716 {
Davidroid 0:92706998571a 717 // if (FnSlpDec <= L6470_MAX_FN_SLP_DEC)
Davidroid 0:92706998571a 718 return (FnSlpDec * ((float)1.5686e-5));
Davidroid 0:92706998571a 719 // else
Davidroid 0:92706998571a 720 // return 0; // Warning
Davidroid 0:92706998571a 721 }
Davidroid 0:92706998571a 722
Davidroid 0:92706998571a 723 /**
Davidroid 0:92706998571a 724 * @brief Convert the intersect speed as step/s into a right value for INT_SPEED register.
Davidroid 0:92706998571a 725 *
Davidroid 0:92706998571a 726 * @param step/s The full-step speed as step/s.
Davidroid 0:92706998571a 727 * @retval FsSpd The FS_SPD register value.
Davidroid 0:92706998571a 728 */
Davidroid 0:92706998571a 729 uint8_t L6470::L6470_s_Step_2_FnSlpDec(float s_Step)
Davidroid 0:92706998571a 730 {
Davidroid 0:92706998571a 731 if (s_Step <= (L6470_MAX_FN_SLP_DEC * ((float)1.5686e-5)))
Davidroid 0:92706998571a 732 return (uint8_t)(s_Step / ((float)1.5686e-5));
Davidroid 0:92706998571a 733 else
Davidroid 0:92706998571a 734 return 0; // Warning
Davidroid 0:92706998571a 735 }
Davidroid 0:92706998571a 736
Davidroid 0:92706998571a 737 /**
Davidroid 0:92706998571a 738 * @brief Convert the OCD_TH register value into mA.
Davidroid 0:92706998571a 739 *
Davidroid 0:92706998571a 740 * @param OcdTh The OCD_TH register value.
Davidroid 0:92706998571a 741 * @retval mA The overcurrent threshold as mA.
Davidroid 0:92706998571a 742 */
Davidroid 0:92706998571a 743 float L6470::L6470_OcdTh_2_mA(uint8_t OcdTh)
Davidroid 0:92706998571a 744 {
Davidroid 0:92706998571a 745 if (OcdTh <= L6470_MAX_OCD_TH)
Davidroid 0:92706998571a 746 return ((OcdTh+1) * ((float)375));
Davidroid 0:92706998571a 747 else
Davidroid 0:92706998571a 748 return 0; // Warning
Davidroid 0:92706998571a 749 }
Davidroid 0:92706998571a 750
Davidroid 0:92706998571a 751 /**
Davidroid 0:92706998571a 752 * @brief Convert the overcurrent threshold as mA into a right value for OCD_TH register.
Davidroid 0:92706998571a 753 *
Davidroid 0:92706998571a 754 * @param mA The overcurrent threshold as mA.
Davidroid 0:92706998571a 755 * @retval OcdTh The OCD_TH register value.
Davidroid 0:92706998571a 756 */
Davidroid 0:92706998571a 757 uint8_t L6470::L6470_mA_2_OcdTh(float mA)
Davidroid 0:92706998571a 758 {
Davidroid 0:92706998571a 759 float result, decimal;
Davidroid 0:92706998571a 760
Davidroid 0:92706998571a 761 if (mA <= ((L6470_MAX_OCD_TH+1) * ((float)375)))
Davidroid 0:92706998571a 762 {
Davidroid 0:92706998571a 763 result = (mA / ((float)375));
Davidroid 0:92706998571a 764 decimal = result - (uint8_t)result;
Davidroid 0:92706998571a 765
Davidroid 0:92706998571a 766 if (decimal < (float)0.5)
Davidroid 0:92706998571a 767 return ((uint8_t)result - 1);
Davidroid 0:92706998571a 768 else
Davidroid 0:92706998571a 769 return ((uint8_t)result);
Davidroid 0:92706998571a 770 }
Davidroid 0:92706998571a 771 else
Davidroid 0:92706998571a 772 return 0; // Warning
Davidroid 0:92706998571a 773 }
Davidroid 0:92706998571a 774
Davidroid 0:92706998571a 775 /**
Davidroid 0:92706998571a 776 * @brief Convert the STALL_TH register value into mA.
Davidroid 0:92706998571a 777 *
Davidroid 0:92706998571a 778 * @param StallTh The STALL_TH register value.
Davidroid 0:92706998571a 779 * @retval mA The stall detection threshold as mA.
Davidroid 0:92706998571a 780 */
Davidroid 0:92706998571a 781 float L6470::L6470_StallTh_2_mA(uint8_t StallTh)
Davidroid 0:92706998571a 782 {
Davidroid 0:92706998571a 783 if (StallTh <= L6470_MAX_STALL_TH)
Davidroid 0:92706998571a 784 return ((StallTh+1) * ((float)31.25));
Davidroid 0:92706998571a 785 else
Davidroid 0:92706998571a 786 return 0; // Warning
Davidroid 0:92706998571a 787 }
Davidroid 0:92706998571a 788
Davidroid 0:92706998571a 789 /**
Davidroid 0:92706998571a 790 * @brief Convert the stall detection threshold as mA into a right value for STALL_TH register.
Davidroid 0:92706998571a 791 *
Davidroid 0:92706998571a 792 * @param mA The stall detection threshold as mA.
Davidroid 0:92706998571a 793 * @retval StallTh The STALL_TH register value.
Davidroid 0:92706998571a 794 */
Davidroid 0:92706998571a 795 uint8_t L6470::L6470_mA_2_StallTh(float mA)
Davidroid 0:92706998571a 796 {
Davidroid 0:92706998571a 797 float result, decimal;
Davidroid 0:92706998571a 798
Davidroid 0:92706998571a 799 if (mA <= ((L6470_MAX_STALL_TH+1) * ((float)31.25)))
Davidroid 0:92706998571a 800 {
Davidroid 0:92706998571a 801 result = (mA / ((float)31.25));
Davidroid 0:92706998571a 802 decimal = result - (uint8_t)result;
Davidroid 0:92706998571a 803
Davidroid 0:92706998571a 804 if (decimal < (float)0.5)
Davidroid 0:92706998571a 805 return ((uint8_t)result - 1);
Davidroid 0:92706998571a 806 else
Davidroid 0:92706998571a 807 return ((uint8_t)result);
Davidroid 0:92706998571a 808 }
Davidroid 0:92706998571a 809 else
Davidroid 0:92706998571a 810 return 0; // Warning
Davidroid 0:92706998571a 811 }
Davidroid 0:92706998571a 812
Davidroid 0:92706998571a 813 /* End of L6470_Conversion_Functions */
Davidroid 0:92706998571a 814
Davidroid 0:92706998571a 815 /**
Davidroid 0:92706998571a 816 * @addtogroup L6470_AppCMDs
Davidroid 0:92706998571a 817 * @{
Davidroid 0:92706998571a 818 */
Davidroid 0:92706998571a 819
Davidroid 0:92706998571a 820 /**
Davidroid 0:92706998571a 821 * @brief SetParam command sets the register value equal to a new value.
Davidroid 0:92706998571a 822 *
Davidroid 0:92706998571a 823 * @param L6470_RegId The identifier of the L6470 register to be addressed.
Davidroid 0:92706998571a 824 * @param Value The new value.
Davidroid 0:92706998571a 825 */
Davidroid 0:92706998571a 826 void L6470::L6470_SetParam(eL6470_RegId_t L6470_RegId, uint32_t Value)
Davidroid 0:92706998571a 827 {
Davidroid 0:92706998571a 828 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SETPARAM_ID, L6470_RegId, Value, 0);
Davidroid 0:92706998571a 829 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 830 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 831 }
Davidroid 0:92706998571a 832
Davidroid 0:92706998571a 833 /**
Davidroid 0:92706998571a 834 * @brief GetParam command reads the register value.
Davidroid 0:92706998571a 835 *
Davidroid 0:92706998571a 836 * @param L6470_RegId The identifier of the L6470 register to be addressed.
Davidroid 0:92706998571a 837 *
Davidroid 0:92706998571a 838 * @retval ReceivedValue The register value.
Davidroid 0:92706998571a 839 */
Davidroid 0:92706998571a 840 uint32_t L6470::L6470_GetParam(eL6470_RegId_t L6470_RegId)
Davidroid 0:92706998571a 841 {
Davidroid 0:92706998571a 842 uint8_t ValueLengthByte;
Davidroid 0:92706998571a 843 uint32_t ReceivedValue;
Davidroid 0:92706998571a 844
Davidroid 0:92706998571a 845 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GETPARAM_ID, L6470_RegId, 0, 0);
Davidroid 0:92706998571a 846 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 847 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 848
Davidroid 0:92706998571a 849 ValueLengthByte = L6470_Register[L6470_RegId].LengthByte;
Davidroid 0:92706998571a 850
Davidroid 0:92706998571a 851 ReceivedValue = L6470_ExtractReturnedData((uint8_t*)L6470_DaisyChainSpiRxStruct, ValueLengthByte);
Davidroid 0:92706998571a 852
Davidroid 0:92706998571a 853 return ReceivedValue;
Davidroid 0:92706998571a 854 }
Davidroid 0:92706998571a 855
Davidroid 0:92706998571a 856 /**
Davidroid 0:92706998571a 857 * @brief Run command produces a motion at fixed speed.
Davidroid 0:92706998571a 858 *
Davidroid 0:92706998571a 859 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 860 * @param Speed The speed value as (([step/s] * 250e-9) / 2^-28)
Davidroid 0:92706998571a 861 */
Davidroid 0:92706998571a 862 void L6470::L6470_Run(eL6470_DirId_t L6470_DirId, uint32_t Speed)
Davidroid 0:92706998571a 863 {
Davidroid 0:92706998571a 864 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RUN_ID, L6470_DirId, Speed, 0);
Davidroid 0:92706998571a 865 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 866 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 867 }
Davidroid 0:92706998571a 868
Davidroid 0:92706998571a 869 /**
Davidroid 0:92706998571a 870 * @brief StepClock command switches the device in Step-clock mode.
Davidroid 0:92706998571a 871 *
Davidroid 0:92706998571a 872 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 873 */
Davidroid 0:92706998571a 874 void L6470::L6470_StepClock(eL6470_DirId_t L6470_DirId)
Davidroid 0:92706998571a 875 {
Davidroid 0:92706998571a 876 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_STEPCLOCK_ID, L6470_DirId, 0, 0);
Davidroid 0:92706998571a 877 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 878 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 879 }
Davidroid 0:92706998571a 880
Davidroid 0:92706998571a 881 /**
Davidroid 0:92706998571a 882 * @brief Move command produces a motion of N_STEP microsteps.
Davidroid 0:92706998571a 883 *
Davidroid 0:92706998571a 884 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 885 * @param N_Step The number of microsteps.
Davidroid 0:92706998571a 886 */
Davidroid 0:92706998571a 887 void L6470::L6470_Move(eL6470_DirId_t L6470_DirId, uint32_t N_Step)
Davidroid 0:92706998571a 888 {
Davidroid 0:92706998571a 889 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_MOVE_ID, L6470_DirId, N_Step, 0);
Davidroid 0:92706998571a 890 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 891 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 892 }
Davidroid 0:92706998571a 893
Davidroid 0:92706998571a 894 /**
Davidroid 0:92706998571a 895 * @brief GoTo command produces a motion to ABS_POS absolute position through the shortest path.
Davidroid 0:92706998571a 896 *
Davidroid 0:92706998571a 897 * @param AbsPos The target absolute position.
Davidroid 0:92706998571a 898 */
Davidroid 0:92706998571a 899 void L6470::L6470_GoTo(uint32_t AbsPos)
Davidroid 0:92706998571a 900 {
Davidroid 0:92706998571a 901 if (AbsPos <= L6470_POSITION_RANGE)
Davidroid 0:92706998571a 902 {
Davidroid 0:92706998571a 903 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOTO_ID, AbsPos, 0, 0);
Davidroid 0:92706998571a 904 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 905 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 906 }
Davidroid 0:92706998571a 907 }
Davidroid 0:92706998571a 908
Davidroid 0:92706998571a 909 /**
Davidroid 0:92706998571a 910 * @brief GoTo_DIR command produces a motion to ABS_POS absolute position imposing a direction.
Davidroid 0:92706998571a 911 *
Davidroid 0:92706998571a 912 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 913 * @param AbsPos The target absolute position.
Davidroid 0:92706998571a 914 */
Davidroid 0:92706998571a 915 void L6470::L6470_GoToDir(eL6470_DirId_t L6470_DirId, uint32_t AbsPos)
Davidroid 0:92706998571a 916 {
Davidroid 0:92706998571a 917 if (AbsPos <= L6470_POSITION_RANGE)
Davidroid 0:92706998571a 918 {
Davidroid 0:92706998571a 919 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOTODIR_ID, L6470_DirId, AbsPos, 0);
Davidroid 0:92706998571a 920 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 921 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 922 }
Davidroid 0:92706998571a 923 }
Davidroid 0:92706998571a 924
Davidroid 0:92706998571a 925 /**
Davidroid 0:92706998571a 926 * @brief GoUntil command produces a motion at fixed speed imposing a direction
Davidroid 0:92706998571a 927 * until an external switch turn-on event occurs.
Davidroid 0:92706998571a 928 *
Davidroid 0:92706998571a 929 * @param L6470_ActId The identifier of the L6470 action about the absolute position.
Davidroid 0:92706998571a 930 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 931 * @param Speed The speed value as (([step/s] * 250e-9) / 2^-28)
Davidroid 0:92706998571a 932 */
Davidroid 0:92706998571a 933 void L6470::L6470_GoUntil(eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId, uint32_t Speed)
Davidroid 0:92706998571a 934 {
Davidroid 0:92706998571a 935 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOUNTIL_ID, L6470_ActId, L6470_DirId, Speed);
Davidroid 0:92706998571a 936 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 937 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 938 }
Davidroid 0:92706998571a 939
Davidroid 0:92706998571a 940 /**
Davidroid 0:92706998571a 941 * @brief ReleaseSW command produces a motion at minimum speed imposing a direction
Davidroid 0:92706998571a 942 * until SW is released.
Davidroid 0:92706998571a 943 *
Davidroid 0:92706998571a 944 * @param L6470_ActId The identifier of the L6470 action about the absolute position.
Davidroid 0:92706998571a 945 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 946 */
Davidroid 0:92706998571a 947 void L6470::L6470_ReleaseSW(eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId)
Davidroid 0:92706998571a 948 {
Davidroid 0:92706998571a 949 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RELEASESW_ID, L6470_ActId, L6470_DirId, 0);
Davidroid 0:92706998571a 950 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 951 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 952 }
Davidroid 0:92706998571a 953
Davidroid 0:92706998571a 954 /**
Davidroid 0:92706998571a 955 * @brief GoHome command produces a motion to the HOME position (zero position)
Davidroid 0:92706998571a 956 * via the shortest path.
Davidroid 0:92706998571a 957 *
Davidroid 0:92706998571a 958 */
Davidroid 0:92706998571a 959 void L6470::L6470_GoHome(void)
Davidroid 0:92706998571a 960 {
Davidroid 0:92706998571a 961 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOHOME_ID, 0, 0, 0);
Davidroid 0:92706998571a 962 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 963 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 964 }
Davidroid 0:92706998571a 965
Davidroid 0:92706998571a 966 /**
Davidroid 0:92706998571a 967 * @brief GoMark command produces a motion to the MARK position performing the
Davidroid 0:92706998571a 968 * minimum path.
Davidroid 0:92706998571a 969 *
Davidroid 0:92706998571a 970 */
Davidroid 0:92706998571a 971 void L6470::L6470_GoMark(void)
Davidroid 0:92706998571a 972 {
Davidroid 0:92706998571a 973 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOMARK_ID, 0, 0, 0);
Davidroid 0:92706998571a 974 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 975 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 976 }
Davidroid 0:92706998571a 977
Davidroid 0:92706998571a 978 /**
Davidroid 0:92706998571a 979 * @brief ResetPos command resets the ABS_POS register to zero.
Davidroid 0:92706998571a 980 *
Davidroid 0:92706998571a 981 */
Davidroid 0:92706998571a 982 void L6470::L6470_ResetPos(void)
Davidroid 0:92706998571a 983 {
Davidroid 0:92706998571a 984 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RESETPOS_ID, 0, 0, 0);
Davidroid 0:92706998571a 985 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 986 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 987 }
Davidroid 0:92706998571a 988
Davidroid 0:92706998571a 989 /**
Davidroid 0:92706998571a 990 * @brief ResetDevice command resets the device to power-up conditions.
Davidroid 0:92706998571a 991 *
Davidroid 0:92706998571a 992 */
Davidroid 0:92706998571a 993 void L6470::L6470_ResetDevice(void)
Davidroid 0:92706998571a 994 {
Davidroid 0:92706998571a 995 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RESETDEVICE_ID, 0, 0, 0);
Davidroid 0:92706998571a 996 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 997 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 998 }
Davidroid 0:92706998571a 999
Davidroid 0:92706998571a 1000 /**
Davidroid 0:92706998571a 1001 * @brief SoftStop command causes an immediate deceleration to zero speed and
Davidroid 0:92706998571a 1002 * a consequent motor stop; the deceleration value used is the one stored
Davidroid 0:92706998571a 1003 * in the DEC register.
Davidroid 0:92706998571a 1004 *
Davidroid 0:92706998571a 1005 */
Davidroid 0:92706998571a 1006 void L6470::L6470_SoftStop(void)
Davidroid 0:92706998571a 1007 {
Davidroid 0:92706998571a 1008 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SOFTSTOP_ID, 0, 0, 0);
Davidroid 0:92706998571a 1009 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 1010 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 1011 }
Davidroid 0:92706998571a 1012
Davidroid 0:92706998571a 1013 /**
Davidroid 0:92706998571a 1014 * @brief HardStop command causes an immediate motor stop with infinite deceleration.
Davidroid 0:92706998571a 1015 *
Davidroid 0:92706998571a 1016 */
Davidroid 0:92706998571a 1017 void L6470::L6470_HardStop(void)
Davidroid 0:92706998571a 1018 {
Davidroid 0:92706998571a 1019 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_HARDSTOP_ID, 0, 0, 0);
Davidroid 0:92706998571a 1020 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 1021 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 1022 }
Davidroid 0:92706998571a 1023
Davidroid 0:92706998571a 1024 /**
Davidroid 0:92706998571a 1025 * @brief SoftHiZ command disables the power bridges (high impedance state)
Davidroid 0:92706998571a 1026 * after a deceleration to zero; the deceleration value used is the one
Davidroid 0:92706998571a 1027 * stored in the DEC register.
Davidroid 0:92706998571a 1028 *
Davidroid 0:92706998571a 1029 */
Davidroid 0:92706998571a 1030 void L6470::L6470_SoftHiZ(void)
Davidroid 0:92706998571a 1031 {
Davidroid 0:92706998571a 1032 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SOFTHIZ_ID, 0, 0, 0);
Davidroid 0:92706998571a 1033 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 1034 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 1035 }
Davidroid 0:92706998571a 1036
Davidroid 0:92706998571a 1037 /**
Davidroid 0:92706998571a 1038 * @brief HardHiZ command immediately disables the power bridges (high impedance state).
Davidroid 0:92706998571a 1039 *
Davidroid 0:92706998571a 1040 */
Davidroid 0:92706998571a 1041 void L6470::L6470_HardHiZ(void)
Davidroid 0:92706998571a 1042 {
Davidroid 0:92706998571a 1043 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_HARDHIZ_ID, 0, 0, 0);
Davidroid 0:92706998571a 1044 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 1045 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 1046 }
Davidroid 0:92706998571a 1047
Davidroid 0:92706998571a 1048 /**
Davidroid 0:92706998571a 1049 * @brief GetStatus command returns the STATUS register value.
Davidroid 0:92706998571a 1050 *
Davidroid 0:92706998571a 1051 *
Davidroid 0:92706998571a 1052 * @retval ReceivedValue The register value.
Davidroid 0:92706998571a 1053 */
Davidroid 0:92706998571a 1054 uint16_t L6470::L6470_GetStatus(void)
Davidroid 0:92706998571a 1055 {
Davidroid 0:92706998571a 1056 uint16_t ReceivedValue;
Davidroid 0:92706998571a 1057
Davidroid 0:92706998571a 1058 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GETSTATUS_ID, 0, 0, 0);
Davidroid 0:92706998571a 1059 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 1060 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 1061
Davidroid 0:92706998571a 1062 ReceivedValue = (uint16_t)L6470_ExtractReturnedData((uint8_t*)L6470_DaisyChainSpiRxStruct, 2);
Davidroid 0:92706998571a 1063
Davidroid 0:92706998571a 1064 return ReceivedValue;
Davidroid 0:92706998571a 1065 }
Davidroid 0:92706998571a 1066
Davidroid 0:92706998571a 1067 /* End of L6470_AppCMDs */
Davidroid 0:92706998571a 1068
Davidroid 0:92706998571a 1069 /**
Davidroid 0:92706998571a 1070 * @addtogroup L6470_AppCMDs_ToBePrepared
Davidroid 0:92706998571a 1071 * @{
Davidroid 0:92706998571a 1072 */
Davidroid 0:92706998571a 1073
Davidroid 0:92706998571a 1074 /**
Davidroid 0:92706998571a 1075 * @brief Prepare to send @ref L6470_SetParam command.
Davidroid 0:92706998571a 1076 *
Davidroid 0:92706998571a 1077 * @param L6470_RegId The identifier of the L6470 register to be addressed.
Davidroid 0:92706998571a 1078 * @param Value The new value.
Davidroid 0:92706998571a 1079 *
Davidroid 0:92706998571a 1080 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1081 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1082 */
Davidroid 0:92706998571a 1083 void L6470::L6470_PrepareSetParam(eL6470_RegId_t L6470_RegId, uint32_t Value)
Davidroid 0:92706998571a 1084 {
Davidroid 1:b78dab6d2c58 1085 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SETPARAM_ID, L6470_RegId, Value, 0);
Davidroid 0:92706998571a 1086 }
Davidroid 0:92706998571a 1087
Davidroid 0:92706998571a 1088 /**
Davidroid 0:92706998571a 1089 * @brief Prepare to send @ref L6470_GetParam command.
Davidroid 0:92706998571a 1090 *
Davidroid 0:92706998571a 1091 * @param L6470_Id The L6470 identifier inside the daisy chain.
Davidroid 0:92706998571a 1092 * @param L6470_RegId The identifier of the L6470 register to be addressed.
Davidroid 0:92706998571a 1093 *
Davidroid 0:92706998571a 1094 * @retval ReceivedValue The register value.
Davidroid 0:92706998571a 1095 *
Davidroid 0:92706998571a 1096 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1097 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1098 */
Davidroid 0:92706998571a 1099 void L6470::L6470_PrepareGetParam(eL6470_RegId_t L6470_RegId)
Davidroid 0:92706998571a 1100 {
Davidroid 1:b78dab6d2c58 1101 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GETPARAM_ID, L6470_RegId, 0, 0);
Davidroid 0:92706998571a 1102 }
Davidroid 0:92706998571a 1103
Davidroid 0:92706998571a 1104 /**
Davidroid 0:92706998571a 1105 * @brief Prepare to send @ref L6470_Run command.
Davidroid 0:92706998571a 1106 *
Davidroid 0:92706998571a 1107 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 1108 * @param Speed The speed value as (([step/s] * 250e-9) / 2^-28)
Davidroid 0:92706998571a 1109 *
Davidroid 0:92706998571a 1110 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1111 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1112 */
Davidroid 0:92706998571a 1113 void L6470::L6470_PrepareRun(eL6470_DirId_t L6470_DirId, uint32_t Speed)
Davidroid 0:92706998571a 1114 {
Davidroid 0:92706998571a 1115 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RUN_ID, L6470_DirId, Speed, 0);
Davidroid 0:92706998571a 1116 }
Davidroid 0:92706998571a 1117
Davidroid 0:92706998571a 1118 /**
Davidroid 0:92706998571a 1119 * @brief Prepare to send @ref L6470_StepClock command.
Davidroid 0:92706998571a 1120 *
Davidroid 0:92706998571a 1121 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 1122 *
Davidroid 0:92706998571a 1123 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1124 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1125 */
Davidroid 0:92706998571a 1126 void L6470::L6470_PrepareStepClock(eL6470_DirId_t L6470_DirId)
Davidroid 0:92706998571a 1127 {
Davidroid 0:92706998571a 1128 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_STEPCLOCK_ID, L6470_DirId, 0, 0);
Davidroid 0:92706998571a 1129 }
Davidroid 0:92706998571a 1130
Davidroid 0:92706998571a 1131 /**
Davidroid 0:92706998571a 1132 * @brief Prepare to send @ref L6470_Move command.
Davidroid 0:92706998571a 1133 *
Davidroid 0:92706998571a 1134 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 1135 * @param N_Step The number of microsteps.
Davidroid 0:92706998571a 1136 *
Davidroid 0:92706998571a 1137 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1138 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1139 */
Davidroid 0:92706998571a 1140 void L6470::L6470_PrepareMove(eL6470_DirId_t L6470_DirId, uint32_t N_Step)
Davidroid 0:92706998571a 1141 {
Davidroid 0:92706998571a 1142 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_MOVE_ID, L6470_DirId, N_Step, 0);
Davidroid 0:92706998571a 1143 }
Davidroid 0:92706998571a 1144
Davidroid 0:92706998571a 1145 /**
Davidroid 0:92706998571a 1146 * @brief Prepare to send @ref L6470_GoTo command.
Davidroid 0:92706998571a 1147 *
Davidroid 0:92706998571a 1148 * @param AbsPos The target absolute position.
Davidroid 0:92706998571a 1149 *
Davidroid 0:92706998571a 1150 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1151 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1152 */
Davidroid 0:92706998571a 1153 void L6470::L6470_PrepareGoTo(uint32_t AbsPos)
Davidroid 0:92706998571a 1154 {
Davidroid 0:92706998571a 1155 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOTO_ID, AbsPos, 0, 0);
Davidroid 0:92706998571a 1156 }
Davidroid 0:92706998571a 1157
Davidroid 0:92706998571a 1158 /**
Davidroid 0:92706998571a 1159 * @brief Prepare to send @ref L6470_GoToDIR command.
Davidroid 0:92706998571a 1160 *
Davidroid 0:92706998571a 1161 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 1162 * @param AbsPos The target absolute position.
Davidroid 0:92706998571a 1163 *
Davidroid 0:92706998571a 1164 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1165 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1166 */
Davidroid 0:92706998571a 1167 void L6470::L6470_PrepareGoToDir(eL6470_DirId_t L6470_DirId, uint32_t AbsPos)
Davidroid 0:92706998571a 1168 {
Davidroid 0:92706998571a 1169 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOTODIR_ID, L6470_DirId, AbsPos, 0);
Davidroid 0:92706998571a 1170 }
Davidroid 0:92706998571a 1171
Davidroid 0:92706998571a 1172 /**
Davidroid 0:92706998571a 1173 * @brief Prepare to send @ref L6470_GoUntil command.
Davidroid 0:92706998571a 1174 *
Davidroid 0:92706998571a 1175 * @param L6470_ActId The identifier of the L6470 action about the absolute position.
Davidroid 0:92706998571a 1176 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 1177 * @param Speed The speed value as (([step/s] * 250e-9) / 2^-28)
Davidroid 0:92706998571a 1178 *
Davidroid 0:92706998571a 1179 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1180 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1181 */
Davidroid 0:92706998571a 1182 void L6470::L6470_PrepareGoUntil(eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId, uint32_t Speed)
Davidroid 0:92706998571a 1183 {
Davidroid 0:92706998571a 1184 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOUNTIL_ID, L6470_ActId, L6470_DirId, Speed);
Davidroid 0:92706998571a 1185 }
Davidroid 0:92706998571a 1186
Davidroid 0:92706998571a 1187 /**
Davidroid 0:92706998571a 1188 * @brief Prepare to send @ref L6470_ReleaseSW.
Davidroid 0:92706998571a 1189 *
Davidroid 0:92706998571a 1190 * @param L6470_ActId The identifier of the L6470 action about the absolute position.
Davidroid 0:92706998571a 1191 * @param L6470_DirId The identifier of the L6470 motion direction.
Davidroid 0:92706998571a 1192 *
Davidroid 0:92706998571a 1193 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1194 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1195 */
Davidroid 0:92706998571a 1196 void L6470::L6470_PrepareReleaseSW(eL6470_ActId_t L6470_ActId, eL6470_DirId_t L6470_DirId)
Davidroid 0:92706998571a 1197 {
Davidroid 0:92706998571a 1198 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RELEASESW_ID, L6470_ActId, L6470_DirId, 0);
Davidroid 0:92706998571a 1199 }
Davidroid 0:92706998571a 1200
Davidroid 0:92706998571a 1201 /**
Davidroid 0:92706998571a 1202 * @brief Prepare to send @ref L6470_GoHome command.
Davidroid 0:92706998571a 1203 *
Davidroid 0:92706998571a 1204 *
Davidroid 0:92706998571a 1205 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1206 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1207 */
Davidroid 0:92706998571a 1208 void L6470::L6470_PrepareGoHome(void)
Davidroid 0:92706998571a 1209 {
Davidroid 0:92706998571a 1210 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOHOME_ID, 0, 0, 0);
Davidroid 0:92706998571a 1211 }
Davidroid 0:92706998571a 1212
Davidroid 0:92706998571a 1213 /**
Davidroid 0:92706998571a 1214 * @brief Prepare to send @ref L6470_GoMark command.
Davidroid 0:92706998571a 1215 *
Davidroid 0:92706998571a 1216 *
Davidroid 0:92706998571a 1217 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1218 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1219 */
Davidroid 0:92706998571a 1220 void L6470::L6470_PrepareGoMark(void)
Davidroid 0:92706998571a 1221 {
Davidroid 0:92706998571a 1222 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GOMARK_ID, 0, 0, 0);
Davidroid 0:92706998571a 1223 }
Davidroid 0:92706998571a 1224
Davidroid 0:92706998571a 1225 /**
Davidroid 0:92706998571a 1226 * @brief Prepare to send @ref L6470_ResetPos command.
Davidroid 0:92706998571a 1227 *
Davidroid 0:92706998571a 1228 *
Davidroid 0:92706998571a 1229 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1230 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1231 */
Davidroid 0:92706998571a 1232 void L6470::L6470_PrepareResetPos(void)
Davidroid 0:92706998571a 1233 {
Davidroid 0:92706998571a 1234 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RESETPOS_ID, 0, 0, 0);
Davidroid 0:92706998571a 1235 }
Davidroid 0:92706998571a 1236
Davidroid 0:92706998571a 1237 /**
Davidroid 0:92706998571a 1238 * @brief Prepare to send @ref L6470_ResetDevice command.
Davidroid 0:92706998571a 1239 *
Davidroid 0:92706998571a 1240 *
Davidroid 0:92706998571a 1241 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1242 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1243 */
Davidroid 0:92706998571a 1244 void L6470::L6470_PrepareResetDevice(void)
Davidroid 0:92706998571a 1245 {
Davidroid 0:92706998571a 1246 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_RESETDEVICE_ID, 0, 0, 0);
Davidroid 0:92706998571a 1247 }
Davidroid 0:92706998571a 1248
Davidroid 0:92706998571a 1249 /**
Davidroid 0:92706998571a 1250 * @brief Prepare to send @ref L6470_SoftStop command.
Davidroid 0:92706998571a 1251 *
Davidroid 0:92706998571a 1252 *
Davidroid 0:92706998571a 1253 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1254 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1255 */
Davidroid 0:92706998571a 1256 void L6470::L6470_PrepareSoftStop(void)
Davidroid 0:92706998571a 1257 {
Davidroid 0:92706998571a 1258 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SOFTSTOP_ID, 0, 0, 0);
Davidroid 0:92706998571a 1259 }
Davidroid 0:92706998571a 1260
Davidroid 0:92706998571a 1261 /**
Davidroid 0:92706998571a 1262 * @brief Prepare to send @ref L6470_HardStop command.
Davidroid 0:92706998571a 1263 *
Davidroid 0:92706998571a 1264 *
Davidroid 0:92706998571a 1265 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1266 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1267 */
Davidroid 0:92706998571a 1268 void L6470::L6470_PrepareHardStop(void)
Davidroid 0:92706998571a 1269 {
Davidroid 0:92706998571a 1270 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_HARDSTOP_ID, 0, 0, 0);
Davidroid 0:92706998571a 1271 }
Davidroid 0:92706998571a 1272
Davidroid 0:92706998571a 1273 /**
Davidroid 0:92706998571a 1274 * @brief Prepare to send @ref L6470_SoftHiZ command.
Davidroid 0:92706998571a 1275 *
Davidroid 0:92706998571a 1276 *
Davidroid 0:92706998571a 1277 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1278 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1279 */
Davidroid 0:92706998571a 1280 void L6470::L6470_PrepareSoftHiZ(void)
Davidroid 0:92706998571a 1281 {
Davidroid 0:92706998571a 1282 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_SOFTHIZ_ID, 0, 0, 0);
Davidroid 0:92706998571a 1283 }
Davidroid 0:92706998571a 1284
Davidroid 0:92706998571a 1285 /**
Davidroid 0:92706998571a 1286 * @brief Prepare to send @ref L6470_HardHiZ command.
Davidroid 0:92706998571a 1287 *
Davidroid 0:92706998571a 1288 *
Davidroid 0:92706998571a 1289 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1290 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1291 */
Davidroid 0:92706998571a 1292 void L6470::L6470_PrepareHardHiZ(void)
Davidroid 0:92706998571a 1293 {
Davidroid 0:92706998571a 1294 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_HARDHIZ_ID, 0, 0, 0);
Davidroid 0:92706998571a 1295 }
Davidroid 0:92706998571a 1296
Davidroid 0:92706998571a 1297 /**
Davidroid 0:92706998571a 1298 * @brief Prepare to send @ref L6470_GetStatus command.
Davidroid 0:92706998571a 1299 *
Davidroid 0:92706998571a 1300 *
Davidroid 0:92706998571a 1301 * @note This function will properly fill the right column of the L6470_AppCmdPkg.
Davidroid 0:92706998571a 1302 * @note The commad will be sent by @ref L6470_PerformPreparedApplicationCommand.
Davidroid 0:92706998571a 1303 */
Davidroid 0:92706998571a 1304 void L6470::L6470_PrepareGetStatus(void)
Davidroid 0:92706998571a 1305 {
Davidroid 0:92706998571a 1306 L6470_PrepareAppCmdPkg(L6470_AppCmdPkg, L6470_GETSTATUS_ID, 0, 0, 0);
Davidroid 0:92706998571a 1307 }
Davidroid 0:92706998571a 1308
Davidroid 0:92706998571a 1309 /* End of L6470_AppCMDs_ToBePrepared */
Davidroid 0:92706998571a 1310
Davidroid 0:92706998571a 1311 /**
Davidroid 0:92706998571a 1312 * @brief Send via SPI the command stored inside the L6470_AppCmdPkg to the
Davidroid 0:92706998571a 1313 * L6470 daisy chain.
Davidroid 0:92706998571a 1314 *
Davidroid 0:92706998571a 1315 * @retval (uint8_t*)data->L6470_DaisyChainSpiRxStruct The pointer to the structure
Davidroid 0:92706998571a 1316 * containing returned values from each L6470 of the daisy chain for each
Davidroid 0:92706998571a 1317 * sent SPI data.
Davidroid 0:92706998571a 1318 */
Davidroid 0:92706998571a 1319 uint8_t* L6470::L6470_PerformPreparedApplicationCommand(void)
Davidroid 0:92706998571a 1320 {
Davidroid 0:92706998571a 1321 L6470_PrepareDaisyChainCommand(L6470_AppCmdPkg, (uint8_t*)L6470_DaisyChainSpiTxStruct);
Davidroid 0:92706998571a 1322 L6470_DaisyChainCommand((uint8_t*)L6470_DaisyChainSpiTxStruct, (uint8_t*)L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 1323
Davidroid 0:92706998571a 1324 return (uint8_t*)(L6470_DaisyChainSpiRxStruct);
Davidroid 0:92706998571a 1325 }
Davidroid 0:92706998571a 1326
Davidroid 0:92706998571a 1327 /**
Davidroid 0:92706998571a 1328 * @brief Send command to the L6470 daisy chain via SPI
Davidroid 0:92706998571a 1329 * @param pL6470_DaisyChainSpiTxStruct Pointer to the matrix array of bytes to be sent to the daisy chain L6470
Davidroid 0:92706998571a 1330 * @param pL6470_DaisyChainSpiRxStruct Pointer to the matrix array of bytes to be received from the daisy chain L6470
Davidroid 0:92706998571a 1331 */
Davidroid 0:92706998571a 1332 void L6470::L6470_DaisyChainCommand(uint8_t* pL6470_DaisyChainSpiTxStruct, uint8_t* pL6470_DaisyChainSpiRxStruct)
Davidroid 0:92706998571a 1333 {
Davidroid 0:92706998571a 1334 uint8_t spibyte;
Davidroid 0:92706998571a 1335
Davidroid 0:92706998571a 1336 L6470_DaisyChain_HalfPrepared = ZERO_F;
Davidroid 0:92706998571a 1337
Davidroid 0:92706998571a 1338 /* Send all command bytes via SPI */
Davidroid 0:92706998571a 1339 for(spibyte=0; spibyte < L6470MAXSPICMDBYTESIZE; spibyte++)
Davidroid 0:92706998571a 1340 {
Davidroid 0:92706998571a 1341 /* Send the command via SPI */
Davidroid 0:92706998571a 1342 L6470_SPI_Communication((pL6470_DaisyChainSpiTxStruct+(spibyte * L6470DAISYCHAINSIZE)), (pL6470_DaisyChainSpiRxStruct+(spibyte * L6470DAISYCHAINSIZE)), L6470DAISYCHAINSIZE, 10);
Davidroid 0:92706998571a 1343
Davidroid 0:92706998571a 1344 //_DELAY(TDISCS);
Davidroid 0:92706998571a 1345 uint8_t delay_cnt;
Davidroid 0:92706998571a 1346 for (delay_cnt=0; delay_cnt<20; delay_cnt++) __NOP(); //!<Simply deselect time delay for SPI nCS
Davidroid 0:92706998571a 1347 }
Davidroid 0:92706998571a 1348 }
Davidroid 0:92706998571a 1349
Davidroid 0:92706998571a 1350 /**
Davidroid 0:92706998571a 1351 * @brief Extracts the data returned by the L6470 from the matrix that
Davidroid 0:92706998571a 1352 * contains the received SPI data.
Davidroid 0:92706998571a 1353 * @param L6470_Id The identifier of the L6470 target inside the daisy chain.
Davidroid 0:92706998571a 1354 * @param pL6470_DaisyChainSpiRxStruct uint8_t-pointer to the matrix that
Davidroid 0:92706998571a 1355 * contains the received data by SPI from the L6470 daisy chain.
Davidroid 0:92706998571a 1356 * @param LengthByte The number of bytes about the received value.
Davidroid 0:92706998571a 1357 */
Davidroid 0:92706998571a 1358 uint32_t L6470::L6470_ExtractReturnedData(uint8_t* pL6470_DaisyChainSpiRxStruct, uint8_t LengthByte)
Davidroid 0:92706998571a 1359 {
Davidroid 0:92706998571a 1360 uint32_t value;
Davidroid 0:92706998571a 1361 uint8_t i;
Davidroid 0:92706998571a 1362
Davidroid 0:92706998571a 1363 value = 0x000000;
Davidroid 0:92706998571a 1364 for (i=1; i<=(L6470MAXSPICMDBYTESIZE-1); i++)
Davidroid 0:92706998571a 1365 {
Davidroid 0:92706998571a 1366 value |= (*(pL6470_DaisyChainSpiRxStruct+(i*L6470DAISYCHAINSIZE)+L6470_Id))<<((LengthByte-i)*8);
Davidroid 0:92706998571a 1367 }
Davidroid 1:b78dab6d2c58 1368
Davidroid 0:92706998571a 1369 return value;
Davidroid 0:92706998571a 1370 }
Davidroid 0:92706998571a 1371
Davidroid 0:92706998571a 1372 /**
Davidroid 0:92706998571a 1373 * @brief Check the state of a flag inside the L6470 STATUS register.
Davidroid 0:92706998571a 1374 *
Davidroid 0:92706998571a 1375 * @param L6470_Id The identifier of the L6470 target inside the daisy chain.
Davidroid 0:92706998571a 1376 * @param L6470_StatusRegisterFlagId The identifier of the L6470 STATUS flag to be checked.
Davidroid 0:92706998571a 1377 *
Davidroid 0:92706998571a 1378 * @retval state The flag state.
Davidroid 0:92706998571a 1379 */
Davidroid 0:92706998571a 1380
Davidroid 0:92706998571a 1381 uint8_t L6470::L6470_CheckStatusRegisterFlag(uint8_t L6470_StatusRegisterFlagId)
Davidroid 0:92706998571a 1382 {
Davidroid 0:92706998571a 1383 uint8_t state = 0;
Davidroid 0:92706998571a 1384
Davidroid 0:92706998571a 1385 *((uint16_t*)pL6470_StatusRegister) = L6470_GetParam(L6470_STATUS_ID);
Davidroid 0:92706998571a 1386
Davidroid 0:92706998571a 1387 switch(L6470_StatusRegisterFlagId)
Davidroid 0:92706998571a 1388 {
Davidroid 0:92706998571a 1389 case HiZ_ID:
Davidroid 0:92706998571a 1390 state = pL6470_StatusRegister->HiZ;
Davidroid 0:92706998571a 1391 break;
Davidroid 0:92706998571a 1392 case BUSY_ID:
Davidroid 0:92706998571a 1393 state = pL6470_StatusRegister->BUSY;
Davidroid 0:92706998571a 1394 break;
Davidroid 0:92706998571a 1395 case SW_F_ID:
Davidroid 0:92706998571a 1396 state = pL6470_StatusRegister->SW_F;
Davidroid 0:92706998571a 1397 break;
Davidroid 0:92706998571a 1398 case SW_EVN_ID:
Davidroid 0:92706998571a 1399 state = pL6470_StatusRegister->SW_EVN;
Davidroid 0:92706998571a 1400 break;
Davidroid 0:92706998571a 1401 case DIR_ID:
Davidroid 0:92706998571a 1402 state = pL6470_StatusRegister->DIR;
Davidroid 0:92706998571a 1403 break;
Davidroid 0:92706998571a 1404 case MOT_STATUS_ID:
Davidroid 0:92706998571a 1405 state = pL6470_StatusRegister->MOT_STATUS;
Davidroid 0:92706998571a 1406 break;
Davidroid 0:92706998571a 1407 case NOTPERF_CMD_ID:
Davidroid 0:92706998571a 1408 state = pL6470_StatusRegister->NOTPERF_CMD;
Davidroid 0:92706998571a 1409 break;
Davidroid 0:92706998571a 1410 case WRONG_CMD_ID:
Davidroid 0:92706998571a 1411 state = pL6470_StatusRegister->WRONG_CMD;
Davidroid 0:92706998571a 1412 break;
Davidroid 0:92706998571a 1413 case UVLO_ID:
Davidroid 0:92706998571a 1414 state = pL6470_StatusRegister->UVLO;
Davidroid 0:92706998571a 1415 break;
Davidroid 0:92706998571a 1416 case TH_WRN_ID:
Davidroid 0:92706998571a 1417 state = pL6470_StatusRegister->TH_WRN;
Davidroid 0:92706998571a 1418 break;
Davidroid 0:92706998571a 1419 case TH_SD_ID:
Davidroid 0:92706998571a 1420 state = pL6470_StatusRegister->TH_SD;
Davidroid 0:92706998571a 1421 break;
Davidroid 0:92706998571a 1422 case OCD_ID:
Davidroid 0:92706998571a 1423 state = pL6470_StatusRegister->OCD;
Davidroid 0:92706998571a 1424 break;
Davidroid 0:92706998571a 1425 case STEP_LOSS_A_ID:
Davidroid 0:92706998571a 1426 state = pL6470_StatusRegister->STEP_LOSS_A;
Davidroid 0:92706998571a 1427 break;
Davidroid 0:92706998571a 1428 case STEP_LOSS_B_ID:
Davidroid 0:92706998571a 1429 state = pL6470_StatusRegister->STEP_LOSS_B;
Davidroid 0:92706998571a 1430 break;
Davidroid 0:92706998571a 1431 case SCK_MOD_ID:
Davidroid 0:92706998571a 1432 state = pL6470_StatusRegister->SCK_MOD;
Davidroid 0:92706998571a 1433 break;
Davidroid 0:92706998571a 1434 }
Davidroid 0:92706998571a 1435
Davidroid 0:92706998571a 1436 return state;
Davidroid 0:92706998571a 1437 }
Davidroid 0:92706998571a 1438
Davidroid 0:92706998571a 1439 /**
Davidroid 0:92706998571a 1440 * @brief Return the mnemonic name for the L6470 register.
Davidroid 0:92706998571a 1441 * @param id The identifier of the L6470 register.
Davidroid 0:92706998571a 1442 */
Davidroid 0:92706998571a 1443 uint8_t *L6470::L6470_GetRegisterName(uint8_t id)
Davidroid 0:92706998571a 1444 {
Davidroid 0:92706998571a 1445 if (id < L6470REGIDSIZE)
Davidroid 0:92706998571a 1446 {
Davidroid 0:92706998571a 1447 return (uint8_t*)L6470_Register[id].Name;
Davidroid 0:92706998571a 1448 }
Davidroid 0:92706998571a 1449 else
Davidroid 0:92706998571a 1450 {
Davidroid 0:92706998571a 1451 return NULL;
Davidroid 0:92706998571a 1452 }
Davidroid 0:92706998571a 1453 }
Davidroid 0:92706998571a 1454
Davidroid 0:92706998571a 1455 /**
Davidroid 0:92706998571a 1456 * @brief Configures the L6470 registers.
Davidroid 0:92706998571a 1457 * @param StepperMotorDriverHandle_t* The pointer to the stepper motor driver handle structure.
Davidroid 0:92706998571a 1458 * @param MotorParameterData_t* The pointer to the related parameter data structure.
Davidroid 0:92706998571a 1459 */
Davidroid 0:92706998571a 1460 DrvStatusTypeDef L6470::L6470_Config(MICROSTEPPING_MOTOR_InitTypeDef *MotorParameterData)
Davidroid 0:92706998571a 1461 {
Davidroid 0:92706998571a 1462 /* Disable the L6470. */
Davidroid 0:92706998571a 1463 L6470_DISABLE();
Davidroid 0:92706998571a 1464
Davidroid 0:92706998571a 1465 /* Enable the L6470. */
Davidroid 0:92706998571a 1466 L6470_ENABLE();
Davidroid 0:92706998571a 1467
Davidroid 0:92706998571a 1468 /* Reset devices. */
Davidroid 0:92706998571a 1469 ResetDevice();
Davidroid 0:92706998571a 1470
Davidroid 0:92706998571a 1471 /* Reset Status Register flags. */
Davidroid 0:92706998571a 1472 GetStatus();
Davidroid 0:92706998571a 1473
Davidroid 0:92706998571a 1474 /* Prepare the 'Register' field of StepperMotorDriverHandle */
Davidroid 0:92706998571a 1475 StepperMotorRegister.ACC = L6470_Step_s2_2_Acc(MotorParameterData->acc);
Davidroid 0:92706998571a 1476 StepperMotorRegister.DEC = L6470_Step_s2_2_Dec(MotorParameterData->dec);
Davidroid 0:92706998571a 1477 StepperMotorRegister.MAX_SPEED = L6470_Step_s_2_MaxSpeed(MotorParameterData->maxspeed);
Davidroid 0:92706998571a 1478 StepperMotorRegister.MIN_SPEED = L6470_Step_s_2_MinSpeed(MotorParameterData->minspeed);
Davidroid 0:92706998571a 1479 StepperMotorRegister.FS_SPD = L6470_Step_s_2_FsSpd(MotorParameterData->fsspd);
Davidroid 0:92706998571a 1480 StepperMotorRegister.KVAL_HOLD = (uint8_t)((float)((float)(MotorParameterData->kvalhold * 256) / (MotorParameterData->motorvoltage)));
Davidroid 0:92706998571a 1481 StepperMotorRegister.KVAL_RUN = (uint8_t)((float)((float)(MotorParameterData->kvalrun * 256) / (MotorParameterData->motorvoltage)));
Davidroid 0:92706998571a 1482 StepperMotorRegister.KVAL_ACC = (uint8_t)((float)((float)(MotorParameterData->kvalacc * 256) / (MotorParameterData->motorvoltage)));
Davidroid 0:92706998571a 1483 StepperMotorRegister.KVAL_DEC = (uint8_t)((float)((float)(MotorParameterData->kvaldec * 256) / (MotorParameterData->motorvoltage)));
Davidroid 0:92706998571a 1484 StepperMotorRegister.INT_SPEED = L6470_Step_s_2_IntSpeed(MotorParameterData->intspeed);
Davidroid 0:92706998571a 1485 StepperMotorRegister.ST_SLP = L6470_s_Step_2_StSlp(MotorParameterData->stslp);
Davidroid 0:92706998571a 1486 StepperMotorRegister.FN_SLP_ACC = L6470_s_Step_2_FnSlpAcc(MotorParameterData->fnslpacc);
Davidroid 0:92706998571a 1487 StepperMotorRegister.FN_SLP_DEC = L6470_s_Step_2_FnSlpDec(MotorParameterData->fnslpdec);
Davidroid 0:92706998571a 1488 StepperMotorRegister.K_THERM = MotorParameterData->kterm;
Davidroid 0:92706998571a 1489 StepperMotorRegister.OCD_TH = L6470_mA_2_OcdTh(MotorParameterData->ocdth);
Davidroid 0:92706998571a 1490 StepperMotorRegister.STALL_TH = L6470_mA_2_StallTh(MotorParameterData->stallth);
Davidroid 0:92706998571a 1491 StepperMotorRegister.STEP_MODE = MotorParameterData->step_sel;
Davidroid 0:92706998571a 1492 StepperMotorRegister.ALARM_EN = MotorParameterData->alarmen;
Davidroid 0:92706998571a 1493 StepperMotorRegister.CONFIG = MotorParameterData->config;
Davidroid 0:92706998571a 1494
Davidroid 0:92706998571a 1495 /* Write the L6470 registers with the prepared data */
Davidroid 0:92706998571a 1496 L6470_SetParam(L6470_ACC_ID, StepperMotorRegister.ACC);
Davidroid 0:92706998571a 1497 L6470_SetParam(L6470_DEC_ID, StepperMotorRegister.DEC);
Davidroid 0:92706998571a 1498 L6470_SetParam(L6470_MAX_SPEED_ID, StepperMotorRegister.MAX_SPEED);
Davidroid 0:92706998571a 1499 L6470_SetParam(L6470_MIN_SPEED_ID, StepperMotorRegister.MIN_SPEED);
Davidroid 0:92706998571a 1500 L6470_SetParam(L6470_FS_SPD_ID, StepperMotorRegister.FS_SPD);
Davidroid 0:92706998571a 1501 L6470_SetParam(L6470_KVAL_HOLD_ID, StepperMotorRegister.KVAL_HOLD);
Davidroid 0:92706998571a 1502 L6470_SetParam(L6470_KVAL_RUN_ID, StepperMotorRegister.KVAL_RUN);
Davidroid 0:92706998571a 1503 L6470_SetParam(L6470_KVAL_ACC_ID, StepperMotorRegister.KVAL_ACC);
Davidroid 0:92706998571a 1504 L6470_SetParam(L6470_KVAL_DEC_ID, StepperMotorRegister.KVAL_DEC);
Davidroid 0:92706998571a 1505 L6470_SetParam(L6470_INT_SPEED_ID, StepperMotorRegister.INT_SPEED);
Davidroid 0:92706998571a 1506 L6470_SetParam(L6470_ST_SLP_ID, StepperMotorRegister.ST_SLP);
Davidroid 0:92706998571a 1507 L6470_SetParam(L6470_FN_SLP_ACC_ID, StepperMotorRegister.FN_SLP_ACC);
Davidroid 0:92706998571a 1508 L6470_SetParam(L6470_FN_SLP_DEC_ID, StepperMotorRegister.FN_SLP_DEC);
Davidroid 0:92706998571a 1509 L6470_SetParam(L6470_K_THERM_ID, StepperMotorRegister.K_THERM);
Davidroid 0:92706998571a 1510 L6470_SetParam(L6470_OCD_TH_ID, StepperMotorRegister.OCD_TH);
Davidroid 0:92706998571a 1511 L6470_SetParam(L6470_STALL_TH_ID, StepperMotorRegister.STALL_TH);
Davidroid 0:92706998571a 1512 L6470_SetParam(L6470_STEP_MODE_ID, StepperMotorRegister.STEP_MODE);
Davidroid 0:92706998571a 1513 L6470_SetParam(L6470_ALARM_EN_ID, StepperMotorRegister.ALARM_EN);
Davidroid 0:92706998571a 1514 L6470_SetParam(L6470_CONFIG_ID, StepperMotorRegister.CONFIG);
Davidroid 0:92706998571a 1515
Davidroid 0:92706998571a 1516 return COMPONENT_OK;
Davidroid 0:92706998571a 1517 }
Davidroid 0:92706998571a 1518
Davidroid 0:92706998571a 1519 /* End of L6470_Exported_Functions */
Davidroid 0:92706998571a 1520
Davidroid 0:92706998571a 1521 /* End of L6470 */
Davidroid 0:92706998571a 1522
Davidroid 0:92706998571a 1523 /* End of Components */
Davidroid 0:92706998571a 1524
Davidroid 0:92706998571a 1525 /* End of BSP */
Davidroid 0:92706998571a 1526
Davidroid 0:92706998571a 1527 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/