Library used to control ST Nucleo Evaluation board IHM04A1, based on L6206 motor control driver.

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_IHM04A1 RoboCane_Motore arm_dcmotor_can arm_linear_can_2 ... more

Fork of X_NUCLEO_IHM04A1 by ST Expansion SW Team

Motor Control Library

Library to handle the X-NUCLEO-IHM04A1 Motor Control Expansion Board based on the L6206 component.

It allows a complete management of the L6206 by providing a complete APIs.

The key features of the library are :

  • Configuration of the L6206 (bridges inputs and enabling signals, bridges paralleling)
  • FLAG interrupts handling (overcurrent and thermal alarms reporting)
  • Handling of up to two bidirectional Brush DC motors or up to 4 unidirectional Brush DC motors depending of the bridges paralleling configuration
  • Nucleo and expansion board configuration (GPIOs, PWMs, IRQs…)

To use the L6206 driver library, the user first has to call its initialization method which:

  • Setups the required GPIOs to handle the bridges enable pins, the FLAG interrupt which reports overcurrent detection or thermal protection.
  • Loads the driver parameters with initial values configured by the user or with their predefined values from “l6206_target_config.h”, in order to program the PWMs frequency of the bridges inputs, the bridges paralleling configuration, the number and the type (bidirectional or unidirectional) of brush DC motors.

Once the initialization is done, the user can modify the driver parameters by calling specific functions to change the bridges paralleling configuration, types and numbers of motors or the PWMs frequency.

The user can also write callback functions and attach them to:

  • The flag interrupt handler depending on the actions he wants to perform when an overcurrent or a thermal alarm is reported.
  • The Error handler which is called by the library when it reports an error.

Then, the user can drive the different brush DC motors by requesting to run in a specified direction and by changing the maximal speed. When a motor is requested to run, the corresponding bridge is automatically enabled.

A motion command can be stopped at any moment:

  • Either by a hard stop which immediately stops the motor.
  • Or by a hardHiz command which immediately stops the motor and disables the bridge which is used by the motor.

The library also provides functions to disable or enable the bridges independently from the run or stop commands.

Arduino Connector Compatibility Warning

Using the X-NUCLEO-IHM04A1 expansion board with the NUCLEO-F429ZI requires adopting the following patch:

  • to connect with a wire the PB_4 Nucleo pin to the IN1A expansion board pin;
  • to connect with a wire the PC_7 Nucleo pin to the IN2A expansion board pin;
  • to connect with a wire the PA_15 Nucleo pin to the IN1B expansion board pin;
  • to connect with a wire the PB_3 Nucleo pin to the IN2B expansion board pin.


Board configuration for HelloWorld_IHM04A1 example

/media/uploads/brdirais/drive4brushdcmotor_ihm04a1.png

