stm8l15x_itc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /**
  2. ******************************************************************************
  3. * @file stm8l15x_itc.h
  4. * @author MCD Application Team
  5. * @version V1.6.1
  6. * @date 30-September-2014
  7. * @brief This file contains all the functions prototypes for the ITC firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM8L15x_ITC_H
  30. #define __STM8L15x_ITC_H
  31. /* Includes ------------------------------------------------------------------*/
  32. #include "stm8l15x.h"
  33. /** @addtogroup STM8L15x_StdPeriph_Driver
  34. * @{
  35. */
  36. /** @addtogroup ITC
  37. * @{
  38. */
  39. /* Exported types ------------------------------------------------------------*/
  40. /** @defgroup ITC_Exported_Types
  41. * @{
  42. */
  43. /** @defgroup ITC_Interrupt_Lines_selection
  44. * @{
  45. */
  46. typedef enum {
  47. FLASH_IRQn = (uint8_t)1, /*!< Flash interrupt */
  48. DMA1_CHANNEL0_1_IRQn = (uint8_t)2, /*!< DMA Channels 0/1 */
  49. DMA1_CHANNEL2_3_IRQn = (uint8_t)3, /*!< DMA Channels 2/3 */
  50. EXTIE_F_PVD_IRQn = (uint8_t)5, /*!< GPIOE/F and PVD interrupt */
  51. EXTI0_IRQn = (uint8_t)8, /*!< PIN0 interrupt */
  52. EXTI1_IRQn = (uint8_t)9, /*!< PIN1 interrupt */
  53. EXTI2_IRQn = (uint8_t)10, /*!< PIN2 interrupt */
  54. EXTI3_IRQn = (uint8_t)11, /*!< PIN3 interrupt */
  55. EXTI4_IRQn = (uint8_t)12, /*!< PIN4 interrupt */
  56. EXTI5_IRQn = (uint8_t)13, /*!< PIN5 interrupt */
  57. EXTI6_IRQn = (uint8_t)14, /*!< PIN6 interrupt */
  58. EXTI7_IRQn = (uint8_t)15, /*!< PIN7 interrupt */
  59. ADC1_COMP_IRQn = (uint8_t)18, /*!< ADC1/Comparator interrupt */
  60. TIM4_UPD_OVF_TRG_IRQn = (uint8_t)25, /*!< TIM4 Update/Overflow/Trigger interrupt */
  61. SPI1_IRQn = (uint8_t)26, /*!< SPI1 interrupt */
  62. #if defined (STM8L15X_MD) || defined (STM8L05X_MD_VL) || defined (STM8AL31_L_MD)
  63. RTC_IRQn = (uint8_t)4, /*!< RTC interrupt */
  64. EXTIB_IRQn = (uint8_t)6, /*!< GPIOB interrupt */
  65. EXTID_IRQn = (uint8_t)7, /*!< GPIOD interrupt */
  66. LCD_IRQn = (uint8_t)16, /*!< LCD Driver interrupt */
  67. SWITCH_CSS_BREAK_DAC_IRQn = (uint8_t)17, /*!< Clock switch/CSS interrupt/TIM1 Break /DAC interrupt */
  68. TIM2_UPD_OVF_TRG_BRK_IRQn = (uint8_t)19, /*!< TIM2 Update/Overflow/Trigger/Break interrupt*/
  69. TIM2_CC_IRQn = (uint8_t)20, /*!< TIM2 input captute/output compare interrupt */
  70. TIM3_UPD_OVF_TRG_BRK_IRQn = (uint8_t)21, /*!< TIM3 Update/Overflow/Trigger/Break interrupt */
  71. TIM3_CC_IRQn = (uint8_t)22, /*!< TIM3 capture/compare interrupt */
  72. TIM1_UPD_OVF_TRG_IRQn = (uint8_t)23, /*!< TIM1 TIM1 Update/Overflow/Trigger interrupt */
  73. TIM1_CC_IRQn = (uint8_t)24, /*!< TIM1 capture/compare interrupt */
  74. USART1_TX_IRQn = (uint8_t)27, /*!< USART1 TX interrupt */
  75. USART1_RX_IRQn = (uint8_t)28, /*!< USART1 RX interrupt */
  76. I2C1_IRQn = (uint8_t)29 /*!< I2C1 interrupt */
  77. #elif defined (STM8L15X_LD) || defined (STM8L05X_LD_VL)
  78. RTC_CSSLSE_IRQn = (uint8_t)4, /*!< RTC / CSSLSE interrupt */
  79. EXTIB_IRQn = (uint8_t)6, /*!< GPIOB interrupt */
  80. EXTID_IRQn = (uint8_t)7, /*!< GPIOD interrupt */
  81. SWITCH_CSS_IRQn = (uint8_t)17, /*!< Clock switch/CSS interrupt/TIM1 Break /DAC interrupt */
  82. TIM2_UPD_OVF_TRG_BRK_IRQn = (uint8_t)19, /*!< TIM2 Update/Overflow/Trigger/Break interrupt*/
  83. TIM2_CC_IRQn = (uint8_t)20, /*!< TIM2 input captute/output compare interrupt */
  84. TIM3_UPD_OVF_TRG_BRK_IRQn = (uint8_t)21, /*!< TIM3 Update/Overflow/Trigger/Break interrupt */
  85. TIM3_CC_IRQn = (uint8_t)22, /*!< TIM3 capture/compare interrupt */
  86. USART1_TX_IRQn = (uint8_t)27, /*!< USART1 TX interrupt */
  87. USART1_RX_IRQn = (uint8_t)28, /*!< USART1 RX interrupt */
  88. I2C1_IRQn = (uint8_t)29 /*!< I2C1 interrupt */
  89. #elif defined (STM8L15X_HD) || defined (STM8L15X_MDP) || defined (STM8L05X_HD_VL)
  90. RTC_CSSLSE_IRQn = (uint8_t)4, /*!< RTC / CSSLSE interrupt */
  91. EXTIB_G_IRQn = (uint8_t)6, /*!< GPIOB / G interrupt */
  92. EXTID_H_IRQn = (uint8_t)7, /*!< GPIOD / H interrupt */
  93. LCD_AES_IRQn = (uint8_t)16, /*!< LCD / AES interrupt */
  94. SWITCH_CSS_BREAK_DAC_IRQn = (uint8_t)17, /*!< Clock switch/CSS interrupt/TIM1 Break /DAC interrupt */
  95. TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQn = (uint8_t)19, /*!< TIM2 Update/Overflow/Trigger/Break /USART2 TX interrupt*/
  96. TIM2_CC_USART2_RX_IRQn = (uint8_t)20, /*!< TIM2 capture/compare / USART2 RX interrupt */
  97. TIM3_UPD_OVF_TRG_BRK_USART3_TX_IRQn = (uint8_t)21, /*!< TIM3 Update/Overflow/Trigger/Break / USART3 TX interrupt */
  98. TIM3_CC_USART3_RX_IRQn = (uint8_t)22, /*!< TIM3 capture/compare / USART3 RX interrupt */
  99. TIM1_UPD_OVF_TRG_IRQn = (uint8_t)23, /*!< TIM1 TIM1 Update/Overflow/Trigger interrupt */
  100. TIM1_CC_IRQn = (uint8_t)24, /*!< TIM1 capture/compare interrupt */
  101. USART1_TX_TIM5_UPD_OVF_TRG_BRK_IRQn = (uint8_t)27, /*!< USART1 TX / TIM5 Update/Overflow/Trigger/Break interrupt */
  102. USART1_RX_TIM5_CC_IRQn = (uint8_t)28, /*!< USART1 RX / TIM5 capture/compare interrupt */
  103. I2C1_SPI2_IRQn = (uint8_t)29 /*!< I2C1 / SPI2 interrupt */
  104. #endif /* STM8L15X_MD */
  105. }IRQn_TypeDef;
  106. #if defined (STM8L15X_MD) || defined (STM8L05X_MD_VL) || defined (STM8AL31_L_MD)
  107. #define IS_ITC_IRQ(Irq) (((Irq) == FLASH_IRQn) || \
  108. ((Irq) == DMA1_CHANNEL0_1_IRQn) || \
  109. ((Irq) == DMA1_CHANNEL2_3_IRQn) || \
  110. ((Irq) == RTC_IRQn) || \
  111. ((Irq) == EXTIE_F_PVD_IRQn) || \
  112. ((Irq) == EXTIB_IRQn) || \
  113. ((Irq) == EXTID_IRQn) || \
  114. ((Irq) == EXTI0_IRQn) || \
  115. ((Irq) == EXTI1_IRQn) || \
  116. ((Irq) == EXTI2_IRQn) || \
  117. ((Irq) == EXTI3_IRQn) || \
  118. ((Irq) == EXTI4_IRQn) || \
  119. ((Irq) == EXTI5_IRQn) || \
  120. ((Irq) == EXTI6_IRQn) || \
  121. ((Irq) == EXTI7_IRQn) || \
  122. ((Irq) == LCD_IRQn) || \
  123. ((Irq) == SWITCH_CSS_BREAK_DAC_IRQn) || \
  124. ((Irq) == ADC1_COMP_IRQn) || \
  125. ((Irq) == TIM2_UPD_OVF_TRG_BRK_IRQn) || \
  126. ((Irq) == TIM2_CC_IRQn) || \
  127. ((Irq) == TIM3_UPD_OVF_TRG_BRK_IRQn) || \
  128. ((Irq) == TIM3_CC_IRQn) || \
  129. ((Irq) == TIM1_UPD_OVF_TRG_IRQn) || \
  130. ((Irq) == TIM1_CC_IRQn) || \
  131. ((Irq) == TIM4_UPD_OVF_TRG_IRQn) || \
  132. ((Irq) == SPI1_IRQn) || \
  133. ((Irq) == USART1_TX_IRQn) || \
  134. ((Irq) == USART1_RX_IRQn) || \
  135. ((Irq) == I2C1_IRQn))
  136. #elif defined (STM8L15X_LD) || defined (STM8L05X_LD_VL)
  137. #define IS_ITC_IRQ(Irq) (((Irq) == FLASH_IRQn) || \
  138. ((Irq) == DMA1_CHANNEL0_1_IRQn) || \
  139. ((Irq) == DMA1_CHANNEL2_3_IRQn) || \
  140. ((Irq) == RTC_CSSLSE_IRQn) || \
  141. ((Irq) == EXTIE_F_PVD_IRQn) || \
  142. ((Irq) == EXTIB_IRQn) || \
  143. ((Irq) == EXTID_IRQn) || \
  144. ((Irq) == EXTI0_IRQn) || \
  145. ((Irq) == EXTI1_IRQn) || \
  146. ((Irq) == EXTI2_IRQn) || \
  147. ((Irq) == EXTI3_IRQn) || \
  148. ((Irq) == EXTI4_IRQn) || \
  149. ((Irq) == EXTI5_IRQn) || \
  150. ((Irq) == EXTI6_IRQn) || \
  151. ((Irq) == EXTI7_IRQn) || \
  152. ((Irq) == SWITCH_CSS_IRQn) || \
  153. ((Irq) == ADC1_COMP_IRQn) || \
  154. ((Irq) == TIM2_UPD_OVF_TRG_BRK_IRQn) || \
  155. ((Irq) == TIM2_CC_IRQn) || \
  156. ((Irq) == TIM3_UPD_OVF_TRG_BRK_IRQn) || \
  157. ((Irq) == TIM3_CC_IRQn) || \
  158. ((Irq) == TIM4_UPD_OVF_TRG_IRQn) || \
  159. ((Irq) == SPI1_IRQn) || \
  160. ((Irq) == USART1_TX_IRQn) || \
  161. ((Irq) == USART1_RX_IRQn) || \
  162. ((Irq) == I2C1_IRQn))
  163. #elif defined (STM8L15X_HD) || defined (STM8L15X_MDP) || defined (STM8L05X_HD_VL)
  164. #define IS_ITC_IRQ(Irq) (((Irq) == FLASH_IRQn) || \
  165. ((Irq) == DMA1_CHANNEL0_1_IRQn) || \
  166. ((Irq) == DMA1_CHANNEL2_3_IRQn) || \
  167. ((Irq) == RTC_CSSLSE_IRQn) || \
  168. ((Irq) == EXTIE_F_PVD_IRQn) || \
  169. ((Irq) == EXTIB_G_IRQn) || \
  170. ((Irq) == EXTID_H_IRQn) || \
  171. ((Irq) == EXTI0_IRQn) || \
  172. ((Irq) == EXTI1_IRQn) || \
  173. ((Irq) == EXTI2_IRQn) || \
  174. ((Irq) == EXTI3_IRQn) || \
  175. ((Irq) == EXTI4_IRQn) || \
  176. ((Irq) == EXTI5_IRQn) || \
  177. ((Irq) == EXTI6_IRQn) || \
  178. ((Irq) == EXTI7_IRQn) || \
  179. ((Irq) == LCD_AES_IRQn) || \
  180. ((Irq) == SWITCH_CSS_BREAK_DAC_IRQn) || \
  181. ((Irq) == ADC1_COMP_IRQn) || \
  182. ((Irq) == TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQn) || \
  183. ((Irq) == TIM2_CC_USART2_RX_IRQn) || \
  184. ((Irq) == TIM3_UPD_OVF_TRG_BRK_USART3_TX_IRQn) || \
  185. ((Irq) == TIM3_CC_USART3_RX_IRQn) || \
  186. ((Irq) == TIM1_UPD_OVF_TRG_IRQn) || \
  187. ((Irq) == TIM1_CC_IRQn) || \
  188. ((Irq) == TIM4_UPD_OVF_TRG_IRQn) || \
  189. ((Irq) == SPI1_IRQn) || \
  190. ((Irq) == USART1_TX_TIM5_UPD_OVF_TRG_BRK_IRQn) || \
  191. ((Irq) == USART1_RX_TIM5_CC_IRQn) || \
  192. ((Irq) == I2C1_SPI2_IRQn))
  193. #endif /* STM8L15X_MD */
  194. /**
  195. * @}
  196. */
  197. /** @defgroup ITC_Priority_Level_selection
  198. * @{
  199. */
  200. typedef enum {
  201. ITC_PriorityLevel_0 = (uint8_t)0x02, /*!< Software priority level 0 (cannot be written) */
  202. ITC_PriorityLevel_1 = (uint8_t)0x01, /*!< Software priority level 1 */
  203. ITC_PriorityLevel_2 = (uint8_t)0x00, /*!< Software priority level 2 */
  204. ITC_PriorityLevel_3 = (uint8_t)0x03 /*!< Software priority level 3 */
  205. } ITC_PriorityLevel_TypeDef;
  206. #define IS_ITC_PRIORITY(PriorityValue) \
  207. (((PriorityValue) == ITC_PriorityLevel_0) || \
  208. ((PriorityValue) == ITC_PriorityLevel_1) || \
  209. ((PriorityValue) == ITC_PriorityLevel_2) || \
  210. ((PriorityValue) == ITC_PriorityLevel_3))
  211. /**
  212. * @}
  213. */
  214. /**
  215. * @}
  216. */
  217. /* Exported constants --------------------------------------------------------*/
  218. /** @defgroup ITC_Exported_Constants
  219. * @{
  220. */
  221. #define CPU_SOFT_INT_DISABLED ((uint8_t)0x28) /*!< Mask for I1 and I0 bits in CPU_CC register */
  222. /**
  223. * @}
  224. */
  225. /* Exported macros -----------------------------------------------------------*/
  226. /** @defgroup ITC_Exported_Constants
  227. * @{
  228. */
  229. #define IS_ITC_INTERRUPTS_DISABLED (ITC_GetSoftIntStatus() == CPU_SOFT_INT_DISABLED)
  230. /**
  231. * @}
  232. */
  233. /* Exported functions ------------------------------------------------------- */
  234. /* Function used to set the ITC configuration to the default reset state ******/
  235. void ITC_DeInit(void);
  236. /* ITC configuration and management functions ******/
  237. uint8_t ITC_GetCPUCC(void);
  238. uint8_t ITC_GetSoftIntStatus(void);
  239. void ITC_SetSoftwarePriority(IRQn_TypeDef IRQn, ITC_PriorityLevel_TypeDef ITC_PriorityLevel);
  240. ITC_PriorityLevel_TypeDef ITC_GetSoftwarePriority(IRQn_TypeDef IRQn);
  241. #endif /* __STM8L15x_ITC_H */
  242. /**
  243. * @}
  244. */
  245. /**
  246. * @}
  247. */
  248. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/