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.

Dependencies:   mbed

Committer:
gregeric
Date:
Tue Oct 13 10:46:01 2015 +0000
Revision:
6:19c1b4a04c24
Parent:
0:b9444a40a999
Ensure bridge is disabled before resetting the L6474.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gregeric 0:b9444a40a999 1 /**
gregeric 0:b9444a40a999 2 ******************************************************************************
gregeric 0:b9444a40a999 3 * @file Multi/Examples/MotionControl/IHM01A1_ExampleFor1Motor/Src/stm32l0xx_it.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 Main Interrupt Service Routines.
gregeric 0:b9444a40a999 8 * This file provides template for all exceptions handler and
gregeric 0:b9444a40a999 9 * peripherals interrupt service routine.
gregeric 0:b9444a40a999 10 ******************************************************************************
gregeric 0:b9444a40a999 11 * @attention
gregeric 0:b9444a40a999 12 *
gregeric 0:b9444a40a999 13 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
gregeric 0:b9444a40a999 14 *
gregeric 0:b9444a40a999 15 * Redistribution and use in source and binary forms, with or without modification,
gregeric 0:b9444a40a999 16 * are permitted provided that the following conditions are met:
gregeric 0:b9444a40a999 17 * 1. Redistributions of source code must retain the above copyright notice,
gregeric 0:b9444a40a999 18 * this list of conditions and the following disclaimer.
gregeric 0:b9444a40a999 19 * 2. Redistributions in binary form must reproduce the above copyright notice,
gregeric 0:b9444a40a999 20 * this list of conditions and the following disclaimer in the documentation
gregeric 0:b9444a40a999 21 * and/or other materials provided with the distribution.
gregeric 0:b9444a40a999 22 * 3. Neither the name of STMicroelectronics nor the names of its contributors
gregeric 0:b9444a40a999 23 * may be used to endorse or promote products derived from this software
gregeric 0:b9444a40a999 24 * without specific prior written permission.
gregeric 0:b9444a40a999 25 *
gregeric 0:b9444a40a999 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
gregeric 0:b9444a40a999 27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
gregeric 0:b9444a40a999 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
gregeric 0:b9444a40a999 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
gregeric 0:b9444a40a999 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
gregeric 0:b9444a40a999 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
gregeric 0:b9444a40a999 32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
gregeric 0:b9444a40a999 33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
gregeric 0:b9444a40a999 34 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
gregeric 0:b9444a40a999 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
gregeric 0:b9444a40a999 36 *
gregeric 0:b9444a40a999 37 ******************************************************************************
gregeric 0:b9444a40a999 38 */
gregeric 0:b9444a40a999 39 #ifdef TARGET_STM32L0
gregeric 0:b9444a40a999 40 /* Includes ------------------------------------------------------------------*/
gregeric 0:b9444a40a999 41 #include "mbed.h"
gregeric 0:b9444a40a999 42 #include "stm32l0xx_it.h"
gregeric 0:b9444a40a999 43 #include "motorcontrol.h"
gregeric 0:b9444a40a999 44
gregeric 0:b9444a40a999 45 /** @addtogroup Interrupt_Handlers
gregeric 0:b9444a40a999 46 * @{
gregeric 0:b9444a40a999 47 */
gregeric 0:b9444a40a999 48
gregeric 0:b9444a40a999 49 /* Private typedef -----------------------------------------------------------*/
gregeric 0:b9444a40a999 50 /* Private define ------------------------------------------------------------*/
gregeric 0:b9444a40a999 51 /* Private macro -------------------------------------------------------------*/
gregeric 0:b9444a40a999 52 /* Private variables ---------------------------------------------------------*/
gregeric 0:b9444a40a999 53 extern TIM_HandleTypeDef hTimPwm1;
gregeric 0:b9444a40a999 54 extern TIM_HandleTypeDef hTimPwm2;
gregeric 0:b9444a40a999 55 extern TIM_HandleTypeDef hTimPwm3;
gregeric 0:b9444a40a999 56
gregeric 0:b9444a40a999 57 /* Private function prototypes -----------------------------------------------*/
gregeric 0:b9444a40a999 58 /* Private functions ---------------------------------------------------------*/
gregeric 0:b9444a40a999 59
gregeric 0:b9444a40a999 60
gregeric 0:b9444a40a999 61 /******************************************************************************/
gregeric 0:b9444a40a999 62 /* Cortex-M0+ Processor Exceptions Handlers */
gregeric 0:b9444a40a999 63 /******************************************************************************/
gregeric 0:b9444a40a999 64
gregeric 0:b9444a40a999 65 /**
gregeric 0:b9444a40a999 66 * @brief This function handles NMI exception.
gregeric 0:b9444a40a999 67 * @param None
gregeric 0:b9444a40a999 68 * @retval None
gregeric 0:b9444a40a999 69 */
gregeric 0:b9444a40a999 70 void NMI_Handler(void)
gregeric 0:b9444a40a999 71 {
gregeric 0:b9444a40a999 72 }
gregeric 0:b9444a40a999 73
gregeric 0:b9444a40a999 74 /**
gregeric 0:b9444a40a999 75 * @brief This function handles Hard Fault exception.
gregeric 0:b9444a40a999 76 * @param None
gregeric 0:b9444a40a999 77 * @retval None
gregeric 0:b9444a40a999 78 */
gregeric 0:b9444a40a999 79 void HardFault_Handler(void)
gregeric 0:b9444a40a999 80 {
gregeric 0:b9444a40a999 81 /* Go to infinite loop when Hard Fault exception occurs */
gregeric 0:b9444a40a999 82 while (1)
gregeric 0:b9444a40a999 83 {
gregeric 0:b9444a40a999 84 }
gregeric 0:b9444a40a999 85 }
gregeric 0:b9444a40a999 86
gregeric 0:b9444a40a999 87 /**
gregeric 0:b9444a40a999 88 * @brief This function handles SVCall exception.
gregeric 0:b9444a40a999 89 * @param None
gregeric 0:b9444a40a999 90 * @retval None
gregeric 0:b9444a40a999 91 */
gregeric 0:b9444a40a999 92 void SVC_Handler(void)
gregeric 0:b9444a40a999 93 {
gregeric 0:b9444a40a999 94 }
gregeric 0:b9444a40a999 95
gregeric 0:b9444a40a999 96 /**
gregeric 0:b9444a40a999 97 * @brief This function handles Debug Monitor exception.
gregeric 0:b9444a40a999 98 * @param None
gregeric 0:b9444a40a999 99 * @retval None
gregeric 0:b9444a40a999 100 */
gregeric 0:b9444a40a999 101 void DebugMon_Handler(void)
gregeric 0:b9444a40a999 102 {
gregeric 0:b9444a40a999 103 }
gregeric 0:b9444a40a999 104
gregeric 0:b9444a40a999 105 /**
gregeric 0:b9444a40a999 106 * @brief This function handles PendSVC exception.
gregeric 0:b9444a40a999 107 * @param None
gregeric 0:b9444a40a999 108 * @retval None
gregeric 0:b9444a40a999 109 */
gregeric 0:b9444a40a999 110 void PendSV_Handler(void)
gregeric 0:b9444a40a999 111 {
gregeric 0:b9444a40a999 112 }
gregeric 0:b9444a40a999 113
gregeric 0:b9444a40a999 114 /**
gregeric 0:b9444a40a999 115 * @brief This function handles SysTick Handler.
gregeric 0:b9444a40a999 116 * @param None
gregeric 0:b9444a40a999 117 * @retval None
gregeric 0:b9444a40a999 118 */
gregeric 0:b9444a40a999 119 void SysTick_Handler(void)
gregeric 0:b9444a40a999 120 {
gregeric 0:b9444a40a999 121 HAL_IncTick();
gregeric 0:b9444a40a999 122 }
gregeric 0:b9444a40a999 123
gregeric 0:b9444a40a999 124 /******************************************************************************/
gregeric 0:b9444a40a999 125 /* STM32L0xx Peripherals Interrupt Handlers */
gregeric 0:b9444a40a999 126 /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
gregeric 0:b9444a40a999 127 /* available peripheral interrupt handler's name please refer to the startup */
gregeric 0:b9444a40a999 128 /* file (startup_stm32l0xx.s). */
gregeric 0:b9444a40a999 129 /******************************************************************************/
gregeric 0:b9444a40a999 130
gregeric 0:b9444a40a999 131 /**
gregeric 0:b9444a40a999 132 * @brief This function handles interrupt for External lines 4 to 15
gregeric 0:b9444a40a999 133 * @param None
gregeric 0:b9444a40a999 134 * @retval None
gregeric 0:b9444a40a999 135 */
gregeric 0:b9444a40a999 136 void EXTI4_15_IRQHandler(void)
gregeric 0:b9444a40a999 137 {
gregeric 0:b9444a40a999 138 HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10);
gregeric 0:b9444a40a999 139 }
gregeric 0:b9444a40a999 140
gregeric 0:b9444a40a999 141 /**
gregeric 0:b9444a40a999 142 * @brief This function handles TIM2 interrupt request.
gregeric 0:b9444a40a999 143 * @param None
gregeric 0:b9444a40a999 144 * @retval None
gregeric 0:b9444a40a999 145 */
gregeric 0:b9444a40a999 146 void TIM2_IRQHandler(void)
gregeric 0:b9444a40a999 147 {
gregeric 0:b9444a40a999 148 HAL_TIM_IRQHandler(&hTimPwm2);
gregeric 0:b9444a40a999 149 }
gregeric 0:b9444a40a999 150
gregeric 0:b9444a40a999 151 /**
gregeric 0:b9444a40a999 152 * @brief This function handles TIM22 interrupt request.
gregeric 0:b9444a40a999 153 * @param None
gregeric 0:b9444a40a999 154 * @retval None
gregeric 0:b9444a40a999 155 */
gregeric 0:b9444a40a999 156 void TIM22_IRQHandler(void)
gregeric 0:b9444a40a999 157 {
gregeric 0:b9444a40a999 158 HAL_TIM_IRQHandler(&hTimPwm1);
gregeric 0:b9444a40a999 159 }
gregeric 0:b9444a40a999 160
gregeric 0:b9444a40a999 161 /**
gregeric 0:b9444a40a999 162 * @brief This function handles TIM21 interrupt request.
gregeric 0:b9444a40a999 163 * @param None
gregeric 0:b9444a40a999 164 * @retval None
gregeric 0:b9444a40a999 165 */
gregeric 0:b9444a40a999 166 void TIM21_IRQHandler(void)
gregeric 0:b9444a40a999 167 {
gregeric 0:b9444a40a999 168 HAL_TIM_IRQHandler(&hTimPwm3);
gregeric 0:b9444a40a999 169 }
gregeric 0:b9444a40a999 170 /**
gregeric 0:b9444a40a999 171 * @brief This function handles PPP interrupt request.
gregeric 0:b9444a40a999 172 * @param None
gregeric 0:b9444a40a999 173 * @retval None
gregeric 0:b9444a40a999 174 */
gregeric 0:b9444a40a999 175 /*void PPP_IRQHandler(void)
gregeric 0:b9444a40a999 176 {
gregeric 0:b9444a40a999 177 }*/
gregeric 0:b9444a40a999 178
gregeric 0:b9444a40a999 179 /**
gregeric 0:b9444a40a999 180 * @}
gregeric 0:b9444a40a999 181 */
gregeric 0:b9444a40a999 182 #endif
gregeric 0:b9444a40a999 183 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/