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:
Thu Dec 10 15:08:48 2015 +0000
Revision:
7:3bb27256c3ed
Parent:
6:c62aa608a493
Child:
11:1aca63b2f034
+ Comments related to the component updated.

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