stm32l1xx_it.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_it.c
  4. * @brief Interrupt Service Routines.
  5. ******************************************************************************
  6. *
  7. * COPYRIGHT(c) 2019 STMicroelectronics
  8. *
  9. * Redistribution and use in source and binary forms, with or without modification,
  10. * are permitted provided that the following conditions are met:
  11. * 1. Redistributions of source code must retain the above copyright notice,
  12. * this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright notice,
  14. * this list of conditions and the following disclaimer in the documentation
  15. * and/or other materials provided with the distribution.
  16. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  17. * may be used to endorse or promote products derived from this software
  18. * without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. ******************************************************************************
  32. */
  33. /* Includes ------------------------------------------------------------------*/
  34. #define STM32L1XX_IT_C
  35. #include "core/config.h"
  36. #include "core/main.h"
  37. #include "stm32l1xx_it.h"
  38. #include "drivers/i2c/i2c.h"
  39. #include "drivers/adc/adc.h"
  40. #if CONFIG_AUTOMAT_MODE
  41. #include "app/automat/automat.h"
  42. #if CONFIG_AUTOMAT_MODE_USB_POWERBANK
  43. #include "app/usbapp/usb_application_enumspy.h"
  44. #endif
  45. #endif
  46. #include "app/led/led.h"
  47. #ifdef STM32L1XX_IT_C
  48. extern PCD_HandleTypeDef hpcd_USB_FS;
  49. #endif
  50. /******************************************************************************/
  51. /* Cortex-M3 Processor Interruption and Exception Handlers */
  52. /******************************************************************************/
  53. /**
  54. * @brief This function handles Non maskable interrupt.
  55. */
  56. void NMI_Handler(void)
  57. {
  58. }
  59. /**
  60. * @brief This function handles Hard fault interrupt.
  61. */
  62. void HardFault_Handler(void)
  63. {
  64. while (1)
  65. {
  66. HAL_NVIC_SystemReset();
  67. }
  68. }
  69. /**
  70. * @brief This function handles Memory management fault.
  71. */
  72. void MemManage_Handler(void)
  73. {
  74. while (1)
  75. {
  76. HAL_NVIC_SystemReset();
  77. }
  78. }
  79. /**
  80. * @brief This function handles Pre-fetch fault, memory access fault.
  81. */
  82. void BusFault_Handler(void)
  83. {
  84. while (1)
  85. {
  86. HAL_NVIC_SystemReset();
  87. }
  88. }
  89. /**
  90. * @brief This function handles Undefined instruction or illegal state.
  91. */
  92. void UsageFault_Handler(void)
  93. {
  94. while (1)
  95. {
  96. HAL_NVIC_SystemReset();
  97. }
  98. }
  99. /**
  100. * @brief This function handles System service call via SWI instruction.
  101. */
  102. void SVC_Handler(void)
  103. {
  104. }
  105. /**
  106. * @brief This function handles Debug monitor.
  107. */
  108. void DebugMon_Handler(void)
  109. {
  110. }
  111. /**
  112. * @brief This function handles Pendable request for system service.
  113. */
  114. void PendSV_Handler(void)
  115. {
  116. }
  117. /**
  118. * @brief This function handles System tick timer.
  119. */
  120. void SysTick_Handler(void)
  121. {
  122. #if CONFIG_SYSTICK_DEBUG
  123. CONFIG_SYSTICK_DEBUG_SETPIN
  124. #endif
  125. #if CONFIG_AUTOMAT_MODE
  126. ACMAutomatHandle.Tick(); // moved from the bottom
  127. #endif
  128. #if CONFIG_SYSTICK_BOOST_MULTIPLIER && (CONFIG_SYSTICK == CONFIG_SYSTICK_NORMAL)
  129. static int prescaller = 0;
  130. if( ++prescaller >= CONFIG_SYSTICK_BOOST_MULTIPLIER )
  131. {
  132. #if CONFIG_HALTICK_DEBUG
  133. CONFIG_HALTICK_DEBUG_SETPIN
  134. #endif
  135. HAL_IncTick();
  136. #if CONFIG_AUTOMAT_MODE && CONFIG_AUTOMAT_MODE_USB_POWERBANK
  137. UsbApplicationEnumSpyHandle.timerTickEventIrq1ms();
  138. #endif
  139. #if CONFIG_LEDS
  140. LEDHandle.Tick();
  141. #endif
  142. prescaller = 0;
  143. #if CONFIG_HALTICK_DEBUG
  144. CONFIG_HALTICK_DEBUG_CLRPIN
  145. #endif
  146. }
  147. #else
  148. HAL_IncTick();
  149. #if CONFIG_AUTOMAT_MODE && CONFIG_AUTOMAT_MODE_USB_POWERBANK
  150. UsbApplicationEnumSpyHandle.timerTickEventIrq1ms();
  151. #endif
  152. #if CONFIG_LEDS
  153. LEDHandle.Tick();
  154. #endif
  155. #endif
  156. #if CONFIG_SYSTICK_DEBUG
  157. CONFIG_SYSTICK_DEBUG_CLRPIN
  158. #endif
  159. }
  160. /******************************************************************************/
  161. /* STM32L1xx Peripheral Interrupt Handlers */
  162. /* Add here the Interrupt Handlers for the used peripherals. */
  163. /* For the available peripheral interrupt handler names, */
  164. /* please refer to the startup file (startup_stm32l1xx.s). */
  165. /******************************************************************************/
  166. // USB Interrupt Event Routing
  167. void USB_LP_IRQHandler(void)
  168. {
  169. #if CONFIG_USB_DEBUGPIN
  170. CONFIG_USB_DEBUGPIN_SETPIN
  171. #endif
  172. HAL_PCD_IRQHandler(&hpcd_USB_FS);
  173. #if CONFIG_USB_DEBUGPIN
  174. CONFIG_USB_DEBUGPIN_CLRPIN
  175. #endif
  176. }
  177. #if CONFIG_PERIF_TSENSI2C == CONFIG_PERIF_I2C1
  178. // I2C Interrupt Event Routing
  179. void I2C1_EV_IRQHandler(void)
  180. {
  181. HAL_I2C_EV_IRQHandler( &i2c_handle );
  182. }
  183. #elif CONFIG_PERIF_TSENSI2C == CONFIG_PERIF_I2C2
  184. // I2C Interrupt Event Routing
  185. void I2C2_EV_IRQHandler(void)
  186. {
  187. HAL_I2C_EV_IRQHandler( &i2c_handle );
  188. }
  189. #else
  190. #error Invalid I2C specified in 'config_pins.h': see 'CONFIG_PERIF_TSENSI2C'
  191. #endif
  192. // ADC Interrupt Event Routing
  193. #if CONFIG_VBATMON
  194. void ADC1_IRQHandler()
  195. {
  196. HAL_ADC_IRQHandler( &Adc1Handle );
  197. }
  198. #endif
  199. // EXTI 10..15 Interrupt Event Routing
  200. void EXTI15_10_IRQHandler()
  201. {
  202. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10);
  203. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_11);
  204. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_12);
  205. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
  206. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14);
  207. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_15);
  208. }
  209. // EXTI 5..9 Interrupt Event Routing
  210. void EXTI9_5_IRQHandler()
  211. {
  212. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5);
  213. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_6);
  214. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7);
  215. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
  216. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9);
  217. HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10);
  218. }
  219. // EXTI 4 Interrupt Event Routing
  220. void EXTI4_IRQHandler()
  221. {
  222. HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_4 );
  223. }
  224. // EXTI 3 Interrupt Event Routing
  225. void EXTI3_IRQHandler()
  226. {
  227. HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_3 );
  228. }
  229. // EXTI 2 Interrupt Event Routing
  230. void EXTI2_IRQHandler()
  231. {
  232. HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_2 );
  233. }
  234. // EXTI 1 Interrupt Event Routing
  235. void EXTI1_IRQHandler()
  236. {
  237. HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_1 );
  238. }
  239. // EXTI 0 Interrupt Event Routing
  240. void EXTI0_IRQHandler()
  241. {
  242. HAL_GPIO_EXTI_IRQHandler( GPIO_PIN_0 );
  243. }
  244. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/