stm8s_itc.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /**
  2. ******************************************************************************
  3. * @file stm8s_itc.h
  4. * @author MCD Application Team
  5. * @version V2.3.0
  6. * @date 16-June-2017
  7. * @brief This file contains all functions prototype and macros for the ITC peripheral.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. /* Define to prevent recursive inclusion -------------------------------------*/
  28. #ifndef __STM8S_ITC_H
  29. #define __STM8S_ITC_H
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm8s.h"
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @addtogroup ITC_Exported_Types
  34. * @{
  35. */
  36. /**
  37. * @brief ITC Interrupt Lines selection
  38. */
  39. typedef enum {
  40. ITC_IRQ_TLI = (uint8_t)0, /*!< Software interrupt */
  41. ITC_IRQ_AWU = (uint8_t)1, /*!< Auto wake up from halt interrupt */
  42. ITC_IRQ_CLK = (uint8_t)2, /*!< Clock controller interrupt */
  43. ITC_IRQ_PORTA = (uint8_t)3, /*!< Port A external interrupts */
  44. ITC_IRQ_PORTB = (uint8_t)4, /*!< Port B external interrupts */
  45. ITC_IRQ_PORTC = (uint8_t)5, /*!< Port C external interrupts */
  46. ITC_IRQ_PORTD = (uint8_t)6, /*!< Port D external interrupts */
  47. ITC_IRQ_PORTE = (uint8_t)7, /*!< Port E external interrupts */
  48. #if defined(STM8S208) || defined(STM8AF52Ax)
  49. ITC_IRQ_CAN_RX = (uint8_t)8, /*!< beCAN RX interrupt */
  50. ITC_IRQ_CAN_TX = (uint8_t)9, /*!< beCAN TX/ER/SC interrupt */
  51. #endif /*STM8S208 or STM8AF52Ax */
  52. #if defined(STM8S903) || defined(STM8AF622x)
  53. ITC_IRQ_PORTF = (uint8_t)8, /*!< Port F external interrupts */
  54. #endif /*STM8S903 or STM8AF622x */
  55. ITC_IRQ_SPI = (uint8_t)10, /*!< SPI interrupt */
  56. ITC_IRQ_TIM1_OVF = (uint8_t)11, /*!< TIM1 update/overflow/underflow/trigger/
  57. break interrupt*/
  58. ITC_IRQ_TIM1_CAPCOM = (uint8_t)12, /*!< TIM1 capture/compare interrupt */
  59. #if defined(STM8S903) || defined(STM8AF622x)
  60. ITC_IRQ_TIM5_OVFTRI = (uint8_t)13, /*!< TIM5 update/overflow/underflow/trigger/
  61. interrupt */
  62. ITC_IRQ_TIM5_CAPCOM = (uint8_t)14, /*!< TIM5 capture/compare interrupt */
  63. #else
  64. ITC_IRQ_TIM2_OVF = (uint8_t)13, /*!< TIM2 update /overflow interrupt */
  65. ITC_IRQ_TIM2_CAPCOM = (uint8_t)14, /*!< TIM2 capture/compare interrupt */
  66. #endif /*STM8S903 or STM8AF622x */
  67. ITC_IRQ_TIM3_OVF = (uint8_t)15, /*!< TIM3 update /overflow interrupt*/
  68. ITC_IRQ_TIM3_CAPCOM = (uint8_t)16, /*!< TIM3 update /overflow interrupt */
  69. #if defined(STM8S208) ||defined(STM8S207) || defined (STM8S007) || defined(STM8S103) || \
  70. defined(STM8S003) || defined(STM8S001) ||defined(STM8S903) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
  71. ITC_IRQ_UART1_TX = (uint8_t)17, /*!< UART1 TX interrupt */
  72. ITC_IRQ_UART1_RX = (uint8_t)18, /*!< UART1 RX interrupt */
  73. #endif /*STM8S208 or STM8S207 or STM8S007 or STM8S103 or STM8S003 or STM8S001 or STM8S903 or STM8AF52Ax or STM8AF62Ax */
  74. #if defined(STM8AF622x)
  75. ITC_IRQ_UART4_TX = (uint8_t)17, /*!< UART4 TX interrupt */
  76. ITC_IRQ_UART4_RX = (uint8_t)18, /*!< UART4 RX interrupt */
  77. #endif /*STM8AF622x */
  78. ITC_IRQ_I2C = (uint8_t)19, /*!< I2C interrupt */
  79. #if defined(STM8S105) || defined(STM8S005) || defined(STM8AF626x)
  80. ITC_IRQ_UART2_TX = (uint8_t)20, /*!< USART2 TX interrupt */
  81. ITC_IRQ_UART2_RX = (uint8_t)21, /*!< USART2 RX interrupt */
  82. #endif /*STM8S105 or STM8AF626x */
  83. #if defined(STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8AF52Ax) || defined(STM8AF62Ax)
  84. ITC_IRQ_UART3_TX = (uint8_t)20, /*!< USART3 TX interrupt */
  85. ITC_IRQ_UART3_RX = (uint8_t)21, /*!< USART3 RX interrupt */
  86. ITC_IRQ_ADC2 = (uint8_t)22, /*!< ADC2 interrupt */
  87. #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
  88. #if defined(STM8S105) || defined(STM8S005) || defined(STM8S103) || defined(STM8S003) || defined(STM8S001) || defined(STM8S903) || defined(STM8AF626x) || defined(STM8AF622x)
  89. ITC_IRQ_ADC1 = (uint8_t)22, /*!< ADC1 interrupt */
  90. #endif /*STM8S105 or STM8S005 or STM8S003 or STM8S103 or STM8S001 or STM8S903 or STM8AF626x or STM8AF622x */
  91. #if defined(STM8S903) || defined(STM8AF622x)
  92. ITC_IRQ_TIM6_OVFTRI = (uint8_t)23, /*!< TIM6 update/overflow/underflow/trigger/
  93. interrupt */
  94. #else
  95. ITC_IRQ_TIM4_OVF = (uint8_t)23, /*!< TIM4 update /overflow interrupt */
  96. #endif /*STM8S903 or STM8AF622x */
  97. ITC_IRQ_EEPROM_EEC = (uint8_t)24 /*!< Flash interrupt */
  98. } ITC_Irq_TypeDef;
  99. /**
  100. * @brief ITC Priority Levels selection
  101. */
  102. typedef enum {
  103. ITC_PRIORITYLEVEL_0 = (uint8_t)0x02, /*!< Software priority level 0 (cannot be written) */
  104. ITC_PRIORITYLEVEL_1 = (uint8_t)0x01, /*!< Software priority level 1 */
  105. ITC_PRIORITYLEVEL_2 = (uint8_t)0x00, /*!< Software priority level 2 */
  106. ITC_PRIORITYLEVEL_3 = (uint8_t)0x03 /*!< Software priority level 3 */
  107. } ITC_PriorityLevel_TypeDef;
  108. /**
  109. * @}
  110. */
  111. /* Exported constants --------------------------------------------------------*/
  112. /** @addtogroup ITC_Exported_Constants
  113. * @{
  114. */
  115. #define CPU_SOFT_INT_DISABLED ((uint8_t)0x28) /*!< Mask for I1 and I0 bits in CPU_CC register */
  116. /**
  117. * @}
  118. */
  119. /* Private macros ------------------------------------------------------------*/
  120. /**
  121. * @brief Macros used by the assert function in order to check the different functions parameters.
  122. * @addtogroup ITC_Private_Macros
  123. * @{
  124. */
  125. /* Used by assert function */
  126. #define IS_ITC_IRQ_OK(IRQ) ((IRQ) <= (uint8_t)24)
  127. /* Used by assert function */
  128. #define IS_ITC_PRIORITY_OK(PriorityValue) \
  129. (((PriorityValue) == ITC_PRIORITYLEVEL_0) || \
  130. ((PriorityValue) == ITC_PRIORITYLEVEL_1) || \
  131. ((PriorityValue) == ITC_PRIORITYLEVEL_2) || \
  132. ((PriorityValue) == ITC_PRIORITYLEVEL_3))
  133. /* Used by assert function */
  134. #define IS_ITC_INTERRUPTS_DISABLED (ITC_GetSoftIntStatus() == CPU_SOFT_INT_DISABLED)
  135. /**
  136. * @}
  137. */
  138. /* Exported functions ------------------------------------------------------- */
  139. /** @addtogroup ITC_Exported_Functions
  140. * @{
  141. */
  142. uint8_t ITC_GetCPUCC(void);
  143. void ITC_DeInit(void);
  144. uint8_t ITC_GetSoftIntStatus(void);
  145. void ITC_SetSoftwarePriority(ITC_Irq_TypeDef IrqNum, ITC_PriorityLevel_TypeDef PriorityValue);
  146. ITC_PriorityLevel_TypeDef ITC_GetSoftwarePriority(ITC_Irq_TypeDef IrqNum);
  147. /**
  148. * @}
  149. */
  150. #endif /* __STM8S_ITC_H */
  151. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/