Library to handle the X_NUCLEO_IHM02A1 Motor Control Expansion Board based on the L6470 component.
Fork of X_NUCLEO_IHM02A1 by
Components/Interfaces/StepperMotor_class.h@4:381d76f5b0b4, 2015-11-26 (annotated)
- Committer:
- Davidroid
- Date:
- Thu Nov 26 16:24:17 2015 +0000
- Revision:
- 4:381d76f5b0b4
- Parent:
- 1:b78dab6d2c58
- Child:
- 5:3cde564db574
+ Updated with the new structure of the Stm32CubeTOO tool.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Davidroid | 0:92706998571a | 1 | /** |
Davidroid | 0:92706998571a | 2 | ****************************************************************************** |
Davidroid | 0:92706998571a | 3 | * @file StepperMotor_class.h |
Davidroid | 4:381d76f5b0b4 | 4 | * @author Davide Aliprandi, STMicrolectronics |
Davidroid | 0:92706998571a | 5 | * @version V1.0.0 |
Davidroid | 0:92706998571a | 6 | * @date November 12th, 2015 |
Davidroid | 0:92706998571a | 7 | * @brief This file contains the abstract class describing the interface of a |
Davidroid | 1:b78dab6d2c58 | 8 | * stepper-motor component. |
Davidroid | 0:92706998571a | 9 | ****************************************************************************** |
Davidroid | 0:92706998571a | 10 | * @attention |
Davidroid | 0:92706998571a | 11 | * |
Davidroid | 0:92706998571a | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
Davidroid | 0:92706998571a | 13 | * |
Davidroid | 0:92706998571a | 14 | * Redistribution and use in source and binary forms, with or without modification, |
Davidroid | 0:92706998571a | 15 | * are permitted provided that the following conditions are met: |
Davidroid | 0:92706998571a | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
Davidroid | 0:92706998571a | 17 | * this list of conditions and the following disclaimer. |
Davidroid | 0:92706998571a | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Davidroid | 0:92706998571a | 19 | * this list of conditions and the following disclaimer in the documentation |
Davidroid | 0:92706998571a | 20 | * and/or other materials provided with the distribution. |
Davidroid | 0:92706998571a | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Davidroid | 0:92706998571a | 22 | * may be used to endorse or promote products derived from this software |
Davidroid | 0:92706998571a | 23 | * without specific prior written permission. |
Davidroid | 0:92706998571a | 24 | * |
Davidroid | 0:92706998571a | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Davidroid | 0:92706998571a | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Davidroid | 0:92706998571a | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Davidroid | 0:92706998571a | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Davidroid | 0:92706998571a | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Davidroid | 0:92706998571a | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Davidroid | 0:92706998571a | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Davidroid | 0:92706998571a | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Davidroid | 0:92706998571a | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Davidroid | 0:92706998571a | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Davidroid | 0:92706998571a | 35 | * |
Davidroid | 0:92706998571a | 36 | ****************************************************************************** |
Davidroid | 0:92706998571a | 37 | */ |
Davidroid | 0:92706998571a | 38 | |
Davidroid | 0:92706998571a | 39 | |
Davidroid | 0:92706998571a | 40 | /* Define to prevent from recursive inclusion --------------------------------*/ |
Davidroid | 0:92706998571a | 41 | |
Davidroid | 0:92706998571a | 42 | #ifndef __STEPPERMOTOR_CLASS_H |
Davidroid | 0:92706998571a | 43 | #define __STEPPERMOTOR_CLASS_H |
Davidroid | 0:92706998571a | 44 | |
Davidroid | 0:92706998571a | 45 | |
Davidroid | 0:92706998571a | 46 | /* Includes ------------------------------------------------------------------*/ |
Davidroid | 0:92706998571a | 47 | |
Davidroid | 0:92706998571a | 48 | #include <Component_class.h> |
Davidroid | 0:92706998571a | 49 | |
Davidroid | 0:92706998571a | 50 | |
Davidroid | 0:92706998571a | 51 | /* Classes ------------------------------------------------------------------*/ |
Davidroid | 0:92706998571a | 52 | |
Davidroid | 0:92706998571a | 53 | /** An abstract class for StepperMotor components. |
Davidroid | 0:92706998571a | 54 | */ |
Davidroid | 0:92706998571a | 55 | class StepperMotor : public Component |
Davidroid | 0:92706998571a | 56 | { |
Davidroid | 0:92706998571a | 57 | public: |
Davidroid | 4:381d76f5b0b4 | 58 | /** |
Davidroid | 4:381d76f5b0b4 | 59 | * @brief Rotation modes. |
Davidroid | 4:381d76f5b0b4 | 60 | */ |
Davidroid | 0:92706998571a | 61 | typedef enum |
Davidroid | 0:92706998571a | 62 | { |
Davidroid | 0:92706998571a | 63 | BWD = 0, /* Backward. */ |
Davidroid | 0:92706998571a | 64 | FWD = 1 /* Forward. */ |
Davidroid | 0:92706998571a | 65 | } direction_t; |
Davidroid | 0:92706998571a | 66 | |
Davidroid | 0:92706998571a | 67 | /** |
Davidroid | 1:b78dab6d2c58 | 68 | * @brief Getting the status. |
Davidroid | 0:92706998571a | 69 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 70 | * @retval The status. |
Davidroid | 0:92706998571a | 71 | */ |
Davidroid | 0:92706998571a | 72 | virtual unsigned int GetStatus(void) = 0; |
Davidroid | 0:92706998571a | 73 | |
Davidroid | 1:b78dab6d2c58 | 74 | /** |
Davidroid | 0:92706998571a | 75 | * @brief Getting a parameter. |
Davidroid | 1:b78dab6d2c58 | 76 | * @param parameter The parameter's identifier (or its register address). |
Davidroid | 1:b78dab6d2c58 | 77 | * @retval The parameter's value. |
Davidroid | 0:92706998571a | 78 | */ |
Davidroid | 0:92706998571a | 79 | virtual unsigned int GetParameter(unsigned int parameter) = 0; |
Davidroid | 0:92706998571a | 80 | |
Davidroid | 1:b78dab6d2c58 | 81 | /** |
Davidroid | 1:b78dab6d2c58 | 82 | * @brief Getting the position. |
Davidroid | 1:b78dab6d2c58 | 83 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 84 | * @retval The position. |
Davidroid | 1:b78dab6d2c58 | 85 | */ |
Davidroid | 0:92706998571a | 86 | virtual signed int GetPosition(void) = 0; |
Davidroid | 0:92706998571a | 87 | |
Davidroid | 1:b78dab6d2c58 | 88 | /** |
Davidroid | 1:b78dab6d2c58 | 89 | * @brief Getting the marked position. |
Davidroid | 1:b78dab6d2c58 | 90 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 91 | * @retval The marked position. |
Davidroid | 1:b78dab6d2c58 | 92 | */ |
Davidroid | 0:92706998571a | 93 | virtual signed int GetMark(void) = 0; |
Davidroid | 0:92706998571a | 94 | |
Davidroid | 1:b78dab6d2c58 | 95 | /** |
Davidroid | 1:b78dab6d2c58 | 96 | * @brief Getting the current speed in pps. |
Davidroid | 1:b78dab6d2c58 | 97 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 98 | * @retval The current speed in pps. |
Davidroid | 1:b78dab6d2c58 | 99 | */ |
Davidroid | 0:92706998571a | 100 | virtual unsigned int GetSpeed(void) = 0; |
Davidroid | 0:92706998571a | 101 | |
Davidroid | 1:b78dab6d2c58 | 102 | /** |
Davidroid | 1:b78dab6d2c58 | 103 | * @brief Getting the maximum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 104 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 105 | * @retval The maximum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 106 | */ |
Davidroid | 0:92706998571a | 107 | virtual unsigned int GetMaxSpeed(void) = 0; |
Davidroid | 0:92706998571a | 108 | |
Davidroid | 1:b78dab6d2c58 | 109 | /** |
Davidroid | 1:b78dab6d2c58 | 110 | * @brief Getting the minimum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 111 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 112 | * @retval The minimum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 113 | */ |
Davidroid | 0:92706998571a | 114 | virtual unsigned int GetMinSpeed(void) = 0; |
Davidroid | 0:92706998571a | 115 | |
Davidroid | 1:b78dab6d2c58 | 116 | /** |
Davidroid | 1:b78dab6d2c58 | 117 | * @brief Getting the acceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 118 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 119 | * @retval The acceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 120 | */ |
Davidroid | 0:92706998571a | 121 | virtual unsigned int GetAcceleration(void) = 0; |
Davidroid | 0:92706998571a | 122 | |
Davidroid | 1:b78dab6d2c58 | 123 | /** |
Davidroid | 1:b78dab6d2c58 | 124 | * @brief Getting the deceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 125 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 126 | * @retval The deceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 127 | */ |
Davidroid | 0:92706998571a | 128 | virtual unsigned int GetDeceleration(void) = 0; |
Davidroid | 0:92706998571a | 129 | |
Davidroid | 1:b78dab6d2c58 | 130 | /** |
Davidroid | 1:b78dab6d2c58 | 131 | * @brief Getting the direction of rotation. |
Davidroid | 1:b78dab6d2c58 | 132 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 133 | * @retval The direction of rotation. |
Davidroid | 1:b78dab6d2c58 | 134 | */ |
Davidroid | 0:92706998571a | 135 | virtual direction_t GetDirection(void) = 0; |
Davidroid | 0:92706998571a | 136 | |
Davidroid | 0:92706998571a | 137 | /** |
Davidroid | 0:92706998571a | 138 | * @brief Setting a parameter. |
Davidroid | 1:b78dab6d2c58 | 139 | * @param parameter The parameter's identifier (or its register address). |
Davidroid | 1:b78dab6d2c58 | 140 | * @param value The parameter's value. |
Davidroid | 0:92706998571a | 141 | * @retval None. |
Davidroid | 0:92706998571a | 142 | */ |
Davidroid | 0:92706998571a | 143 | virtual void SetParameter(unsigned int parameter, unsigned int value) = 0; |
Davidroid | 0:92706998571a | 144 | |
Davidroid | 1:b78dab6d2c58 | 145 | /** |
Davidroid | 1:b78dab6d2c58 | 146 | * @brief Setting the current position to be the home position. |
Davidroid | 1:b78dab6d2c58 | 147 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 148 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 149 | */ |
Davidroid | 0:92706998571a | 150 | virtual void SetHome(void) = 0; |
Davidroid | 0:92706998571a | 151 | |
Davidroid | 1:b78dab6d2c58 | 152 | /** |
Davidroid | 1:b78dab6d2c58 | 153 | * @brief Setting the current position to be the marked position. |
Davidroid | 1:b78dab6d2c58 | 154 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 155 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 156 | */ |
Davidroid | 0:92706998571a | 157 | virtual void SetMark(void) = 0; |
Davidroid | 0:92706998571a | 158 | |
Davidroid | 1:b78dab6d2c58 | 159 | /** |
Davidroid | 1:b78dab6d2c58 | 160 | * @brief Setting the maximum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 161 | * @param speed The maximum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 162 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 163 | */ |
Davidroid | 0:92706998571a | 164 | virtual void SetMaxSpeed(unsigned int speed) = 0; |
Davidroid | 0:92706998571a | 165 | |
Davidroid | 1:b78dab6d2c58 | 166 | /** |
Davidroid | 1:b78dab6d2c58 | 167 | * @brief Setting the minimum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 168 | * @param speed The minimum speed in pps. |
Davidroid | 1:b78dab6d2c58 | 169 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 170 | */ |
Davidroid | 0:92706998571a | 171 | virtual void SetMinSpeed(unsigned int speed) = 0; |
Davidroid | 0:92706998571a | 172 | |
Davidroid | 1:b78dab6d2c58 | 173 | /** |
Davidroid | 1:b78dab6d2c58 | 174 | * @brief Setting the acceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 175 | * @param acceleration The acceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 176 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 177 | */ |
Davidroid | 0:92706998571a | 178 | virtual void SetAcceleration(unsigned int acceleration) = 0; |
Davidroid | 0:92706998571a | 179 | |
Davidroid | 1:b78dab6d2c58 | 180 | /** |
Davidroid | 1:b78dab6d2c58 | 181 | * @brief Setting the deceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 182 | * @param deceleration The deceleration in pps^2. |
Davidroid | 1:b78dab6d2c58 | 183 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 184 | */ |
Davidroid | 0:92706998571a | 185 | virtual void SetDeceleration(unsigned int deceleration) = 0; |
Davidroid | 0:92706998571a | 186 | |
Davidroid | 1:b78dab6d2c58 | 187 | /** |
Davidroid | 1:b78dab6d2c58 | 188 | * @brief Going to a specified position. |
Davidroid | 1:b78dab6d2c58 | 189 | * @param position The desired position. |
Davidroid | 1:b78dab6d2c58 | 190 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 191 | */ |
Davidroid | 0:92706998571a | 192 | virtual void GoTo(signed int position) = 0; |
Davidroid | 0:92706998571a | 193 | |
Davidroid | 1:b78dab6d2c58 | 194 | /** |
Davidroid | 1:b78dab6d2c58 | 195 | * @brief Going to the home position. |
Davidroid | 1:b78dab6d2c58 | 196 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 197 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 198 | */ |
Davidroid | 0:92706998571a | 199 | virtual void GoHome(void) = 0; |
Davidroid | 0:92706998571a | 200 | |
Davidroid | 1:b78dab6d2c58 | 201 | /** |
Davidroid | 1:b78dab6d2c58 | 202 | * @brief Going to the marked position. |
Davidroid | 1:b78dab6d2c58 | 203 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 204 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 205 | */ |
Davidroid | 0:92706998571a | 206 | virtual void GoMark(void) = 0; |
Davidroid | 0:92706998571a | 207 | |
Davidroid | 1:b78dab6d2c58 | 208 | /** |
Davidroid | 1:b78dab6d2c58 | 209 | * @brief Running the motor towards a specified direction. |
Davidroid | 1:b78dab6d2c58 | 210 | * @param direction The direction of rotation. |
Davidroid | 1:b78dab6d2c58 | 211 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 212 | */ |
Davidroid | 0:92706998571a | 213 | virtual void Run(direction_t direction) = 0; |
Davidroid | 0:92706998571a | 214 | |
Davidroid | 1:b78dab6d2c58 | 215 | /** |
Davidroid | 1:b78dab6d2c58 | 216 | * @brief Moving the motor towards a specified direction for a certain number of steps. |
Davidroid | 1:b78dab6d2c58 | 217 | * @param direction The direction of rotation. |
Davidroid | 1:b78dab6d2c58 | 218 | * @param steps The desired number of steps. |
Davidroid | 1:b78dab6d2c58 | 219 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 220 | */ |
Davidroid | 0:92706998571a | 221 | virtual void Move(direction_t direction, unsigned int steps) = 0; |
Davidroid | 0:92706998571a | 222 | |
Davidroid | 1:b78dab6d2c58 | 223 | /** |
Davidroid | 1:b78dab6d2c58 | 224 | * @brief Stopping the motor. |
Davidroid | 1:b78dab6d2c58 | 225 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 226 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 227 | */ |
Davidroid | 0:92706998571a | 228 | virtual void SoftStop(void) = 0; |
Davidroid | 0:92706998571a | 229 | |
Davidroid | 1:b78dab6d2c58 | 230 | /** |
Davidroid | 1:b78dab6d2c58 | 231 | * @brief Stopping the motor and disabling the power bridge. |
Davidroid | 1:b78dab6d2c58 | 232 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 233 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 234 | */ |
Davidroid | 0:92706998571a | 235 | virtual void HardStop(void) = 0; |
Davidroid | 0:92706998571a | 236 | |
Davidroid | 1:b78dab6d2c58 | 237 | /** |
Davidroid | 1:b78dab6d2c58 | 238 | * @brief Waiting while the motor is active. |
Davidroid | 1:b78dab6d2c58 | 239 | * @param None. |
Davidroid | 1:b78dab6d2c58 | 240 | * @retval None. |
Davidroid | 1:b78dab6d2c58 | 241 | */ |
Davidroid | 0:92706998571a | 242 | virtual void WaitWhileActive(void) = 0; |
Davidroid | 0:92706998571a | 243 | }; |
Davidroid | 0:92706998571a | 244 | |
Davidroid | 0:92706998571a | 245 | #endif /* __STEPPERMOTOR_CLASS_H */ |
Davidroid | 0:92706998571a | 246 | |
Davidroid | 0:92706998571a | 247 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |