st25r3916_irq.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /******************************************************************************
  2. * \attention
  3. *
  4. * <h2><center>&copy; COPYRIGHT 2020 STMicroelectronics</center></h2>
  5. *
  6. * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
  7. * You may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * www.st.com/myliberty
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
  15. * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. ******************************************************************************/
  21. /*
  22. * PROJECT: ST25R3916 firmware
  23. * Revision:
  24. * LANGUAGE: ISO C99
  25. */
  26. /*! \file
  27. *
  28. * \author Gustavo Patricio
  29. *
  30. * \brief ST25R3916 Interrupt handling
  31. *
  32. * \addtogroup RFAL
  33. * @{
  34. *
  35. * \addtogroup RFAL-HAL
  36. * \brief RFAL Hardware Abstraction Layer
  37. * @{
  38. *
  39. * \addtogroup ST25R3916
  40. * \brief RFAL ST25R3916 Driver
  41. * @{
  42. *
  43. * \addtogroup ST25R3916_IRQ
  44. * \brief RFAL ST25R3916 IRQ
  45. * @{
  46. *
  47. */
  48. #ifndef ST25R3916_IRQ_H
  49. #define ST25R3916_IRQ_H
  50. /*
  51. ******************************************************************************
  52. * INCLUDES
  53. ******************************************************************************
  54. */
  55. #include "platform.h"
  56. /*
  57. ******************************************************************************
  58. * GLOBAL DEFINES
  59. ******************************************************************************
  60. */
  61. #define ST25R3916_IRQ_MASK_ALL \
  62. (uint32_t)(0xFFFFFFFFUL) /*!< All ST25R3916 interrupt sources */
  63. #define ST25R3916_IRQ_MASK_NONE \
  64. (uint32_t)(0x00000000UL) /*!< No ST25R3916 interrupt source */
  65. /* Main interrupt register */
  66. #define ST25R3916_IRQ_MASK_OSC \
  67. (uint32_t)(0x00000080U) /*!< ST25R3916 oscillator stable interrupt */
  68. #define ST25R3916_IRQ_MASK_FWL \
  69. (uint32_t)(0x00000040U) /*!< ST25R3916 FIFO water level interrupt */
  70. #define ST25R3916_IRQ_MASK_RXS \
  71. (uint32_t)(0x00000020U) /*!< ST25R3916 start of receive interrupt */
  72. #define ST25R3916_IRQ_MASK_RXE \
  73. (uint32_t)(0x00000010U) /*!< ST25R3916 end of receive interrupt */
  74. #define ST25R3916_IRQ_MASK_TXE \
  75. (uint32_t)(0x00000008U) /*!< ST25R3916 end of transmission interrupt */
  76. #define ST25R3916_IRQ_MASK_COL \
  77. (uint32_t)(0x00000004U) /*!< ST25R3916 bit collision interrupt */
  78. #define ST25R3916_IRQ_MASK_RX_REST \
  79. (uint32_t)(0x00000002U) /*!< ST25R3916 automatic reception restart interrupt */
  80. #define ST25R3916_IRQ_MASK_RFU \
  81. (uint32_t)(0x00000001U) /*!< ST25R3916 RFU interrupt */
  82. /* Timer and NFC interrupt register */
  83. #define ST25R3916_IRQ_MASK_DCT \
  84. (uint32_t)(0x00008000U) /*!< ST25R3916 termination of direct command interrupt. */
  85. #define ST25R3916_IRQ_MASK_NRE \
  86. (uint32_t)(0x00004000U) /*!< ST25R3916 no-response timer expired interrupt */
  87. #define ST25R3916_IRQ_MASK_GPE \
  88. (uint32_t)(0x00002000U) /*!< ST25R3916 general purpose timer expired interrupt */
  89. #define ST25R3916_IRQ_MASK_EON \
  90. (uint32_t)(0x00001000U) /*!< ST25R3916 external field on interrupt */
  91. #define ST25R3916_IRQ_MASK_EOF \
  92. (uint32_t)(0x00000800U) /*!< ST25R3916 external field off interrupt */
  93. #define ST25R3916_IRQ_MASK_CAC \
  94. (uint32_t)(0x00000400U) /*!< ST25R3916 collision during RF collision avoidance interrupt */
  95. #define ST25R3916_IRQ_MASK_CAT \
  96. (uint32_t)(0x00000200U) /*!< ST25R3916 minimum guard time expired interrupt */
  97. #define ST25R3916_IRQ_MASK_NFCT \
  98. (uint32_t)(0x00000100U) /*!< ST25R3916 initiator bit rate recognised interrupt */
  99. /* Error and wake-up interrupt register */
  100. #define ST25R3916_IRQ_MASK_CRC \
  101. (uint32_t)(0x00800000U) /*!< ST25R3916 CRC error interrupt */
  102. #define ST25R3916_IRQ_MASK_PAR \
  103. (uint32_t)(0x00400000U) /*!< ST25R3916 parity error interrupt */
  104. #define ST25R3916_IRQ_MASK_ERR2 \
  105. (uint32_t)(0x00200000U) /*!< ST25R3916 soft framing error interrupt */
  106. #define ST25R3916_IRQ_MASK_ERR1 \
  107. (uint32_t)(0x00100000U) /*!< ST25R3916 hard framing error interrupt */
  108. #define ST25R3916_IRQ_MASK_WT \
  109. (uint32_t)(0x00080000U) /*!< ST25R3916 wake-up interrupt */
  110. #define ST25R3916_IRQ_MASK_WAM \
  111. (uint32_t)(0x00040000U) /*!< ST25R3916 wake-up due to amplitude interrupt */
  112. #define ST25R3916_IRQ_MASK_WPH \
  113. (uint32_t)(0x00020000U) /*!< ST25R3916 wake-up due to phase interrupt */
  114. #define ST25R3916_IRQ_MASK_WCAP \
  115. (uint32_t)(0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
  116. /* Passive Target Interrupt Register */
  117. #define ST25R3916_IRQ_MASK_PPON2 \
  118. (uint32_t)(0x80000000U) /*!< ST25R3916 PPON2 Field on waiting Timer interrupt */
  119. #define ST25R3916_IRQ_MASK_SL_WL \
  120. (uint32_t)(0x40000000U) /*!< ST25R3916 Passive target slot number water level interrupt */
  121. #define ST25R3916_IRQ_MASK_APON \
  122. (uint32_t)(0x20000000U) /*!< ST25R3916 Anticollision done and Field On interrupt */
  123. #define ST25R3916_IRQ_MASK_RXE_PTA \
  124. (uint32_t)(0x10000000U) /*!< ST25R3916 RXE with an automatic response interrupt */
  125. #define ST25R3916_IRQ_MASK_WU_F \
  126. (uint32_t)(0x08000000U) /*!< ST25R3916 212/424b/s Passive target interrupt: Active */
  127. #define ST25R3916_IRQ_MASK_RFU2 \
  128. (uint32_t)(0x04000000U) /*!< ST25R3916 RFU2 interrupt */
  129. #define ST25R3916_IRQ_MASK_WU_A_X \
  130. (uint32_t)(0x02000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active* */
  131. #define ST25R3916_IRQ_MASK_WU_A \
  132. (uint32_t)(0x01000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active */
  133. /*
  134. ******************************************************************************
  135. * GLOBAL FUNCTION PROTOTYPES
  136. ******************************************************************************
  137. */
  138. /*!
  139. *****************************************************************************
  140. * \brief Wait until an ST25R3916 interrupt occurs
  141. *
  142. * This function is used to access the ST25R3916 interrupt flags. Use this
  143. * to wait for max. \a tmo milliseconds for the \b first interrupt indicated
  144. * with mask \a mask to occur.
  145. *
  146. * \param[in] mask : mask indicating the interrupts to wait for.
  147. * \param[in] tmo : time in milliseconds until timeout occurs. If set to 0
  148. * the functions waits forever.
  149. *
  150. * \return : 0 if timeout occured otherwise a mask indicating the cleared
  151. * interrupts.
  152. *
  153. *****************************************************************************
  154. */
  155. uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo);
  156. /*!
  157. *****************************************************************************
  158. * \brief Get status for the given interrupt
  159. *
  160. * This function is used to check whether the interrupt given by \a mask
  161. * has occured. If yes the interrupt gets cleared. This function returns
  162. * only status bits which are inside \a mask.
  163. *
  164. * \param[in] mask : mask indicating the interrupt to check for.
  165. *
  166. * \return the mask of the interrupts occurred
  167. *
  168. *****************************************************************************
  169. */
  170. uint32_t st25r3916GetInterrupt(uint32_t mask);
  171. /*!
  172. *****************************************************************************
  173. * \brief Init the 3916 interrupt
  174. *
  175. * This function is used to check whether the interrupt given by \a mask
  176. * has occured.
  177. *
  178. *****************************************************************************
  179. */
  180. void st25r3916InitInterrupts(void);
  181. /*!
  182. *****************************************************************************
  183. * \brief Modifies the Interrupt
  184. *
  185. * This function modifies the interrupt
  186. *
  187. * \param[in] clr_mask : bit mask to be cleared on the interrupt mask
  188. * \param[in] set_mask : bit mask to be set on the interrupt mask
  189. *****************************************************************************
  190. */
  191. void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask);
  192. /*!
  193. *****************************************************************************
  194. * \brief Checks received interrupts
  195. *
  196. * Checks received interrupts and saves the result into global params
  197. *****************************************************************************
  198. */
  199. void st25r3916CheckForReceivedInterrupts(void);
  200. /*!
  201. *****************************************************************************
  202. * \brief ISR Service routine
  203. *
  204. * This function modiefies the interupt
  205. *****************************************************************************
  206. */
  207. void st25r3916Isr(void);
  208. /*!
  209. *****************************************************************************
  210. * \brief Enable a given ST25R3916 Interrupt source
  211. *
  212. * This function enables all interrupts given by \a mask,
  213. * ST25R3916_IRQ_MASK_ALL enables all interrupts.
  214. *
  215. * \param[in] mask: mask indicating the interrupts to be enabled
  216. *
  217. *****************************************************************************
  218. */
  219. void st25r3916EnableInterrupts(uint32_t mask);
  220. /*!
  221. *****************************************************************************
  222. * \brief Disable one or more a given ST25R3916 Interrupt sources
  223. *
  224. * This function disables all interrupts given by \a mask. 0xff disables all.
  225. *
  226. * \param[in] mask: mask indicating the interrupts to be disabled.
  227. *
  228. *****************************************************************************
  229. */
  230. void st25r3916DisableInterrupts(uint32_t mask);
  231. /*!
  232. *****************************************************************************
  233. * \brief Clear all ST25R3916 irq flags
  234. *
  235. *****************************************************************************
  236. */
  237. void st25r3916ClearInterrupts(void);
  238. /*!
  239. *****************************************************************************
  240. * \brief Clears and then enables the given ST25R3916 Interrupt sources
  241. *
  242. * \param[in] mask: mask indicating the interrupts to be cleared and enabled
  243. *****************************************************************************
  244. */
  245. void st25r3916ClearAndEnableInterrupts(uint32_t mask);
  246. /*!
  247. *****************************************************************************
  248. * \brief Sets IRQ callback for the ST25R3916 interrupt
  249. *
  250. *****************************************************************************
  251. */
  252. void st25r3916IRQCallbackSet(void (*cb)(void));
  253. /*!
  254. *****************************************************************************
  255. * \brief Sets IRQ callback for the ST25R3916 interrupt
  256. *
  257. *****************************************************************************
  258. */
  259. void st25r3916IRQCallbackRestore(void);
  260. #endif /* ST25R3916_IRQ_H */
  261. /**
  262. * @}
  263. *
  264. * @}
  265. *
  266. * @}
  267. *
  268. * @}
  269. */