Use BDCMotor_class.h instead of motor_class.h

Dependents:   HelloWorld_IHM04A1

Fork of X_NUCLEO_IHM04A1 by ST

Committer:
brdirais
Date:
Tue May 17 12:14:35 2016 +0000
Revision:
2:65057305b86e
Parent:
1:2597a6165252
Change 1E6 by 1000000

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brdirais 1:2597a6165252 1 /**
brdirais 1:2597a6165252 2 ******************************************************************************
brdirais 1:2597a6165252 3 * @file Motor_class.h
brdirais 1:2597a6165252 4 * @author AST
brdirais 1:2597a6165252 5 * @version V1.0.0
brdirais 1:2597a6165252 6 * @date April 13th, 2015
brdirais 1:2597a6165252 7 * @brief This file contains the abstract class describing the interface of a
brdirais 1:2597a6165252 8 * motor component.
brdirais 1:2597a6165252 9 ******************************************************************************
brdirais 1:2597a6165252 10 * @attention
brdirais 1:2597a6165252 11 *
brdirais 1:2597a6165252 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
brdirais 1:2597a6165252 13 *
brdirais 1:2597a6165252 14 * Redistribution and use in source and binary forms, with or without modification,
brdirais 1:2597a6165252 15 * are permitted provided that the following conditions are met:
brdirais 1:2597a6165252 16 * 1. Redistributions of source code must retain the above copyright notice,
brdirais 1:2597a6165252 17 * this list of conditions and the following disclaimer.
brdirais 1:2597a6165252 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
brdirais 1:2597a6165252 19 * this list of conditions and the following disclaimer in the documentation
brdirais 1:2597a6165252 20 * and/or other materials provided with the distribution.
brdirais 1:2597a6165252 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
brdirais 1:2597a6165252 22 * may be used to endorse or promote products derived from this software
brdirais 1:2597a6165252 23 * without specific prior written permission.
brdirais 1:2597a6165252 24 *
brdirais 1:2597a6165252 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
brdirais 1:2597a6165252 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
brdirais 1:2597a6165252 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
brdirais 1:2597a6165252 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
brdirais 1:2597a6165252 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
brdirais 1:2597a6165252 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
brdirais 1:2597a6165252 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
brdirais 1:2597a6165252 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
brdirais 1:2597a6165252 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
brdirais 1:2597a6165252 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
brdirais 1:2597a6165252 35 *
brdirais 1:2597a6165252 36 ******************************************************************************
brdirais 1:2597a6165252 37 */
brdirais 1:2597a6165252 38
brdirais 1:2597a6165252 39
brdirais 1:2597a6165252 40 /* Generated with STM32CubeTOO -----------------------------------------------*/
brdirais 1:2597a6165252 41
brdirais 1:2597a6165252 42
brdirais 1:2597a6165252 43 /* Revision ------------------------------------------------------------------*/
brdirais 1:2597a6165252 44 /*
brdirais 1:2597a6165252 45 Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
brdirais 1:2597a6165252 46 Branch/Trunk/Tag: trunk
brdirais 1:2597a6165252 47 Based on: X-CUBE-SPN4/trunk/Drivers/BSP/Components/Common/motor.h
brdirais 1:2597a6165252 48 Revision: 0
brdirais 1:2597a6165252 49 */
brdirais 1:2597a6165252 50
brdirais 1:2597a6165252 51
brdirais 1:2597a6165252 52 /* Define to prevent recursive inclusion -------------------------------------*/
brdirais 1:2597a6165252 53
brdirais 1:2597a6165252 54 #ifndef __MOTOR_CLASS_H
brdirais 1:2597a6165252 55 #define __MOTOR_CLASS_H
brdirais 1:2597a6165252 56
brdirais 1:2597a6165252 57
brdirais 1:2597a6165252 58 /* Includes ------------------------------------------------------------------*/
brdirais 1:2597a6165252 59
brdirais 1:2597a6165252 60 #include "Component_class.h"
brdirais 1:2597a6165252 61
brdirais 1:2597a6165252 62
brdirais 1:2597a6165252 63 /* Classes ------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 64
brdirais 1:2597a6165252 65 /** An abstract class for Motor components.
brdirais 1:2597a6165252 66 */
brdirais 1:2597a6165252 67 class Motor : public Component
brdirais 1:2597a6165252 68 {
brdirais 1:2597a6165252 69 public:
brdirais 1:2597a6165252 70 /* ACTION 1 --------------------------------------------------------------*
brdirais 1:2597a6165252 71 * Declare here the interface's methods. *
brdirais 1:2597a6165252 72 * They should be: *
brdirais 1:2597a6165252 73 * + Methods with the same name of the C component's virtual table *
brdirais 1:2597a6165252 74 * (and extended virtual table, if any)'s functions, provided that *
brdirais 1:2597a6165252 75 * the component's driver implements them (i.e.: the corresponding *
brdirais 1:2597a6165252 76 * pointer to function is not "0"). *
brdirais 1:2597a6165252 77 * *
brdirais 1:2597a6165252 78 * Example: *
brdirais 1:2597a6165252 79 * virtual int GetValue(float *f) = 0; *
brdirais 1:2597a6165252 80 *------------------------------------------------------------------------*/
brdirais 1:2597a6165252 81
brdirais 1:2597a6165252 82 /**
brdirais 1:2597a6165252 83 * @brief Getting the current speed in pps.
brdirais 1:2597a6165252 84 * @param None.
brdirais 1:2597a6165252 85 * @retval The current speed in pps.
brdirais 1:2597a6165252 86 */
brdirais 1:2597a6165252 87 virtual uint16_t GetCurrentSpeed(uint8_t motorId) = 0;
brdirais 1:2597a6165252 88
brdirais 1:2597a6165252 89 /**
brdirais 1:2597a6165252 90 * @brief Returns the device state
brdirais 1:2597a6165252 91 * @param[in] motorId from 0 to MAX_NUMBER_OF_BRUSH_DC_MOTORS
brdirais 1:2597a6165252 92 * @retval State (STEADY or INACTIVE)
brdirais 1:2597a6165252 93 */
brdirais 1:2597a6165252 94 virtual motorState_t GetDeviceState(uint8_t motorId) = 0;
brdirais 1:2597a6165252 95
brdirais 1:2597a6165252 96 /**
brdirais 1:2597a6165252 97 * @brief Returns the FW version of the library
brdirais 1:2597a6165252 98 * @retval L6206_FW_VERSION
brdirais 1:2597a6165252 99 */
brdirais 1:2597a6165252 100 virtual uint8_t GetFwVersion(void) = 0;
brdirais 1:2597a6165252 101
brdirais 1:2597a6165252 102 /**
brdirais 1:2597a6165252 103 * @brief Returns the max speed of the specified motor
brdirais 1:2597a6165252 104 * @param[in] motorId from 0 to MAX_NUMBER_OF_BRUSH_DC_MOTORS
brdirais 1:2597a6165252 105 * @retval maxSpeed in % from 0 to 100
brdirais 1:2597a6165252 106 */
brdirais 1:2597a6165252 107 virtual uint16_t GetMaxSpeed(uint8_t motorId) = 0;
brdirais 1:2597a6165252 108
brdirais 1:2597a6165252 109 /**
brdirais 1:2597a6165252 110 * @brief Stops the motor without disabling the bridge
brdirais 1:2597a6165252 111 * @param[in] motorId from 0 to MAX_NUMBER_OF_BRUSH_DC_MOTORS
brdirais 1:2597a6165252 112 * @retval none
brdirais 1:2597a6165252 113 */
brdirais 1:2597a6165252 114 virtual void HardStop(uint8_t motorId) = 0;
brdirais 1:2597a6165252 115
brdirais 1:2597a6165252 116 /**
brdirais 1:2597a6165252 117 * @brief Runs the motor
brdirais 1:2597a6165252 118 * @param[in] motorId from 0 to MAX_NUMBER_OF_BRUSH_DC_MOTORS
brdirais 1:2597a6165252 119 * @param[in] direction FORWARD or BACKWARD
brdirais 1:2597a6165252 120 * @retval None
brdirais 1:2597a6165252 121 * @note For unidirectionnal motor, direction parameter has no effect
brdirais 1:2597a6165252 122 */
brdirais 1:2597a6165252 123 virtual void Run(uint8_t stepCount, motorDir_t direction) = 0;
brdirais 1:2597a6165252 124
brdirais 1:2597a6165252 125 /**
brdirais 1:2597a6165252 126 * @brief Changes the max speed of the specified device
brdirais 1:2597a6165252 127 * @param[in] motorId from 0 to MAX_NUMBER_OF_BRUSH_DC_MOTORS
brdirais 1:2597a6165252 128 * @param[in] newMaxSpeed in % from 0 to 100
brdirais 1:2597a6165252 129 * @retval true if the command is successfully executed, else false
brdirais 1:2597a6165252 130 */
brdirais 1:2597a6165252 131 virtual bool SetMaxSpeed(uint8_t motorId, uint16_t newMaxSpeed) = 0;
brdirais 1:2597a6165252 132
brdirais 1:2597a6165252 133 /**
brdirais 1:2597a6165252 134 * @brief Disable the specified bridge
brdirais 1:2597a6165252 135 * @param[in] bridgeId (from 0 for bridge A to 1 for bridge B)
brdirais 1:2597a6165252 136 * @retval None
brdirais 1:2597a6165252 137 * @note When input of different brigdes are parallelized
brdirais 1:2597a6165252 138 * together, the disabling of one bridge leads to the disabling
brdirais 1:2597a6165252 139 * of the second one
brdirais 1:2597a6165252 140 */
brdirais 1:2597a6165252 141 virtual void CmdDisable(uint8_t bridgeId) = 0;
brdirais 1:2597a6165252 142
brdirais 1:2597a6165252 143 /**
brdirais 1:2597a6165252 144 * @brief Enable the specified bridge
brdirais 1:2597a6165252 145 * @param[in] bridgeId (from 0 for bridge A to 1 for bridge B)
brdirais 1:2597a6165252 146 * @retval None
brdirais 1:2597a6165252 147 * @note When input of different brigdes are parallelized
brdirais 1:2597a6165252 148 * together, the enabling of one bridge leads to the enabling
brdirais 1:2597a6165252 149 * of the second one
brdirais 1:2597a6165252 150 */
brdirais 1:2597a6165252 151 virtual void CmdEnable(uint8_t bridgeId) = 0;
brdirais 1:2597a6165252 152
brdirais 1:2597a6165252 153 /**
brdirais 1:2597a6165252 154 * @brief Get the status of the bridge enabling of the corresponding bridge
brdirais 1:2597a6165252 155 * @param[in] bridgeId from 0 for bridge A to 1 for bridge B
brdirais 1:2597a6165252 156 * @retval State of the Enable&Flag pin of the corresponding bridge (1 set, 0 for reset)
brdirais 1:2597a6165252 157 */
brdirais 1:2597a6165252 158 virtual uint16_t CmdGetStatus(uint8_t bridgeId) = 0;
brdirais 1:2597a6165252 159
brdirais 1:2597a6165252 160 /**
brdirais 1:2597a6165252 161 * @brief Immediatly stops the motor and disable the power bridge
brdirais 1:2597a6165252 162 * @param[in] motorId from 0 to MAX_NUMBER_OF_BRUSH_DC_MOTORS
brdirais 1:2597a6165252 163 * @retval None
brdirais 1:2597a6165252 164 * @note if two motors uses the same power bridge, the
brdirais 1:2597a6165252 165 * power bridge will be disable only if the two motors are stopped
brdirais 1:2597a6165252 166 */
brdirais 1:2597a6165252 167 virtual void CmdHardHiZ(uint8_t motorId) = 0;
brdirais 1:2597a6165252 168
brdirais 1:2597a6165252 169 /**
brdirais 1:2597a6165252 170 * @brief Error handler which calls the user callback (if defined)
brdirais 1:2597a6165252 171 * @param[in] error Number of the error
brdirais 1:2597a6165252 172 * @retval None
brdirais 1:2597a6165252 173 */
brdirais 1:2597a6165252 174 virtual void ErrorHandler(uint16_t error) = 0;
brdirais 1:2597a6165252 175
brdirais 1:2597a6165252 176 /**
brdirais 1:2597a6165252 177 * @brief Set dual full bridge parallelling configuration
brdirais 1:2597a6165252 178 * @param[in] newConfig bridge configuration to apply from
brdirais 1:2597a6165252 179 * dualFullBridgeConfig_t enum
brdirais 1:2597a6165252 180 * @retval None
brdirais 1:2597a6165252 181 */
brdirais 1:2597a6165252 182 virtual void SetDualFullBridgeConfig(uint8_t newConfig) = 0;
brdirais 1:2597a6165252 183
brdirais 1:2597a6165252 184 /**
brdirais 1:2597a6165252 185 * @brief Get the PWM frequency of the specified bridge
brdirais 1:2597a6165252 186 * @param[in] bridgeId 0 for bridge A, 1 for bridge B
brdirais 1:2597a6165252 187 * @retval Freq in Hz
brdirais 1:2597a6165252 188 */
brdirais 1:2597a6165252 189 virtual uint32_t GetBridgeInputPwmFreq(uint8_t bridgeId) = 0;
brdirais 1:2597a6165252 190
brdirais 1:2597a6165252 191 /**
brdirais 1:2597a6165252 192 * @brief Changes the PWM frequency of the bridge input
brdirais 1:2597a6165252 193 * @param[in] bridgeId 0 for bridge A, 1 for bridge B
brdirais 1:2597a6165252 194 * @param[in] newFreq in Hz
brdirais 1:2597a6165252 195 * @retval None
brdirais 1:2597a6165252 196 */
brdirais 1:2597a6165252 197 virtual void SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq) = 0;
brdirais 1:2597a6165252 198
brdirais 1:2597a6165252 199 /**
brdirais 1:2597a6165252 200 * @brief Sets the number of devices to be used
brdirais 1:2597a6165252 201 * @param[in] nbDevices (from 1 to MAX_NUMBER_OF_DEVICES)
brdirais 1:2597a6165252 202 * @retval TRUE if successfull, FALSE if failure, attempt to set a number of
brdirais 1:2597a6165252 203 * devices greater than MAX_NUMBER_OF_DEVICES
brdirais 1:2597a6165252 204 */
brdirais 1:2597a6165252 205 virtual bool SetNbDevices(uint8_t nbDevices) = 0;
brdirais 1:2597a6165252 206 };
brdirais 1:2597a6165252 207
brdirais 1:2597a6165252 208 #endif /* __MOTOR_CLASS_H */
brdirais 1:2597a6165252 209
brdirais 1:2597a6165252 210 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
brdirais 1:2597a6165252 211