Committer:
brdirais
Date:
Tue May 03 11:16:57 2016 +0000
Revision:
0:2cb6ce8e07bd
Child:
1:2597a6165252
Initial version of X-NUCLEO-IHM04A1 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brdirais 0:2cb6ce8e07bd 1 /**
brdirais 0:2cb6ce8e07bd 2 ******************************************************************************
brdirais 0:2cb6ce8e07bd 3 * @file l6206_class.h
brdirais 0:2cb6ce8e07bd 4 * @author IPC Rennes
brdirais 0:2cb6ce8e07bd 5 * @version V1.1.0
brdirais 0:2cb6ce8e07bd 6 * @date March 02, 2016
brdirais 0:2cb6ce8e07bd 7 * @brief L6206 driver (dual full bridge driver)
brdirais 0:2cb6ce8e07bd 8 * @note (C) COPYRIGHT 2015 STMicroelectronics
brdirais 0:2cb6ce8e07bd 9 ******************************************************************************
brdirais 0:2cb6ce8e07bd 10 * @attention
brdirais 0:2cb6ce8e07bd 11 *
brdirais 0:2cb6ce8e07bd 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
brdirais 0:2cb6ce8e07bd 13 *
brdirais 0:2cb6ce8e07bd 14 * Redistribution and use in source and binary forms, with or without modification,
brdirais 0:2cb6ce8e07bd 15 * are permitted provided that the following conditions are met:
brdirais 0:2cb6ce8e07bd 16 * 1. Redistributions of source code must retain the above copyright notice,
brdirais 0:2cb6ce8e07bd 17 * this list of conditions and the following disclaimer.
brdirais 0:2cb6ce8e07bd 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
brdirais 0:2cb6ce8e07bd 19 * this list of conditions and the following disclaimer in the documentation
brdirais 0:2cb6ce8e07bd 20 * and/or other materials provided with the distribution.
brdirais 0:2cb6ce8e07bd 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
brdirais 0:2cb6ce8e07bd 22 * may be used to endorse or promote products derived from this software
brdirais 0:2cb6ce8e07bd 23 * without specific prior written permission.
brdirais 0:2cb6ce8e07bd 24 *
brdirais 0:2cb6ce8e07bd 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
brdirais 0:2cb6ce8e07bd 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
brdirais 0:2cb6ce8e07bd 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
brdirais 0:2cb6ce8e07bd 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
brdirais 0:2cb6ce8e07bd 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
brdirais 0:2cb6ce8e07bd 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
brdirais 0:2cb6ce8e07bd 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
brdirais 0:2cb6ce8e07bd 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
brdirais 0:2cb6ce8e07bd 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
brdirais 0:2cb6ce8e07bd 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
brdirais 0:2cb6ce8e07bd 35 *
brdirais 0:2cb6ce8e07bd 36 ******************************************************************************
brdirais 0:2cb6ce8e07bd 37 */
brdirais 0:2cb6ce8e07bd 38
brdirais 0:2cb6ce8e07bd 39
brdirais 0:2cb6ce8e07bd 40 /* Generated with STM32CubeTOO -----------------------------------------------*/
brdirais 0:2cb6ce8e07bd 41
brdirais 0:2cb6ce8e07bd 42
brdirais 0:2cb6ce8e07bd 43 /* Revision ------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 44 /*
brdirais 0:2cb6ce8e07bd 45 Repository: http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
brdirais 0:2cb6ce8e07bd 46 Branch/Trunk/Tag: trunk
brdirais 0:2cb6ce8e07bd 47 Based on: X-CUBE-SPN4/trunk/Drivers/BSP/Components/l6206/l6206.h
brdirais 0:2cb6ce8e07bd 48 Revision: 0
brdirais 0:2cb6ce8e07bd 49 */
brdirais 0:2cb6ce8e07bd 50
brdirais 0:2cb6ce8e07bd 51
brdirais 0:2cb6ce8e07bd 52 /* Define to prevent recursive inclusion -------------------------------------*/
brdirais 0:2cb6ce8e07bd 53
brdirais 0:2cb6ce8e07bd 54 #ifndef __L6206_CLASS_H
brdirais 0:2cb6ce8e07bd 55 #define __L6206_CLASS_H
brdirais 0:2cb6ce8e07bd 56
brdirais 0:2cb6ce8e07bd 57
brdirais 0:2cb6ce8e07bd 58 /* Includes ------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 59
brdirais 0:2cb6ce8e07bd 60 /* ACTION 1 ------------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 61 * Include here platform specific header files. *
brdirais 0:2cb6ce8e07bd 62 *----------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 63 #include "mbed.h"
brdirais 0:2cb6ce8e07bd 64 /* ACTION 2 ------------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 65 * Include here component specific header files. *
brdirais 0:2cb6ce8e07bd 66 *----------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 67 #include "l6206.h"
brdirais 0:2cb6ce8e07bd 68 /* ACTION 3 ------------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 69 * Include here interface specific header files. *
brdirais 0:2cb6ce8e07bd 70 * *
brdirais 0:2cb6ce8e07bd 71 * Example: *
brdirais 0:2cb6ce8e07bd 72 * #include "../Interfaces/Humidity_class.h" *
brdirais 0:2cb6ce8e07bd 73 * #include "../Interfaces/Temperature_class.h" *
brdirais 0:2cb6ce8e07bd 74 *----------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 75 #include "../Interfaces/Motor_class.h"
brdirais 0:2cb6ce8e07bd 76
brdirais 0:2cb6ce8e07bd 77
brdirais 0:2cb6ce8e07bd 78
brdirais 0:2cb6ce8e07bd 79 /* Private constants ---------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 80
brdirais 0:2cb6ce8e07bd 81 /** @defgroup L6206_Private_Constants L6206 Private Constants
brdirais 0:2cb6ce8e07bd 82 * @{
brdirais 0:2cb6ce8e07bd 83 */
brdirais 0:2cb6ce8e07bd 84
brdirais 0:2cb6ce8e07bd 85 /// The Number of L6206 devices required for initialisation is not supported
brdirais 0:2cb6ce8e07bd 86 #define L6206_ERROR_0 (0x8000)
brdirais 0:2cb6ce8e07bd 87 /// Error: Access a motor index greater than the one of the current brigde configuration
brdirais 0:2cb6ce8e07bd 88 #define L6206_ERROR_1 (0x8001)
brdirais 0:2cb6ce8e07bd 89 /// Error: Access a motor index which is not bidirectionnal
brdirais 0:2cb6ce8e07bd 90 #define L6206_ERROR_2 (0x8002)
brdirais 0:2cb6ce8e07bd 91
brdirais 0:2cb6ce8e07bd 92 /// Maximum frequency of the PWMs in Hz
brdirais 0:2cb6ce8e07bd 93 #define L6206_MAX_PWM_FREQ (100000)
brdirais 0:2cb6ce8e07bd 94
brdirais 0:2cb6ce8e07bd 95 /// Minimum frequency of the PWMs in Hz
brdirais 0:2cb6ce8e07bd 96 #define L6206_MIN_PWM_FREQ (2)
brdirais 0:2cb6ce8e07bd 97
brdirais 0:2cb6ce8e07bd 98 /// Bridge Input 1A
brdirais 0:2cb6ce8e07bd 99 #define INPUT_1A (0)
brdirais 0:2cb6ce8e07bd 100 /// Bridge Input 2A
brdirais 0:2cb6ce8e07bd 101 #define INPUT_2A (1)
brdirais 0:2cb6ce8e07bd 102 /// Bridge Input 1B
brdirais 0:2cb6ce8e07bd 103 #define INPUT_1B (2)
brdirais 0:2cb6ce8e07bd 104 /// Bridge Input 2B
brdirais 0:2cb6ce8e07bd 105 #define INPUT_2B (3)
brdirais 0:2cb6ce8e07bd 106
brdirais 0:2cb6ce8e07bd 107 /// Bridge A
brdirais 0:2cb6ce8e07bd 108 #define BRIDGE_A (0)
brdirais 0:2cb6ce8e07bd 109 /// Bridge B
brdirais 0:2cb6ce8e07bd 110 #define BRIDGE_B (1)
brdirais 0:2cb6ce8e07bd 111
brdirais 0:2cb6ce8e07bd 112
brdirais 0:2cb6ce8e07bd 113
brdirais 0:2cb6ce8e07bd 114
brdirais 0:2cb6ce8e07bd 115
brdirais 0:2cb6ce8e07bd 116 /* Classes -------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 117
brdirais 0:2cb6ce8e07bd 118 /**
brdirais 0:2cb6ce8e07bd 119 * @brief Class representing a L6206 component.
brdirais 0:2cb6ce8e07bd 120 */
brdirais 0:2cb6ce8e07bd 121 class L6206 : public Motor
brdirais 0:2cb6ce8e07bd 122 {
brdirais 0:2cb6ce8e07bd 123 public:
brdirais 0:2cb6ce8e07bd 124
brdirais 0:2cb6ce8e07bd 125 /*** Constructor and Destructor Methods ***/
brdirais 0:2cb6ce8e07bd 126
brdirais 0:2cb6ce8e07bd 127 /**
brdirais 0:2cb6ce8e07bd 128 * @brief Constructor.
brdirais 0:2cb6ce8e07bd 129 */
brdirais 0:2cb6ce8e07bd 130 L6206(PinName EN_flag_A, PinName EN_flag_B, PinName pwm_1A, PinName pwm_2A, PinName pwm_1B, PinName pwm_2B) : Motor(), flag_A_irq(EN_flag_A), flag_B_irq(EN_flag_B), EN_flag_A(EN_flag_A), EN_flag_B(EN_flag_B), pwm_1A(pwm_1A), pwm_2A(pwm_2A), pwm_1B(pwm_1B), pwm_2B(pwm_2B)
brdirais 0:2cb6ce8e07bd 131 {
brdirais 0:2cb6ce8e07bd 132 /* ACTION 4 ----------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 133 * Initialize here the component's member variables, one variable per *
brdirais 0:2cb6ce8e07bd 134 * line. *
brdirais 0:2cb6ce8e07bd 135 * *
brdirais 0:2cb6ce8e07bd 136 * Example: *
brdirais 0:2cb6ce8e07bd 137 * measure = 0; *
brdirais 0:2cb6ce8e07bd 138 * instance_id = number_of_instances++; *
brdirais 0:2cb6ce8e07bd 139 *--------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 140
brdirais 0:2cb6ce8e07bd 141 flagInterruptCallback = 0;
brdirais 0:2cb6ce8e07bd 142 errorHandlerCallback = 0;
brdirais 0:2cb6ce8e07bd 143 numberOfDevices = 0;
brdirais 0:2cb6ce8e07bd 144 deviceInstance = 0;
brdirais 0:2cb6ce8e07bd 145 }
brdirais 0:2cb6ce8e07bd 146
brdirais 0:2cb6ce8e07bd 147 /**
brdirais 0:2cb6ce8e07bd 148 * @brief Destructor.
brdirais 0:2cb6ce8e07bd 149 */
brdirais 0:2cb6ce8e07bd 150 virtual ~L6206(void) {}
brdirais 0:2cb6ce8e07bd 151
brdirais 0:2cb6ce8e07bd 152
brdirais 0:2cb6ce8e07bd 153 /*** Public Component Related Methods ***/
brdirais 0:2cb6ce8e07bd 154
brdirais 0:2cb6ce8e07bd 155 /* ACTION 5 --------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 156 * Implement here the component's public methods, as wrappers of the C *
brdirais 0:2cb6ce8e07bd 157 * component's functions. *
brdirais 0:2cb6ce8e07bd 158 * They should be: *
brdirais 0:2cb6ce8e07bd 159 * + Methods with the same name of the C component's virtual table's *
brdirais 0:2cb6ce8e07bd 160 * functions (1); *
brdirais 0:2cb6ce8e07bd 161 * + Methods with the same name of the C component's extended virtual *
brdirais 0:2cb6ce8e07bd 162 * table's functions, if any (2). *
brdirais 0:2cb6ce8e07bd 163 * *
brdirais 0:2cb6ce8e07bd 164 * Example: *
brdirais 0:2cb6ce8e07bd 165 * virtual int GetValue(float *f) //(1) *
brdirais 0:2cb6ce8e07bd 166 * { *
brdirais 0:2cb6ce8e07bd 167 * return COMPONENT_GetValue(float *f); *
brdirais 0:2cb6ce8e07bd 168 * } *
brdirais 0:2cb6ce8e07bd 169 * *
brdirais 0:2cb6ce8e07bd 170 * virtual int EnableFeature(void) //(2) *
brdirais 0:2cb6ce8e07bd 171 * { *
brdirais 0:2cb6ce8e07bd 172 * return COMPONENT_EnableFeature(); *
brdirais 0:2cb6ce8e07bd 173 * } *
brdirais 0:2cb6ce8e07bd 174 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 175 virtual int Init(void *init = NULL)
brdirais 0:2cb6ce8e07bd 176 {
brdirais 0:2cb6ce8e07bd 177 return (int) L6206_Init((void *) init);
brdirais 0:2cb6ce8e07bd 178 }
brdirais 0:2cb6ce8e07bd 179
brdirais 0:2cb6ce8e07bd 180 virtual int ReadID(uint8_t *id = NULL)
brdirais 0:2cb6ce8e07bd 181 {
brdirais 0:2cb6ce8e07bd 182 return (int) L6206_ReadId((uint8_t *) id);
brdirais 0:2cb6ce8e07bd 183 }
brdirais 0:2cb6ce8e07bd 184
brdirais 0:2cb6ce8e07bd 185 virtual void AttachErrorHandler(void (*callback)(uint16_t error))
brdirais 0:2cb6ce8e07bd 186 {
brdirais 0:2cb6ce8e07bd 187 L6206_AttachErrorHandler((void (*)(uint16_t error)) callback);
brdirais 0:2cb6ce8e07bd 188 }
brdirais 0:2cb6ce8e07bd 189
brdirais 0:2cb6ce8e07bd 190 virtual void AttachFlagInterrupt(void (*callback)(void))
brdirais 0:2cb6ce8e07bd 191 {
brdirais 0:2cb6ce8e07bd 192 L6206_AttachFlagInterrupt((void (*)(void)) callback);
brdirais 0:2cb6ce8e07bd 193 }
brdirais 0:2cb6ce8e07bd 194
brdirais 0:2cb6ce8e07bd 195 virtual uint16_t GetCurrentSpeed(uint8_t motorId)
brdirais 0:2cb6ce8e07bd 196 {
brdirais 0:2cb6ce8e07bd 197 return (uint16_t) L6206_GetCurrentSpeed((uint8_t) motorId);
brdirais 0:2cb6ce8e07bd 198 }
brdirais 0:2cb6ce8e07bd 199
brdirais 0:2cb6ce8e07bd 200 virtual motorState_t GetDeviceState(uint8_t motorId)
brdirais 0:2cb6ce8e07bd 201 {
brdirais 0:2cb6ce8e07bd 202 return (motorState_t) L6206_GetDeviceState((uint8_t) motorId);
brdirais 0:2cb6ce8e07bd 203 }
brdirais 0:2cb6ce8e07bd 204
brdirais 0:2cb6ce8e07bd 205 virtual uint8_t GetFwVersion(void)
brdirais 0:2cb6ce8e07bd 206 {
brdirais 0:2cb6ce8e07bd 207 return (uint8_t) L6206_GetFwVersion();
brdirais 0:2cb6ce8e07bd 208 }
brdirais 0:2cb6ce8e07bd 209
brdirais 0:2cb6ce8e07bd 210 virtual uint16_t GetMaxSpeed(uint8_t motorId)
brdirais 0:2cb6ce8e07bd 211 {
brdirais 0:2cb6ce8e07bd 212 return (uint16_t) L6206_GetMaxSpeed((uint8_t) motorId);
brdirais 0:2cb6ce8e07bd 213 }
brdirais 0:2cb6ce8e07bd 214
brdirais 0:2cb6ce8e07bd 215 virtual void HardStop(uint8_t motorId)
brdirais 0:2cb6ce8e07bd 216 {
brdirais 0:2cb6ce8e07bd 217 L6206_HardStop((uint8_t) motorId);
brdirais 0:2cb6ce8e07bd 218 }
brdirais 0:2cb6ce8e07bd 219
brdirais 0:2cb6ce8e07bd 220 virtual void Run(uint8_t stepCount, motorDir_t direction)
brdirais 0:2cb6ce8e07bd 221 {
brdirais 0:2cb6ce8e07bd 222 L6206_Run((uint8_t) stepCount, (motorDir_t) direction);
brdirais 0:2cb6ce8e07bd 223 }
brdirais 0:2cb6ce8e07bd 224
brdirais 0:2cb6ce8e07bd 225 virtual bool SetMaxSpeed(uint8_t motorId, uint16_t newMaxSpeed)
brdirais 0:2cb6ce8e07bd 226 {
brdirais 0:2cb6ce8e07bd 227 return (bool) L6206_SetMaxSpeed((uint8_t) motorId, (uint16_t) newMaxSpeed);
brdirais 0:2cb6ce8e07bd 228 }
brdirais 0:2cb6ce8e07bd 229
brdirais 0:2cb6ce8e07bd 230 virtual void CmdDisable(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 231 {
brdirais 0:2cb6ce8e07bd 232 L6206_DisableBridge((uint8_t) bridgeId);
brdirais 0:2cb6ce8e07bd 233 }
brdirais 0:2cb6ce8e07bd 234
brdirais 0:2cb6ce8e07bd 235 virtual void CmdEnable(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 236 {
brdirais 0:2cb6ce8e07bd 237 L6206_EnableBridge((uint8_t) bridgeId);
brdirais 0:2cb6ce8e07bd 238 }
brdirais 0:2cb6ce8e07bd 239
brdirais 0:2cb6ce8e07bd 240 virtual uint16_t CmdGetStatus(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 241 {
brdirais 0:2cb6ce8e07bd 242 return (uint16_t) L6206_GetBridgeStatus((uint8_t) bridgeId);
brdirais 0:2cb6ce8e07bd 243 }
brdirais 0:2cb6ce8e07bd 244
brdirais 0:2cb6ce8e07bd 245 virtual void CmdHardHiZ(uint8_t motorId)
brdirais 0:2cb6ce8e07bd 246 {
brdirais 0:2cb6ce8e07bd 247 L6206_HardHiz((uint8_t) motorId);
brdirais 0:2cb6ce8e07bd 248 }
brdirais 0:2cb6ce8e07bd 249
brdirais 0:2cb6ce8e07bd 250 virtual void ErrorHandler(uint16_t error)
brdirais 0:2cb6ce8e07bd 251 {
brdirais 0:2cb6ce8e07bd 252 L6206_ErrorHandler((uint16_t) error);
brdirais 0:2cb6ce8e07bd 253 }
brdirais 0:2cb6ce8e07bd 254
brdirais 0:2cb6ce8e07bd 255 virtual void SetDualFullBridgeConfig(uint8_t newConfig)
brdirais 0:2cb6ce8e07bd 256 {
brdirais 0:2cb6ce8e07bd 257 L6206_SetDualFullBridgeConfig((uint8_t) newConfig);
brdirais 0:2cb6ce8e07bd 258 }
brdirais 0:2cb6ce8e07bd 259
brdirais 0:2cb6ce8e07bd 260 virtual uint32_t GetBridgeInputPwmFreq(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 261 {
brdirais 0:2cb6ce8e07bd 262 return (uint32_t) L6206_GetBridgeInputPwmFreq((uint8_t) bridgeId);
brdirais 0:2cb6ce8e07bd 263 }
brdirais 0:2cb6ce8e07bd 264
brdirais 0:2cb6ce8e07bd 265 virtual void SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq)
brdirais 0:2cb6ce8e07bd 266 {
brdirais 0:2cb6ce8e07bd 267 L6206_SetBridgeInputPwmFreq((uint8_t) bridgeId, (uint32_t) newFreq);
brdirais 0:2cb6ce8e07bd 268 }
brdirais 0:2cb6ce8e07bd 269
brdirais 0:2cb6ce8e07bd 270 virtual bool SetNbDevices(uint8_t nbDevices)
brdirais 0:2cb6ce8e07bd 271 {
brdirais 0:2cb6ce8e07bd 272 return (bool) L6206_SetNbDevices((uint8_t) nbDevices);
brdirais 0:2cb6ce8e07bd 273 }
brdirais 0:2cb6ce8e07bd 274
brdirais 0:2cb6ce8e07bd 275
brdirais 0:2cb6ce8e07bd 276 /*** Public Interrupt Related Methods ***/
brdirais 0:2cb6ce8e07bd 277
brdirais 0:2cb6ce8e07bd 278 /* ACTION 6 --------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 279 * Implement here interrupt related methods, if any. *
brdirais 0:2cb6ce8e07bd 280 * Note that interrupt handling is platform dependent, e.g.: *
brdirais 0:2cb6ce8e07bd 281 * + mbed: *
brdirais 0:2cb6ce8e07bd 282 * InterruptIn feature_irq(pin); //Interrupt object. *
brdirais 0:2cb6ce8e07bd 283 * feature_irq.fall(callback); //Attach a callback. *
brdirais 0:2cb6ce8e07bd 284 * feature_irq.mode(PullNone); //Set interrupt mode. *
brdirais 0:2cb6ce8e07bd 285 * feature_irq.enable_irq(); //Enable interrupt. *
brdirais 0:2cb6ce8e07bd 286 * feature_irq.disable_irq(); //Disable interrupt. *
brdirais 0:2cb6ce8e07bd 287 * + Arduino: *
brdirais 0:2cb6ce8e07bd 288 * attachInterrupt(pin, callback, RISING); //Attach a callback. *
brdirais 0:2cb6ce8e07bd 289 * detachInterrupt(pin); //Detach a callback. *
brdirais 0:2cb6ce8e07bd 290 * *
brdirais 0:2cb6ce8e07bd 291 * Example (mbed): *
brdirais 0:2cb6ce8e07bd 292 * void AttachFeatureIRQ(void (*fptr) (void)) *
brdirais 0:2cb6ce8e07bd 293 * { *
brdirais 0:2cb6ce8e07bd 294 * feature_irq.fall(fptr); *
brdirais 0:2cb6ce8e07bd 295 * } *
brdirais 0:2cb6ce8e07bd 296 * *
brdirais 0:2cb6ce8e07bd 297 * void EnableFeatureIRQ(void) *
brdirais 0:2cb6ce8e07bd 298 * { *
brdirais 0:2cb6ce8e07bd 299 * feature_irq.enable_irq(); *
brdirais 0:2cb6ce8e07bd 300 * } *
brdirais 0:2cb6ce8e07bd 301 * *
brdirais 0:2cb6ce8e07bd 302 * void DisableFeatureIRQ(void) *
brdirais 0:2cb6ce8e07bd 303 * { *
brdirais 0:2cb6ce8e07bd 304 * feature_irq.disable_irq(); *
brdirais 0:2cb6ce8e07bd 305 * } *
brdirais 0:2cb6ce8e07bd 306 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 307
brdirais 0:2cb6ce8e07bd 308
brdirais 0:2cb6ce8e07bd 309 /**
brdirais 0:2cb6ce8e07bd 310 * @brief Enabling the FLAG interrupt handling.
brdirais 0:2cb6ce8e07bd 311 * @param None.
brdirais 0:2cb6ce8e07bd 312 * @retval None.
brdirais 0:2cb6ce8e07bd 313 */
brdirais 0:2cb6ce8e07bd 314 void EnableFlagIRQ(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 315 {
brdirais 0:2cb6ce8e07bd 316 if (bridgeId == BRIDGE_A)
brdirais 0:2cb6ce8e07bd 317 {
brdirais 0:2cb6ce8e07bd 318 flag_A_irq.mode(PullUp);
brdirais 0:2cb6ce8e07bd 319 flag_A_irq.fall(this, &L6206::L6206_FlagInterruptHandler);
brdirais 0:2cb6ce8e07bd 320 }
brdirais 0:2cb6ce8e07bd 321 else
brdirais 0:2cb6ce8e07bd 322 {
brdirais 0:2cb6ce8e07bd 323 flag_B_irq.mode(PullUp);
brdirais 0:2cb6ce8e07bd 324 flag_B_irq.fall(this, &L6206::L6206_FlagInterruptHandler);
brdirais 0:2cb6ce8e07bd 325 }
brdirais 0:2cb6ce8e07bd 326 }
brdirais 0:2cb6ce8e07bd 327
brdirais 0:2cb6ce8e07bd 328 /**
brdirais 0:2cb6ce8e07bd 329 * @brief Disabling the FLAG interrupt handling.
brdirais 0:2cb6ce8e07bd 330 * @param None.
brdirais 0:2cb6ce8e07bd 331 * @retval None.
brdirais 0:2cb6ce8e07bd 332 */
brdirais 0:2cb6ce8e07bd 333 void DisableFlagIRQ(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 334 {
brdirais 0:2cb6ce8e07bd 335 if (bridgeId == BRIDGE_A)
brdirais 0:2cb6ce8e07bd 336 flag_A_irq.fall(NULL);
brdirais 0:2cb6ce8e07bd 337 else
brdirais 0:2cb6ce8e07bd 338 flag_B_irq.fall(NULL);
brdirais 0:2cb6ce8e07bd 339 }
brdirais 0:2cb6ce8e07bd 340
brdirais 0:2cb6ce8e07bd 341
brdirais 0:2cb6ce8e07bd 342 /*** Public In/Out Related Methods ***/
brdirais 0:2cb6ce8e07bd 343
brdirais 0:2cb6ce8e07bd 344 void OutVal( uint8_t bridgeId, uint8_t val)
brdirais 0:2cb6ce8e07bd 345 {
brdirais 0:2cb6ce8e07bd 346 if( bridgeId == BRIDGE_A)
brdirais 0:2cb6ce8e07bd 347 {
brdirais 0:2cb6ce8e07bd 348 EN_flag_A.output();
brdirais 0:2cb6ce8e07bd 349 EN_flag_A.mode(PullNone);
brdirais 0:2cb6ce8e07bd 350 EN_flag_A.write(val);
brdirais 0:2cb6ce8e07bd 351 }
brdirais 0:2cb6ce8e07bd 352 else
brdirais 0:2cb6ce8e07bd 353 {
brdirais 0:2cb6ce8e07bd 354 EN_flag_B.output();
brdirais 0:2cb6ce8e07bd 355 EN_flag_B.mode(PullNone);
brdirais 0:2cb6ce8e07bd 356 EN_flag_B.write(val);
brdirais 0:2cb6ce8e07bd 357 }
brdirais 0:2cb6ce8e07bd 358 }
brdirais 0:2cb6ce8e07bd 359
brdirais 0:2cb6ce8e07bd 360 protected:
brdirais 0:2cb6ce8e07bd 361
brdirais 0:2cb6ce8e07bd 362 /*** Protected Component Related Methods ***/
brdirais 0:2cb6ce8e07bd 363
brdirais 0:2cb6ce8e07bd 364 /* ACTION 7 --------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 365 * Declare here the component's specific methods. *
brdirais 0:2cb6ce8e07bd 366 * They should be: *
brdirais 0:2cb6ce8e07bd 367 * + Methods with the same name of the C component's virtual table's *
brdirais 0:2cb6ce8e07bd 368 * functions (1); *
brdirais 0:2cb6ce8e07bd 369 * + Methods with the same name of the C component's extended virtual *
brdirais 0:2cb6ce8e07bd 370 * table's functions, if any (2); *
brdirais 0:2cb6ce8e07bd 371 * + Helper methods, if any, like functions declared in the component's *
brdirais 0:2cb6ce8e07bd 372 * source files but not pointed by the component's virtual table (3). *
brdirais 0:2cb6ce8e07bd 373 * *
brdirais 0:2cb6ce8e07bd 374 * Example: *
brdirais 0:2cb6ce8e07bd 375 * Status_t COMPONENT_GetValue(float *f); //(1) *
brdirais 0:2cb6ce8e07bd 376 * Status_t COMPONENT_EnableFeature(void); //(2) *
brdirais 0:2cb6ce8e07bd 377 * Status_t COMPONENT_ComputeAverage(void); //(3) *
brdirais 0:2cb6ce8e07bd 378 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 379 Status_t L6206_Init(void *init);
brdirais 0:2cb6ce8e07bd 380 Status_t L6206_ReadId(uint8_t *id);
brdirais 0:2cb6ce8e07bd 381 void L6206_TickHandler(uint8_t deviceId); //Handle the device state machine at each tick timer pulse end
brdirais 0:2cb6ce8e07bd 382 void L6206_AttachErrorHandler(void (*callback)(uint16_t error)); //Attach a user callback to the error handler
brdirais 0:2cb6ce8e07bd 383 void L6206_AttachFlagInterrupt(void (*callback)(void)); //Attach a user callback to the flag Interrupt
brdirais 0:2cb6ce8e07bd 384 void L6206_DisableBridge(uint8_t bridgeId); //Disable the specified bridge
brdirais 0:2cb6ce8e07bd 385 void L6206_EnableBridge(uint8_t bridgeId); //Enable the specified bridge
brdirais 0:2cb6ce8e07bd 386 uint16_t L6206_GetBridgeStatus(uint8_t deviceId); //Get bridge status
brdirais 0:2cb6ce8e07bd 387 uint16_t L6206_GetCurrentSpeed(uint8_t motorId); //Return the current speed in pps
brdirais 0:2cb6ce8e07bd 388 motorState_t L6206_GetDeviceState(uint8_t motorId); //Return the device state
brdirais 0:2cb6ce8e07bd 389 uint8_t L6206_GetFwVersion(void); //Return the FW version
brdirais 0:2cb6ce8e07bd 390 uint16_t L6206_GetMaxSpeed(uint8_t motorId); //Return the max speed in pps
brdirais 0:2cb6ce8e07bd 391 void L6206_HardHiz(uint8_t motorId); //Stop the motor and disable the power bridge
brdirais 0:2cb6ce8e07bd 392 void L6206_HardStop(uint8_t motorId); //Stop the motor without disabling the power bridge
brdirais 0:2cb6ce8e07bd 393 void L6206_Run(uint8_t motorId, motorDir_t direction); //Run the motor
brdirais 0:2cb6ce8e07bd 394 uint32_t L6206_GetBridgeInputPwmFreq(uint8_t bridgeId); // Get the PWM frequency of the bridge input
brdirais 0:2cb6ce8e07bd 395 void L6206_SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq); // Set the PWM frequency of the bridge input
brdirais 0:2cb6ce8e07bd 396 void L6206_SetDualFullBridgeConfig(uint8_t newConfig); // Set dual full bridge configuration
brdirais 0:2cb6ce8e07bd 397 bool L6206_SetMaxSpeed(uint8_t motorId,uint16_t newMaxSpeed); //Set the max speed in pps
brdirais 0:2cb6ce8e07bd 398 bool L6206_SetNbDevices(uint8_t nbDevices); //Set the number of driver devices
brdirais 0:2cb6ce8e07bd 399 void L6206_ErrorHandler(uint16_t error);
brdirais 0:2cb6ce8e07bd 400 void L6206_FlagInterruptHandler(void);
brdirais 0:2cb6ce8e07bd 401 uint8_t L6206_GetBridgeIdUsedByMotorId(uint8_t motorId);
brdirais 0:2cb6ce8e07bd 402 uint8_t L6206_GetBridgeInputUsedByMotorId(uint8_t motorId);
brdirais 0:2cb6ce8e07bd 403 uint8_t L6206_GetMotorIdUsingbridgeInput(uint8_t bridgeInput);
brdirais 0:2cb6ce8e07bd 404 uint8_t L6206_GetSecondBridgeInputUsedByMotorId(uint8_t motorId);
brdirais 0:2cb6ce8e07bd 405 bool L6206_IsBidirectionnalMotor(uint8_t motorId);
brdirais 0:2cb6ce8e07bd 406 void L6206_SetDeviceParamsToPredefinedValues(void);
brdirais 0:2cb6ce8e07bd 407 void L6206_SetDeviceParamsToGivenValues(L6206_Init_t* initDevicePrm);
brdirais 0:2cb6ce8e07bd 408
brdirais 0:2cb6ce8e07bd 409 /*** Component's I/O Methods ***/
brdirais 0:2cb6ce8e07bd 410
brdirais 0:2cb6ce8e07bd 411 /* ACTION 8 --------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 412 * Implement here other I/O methods beyond those already implemented *
brdirais 0:2cb6ce8e07bd 413 * above, which are declared extern within the component's header file. *
brdirais 0:2cb6ce8e07bd 414 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 415 void L6206_Board_Delay(uint32_t delay)
brdirais 0:2cb6ce8e07bd 416 {
brdirais 0:2cb6ce8e07bd 417 wait_ms(delay);
brdirais 0:2cb6ce8e07bd 418 }
brdirais 0:2cb6ce8e07bd 419
brdirais 0:2cb6ce8e07bd 420 void L6206_Board_DisableBridge(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 421 {
brdirais 0:2cb6ce8e07bd 422 DisableFlagIRQ(BRIDGE_A);
brdirais 0:2cb6ce8e07bd 423 DisableFlagIRQ(BRIDGE_B);
brdirais 0:2cb6ce8e07bd 424
brdirais 0:2cb6ce8e07bd 425 __disable_irq();
brdirais 0:2cb6ce8e07bd 426 OutVal( bridgeId, 0);
brdirais 0:2cb6ce8e07bd 427 __enable_irq();
brdirais 0:2cb6ce8e07bd 428 }
brdirais 0:2cb6ce8e07bd 429
brdirais 0:2cb6ce8e07bd 430 void L6206_Board_EnableBridge(uint8_t bridgeId, uint8_t addDelay)
brdirais 0:2cb6ce8e07bd 431 {
brdirais 0:2cb6ce8e07bd 432 OutVal( bridgeId, 1);
brdirais 0:2cb6ce8e07bd 433
brdirais 0:2cb6ce8e07bd 434 if (addDelay != 0)
brdirais 0:2cb6ce8e07bd 435 {
brdirais 0:2cb6ce8e07bd 436 wait_ms(BSP_MOTOR_CONTROL_BOARD_BRIDGE_TURN_ON_DELAY);
brdirais 0:2cb6ce8e07bd 437 }
brdirais 0:2cb6ce8e07bd 438
brdirais 0:2cb6ce8e07bd 439 EnableFlagIRQ( bridgeId);
brdirais 0:2cb6ce8e07bd 440 }
brdirais 0:2cb6ce8e07bd 441
brdirais 0:2cb6ce8e07bd 442
brdirais 0:2cb6ce8e07bd 443 uint32_t L6206_Board_GetFlagPinState(uint8_t bridgeId)
brdirais 0:2cb6ce8e07bd 444 {
brdirais 0:2cb6ce8e07bd 445 if (bridgeId == 0)
brdirais 0:2cb6ce8e07bd 446 {
brdirais 0:2cb6ce8e07bd 447 EN_flag_A.input();
brdirais 0:2cb6ce8e07bd 448 return EN_flag_A.read();
brdirais 0:2cb6ce8e07bd 449 }
brdirais 0:2cb6ce8e07bd 450 else
brdirais 0:2cb6ce8e07bd 451 {
brdirais 0:2cb6ce8e07bd 452 EN_flag_B.input();
brdirais 0:2cb6ce8e07bd 453 return EN_flag_B.read();
brdirais 0:2cb6ce8e07bd 454 }
brdirais 0:2cb6ce8e07bd 455 }
brdirais 0:2cb6ce8e07bd 456
brdirais 0:2cb6ce8e07bd 457 void L6206_Board_GpioInit(void)
brdirais 0:2cb6ce8e07bd 458 {
brdirais 0:2cb6ce8e07bd 459 /* Init bridge Enable */
brdirais 0:2cb6ce8e07bd 460 EN_flag_A.output();
brdirais 0:2cb6ce8e07bd 461 EN_flag_A.write(0);
brdirais 0:2cb6ce8e07bd 462 EN_flag_A.input();
brdirais 0:2cb6ce8e07bd 463
brdirais 0:2cb6ce8e07bd 464 EN_flag_B.output();
brdirais 0:2cb6ce8e07bd 465 EN_flag_B.write(0);
brdirais 0:2cb6ce8e07bd 466 EN_flag_B.input();
brdirais 0:2cb6ce8e07bd 467
brdirais 0:2cb6ce8e07bd 468
brdirais 0:2cb6ce8e07bd 469 /* Init flag Irq */
brdirais 0:2cb6ce8e07bd 470 DisableFlagIRQ(BRIDGE_A);
brdirais 0:2cb6ce8e07bd 471 DisableFlagIRQ(BRIDGE_B);
brdirais 0:2cb6ce8e07bd 472
brdirais 0:2cb6ce8e07bd 473 }
brdirais 0:2cb6ce8e07bd 474
brdirais 0:2cb6ce8e07bd 475 /** Board PWM management **/
brdirais 0:2cb6ce8e07bd 476
brdirais 0:2cb6ce8e07bd 477 void L6206_Board_PwmSetFreq(uint8_t bridgeInput, uint32_t newFreq, uint8_t duty)
brdirais 0:2cb6ce8e07bd 478 {
brdirais 0:2cb6ce8e07bd 479 /* Computing the period of PWM. */
brdirais 0:2cb6ce8e07bd 480 float period = 1.0f / newFreq;
brdirais 0:2cb6ce8e07bd 481 float duty_cycle;
brdirais 0:2cb6ce8e07bd 482 int period_us = (int)(period * 1E6);
brdirais 0:2cb6ce8e07bd 483
brdirais 0:2cb6ce8e07bd 484 if (duty > 100) duty = 100;
brdirais 0:2cb6ce8e07bd 485 duty_cycle = (float)duty / 100.0f;
brdirais 0:2cb6ce8e07bd 486
brdirais 0:2cb6ce8e07bd 487 switch (bridgeInput)
brdirais 0:2cb6ce8e07bd 488 {
brdirais 0:2cb6ce8e07bd 489 case 0:
brdirais 0:2cb6ce8e07bd 490 default:
brdirais 0:2cb6ce8e07bd 491 /* Setting the period and the duty-cycle of PWM. */
brdirais 0:2cb6ce8e07bd 492 pwm_1A.period_us(period_us);
brdirais 0:2cb6ce8e07bd 493 pwm_1A.write(duty_cycle);
brdirais 0:2cb6ce8e07bd 494 break;
brdirais 0:2cb6ce8e07bd 495
brdirais 0:2cb6ce8e07bd 496 case 1:
brdirais 0:2cb6ce8e07bd 497 /* Setting the period and the duty-cycle of PWM. */
brdirais 0:2cb6ce8e07bd 498 pwm_2A.period_us(period_us);
brdirais 0:2cb6ce8e07bd 499 pwm_2A.write(duty_cycle);
brdirais 0:2cb6ce8e07bd 500 break;
brdirais 0:2cb6ce8e07bd 501
brdirais 0:2cb6ce8e07bd 502 case 2:
brdirais 0:2cb6ce8e07bd 503 /* Setting the period and the duty-cycle of PWM. */
brdirais 0:2cb6ce8e07bd 504 pwm_1B.period_us(period_us);
brdirais 0:2cb6ce8e07bd 505 pwm_1B.write(duty_cycle);
brdirais 0:2cb6ce8e07bd 506 break;
brdirais 0:2cb6ce8e07bd 507
brdirais 0:2cb6ce8e07bd 508 case 3:
brdirais 0:2cb6ce8e07bd 509 /* Setting the period and the duty-cycle of PWM. */
brdirais 0:2cb6ce8e07bd 510 pwm_2B.period_us(period_us);
brdirais 0:2cb6ce8e07bd 511 pwm_2B.write(duty_cycle);
brdirais 0:2cb6ce8e07bd 512 break;
brdirais 0:2cb6ce8e07bd 513 }
brdirais 0:2cb6ce8e07bd 514 }
brdirais 0:2cb6ce8e07bd 515
brdirais 0:2cb6ce8e07bd 516 void L6206_Board_PwmDeInit(uint8_t bridgeInput)
brdirais 0:2cb6ce8e07bd 517 {
brdirais 0:2cb6ce8e07bd 518 switch (bridgeInput)
brdirais 0:2cb6ce8e07bd 519 {
brdirais 0:2cb6ce8e07bd 520 case 0:
brdirais 0:2cb6ce8e07bd 521 default:
brdirais 0:2cb6ce8e07bd 522 //timer_pwm_1A.detach();
brdirais 0:2cb6ce8e07bd 523 break;
brdirais 0:2cb6ce8e07bd 524
brdirais 0:2cb6ce8e07bd 525 case 1:
brdirais 0:2cb6ce8e07bd 526 //timer_pwm_2A.detach();
brdirais 0:2cb6ce8e07bd 527 break;
brdirais 0:2cb6ce8e07bd 528
brdirais 0:2cb6ce8e07bd 529 case 2:
brdirais 0:2cb6ce8e07bd 530 //timer_pwm_1B.detach();
brdirais 0:2cb6ce8e07bd 531 break;
brdirais 0:2cb6ce8e07bd 532
brdirais 0:2cb6ce8e07bd 533 case 3:
brdirais 0:2cb6ce8e07bd 534 //timer_pwm_2B.detach();
brdirais 0:2cb6ce8e07bd 535 break;
brdirais 0:2cb6ce8e07bd 536 }
brdirais 0:2cb6ce8e07bd 537 }
brdirais 0:2cb6ce8e07bd 538
brdirais 0:2cb6ce8e07bd 539 void L6206_Board_PwmInit(uint8_t bridgeInput)
brdirais 0:2cb6ce8e07bd 540 {
brdirais 0:2cb6ce8e07bd 541 }
brdirais 0:2cb6ce8e07bd 542
brdirais 0:2cb6ce8e07bd 543 void L6206_Board_PwmStop(uint8_t bridgeInput)
brdirais 0:2cb6ce8e07bd 544 {
brdirais 0:2cb6ce8e07bd 545 switch (bridgeInput)
brdirais 0:2cb6ce8e07bd 546 {
brdirais 0:2cb6ce8e07bd 547 case 0:
brdirais 0:2cb6ce8e07bd 548 default:
brdirais 0:2cb6ce8e07bd 549 pwm_1A.write(0.0);
brdirais 0:2cb6ce8e07bd 550 break;
brdirais 0:2cb6ce8e07bd 551
brdirais 0:2cb6ce8e07bd 552 case 1:
brdirais 0:2cb6ce8e07bd 553 pwm_2A.write(0.0);
brdirais 0:2cb6ce8e07bd 554 break;
brdirais 0:2cb6ce8e07bd 555
brdirais 0:2cb6ce8e07bd 556 case 2:
brdirais 0:2cb6ce8e07bd 557 pwm_1B.write(0.0);
brdirais 0:2cb6ce8e07bd 558 break;
brdirais 0:2cb6ce8e07bd 559
brdirais 0:2cb6ce8e07bd 560 case 3:
brdirais 0:2cb6ce8e07bd 561 pwm_2B.write(0.0);
brdirais 0:2cb6ce8e07bd 562 break;
brdirais 0:2cb6ce8e07bd 563 }
brdirais 0:2cb6ce8e07bd 564 }
brdirais 0:2cb6ce8e07bd 565
brdirais 0:2cb6ce8e07bd 566
brdirais 0:2cb6ce8e07bd 567 /*** Component's Instance Variables ***/
brdirais 0:2cb6ce8e07bd 568
brdirais 0:2cb6ce8e07bd 569 /* ACTION 9 --------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 570 * Declare here interrupt related variables, if needed. *
brdirais 0:2cb6ce8e07bd 571 * Note that interrupt handling is platform dependent, see *
brdirais 0:2cb6ce8e07bd 572 * "Interrupt Related Methods" above. *
brdirais 0:2cb6ce8e07bd 573 * *
brdirais 0:2cb6ce8e07bd 574 * Example: *
brdirais 0:2cb6ce8e07bd 575 * + mbed: *
brdirais 0:2cb6ce8e07bd 576 * InterruptIn feature_irq; *
brdirais 0:2cb6ce8e07bd 577 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 578
brdirais 0:2cb6ce8e07bd 579 /* Flag Interrupt. */
brdirais 0:2cb6ce8e07bd 580 InterruptIn flag_A_irq;
brdirais 0:2cb6ce8e07bd 581 InterruptIn flag_B_irq;
brdirais 0:2cb6ce8e07bd 582
brdirais 0:2cb6ce8e07bd 583 /* ACTION 10 -------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 584 * Declare here other pin related variables, if needed. *
brdirais 0:2cb6ce8e07bd 585 * *
brdirais 0:2cb6ce8e07bd 586 * Example: *
brdirais 0:2cb6ce8e07bd 587 * + mbed: *
brdirais 0:2cb6ce8e07bd 588 * DigitalOut standby_reset; *
brdirais 0:2cb6ce8e07bd 589 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 590
brdirais 0:2cb6ce8e07bd 591 /* Digital In/Out for Flag EN pin */
brdirais 0:2cb6ce8e07bd 592 DigitalInOut EN_flag_A;
brdirais 0:2cb6ce8e07bd 593 DigitalInOut EN_flag_B;
brdirais 0:2cb6ce8e07bd 594
brdirais 0:2cb6ce8e07bd 595 /* PWM Out pin */
brdirais 0:2cb6ce8e07bd 596 PwmOut pwm_1A;
brdirais 0:2cb6ce8e07bd 597 PwmOut pwm_2A;
brdirais 0:2cb6ce8e07bd 598 PwmOut pwm_1B;
brdirais 0:2cb6ce8e07bd 599 PwmOut pwm_2B;
brdirais 0:2cb6ce8e07bd 600
brdirais 0:2cb6ce8e07bd 601 /* ACTION 11 -------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 602 * Declare here communication related variables, if needed. *
brdirais 0:2cb6ce8e07bd 603 * *
brdirais 0:2cb6ce8e07bd 604 * Example: *
brdirais 0:2cb6ce8e07bd 605 * + mbed: *
brdirais 0:2cb6ce8e07bd 606 * DigitalOut address; *
brdirais 0:2cb6ce8e07bd 607 * DevI2C &dev_i2c; *
brdirais 0:2cb6ce8e07bd 608 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 609
brdirais 0:2cb6ce8e07bd 610 /* ACTION 12 -------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 611 * Declare here identity related variables, if needed. *
brdirais 0:2cb6ce8e07bd 612 * Note that there should be only a unique identifier for each component, *
brdirais 0:2cb6ce8e07bd 613 * which should be the "who_am_i" parameter. *
brdirais 0:2cb6ce8e07bd 614 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 615 /* Identity */
brdirais 0:2cb6ce8e07bd 616 uint8_t who_am_i;
brdirais 0:2cb6ce8e07bd 617
brdirais 0:2cb6ce8e07bd 618 /* ACTION 13 -------------------------------------------------------------*
brdirais 0:2cb6ce8e07bd 619 * Declare here the component's static and non-static data, one variable *
brdirais 0:2cb6ce8e07bd 620 * per line. *
brdirais 0:2cb6ce8e07bd 621 * *
brdirais 0:2cb6ce8e07bd 622 * Example: *
brdirais 0:2cb6ce8e07bd 623 * float measure; *
brdirais 0:2cb6ce8e07bd 624 * int instance_id; *
brdirais 0:2cb6ce8e07bd 625 * static int number_of_instances; *
brdirais 0:2cb6ce8e07bd 626 *------------------------------------------------------------------------*/
brdirais 0:2cb6ce8e07bd 627 void (*flagInterruptCallback)(void);
brdirais 0:2cb6ce8e07bd 628
brdirais 0:2cb6ce8e07bd 629 void (*errorHandlerCallback)(uint16_t error);
brdirais 0:2cb6ce8e07bd 630
brdirais 0:2cb6ce8e07bd 631 uint8_t numberOfDevices;
brdirais 0:2cb6ce8e07bd 632
brdirais 0:2cb6ce8e07bd 633 uint8_t deviceInstance;
brdirais 0:2cb6ce8e07bd 634
brdirais 0:2cb6ce8e07bd 635 deviceParams_t devicePrm;
brdirais 0:2cb6ce8e07bd 636
brdirais 0:2cb6ce8e07bd 637
brdirais 0:2cb6ce8e07bd 638 /** PWM timer variables */
brdirais 0:2cb6ce8e07bd 639
brdirais 0:2cb6ce8e07bd 640 bool pwm_1A_activated;
brdirais 0:2cb6ce8e07bd 641 bool pwm_2A_activated;
brdirais 0:2cb6ce8e07bd 642 bool pwm_1B_activated;
brdirais 0:2cb6ce8e07bd 643 bool pwm_2B_activated;
brdirais 0:2cb6ce8e07bd 644 };
brdirais 0:2cb6ce8e07bd 645
brdirais 0:2cb6ce8e07bd 646 #endif /* __L6206_CLASS_H */
brdirais 0:2cb6ce8e07bd 647
brdirais 0:2cb6ce8e07bd 648 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
brdirais 0:2cb6ce8e07bd 649
brdirais 0:2cb6ce8e07bd 650
brdirais 0:2cb6ce8e07bd 651