X-CUBE-SPN1-20150128 example source code for one motor compiled under mbed. Tested OK on Nucleo F401. l6474.cpp is modified from original with defines in l6474_target_config.h to select the original behaviour (motor de-energised when halted), or new mode to continue powering with a (reduced) current in the coils (braking/position hold capability). On F401 avoid using mbed's InterruptIn on pins 10-15 (any port). Beware of other conflicts! L0 & F0 are included but untested.
IHM01A1/stm32f0xx_hal_msp.cpp@6:19c1b4a04c24, 2015-10-13 (annotated)
- Committer:
- gregeric
- Date:
- Tue Oct 13 10:46:01 2015 +0000
- Revision:
- 6:19c1b4a04c24
- Parent:
- 5:615cacd7d036
Ensure bridge is disabled before resetting the L6474.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gregeric | 0:b9444a40a999 | 1 | /** |
gregeric | 0:b9444a40a999 | 2 | ****************************************************************************** |
gregeric | 0:b9444a40a999 | 3 | * @file Multi/Examples/MotionControl/IHM01A1_ExampleFor1Motor/Src/stm32f0xx_hal_msp.c |
gregeric | 0:b9444a40a999 | 4 | * @author IPC Rennes |
gregeric | 0:b9444a40a999 | 5 | * @version V1.5.0 |
gregeric | 0:b9444a40a999 | 6 | * @date November 12, 2014 |
gregeric | 0:b9444a40a999 | 7 | * @brief HAL MSP module. |
gregeric | 0:b9444a40a999 | 8 | ****************************************************************************** |
gregeric | 0:b9444a40a999 | 9 | * @attention |
gregeric | 0:b9444a40a999 | 10 | * |
gregeric | 0:b9444a40a999 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
gregeric | 0:b9444a40a999 | 12 | * |
gregeric | 0:b9444a40a999 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
gregeric | 0:b9444a40a999 | 14 | * are permitted provided that the following conditions are met: |
gregeric | 0:b9444a40a999 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
gregeric | 0:b9444a40a999 | 16 | * this list of conditions and the following disclaimer. |
gregeric | 0:b9444a40a999 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
gregeric | 0:b9444a40a999 | 18 | * this list of conditions and the following disclaimer in the documentation |
gregeric | 0:b9444a40a999 | 19 | * and/or other materials provided with the distribution. |
gregeric | 0:b9444a40a999 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
gregeric | 0:b9444a40a999 | 21 | * may be used to endorse or promote products derived from this software |
gregeric | 0:b9444a40a999 | 22 | * without specific prior written permission. |
gregeric | 0:b9444a40a999 | 23 | * |
gregeric | 0:b9444a40a999 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
gregeric | 0:b9444a40a999 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
gregeric | 0:b9444a40a999 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
gregeric | 0:b9444a40a999 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
gregeric | 0:b9444a40a999 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
gregeric | 0:b9444a40a999 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
gregeric | 0:b9444a40a999 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
gregeric | 0:b9444a40a999 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
gregeric | 0:b9444a40a999 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
gregeric | 0:b9444a40a999 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
gregeric | 0:b9444a40a999 | 34 | * |
gregeric | 0:b9444a40a999 | 35 | ****************************************************************************** |
gregeric | 0:b9444a40a999 | 36 | */ |
gregeric | 0:b9444a40a999 | 37 | #ifdef TARGET_STM32F0 |
gregeric | 0:b9444a40a999 | 38 | /* Includes ------------------------------------------------------------------*/ |
gregeric | 0:b9444a40a999 | 39 | #include "mbed.h" |
gregeric | 5:615cacd7d036 | 40 | #include "ihm01a1.h" |
gregeric | 0:b9444a40a999 | 41 | |
gregeric | 0:b9444a40a999 | 42 | |
gregeric | 0:b9444a40a999 | 43 | /** @defgroup MSP_module |
gregeric | 0:b9444a40a999 | 44 | * @brief HAL MSP module. |
gregeric | 0:b9444a40a999 | 45 | * @{ |
gregeric | 0:b9444a40a999 | 46 | */ |
gregeric | 0:b9444a40a999 | 47 | |
gregeric | 0:b9444a40a999 | 48 | /* Private typedef -----------------------------------------------------------*/ |
gregeric | 0:b9444a40a999 | 49 | /* Private define ------------------------------------------------------------*/ |
gregeric | 0:b9444a40a999 | 50 | /* Private macro -------------------------------------------------------------*/ |
gregeric | 0:b9444a40a999 | 51 | /* Private variables ---------------------------------------------------------*/ |
gregeric | 0:b9444a40a999 | 52 | |
gregeric | 0:b9444a40a999 | 53 | /* Private function prototypes -----------------------------------------------*/ |
gregeric | 0:b9444a40a999 | 54 | extern void BSP_MotorControl_StepClockHandler(uint8_t deviceId); |
gregeric | 0:b9444a40a999 | 55 | extern void BSP_MotorControl_FlagInterruptHandler(void); |
gregeric | 0:b9444a40a999 | 56 | /* Private functions ---------------------------------------------------------*/ |
gregeric | 0:b9444a40a999 | 57 | |
gregeric | 0:b9444a40a999 | 58 | /** @defgroup HAL_MSP_Private_Functions |
gregeric | 0:b9444a40a999 | 59 | * @{ |
gregeric | 0:b9444a40a999 | 60 | */ |
gregeric | 0:b9444a40a999 | 61 | |
gregeric | 0:b9444a40a999 | 62 | /** |
gregeric | 0:b9444a40a999 | 63 | * @brief SPI MSP Initialization |
gregeric | 0:b9444a40a999 | 64 | * This function configures the hardware resources used in this example: |
gregeric | 0:b9444a40a999 | 65 | * - Peripheral's clock enable |
gregeric | 0:b9444a40a999 | 66 | * - Peripheral's GPIO Configuration |
gregeric | 0:b9444a40a999 | 67 | * @param[in] hspi SPI handle pointer |
gregeric | 0:b9444a40a999 | 68 | * @retval None |
gregeric | 0:b9444a40a999 | 69 | */ |
gregeric | 0:b9444a40a999 | 70 | void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi) |
gregeric | 0:b9444a40a999 | 71 | { |
gregeric | 0:b9444a40a999 | 72 | GPIO_InitTypeDef GPIO_InitStruct; |
gregeric | 0:b9444a40a999 | 73 | |
gregeric | 0:b9444a40a999 | 74 | if(hspi->Instance == SPIx) |
gregeric | 0:b9444a40a999 | 75 | { |
gregeric | 0:b9444a40a999 | 76 | /*##-1- Enable peripherals and GPIO Clocks #################################*/ |
gregeric | 0:b9444a40a999 | 77 | /* Enable GPIO TX/RX clock */ |
gregeric | 0:b9444a40a999 | 78 | SPIx_SCK_GPIO_CLK_ENABLE(); |
gregeric | 0:b9444a40a999 | 79 | SPIx_MISO_GPIO_CLK_ENABLE(); |
gregeric | 0:b9444a40a999 | 80 | SPIx_MOSI_GPIO_CLK_ENABLE(); |
gregeric | 0:b9444a40a999 | 81 | /* Enable SPI clock */ |
gregeric | 0:b9444a40a999 | 82 | SPIx_CLK_ENABLE(); |
gregeric | 0:b9444a40a999 | 83 | |
gregeric | 0:b9444a40a999 | 84 | /*##-2- Configure peripheral GPIO ##########################################*/ |
gregeric | 0:b9444a40a999 | 85 | /* SPI SCK GPIO pin configuration */ |
gregeric | 0:b9444a40a999 | 86 | GPIO_InitStruct.Pin = SPIx_SCK_PIN; |
gregeric | 0:b9444a40a999 | 87 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
gregeric | 0:b9444a40a999 | 88 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
gregeric | 0:b9444a40a999 | 89 | GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM; |
gregeric | 0:b9444a40a999 | 90 | GPIO_InitStruct.Alternate = SPIx_SCK_AF; |
gregeric | 0:b9444a40a999 | 91 | |
gregeric | 0:b9444a40a999 | 92 | HAL_GPIO_Init(SPIx_SCK_GPIO_PORT, &GPIO_InitStruct); |
gregeric | 0:b9444a40a999 | 93 | |
gregeric | 0:b9444a40a999 | 94 | /* SPI MISO GPIO pin configuration */ |
gregeric | 0:b9444a40a999 | 95 | GPIO_InitStruct.Pin = SPIx_MISO_PIN; |
gregeric | 0:b9444a40a999 | 96 | GPIO_InitStruct.Alternate = SPIx_MISO_AF; |
gregeric | 0:b9444a40a999 | 97 | |
gregeric | 0:b9444a40a999 | 98 | HAL_GPIO_Init(SPIx_MISO_GPIO_PORT, &GPIO_InitStruct); |
gregeric | 0:b9444a40a999 | 99 | |
gregeric | 0:b9444a40a999 | 100 | /* SPI MOSI GPIO pin configuration */ |
gregeric | 0:b9444a40a999 | 101 | GPIO_InitStruct.Pin = SPIx_MOSI_PIN; |
gregeric | 0:b9444a40a999 | 102 | GPIO_InitStruct.Alternate = SPIx_MOSI_AF; |
gregeric | 0:b9444a40a999 | 103 | |
gregeric | 0:b9444a40a999 | 104 | HAL_GPIO_Init(SPIx_MOSI_GPIO_PORT, &GPIO_InitStruct); |
gregeric | 0:b9444a40a999 | 105 | } |
gregeric | 0:b9444a40a999 | 106 | } |
gregeric | 0:b9444a40a999 | 107 | |
gregeric | 0:b9444a40a999 | 108 | /** |
gregeric | 0:b9444a40a999 | 109 | * @brief SPI MSP De-Initialization |
gregeric | 0:b9444a40a999 | 110 | * This function frees the hardware resources used in this example: |
gregeric | 0:b9444a40a999 | 111 | * - Disable the Peripheral's clock |
gregeric | 0:b9444a40a999 | 112 | * - Revert GPIO configuration to its default state |
gregeric | 0:b9444a40a999 | 113 | * @param[in] hspi SPI handle pointer |
gregeric | 0:b9444a40a999 | 114 | * @retval None |
gregeric | 0:b9444a40a999 | 115 | */ |
gregeric | 0:b9444a40a999 | 116 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi) |
gregeric | 0:b9444a40a999 | 117 | { |
gregeric | 0:b9444a40a999 | 118 | if(hspi->Instance == SPIx) |
gregeric | 0:b9444a40a999 | 119 | { |
gregeric | 0:b9444a40a999 | 120 | /*##-1- Reset peripherals ##################################################*/ |
gregeric | 0:b9444a40a999 | 121 | SPIx_FORCE_RESET(); |
gregeric | 0:b9444a40a999 | 122 | SPIx_RELEASE_RESET(); |
gregeric | 0:b9444a40a999 | 123 | |
gregeric | 0:b9444a40a999 | 124 | /*##-2- Disable peripherals and GPIO Clocks ################################*/ |
gregeric | 0:b9444a40a999 | 125 | /* Configure SPI SCK as alternate function */ |
gregeric | 0:b9444a40a999 | 126 | HAL_GPIO_DeInit(SPIx_SCK_GPIO_PORT, SPIx_SCK_PIN); |
gregeric | 0:b9444a40a999 | 127 | /* Configure SPI MISO as alternate function */ |
gregeric | 0:b9444a40a999 | 128 | HAL_GPIO_DeInit(SPIx_MISO_GPIO_PORT, SPIx_MISO_PIN); |
gregeric | 0:b9444a40a999 | 129 | /* Configure SPI MOSI as alternate function */ |
gregeric | 0:b9444a40a999 | 130 | HAL_GPIO_DeInit(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_PIN); |
gregeric | 0:b9444a40a999 | 131 | } |
gregeric | 0:b9444a40a999 | 132 | } |
gregeric | 0:b9444a40a999 | 133 | |
gregeric | 0:b9444a40a999 | 134 | /** |
gregeric | 0:b9444a40a999 | 135 | * @brief PWM MSP Initialization |
gregeric | 0:b9444a40a999 | 136 | * @param[in] htim_pwm PWM handle pointer |
gregeric | 0:b9444a40a999 | 137 | * @retval None |
gregeric | 0:b9444a40a999 | 138 | */ |
gregeric | 0:b9444a40a999 | 139 | void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) |
gregeric | 0:b9444a40a999 | 140 | { |
gregeric | 0:b9444a40a999 | 141 | GPIO_InitTypeDef GPIO_InitStruct; |
gregeric | 0:b9444a40a999 | 142 | if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM1) |
gregeric | 0:b9444a40a999 | 143 | { |
gregeric | 0:b9444a40a999 | 144 | /* Peripheral clock enable */ |
gregeric | 0:b9444a40a999 | 145 | __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM1_CLCK_ENABLE(); |
gregeric | 0:b9444a40a999 | 146 | |
gregeric | 0:b9444a40a999 | 147 | /* GPIO configuration */ |
gregeric | 0:b9444a40a999 | 148 | GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_PWM_1_PIN; |
gregeric | 0:b9444a40a999 | 149 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
gregeric | 0:b9444a40a999 | 150 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
gregeric | 0:b9444a40a999 | 151 | GPIO_InitStruct.Speed = GPIO_SPEED_LOW; |
gregeric | 0:b9444a40a999 | 152 | GPIO_InitStruct.Alternate = BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_PWM1; |
gregeric | 0:b9444a40a999 | 153 | HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_PWM_1_PORT, &GPIO_InitStruct); |
gregeric | 0:b9444a40a999 | 154 | |
gregeric | 0:b9444a40a999 | 155 | /* Set Interrupt Group Priority of Timer Interrupt*/ |
gregeric | 0:b9444a40a999 | 156 | HAL_NVIC_SetPriority(BSP_MOTOR_CONTROL_BOARD_PWM1_IRQn, 4, 0); |
gregeric | 0:b9444a40a999 | 157 | |
gregeric | 0:b9444a40a999 | 158 | /* Enable the timer global Interrupt */ |
gregeric | 0:b9444a40a999 | 159 | HAL_NVIC_EnableIRQ(BSP_MOTOR_CONTROL_BOARD_PWM1_IRQn); |
gregeric | 0:b9444a40a999 | 160 | } |
gregeric | 0:b9444a40a999 | 161 | else if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM2) |
gregeric | 0:b9444a40a999 | 162 | { |
gregeric | 0:b9444a40a999 | 163 | /* Peripheral clock enable */ |
gregeric | 0:b9444a40a999 | 164 | __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM2_CLCK_ENABLE(); |
gregeric | 0:b9444a40a999 | 165 | |
gregeric | 0:b9444a40a999 | 166 | /* GPIO configuration */ |
gregeric | 0:b9444a40a999 | 167 | GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_PWM_2_PIN; |
gregeric | 0:b9444a40a999 | 168 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
gregeric | 0:b9444a40a999 | 169 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
gregeric | 0:b9444a40a999 | 170 | GPIO_InitStruct.Speed = GPIO_SPEED_LOW; |
gregeric | 0:b9444a40a999 | 171 | HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_PWM_2_PORT, &GPIO_InitStruct); |
gregeric | 0:b9444a40a999 | 172 | |
gregeric | 0:b9444a40a999 | 173 | /* Set Interrupt Group Priority of Timer Interrupt*/ |
gregeric | 0:b9444a40a999 | 174 | HAL_NVIC_SetPriority(BSP_MOTOR_CONTROL_BOARD_PWM2_IRQn, 3, 0); |
gregeric | 0:b9444a40a999 | 175 | |
gregeric | 0:b9444a40a999 | 176 | /* Enable the timer global Interrupt */ |
gregeric | 0:b9444a40a999 | 177 | HAL_NVIC_EnableIRQ(BSP_MOTOR_CONTROL_BOARD_PWM2_IRQn); |
gregeric | 0:b9444a40a999 | 178 | |
gregeric | 0:b9444a40a999 | 179 | } |
gregeric | 0:b9444a40a999 | 180 | else if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM3) |
gregeric | 0:b9444a40a999 | 181 | { |
gregeric | 0:b9444a40a999 | 182 | /* Peripheral clock enable */ |
gregeric | 0:b9444a40a999 | 183 | __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM3_CLCK_ENABLE(); |
gregeric | 0:b9444a40a999 | 184 | |
gregeric | 0:b9444a40a999 | 185 | /* GPIO configuration */ |
gregeric | 0:b9444a40a999 | 186 | GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_PWM_3_PIN; |
gregeric | 0:b9444a40a999 | 187 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
gregeric | 0:b9444a40a999 | 188 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
gregeric | 0:b9444a40a999 | 189 | GPIO_InitStruct.Speed = GPIO_SPEED_LOW; |
gregeric | 0:b9444a40a999 | 190 | HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_PWM_3_PORT, &GPIO_InitStruct); |
gregeric | 0:b9444a40a999 | 191 | |
gregeric | 0:b9444a40a999 | 192 | /* Set Interrupt Group Priority of Timer Interrupt*/ |
gregeric | 0:b9444a40a999 | 193 | HAL_NVIC_SetPriority(BSP_MOTOR_CONTROL_BOARD_PWM3_IRQn, 3, 0); |
gregeric | 0:b9444a40a999 | 194 | |
gregeric | 0:b9444a40a999 | 195 | /* Enable the timer global Interrupt */ |
gregeric | 0:b9444a40a999 | 196 | HAL_NVIC_EnableIRQ(BSP_MOTOR_CONTROL_BOARD_PWM3_IRQn); |
gregeric | 0:b9444a40a999 | 197 | } |
gregeric | 0:b9444a40a999 | 198 | } |
gregeric | 0:b9444a40a999 | 199 | |
gregeric | 0:b9444a40a999 | 200 | /** |
gregeric | 0:b9444a40a999 | 201 | * @brief PWM MSP De-Initialization |
gregeric | 0:b9444a40a999 | 202 | * @param[in] htim_pwm PWM handle pointer |
gregeric | 0:b9444a40a999 | 203 | * @retval None |
gregeric | 0:b9444a40a999 | 204 | */ |
gregeric | 0:b9444a40a999 | 205 | void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) |
gregeric | 0:b9444a40a999 | 206 | { |
gregeric | 0:b9444a40a999 | 207 | if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM1) |
gregeric | 0:b9444a40a999 | 208 | { |
gregeric | 0:b9444a40a999 | 209 | /* Peripheral clock disable */ |
gregeric | 0:b9444a40a999 | 210 | __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM1_CLCK_DISABLE(); |
gregeric | 0:b9444a40a999 | 211 | |
gregeric | 0:b9444a40a999 | 212 | /* GPIO Deconfiguration */ |
gregeric | 0:b9444a40a999 | 213 | HAL_GPIO_DeInit(BSP_MOTOR_CONTROL_BOARD_PWM_1_PORT, BSP_MOTOR_CONTROL_BOARD_PWM_1_PIN); |
gregeric | 0:b9444a40a999 | 214 | |
gregeric | 0:b9444a40a999 | 215 | } |
gregeric | 0:b9444a40a999 | 216 | else if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM2) |
gregeric | 0:b9444a40a999 | 217 | { |
gregeric | 0:b9444a40a999 | 218 | /* Peripheral clock disable */ |
gregeric | 0:b9444a40a999 | 219 | __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM2_CLCK_DISABLE(); |
gregeric | 0:b9444a40a999 | 220 | |
gregeric | 0:b9444a40a999 | 221 | /* GPIO Deconfiguration */ |
gregeric | 0:b9444a40a999 | 222 | HAL_GPIO_DeInit(BSP_MOTOR_CONTROL_BOARD_PWM_2_PORT, BSP_MOTOR_CONTROL_BOARD_PWM_2_PIN); |
gregeric | 0:b9444a40a999 | 223 | |
gregeric | 0:b9444a40a999 | 224 | } |
gregeric | 0:b9444a40a999 | 225 | else if(htim_pwm->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM3) |
gregeric | 0:b9444a40a999 | 226 | { |
gregeric | 0:b9444a40a999 | 227 | /* Peripheral clock disable */ |
gregeric | 0:b9444a40a999 | 228 | __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM3_CLCK_DISABLE(); |
gregeric | 0:b9444a40a999 | 229 | |
gregeric | 0:b9444a40a999 | 230 | /* GPIO Deconfiguration */ |
gregeric | 0:b9444a40a999 | 231 | HAL_GPIO_DeInit(BSP_MOTOR_CONTROL_BOARD_PWM_3_PORT, BSP_MOTOR_CONTROL_BOARD_PWM_3_PIN); |
gregeric | 0:b9444a40a999 | 232 | } |
gregeric | 0:b9444a40a999 | 233 | } |
gregeric | 0:b9444a40a999 | 234 | |
gregeric | 0:b9444a40a999 | 235 | /** |
gregeric | 0:b9444a40a999 | 236 | * @brief PWM Callback |
gregeric | 0:b9444a40a999 | 237 | * @param[in] htim PWM handle pointer |
gregeric | 0:b9444a40a999 | 238 | * @retval None |
gregeric | 0:b9444a40a999 | 239 | */ |
gregeric | 0:b9444a40a999 | 240 | void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) |
gregeric | 0:b9444a40a999 | 241 | { |
gregeric | 0:b9444a40a999 | 242 | if ((htim->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM1)&& (htim->Channel == BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM1)) |
gregeric | 0:b9444a40a999 | 243 | { |
gregeric | 0:b9444a40a999 | 244 | if (BSP_MotorControl_GetDeviceState(0) != INACTIVE) |
gregeric | 0:b9444a40a999 | 245 | { |
gregeric | 0:b9444a40a999 | 246 | BSP_MotorControl_StepClockHandler(0); |
gregeric | 0:b9444a40a999 | 247 | } |
gregeric | 0:b9444a40a999 | 248 | } |
gregeric | 0:b9444a40a999 | 249 | if ((htim->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM2)&& (htim->Channel == BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM2)) |
gregeric | 0:b9444a40a999 | 250 | { |
gregeric | 0:b9444a40a999 | 251 | HAL_GPIO_TogglePin(BSP_MOTOR_CONTROL_BOARD_PWM_2_PORT, BSP_MOTOR_CONTROL_BOARD_PWM_2_PIN); |
gregeric | 0:b9444a40a999 | 252 | if ((BSP_MotorControl_GetDeviceState(1) != INACTIVE)&& |
gregeric | 0:b9444a40a999 | 253 | (HAL_GPIO_ReadPin(BSP_MOTOR_CONTROL_BOARD_PWM_2_PORT, BSP_MOTOR_CONTROL_BOARD_PWM_2_PIN) == GPIO_PIN_SET)) |
gregeric | 0:b9444a40a999 | 254 | { |
gregeric | 0:b9444a40a999 | 255 | BSP_MotorControl_StepClockHandler(1); |
gregeric | 0:b9444a40a999 | 256 | } |
gregeric | 0:b9444a40a999 | 257 | } |
gregeric | 0:b9444a40a999 | 258 | if ((htim->Instance == BSP_MOTOR_CONTROL_BOARD_TIMER_PWM3)&& (htim->Channel == BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM3)) |
gregeric | 0:b9444a40a999 | 259 | { |
gregeric | 0:b9444a40a999 | 260 | HAL_GPIO_TogglePin(BSP_MOTOR_CONTROL_BOARD_PWM_3_PORT, BSP_MOTOR_CONTROL_BOARD_PWM_3_PIN); |
gregeric | 0:b9444a40a999 | 261 | if ((BSP_MotorControl_GetDeviceState(2) != INACTIVE)&& |
gregeric | 0:b9444a40a999 | 262 | (HAL_GPIO_ReadPin(BSP_MOTOR_CONTROL_BOARD_PWM_3_PORT, BSP_MOTOR_CONTROL_BOARD_PWM_3_PIN) == GPIO_PIN_SET)) |
gregeric | 0:b9444a40a999 | 263 | { |
gregeric | 0:b9444a40a999 | 264 | BSP_MotorControl_StepClockHandler(2); |
gregeric | 0:b9444a40a999 | 265 | } |
gregeric | 0:b9444a40a999 | 266 | } |
gregeric | 0:b9444a40a999 | 267 | } |
gregeric | 0:b9444a40a999 | 268 | |
gregeric | 0:b9444a40a999 | 269 | /** |
gregeric | 0:b9444a40a999 | 270 | * @brief External Line Callback |
gregeric | 0:b9444a40a999 | 271 | * @param[in] GPIO_Pin pin number |
gregeric | 0:b9444a40a999 | 272 | * @retval None |
gregeric | 0:b9444a40a999 | 273 | */ |
gregeric | 0:b9444a40a999 | 274 | void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) |
gregeric | 0:b9444a40a999 | 275 | { |
gregeric | 0:b9444a40a999 | 276 | if (GPIO_Pin == BSP_MOTOR_CONTROL_BOARD_FLAG_PIN) |
gregeric | 0:b9444a40a999 | 277 | { |
gregeric | 0:b9444a40a999 | 278 | BSP_MotorControl_FlagInterruptHandler(); |
gregeric | 0:b9444a40a999 | 279 | } |
gregeric | 0:b9444a40a999 | 280 | } |
gregeric | 0:b9444a40a999 | 281 | /** |
gregeric | 0:b9444a40a999 | 282 | * @} |
gregeric | 0:b9444a40a999 | 283 | */ |
gregeric | 0:b9444a40a999 | 284 | |
gregeric | 0:b9444a40a999 | 285 | /** |
gregeric | 0:b9444a40a999 | 286 | * @} |
gregeric | 0:b9444a40a999 | 287 | */ |
gregeric | 0:b9444a40a999 | 288 | #endif |
gregeric | 0:b9444a40a999 | 289 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |