st25r3916_irq.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 (uint32_t)(0xFFFFFFFFUL) /*!< All ST25R3916 interrupt sources */
  62. #define ST25R3916_IRQ_MASK_NONE (uint32_t)(0x00000000UL) /*!< No ST25R3916 interrupt source */
  63. /* Main interrupt register */
  64. #define ST25R3916_IRQ_MASK_OSC (uint32_t)(0x00000080U) /*!< ST25R3916 oscillator stable interrupt */
  65. #define ST25R3916_IRQ_MASK_FWL (uint32_t)(0x00000040U) /*!< ST25R3916 FIFO water level interrupt */
  66. #define ST25R3916_IRQ_MASK_RXS (uint32_t)(0x00000020U) /*!< ST25R3916 start of receive interrupt */
  67. #define ST25R3916_IRQ_MASK_RXE (uint32_t)(0x00000010U) /*!< ST25R3916 end of receive interrupt */
  68. #define ST25R3916_IRQ_MASK_TXE (uint32_t)(0x00000008U) /*!< ST25R3916 end of transmission interrupt */
  69. #define ST25R3916_IRQ_MASK_COL (uint32_t)(0x00000004U) /*!< ST25R3916 bit collision interrupt */
  70. #define ST25R3916_IRQ_MASK_RX_REST (uint32_t)(0x00000002U) /*!< ST25R3916 automatic reception restart interrupt */
  71. #define ST25R3916_IRQ_MASK_RFU (uint32_t)(0x00000001U) /*!< ST25R3916 RFU interrupt */
  72. /* Timer and NFC interrupt register */
  73. #define ST25R3916_IRQ_MASK_DCT (uint32_t)(0x00008000U) /*!< ST25R3916 termination of direct command interrupt. */
  74. #define ST25R3916_IRQ_MASK_NRE (uint32_t)(0x00004000U) /*!< ST25R3916 no-response timer expired interrupt */
  75. #define ST25R3916_IRQ_MASK_GPE (uint32_t)(0x00002000U) /*!< ST25R3916 general purpose timer expired interrupt */
  76. #define ST25R3916_IRQ_MASK_EON (uint32_t)(0x00001000U) /*!< ST25R3916 external field on interrupt */
  77. #define ST25R3916_IRQ_MASK_EOF (uint32_t)(0x00000800U) /*!< ST25R3916 external field off interrupt */
  78. #define ST25R3916_IRQ_MASK_CAC (uint32_t)(0x00000400U) /*!< ST25R3916 collision during RF collision avoidance interrupt */
  79. #define ST25R3916_IRQ_MASK_CAT (uint32_t)(0x00000200U) /*!< ST25R3916 minimum guard time expired interrupt */
  80. #define ST25R3916_IRQ_MASK_NFCT (uint32_t)(0x00000100U) /*!< ST25R3916 initiator bit rate recognised interrupt */
  81. /* Error and wake-up interrupt register */
  82. #define ST25R3916_IRQ_MASK_CRC (uint32_t)(0x00800000U) /*!< ST25R3916 CRC error interrupt */
  83. #define ST25R3916_IRQ_MASK_PAR (uint32_t)(0x00400000U) /*!< ST25R3916 parity error interrupt */
  84. #define ST25R3916_IRQ_MASK_ERR2 (uint32_t)(0x00200000U) /*!< ST25R3916 soft framing error interrupt */
  85. #define ST25R3916_IRQ_MASK_ERR1 (uint32_t)(0x00100000U) /*!< ST25R3916 hard framing error interrupt */
  86. #define ST25R3916_IRQ_MASK_WT (uint32_t)(0x00080000U) /*!< ST25R3916 wake-up interrupt */
  87. #define ST25R3916_IRQ_MASK_WAM (uint32_t)(0x00040000U) /*!< ST25R3916 wake-up due to amplitude interrupt */
  88. #define ST25R3916_IRQ_MASK_WPH (uint32_t)(0x00020000U) /*!< ST25R3916 wake-up due to phase interrupt */
  89. #define ST25R3916_IRQ_MASK_WCAP (uint32_t)(0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
  90. /* Passive Target Interrupt Register */
  91. #define ST25R3916_IRQ_MASK_PPON2 (uint32_t)(0x80000000U) /*!< ST25R3916 PPON2 Field on waiting Timer interrupt */
  92. #define ST25R3916_IRQ_MASK_SL_WL (uint32_t)(0x40000000U) /*!< ST25R3916 Passive target slot number water level interrupt */
  93. #define ST25R3916_IRQ_MASK_APON (uint32_t)(0x20000000U) /*!< ST25R3916 Anticollision done and Field On interrupt */
  94. #define ST25R3916_IRQ_MASK_RXE_PTA (uint32_t)(0x10000000U) /*!< ST25R3916 RXE with an automatic response interrupt */
  95. #define ST25R3916_IRQ_MASK_WU_F (uint32_t)(0x08000000U) /*!< ST25R3916 212/424b/s Passive target interrupt: Active */
  96. #define ST25R3916_IRQ_MASK_RFU2 (uint32_t)(0x04000000U) /*!< ST25R3916 RFU2 interrupt */
  97. #define ST25R3916_IRQ_MASK_WU_A_X (uint32_t)(0x02000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active* */
  98. #define ST25R3916_IRQ_MASK_WU_A (uint32_t)(0x01000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active */
  99. /*
  100. ******************************************************************************
  101. * GLOBAL FUNCTION PROTOTYPES
  102. ******************************************************************************
  103. */
  104. /*!
  105. *****************************************************************************
  106. * \brief Wait until an ST25R3916 interrupt occurs
  107. *
  108. * This function is used to access the ST25R3916 interrupt flags. Use this
  109. * to wait for max. \a tmo milliseconds for the \b first interrupt indicated
  110. * with mask \a mask to occur.
  111. *
  112. * \param[in] mask : mask indicating the interrupts to wait for.
  113. * \param[in] tmo : time in milliseconds until timeout occurs. If set to 0
  114. * the functions waits forever.
  115. *
  116. * \return : 0 if timeout occured otherwise a mask indicating the cleared
  117. * interrupts.
  118. *
  119. *****************************************************************************
  120. */
  121. uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo );
  122. /*!
  123. *****************************************************************************
  124. * \brief Get status for the given interrupt
  125. *
  126. * This function is used to check whether the interrupt given by \a mask
  127. * has occured. If yes the interrupt gets cleared. This function returns
  128. * only status bits which are inside \a mask.
  129. *
  130. * \param[in] mask : mask indicating the interrupt to check for.
  131. *
  132. * \return the mask of the interrupts occurred
  133. *
  134. *****************************************************************************
  135. */
  136. uint32_t st25r3916GetInterrupt( uint32_t mask );
  137. /*!
  138. *****************************************************************************
  139. * \brief Init the 3916 interrupt
  140. *
  141. * This function is used to check whether the interrupt given by \a mask
  142. * has occured.
  143. *
  144. *****************************************************************************
  145. */
  146. void st25r3916InitInterrupts( void );
  147. /*!
  148. *****************************************************************************
  149. * \brief Modifies the Interrupt
  150. *
  151. * This function modifies the interrupt
  152. *
  153. * \param[in] clr_mask : bit mask to be cleared on the interrupt mask
  154. * \param[in] set_mask : bit mask to be set on the interrupt mask
  155. *****************************************************************************
  156. */
  157. void st25r3916ModifyInterrupts( uint32_t clr_mask, uint32_t set_mask );
  158. /*!
  159. *****************************************************************************
  160. * \brief Checks received interrupts
  161. *
  162. * Checks received interrupts and saves the result into global params
  163. *****************************************************************************
  164. */
  165. void st25r3916CheckForReceivedInterrupts( void );
  166. /*!
  167. *****************************************************************************
  168. * \brief ISR Service routine
  169. *
  170. * This function modiefies the interupt
  171. *****************************************************************************
  172. */
  173. void st25r3916Isr( void );
  174. /*!
  175. *****************************************************************************
  176. * \brief Enable a given ST25R3916 Interrupt source
  177. *
  178. * This function enables all interrupts given by \a mask,
  179. * ST25R3916_IRQ_MASK_ALL enables all interrupts.
  180. *
  181. * \param[in] mask: mask indicating the interrupts to be enabled
  182. *
  183. *****************************************************************************
  184. */
  185. void st25r3916EnableInterrupts( uint32_t mask );
  186. /*!
  187. *****************************************************************************
  188. * \brief Disable one or more a given ST25R3916 Interrupt sources
  189. *
  190. * This function disables all interrupts given by \a mask. 0xff disables all.
  191. *
  192. * \param[in] mask: mask indicating the interrupts to be disabled.
  193. *
  194. *****************************************************************************
  195. */
  196. void st25r3916DisableInterrupts( uint32_t mask );
  197. /*!
  198. *****************************************************************************
  199. * \brief Clear all ST25R3916 irq flags
  200. *
  201. *****************************************************************************
  202. */
  203. void st25r3916ClearInterrupts( void );
  204. /*!
  205. *****************************************************************************
  206. * \brief Clears and then enables the given ST25R3916 Interrupt sources
  207. *
  208. * \param[in] mask: mask indicating the interrupts to be cleared and enabled
  209. *****************************************************************************
  210. */
  211. void st25r3916ClearAndEnableInterrupts( uint32_t mask );
  212. /*!
  213. *****************************************************************************
  214. * \brief Sets IRQ callback for the ST25R3916 interrupt
  215. *
  216. *****************************************************************************
  217. */
  218. void st25r3916IRQCallbackSet( void (*cb)( void ) );
  219. /*!
  220. *****************************************************************************
  221. * \brief Sets IRQ callback for the ST25R3916 interrupt
  222. *
  223. *****************************************************************************
  224. */
  225. void st25r3916IRQCallbackRestore( void );
  226. #endif /* ST25R3916_IRQ_H */
  227. /**
  228. * @}
  229. *
  230. * @}
  231. *
  232. * @}
  233. *
  234. * @}
  235. */