nrf_nfct.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  1. /**
  2. * Copyright (c) 2018 - 2019, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef NRF_NFCT_H__
  41. #define NRF_NFCT_H__
  42. #include <nrfx.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @defgroup nrf_nfct_hal NFCT HAL
  48. * @{
  49. * @ingroup nrf_nfct
  50. *
  51. * @brief Hardware access layer (HAL) for the Near Field Communication Tag (NFCT) peripheral.
  52. */
  53. #define NRF_NFCT_CRC_SIZE 2 /**< CRC size in bytes. */
  54. #define NRF_NFCT_DISABLE_ALL_INT 0xFFFFFFFF /**< Value to disable all interrupts. */
  55. /**
  56. * @brief NFCT tasks
  57. */
  58. typedef enum /*lint -save -e30 */
  59. {
  60. NRF_NFCT_TASK_ACTIVATE = offsetof(NRF_NFCT_Type, TASKS_ACTIVATE), /**< Activate the NFCT peripheral for the incoming and outgoing frames, change state to activated. */
  61. NRF_NFCT_TASK_DISABLE = offsetof(NRF_NFCT_Type, TASKS_DISABLE), /**< Disable the NFCT peripheral. */
  62. NRF_NFCT_TASK_SENSE = offsetof(NRF_NFCT_Type, TASKS_SENSE), /**< Enable the NFC sense field mode, change state to sense mode. */
  63. NRF_NFCT_TASK_STARTTX = offsetof(NRF_NFCT_Type, TASKS_STARTTX), /**< Start the transmission of an outgoing frame, change state to transmit. */
  64. NRF_NFCT_TASK_ENABLERXDATA = offsetof(NRF_NFCT_Type, TASKS_ENABLERXDATA), /**< Initialize EasyDMA for receive. */
  65. NRF_NFCT_TASK_GOIDLE = offsetof(NRF_NFCT_Type, TASKS_GOIDLE), /**< Force state machine to the IDLE state. */
  66. NRF_NFCT_TASK_GOSLEEP = offsetof(NRF_NFCT_Type, TASKS_GOSLEEP), /**< Force state machine to the SLEEP_A state. */
  67. } nrf_nfct_task_t; /*lint -restore */
  68. /**
  69. * @brief NFCT events
  70. */
  71. typedef enum /*lint -save -e30 */
  72. {
  73. NRF_NFCT_EVENT_READY = offsetof(NRF_NFCT_Type, EVENTS_READY), /**< The NFCT peripheral is ready to receive and send frames. */
  74. NRF_NFCT_EVENT_FIELDDETECTED = offsetof(NRF_NFCT_Type, EVENTS_FIELDDETECTED), /**< Remote NFC field is detected. */
  75. NRF_NFCT_EVENT_FIELDLOST = offsetof(NRF_NFCT_Type, EVENTS_FIELDLOST), /**< Remote NFC field is lost. */
  76. NRF_NFCT_EVENT_TXFRAMESTART = offsetof(NRF_NFCT_Type, EVENTS_TXFRAMESTART), /**< The start of the first symbol of a transmitted frame. */
  77. NRF_NFCT_EVENT_TXFRAMEEND = offsetof(NRF_NFCT_Type, EVENTS_TXFRAMEEND), /**< The end of the last transmitted on-air symbol of a frame. */
  78. NRF_NFCT_EVENT_RXFRAMESTART = offsetof(NRF_NFCT_Type, EVENTS_RXFRAMESTART), /**< The end of the first symbol of a received frame. */
  79. NRF_NFCT_EVENT_RXFRAMEEND = offsetof(NRF_NFCT_Type, EVENTS_RXFRAMEEND), /**< Received data was checked (CRC, parity) and transferred to RAM, and EasyDMA ended accessing the RX buffer. */
  80. NRF_NFCT_EVENT_ERROR = offsetof(NRF_NFCT_Type, EVENTS_ERROR), /**< NFC error reported. The ERRORSTATUS register contains details on the source of the error. */
  81. NRF_NFCT_EVENT_RXERROR = offsetof(NRF_NFCT_Type, EVENTS_RXERROR), /**< NFC RX frame error reported. The FRAMESTATUS.RX register contains details on the source of the error. */
  82. NRF_NFCT_EVENT_ENDRX = offsetof(NRF_NFCT_Type, EVENTS_ENDRX), /**< RX buffer (as defined by PACKETPTR and MAXLEN) in Data RAM full. */
  83. NRF_NFCT_EVENT_ENDTX = offsetof(NRF_NFCT_Type, EVENTS_ENDTX), /**< Transmission of data in RAM ended, and EasyDMA ended accessing the TX buffer. */
  84. NRF_NFCT_EVENT_AUTOCOLRESSTARTED = offsetof(NRF_NFCT_Type, EVENTS_AUTOCOLRESSTARTED), /**< Auto collision resolution process started. */
  85. NRF_NFCT_EVENT_COLLISION = offsetof(NRF_NFCT_Type, EVENTS_COLLISION), /**< NFC auto collision resolution error reported. */
  86. NRF_NFCT_EVENT_SELECTED = offsetof(NRF_NFCT_Type, EVENTS_SELECTED), /**< NFC auto collision resolution successfully completed. */
  87. NRF_NFCT_EVENT_STARTED = offsetof(NRF_NFCT_Type, EVENTS_STARTED), /**< EasyDMA is ready to receive or send frames. */
  88. } nrf_nfct_event_t; /*lint -restore */
  89. /**
  90. * @brief NFCT shorts
  91. */
  92. typedef enum
  93. {
  94. NRF_NFCT_SHORT_FIELDDETECTED_ACTIVATE_MASK = NFCT_SHORTS_FIELDDETECTED_ACTIVATE_Msk, /**< Shortcut between the FIELDDETECTED event and the ACTIVATE task. */
  95. NRF_NFCT_SHORT_FIELDLOST_SENSE_MASK = NFCT_SHORTS_FIELDLOST_SENSE_Msk, /**< Shortcut between the FIELDLOST event and the SENSE task. */
  96. #if defined(NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Msk) || defined(__NRFX_DOXYGEN__)
  97. NRF_NFCT_SHORT_TXFRAMEEND_ENABLERXDATA_MASK = NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Msk, /**< Shortcut between the TXFRAMEEND event and the ENABLERXDATA task. */
  98. #endif // defined(NFCT_SHORTS_TXFRAMEEND_ENABLERXDATA_Msk) || defined(__NRFX_DOXYGEN__)
  99. } nrf_nfct_short_mask_t;
  100. /**
  101. * @brief NFCT interrupts
  102. */
  103. typedef enum
  104. {
  105. NRF_NFCT_INT_READY_MASK = NFCT_INTEN_READY_Msk, /**< Interrupt on READY event. */
  106. NRF_NFCT_INT_FIELDDETECTED_MASK = NFCT_INTEN_FIELDDETECTED_Msk, /**< Interrupt on FIELDDETECTED event. */
  107. NRF_NFCT_INT_FIELDLOST_MASK = NFCT_INTEN_FIELDLOST_Msk, /**< Interrupt on FIELDLOST event. */
  108. NRF_NFCT_INT_TXFRAMESTART_MASK = NFCT_INTEN_TXFRAMESTART_Msk, /**< Interrupt on TXFRAMESTART event. */
  109. NRF_NFCT_INT_TXFRAMEEND_MASK = NFCT_INTEN_TXFRAMEEND_Msk, /**< Interrupt on TXFRAMEEND event. */
  110. NRF_NFCT_INT_RXFRAMESTART_MASK = NFCT_INTEN_RXFRAMESTART_Msk, /**< Interrupt on RXFRAMESTART event. */
  111. NRF_NFCT_INT_RXFRAMEEND_MASK = NFCT_INTEN_RXFRAMEEND_Msk, /**< Interrupt on RXFRAMEEND event. */
  112. NRF_NFCT_INT_ERROR_MASK = NFCT_INTEN_ERROR_Msk, /**< Interrupt on ERROR event. */
  113. NRF_NFCT_INT_RXERROR_MASK = NFCT_INTEN_RXERROR_Msk, /**< Interrupt on RXERROR event. */
  114. NRF_NFCT_INT_ENDRX_MASK = NFCT_INTEN_ENDRX_Msk, /**< Interrupt on ENDRX event. */
  115. NRF_NFCT_INT_ENDTX_MASK = NFCT_INTEN_ENDTX_Msk, /**< Interrupt on ENDTX event. */
  116. NRF_NFCT_INT_AUTOCOLRESSTARTED_MASK = NFCT_INTEN_AUTOCOLRESSTARTED_Msk, /**< Interrupt on AUTOCOLRESSTARTED event. */
  117. NRF_NFCT_INT_COLLISION_MASK = NFCT_INTEN_COLLISION_Msk, /**< Interrupt on COLLISION event. */
  118. NRF_NFCT_INT_SELECTED_MASK = NFCT_INTEN_SELECTED_Msk, /**< Interrupt on SELECTED event. */
  119. NRF_NFCT_INT_STARTED_MASK = NFCT_INTEN_STARTED_Msk, /**< Interrupt on STARTED event. */
  120. } nrf_nfct_int_mask_t;
  121. /**
  122. * @brief NFC error status bit masks.
  123. */
  124. typedef enum
  125. {
  126. NRF_NFCT_ERROR_FRAMEDELAYTIMEOUT_MASK = NFCT_ERRORSTATUS_FRAMEDELAYTIMEOUT_Msk, /**< Timeout of the Frame Delay Timer (no frame transmission started in the FDT window). */
  127. #if defined(NFCT_ERRORSTATUS_NFCFIELDTOOSTRONG_Msk) || defined(__NRFX_DOXYGEN__)
  128. NRF_NFCT_ERROR_NFCFIELDTOOSTRONG_MASK = NFCT_ERRORSTATUS_NFCFIELDTOOSTRONG_Msk, /**< Field level is too high at maximum load resistance. */
  129. #endif // defined(NFCT_ERRORSTATUS_NFCFIELDTOOSTRONG_Msk) || defined(__NRFX_DOXYGEN__)
  130. #if defined(NFCT_ERRORSTATUS_NFCFIELDTOOWEAK_Msk) || defined(__NRFX_DOXYGEN__)
  131. NRF_NFCT_ERROR_NFCFIELDTOOWEAK_MASK = NFCT_ERRORSTATUS_NFCFIELDTOOWEAK_Msk, /**< Field level is too low at minimum load resistance. */
  132. #endif // defined(NFCT_ERRORSTATUS_NFCFIELDTOOWEAK_Msk) || defined(__NRFX_DOXYGEN__)
  133. } nrf_nfct_error_status_t;
  134. /**
  135. * @brief NFC received frame status bit masks.
  136. */
  137. typedef enum
  138. {
  139. NRF_NFCT_RX_FRAME_STATUS_CRC_MASK = NFCT_FRAMESTATUS_RX_CRCERROR_Msk, /**< CRC status mask. */
  140. NRF_NFCT_RX_FRAME_STATUS_PARITY_MASK = NFCT_FRAMESTATUS_RX_PARITYSTATUS_Msk, /**< Parity status mask. */
  141. NRF_NFCT_RX_FRAME_STATUS_OVERRUN_MASK = NFCT_FRAMESTATUS_RX_OVERRUN_Msk, /**< Overrun status mask. */
  142. } nrf_nfct_rx_frame_status_t;
  143. #if defined(NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  144. /**
  145. * @brief NFC tag state.
  146. */
  147. typedef enum
  148. {
  149. NRF_NFCT_TAG_STATE_DISABLED = NFCT_NFCTAGSTATE_NFCTAGSTATE_Disabled, /**< Disabled or sensing NFC field. */
  150. NRF_NFCT_TAG_STATE_RAMP_UP = NFCT_NFCTAGSTATE_NFCTAGSTATE_RampUp, /**< Ramping up. */
  151. NRF_NFCT_TAG_STATE_IDLE = NFCT_NFCTAGSTATE_NFCTAGSTATE_Idle, /**< Idle. */
  152. NRF_NFCT_TAG_STATE_RECEIVE = NFCT_NFCTAGSTATE_NFCTAGSTATE_Receive, /**< Receiving data. */
  153. NRF_NFCT_TAG_STATE_FRAME_DELAY = NFCT_NFCTAGSTATE_NFCTAGSTATE_FrameDelay, /**< Counting Frame Delay Time since the last symbol of the last received frame. */
  154. NRF_NFCT_TAG_STATE_TRANSMIT = NFCT_NFCTAGSTATE_NFCTAGSTATE_Transmit /**< Transmitting data. */
  155. } nrf_nfct_tag_state_t;
  156. #endif // defined(NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  157. #if defined (NFCT_SLEEPSTATE_SLEEPSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  158. /**
  159. * @brief NFC tag sleep state.
  160. *
  161. * @details Shows the sleep state during automatic collision resolution
  162. * according to the NFC Forum Activity Technical Specification v2.0.
  163. */
  164. typedef enum
  165. {
  166. NRF_NFCT_SLEEP_STATE_IDLE = NFCT_SLEEPSTATE_SLEEPSTATE_Idle, /**< 'IDLE' state. */
  167. NRF_NFCT_SLEEP_STATE_SLEEP_A = NFCT_SLEEPSTATE_SLEEPSTATE_SleepA /**< 'SLEEP_A' state. */
  168. } nrf_nfct_sleep_state_t;
  169. #endif // defined (NFCT_SLEEPSTATE_SLEEPSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  170. /**
  171. * @brief NFC field state bit masks.
  172. */
  173. typedef enum
  174. {
  175. NRF_NFCT_FIELD_STATE_PRESENT_MASK = NFCT_FIELDPRESENT_FIELDPRESENT_Msk, /**< Field presence mask. */
  176. NRF_NFCT_FIELD_STATE_LOCK_MASK = NFCT_FIELDPRESENT_LOCKDETECT_Msk /**< Field lock mask. */
  177. } nrf_nfct_field_state_t;
  178. /**
  179. * @brief NFC frame delay mode for data transmission.
  180. */
  181. typedef enum
  182. {
  183. NRF_NFCT_FRAME_DELAY_MODE_FREERUN = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_FreeRun, /**< Frame transmission starts when @ref NRF_NFCT_TASK_STARTTX is set (delay timer is not used). */
  184. NRF_NFCT_FRAME_DELAY_MODE_WINDOW = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Window, /**< Frame transmission starts in a window between FRAMEDELAYMIN and FRAMEDELAYMAX. */
  185. NRF_NFCT_FRAME_DELAY_MODE_EXACTVAL = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_ExactVal, /**< Frame transmission starts when the delay timer reaches FRAMEDELAYMAX. */
  186. NRF_NFCT_FRAME_DELAY_MODE_WINDOWGRID = NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_WindowGrid /**< Frame transmission starts in a bit grid between FRAMEDELAYMIN and FRAMEDELAYMAX. */
  187. } nrf_nfct_frame_delay_mode_t;
  188. /**
  189. * @brief Bit masks for NFC transmission frame configuration.
  190. */
  191. typedef enum
  192. {
  193. NRF_NFCT_TX_FRAME_CONFIG_PARITY = NFCT_TXD_FRAMECONFIG_PARITY_Msk, /**< Indicates whether parity is added in the transmitted frames. */
  194. NRF_NFCT_TX_FRAME_CONFIG_DISCARD_START = NFCT_TXD_FRAMECONFIG_DISCARDMODE_Msk, /**< Indicates whether unused bits are discarded at the start or at the end of the transmitted frames. */
  195. NRF_NFCT_TX_FRAME_CONFIG_SOF = NFCT_TXD_FRAMECONFIG_SOF_Msk, /**< Indicates whether SoF symbol is added in the transmitted frames. */
  196. NRF_NFCT_TX_FRAME_CONFIG_CRC16 = NFCT_TXD_FRAMECONFIG_CRCMODETX_Msk /**< Indicates whether CRC is added in the transmitted frames. */
  197. } nrf_nfct_tx_frame_config_t;
  198. /**
  199. * @brief Bit masks for NFC reception frame configuration.
  200. */
  201. typedef enum
  202. {
  203. NRF_NFCT_RX_FRAME_CONFIG_PARITY = NFCT_RXD_FRAMECONFIG_PARITY_Msk, /**< Indicates whether parity is expected in the received frames. */
  204. NRF_NFCT_RX_FRAME_CONFIG_SOF = NFCT_RXD_FRAMECONFIG_SOF_Msk, /**< Indicates whether SoF symbol is expected in the received frames. */
  205. NRF_NFCT_RX_FRAME_CONFIG_CRC16 = NFCT_RXD_FRAMECONFIG_CRCMODERX_Msk /**< Indicates whether CRC is expected and checked in the received frames. */
  206. } nrf_nfct_rx_frame_config_t;
  207. /**
  208. * @brief 'NFCI1 size' NFC field configuration for the SENS_RES frame according to the NFC Forum Digital Protocol Technical Specification.
  209. */
  210. typedef enum
  211. {
  212. NRF_NFCT_SENSRES_NFCID1_SIZE_SINGLE =
  213. NFCT_SENSRES_NFCIDSIZE_NFCID1Single << NFCT_SENSRES_NFCIDSIZE_Pos, /**< Single size NFCID1 (4 bytes). */
  214. NRF_NFCT_SENSRES_NFCID1_SIZE_DOUBLE =
  215. NFCT_SENSRES_NFCIDSIZE_NFCID1Double << NFCT_SENSRES_NFCIDSIZE_Pos, /**< Double size NFCID1 (7 bytes). */
  216. NRF_NFCT_SENSRES_NFCID1_SIZE_TRIPLE =
  217. NFCT_SENSRES_NFCIDSIZE_NFCID1Triple << NFCT_SENSRES_NFCIDSIZE_Pos, /**< Triple size NFCID1 (10 bytes). */
  218. NRF_NFCT_SENSRES_NFCID1_SIZE_DEFAULT =
  219. NFCT_SENSRES_NFCIDSIZE_Msk /**< Default size. Use this option to leave NFCID1 size unchanged. */
  220. } nrf_nfct_sensres_nfcid1_size_t;
  221. /**
  222. * @brief 'Bit frame SDD' NFC field configuration for the SENS_RES frame according to the NFC Forum Digital Protocol Technical Specification.
  223. */
  224. typedef enum
  225. {
  226. NRF_NFCT_SENSRES_BIT_FRAME_SDD_00000 =
  227. NFCT_SENSRES_BITFRAMESDD_SDD00000 << NFCT_SENSRES_BITFRAMESDD_Pos, /**< SDD pattern 00000. */
  228. NRF_NFCT_SENSRES_BIT_FRAME_SDD_00001 =
  229. NFCT_SENSRES_BITFRAMESDD_SDD00001 << NFCT_SENSRES_BITFRAMESDD_Pos, /**< SDD pattern 00001. */
  230. NRF_NFCT_SENSRES_BIT_FRAME_SDD_00010 =
  231. NFCT_SENSRES_BITFRAMESDD_SDD00010 << NFCT_SENSRES_BITFRAMESDD_Pos, /**< SDD pattern 00010. */
  232. NRF_NFCT_SENSRES_BIT_FRAME_SDD_00100 =
  233. NFCT_SENSRES_BITFRAMESDD_SDD00100 << NFCT_SENSRES_BITFRAMESDD_Pos, /**< SDD pattern 00100. */
  234. NRF_NFCT_SENSRES_BIT_FRAME_SDD_01000 =
  235. NFCT_SENSRES_BITFRAMESDD_SDD01000 << NFCT_SENSRES_BITFRAMESDD_Pos, /**< SDD pattern 01000. */
  236. NRF_NFCT_SENSRES_BIT_FRAME_SDD_10000 =
  237. NFCT_SENSRES_BITFRAMESDD_SDD10000 << NFCT_SENSRES_BITFRAMESDD_Pos /**< SDD pattern 10000. */
  238. } nrf_nfct_sensres_bit_frame_sdd_t;
  239. /**
  240. * @brief 'Platofrm Config' NFC field configuration for the SENS_RES frame according to the NFC Forum Digital Protocol Technical Specification.
  241. */
  242. typedef enum
  243. {
  244. /**< SENS_RES 'Platform Config' field (b4-b1) value for Type 1 Tag platform. */
  245. NRF_NFCT_SENSRES_PLATFORM_CONFIG_T1T = 6 << NFCT_SENSRES_PLATFCONFIG_Pos,
  246. /**< SENS_RES 'Platform Config' field (b7-b6) value for any platform except Type 1 Tag platform. */
  247. NRF_NFCT_SENSRES_PLATFORM_CONFIG_OTHER = 0 << NFCT_SENSRES_PLATFCONFIG_Pos
  248. } nrf_nfct_sensres_platform_config_t;
  249. /**
  250. * @brief Bit masks for SEL_RES NFC frame configuration.
  251. */
  252. typedef enum
  253. {
  254. NRF_NFCT_SELRES_CASCADE_MASK = NFCT_SELRES_CASCADE_Msk, /**< SEL_RES Cascade field bit mask. */
  255. NRF_NFCT_SELRES_PROTOCOL_MASK = NFCT_SELRES_PROTOCOL_Msk /**< SEL_RES Protocol field bit mask. */
  256. } nrf_nfct_selres_t;
  257. /**
  258. * @brief Protocol NFC field (bits b7 and b6) configuration for the SEL_RES frame according to the NFC Forum Digital Protocol Technical Specification.
  259. */
  260. typedef enum
  261. {
  262. NRF_NFCT_SELRES_PROTOCOL_T2T = 0, /**< Type 2 Tag platform. */
  263. NRF_NFCT_SELRES_PROTOCOL_T4AT = 1, /**< Type 4A Tag platform. */
  264. NRF_NFCT_SELRES_PROTOCOL_NFCDEP = 2, /**< NFC-DEP Protocol. */
  265. NRF_NFCT_SELRES_PROTOCOL_NFCDEP_T4AT = 3, /**< NFC-DEP Protocol and Type 4A Tag platform). */
  266. } nrf_nfct_selres_protocol_t;
  267. /**
  268. * @brief Function for activating a specific NFCT task.
  269. *
  270. * @param[in] task Task.
  271. */
  272. __STATIC_INLINE void nrf_nfct_task_trigger(nrf_nfct_task_t task);
  273. /**
  274. * @brief Function for returning the address of a specific NFCT task register.
  275. *
  276. * @param[in] task Task.
  277. *
  278. * @return Task address.
  279. */
  280. __STATIC_INLINE uint32_t nrf_nfct_task_address_get(nrf_nfct_task_t task);
  281. /**
  282. * @brief Function for clearing a specific event.
  283. *
  284. * @param[in] event Event.
  285. */
  286. __STATIC_INLINE void nrf_nfct_event_clear(nrf_nfct_event_t event);
  287. /**
  288. * @brief Function for returning the state of a specific event.
  289. *
  290. * @param[in] event Event.
  291. *
  292. * @retval true If the event is set.
  293. * @retval false If the event is not set.
  294. */
  295. __STATIC_INLINE bool nrf_nfct_event_check(nrf_nfct_event_t event);
  296. /**
  297. * @brief Function for returning the address of a specific NFCT event register.
  298. *
  299. * @param[in] event Event.
  300. *
  301. * @return Address.
  302. */
  303. __STATIC_INLINE uint32_t nrf_nfct_event_address_get(nrf_nfct_event_t event);
  304. /**
  305. * @brief Function for enabling selected shortcuts.
  306. *
  307. * @param[in] short_mask Shortcut mask.
  308. */
  309. __STATIC_INLINE void nrf_nfct_shorts_enable(uint32_t short_mask);
  310. /**
  311. * @brief Function for disabling selected shortcuts.
  312. *
  313. * @param[in] short_mask Shortcut mask.
  314. */
  315. __STATIC_INLINE void nrf_nfct_shorts_disable(uint32_t short_mask);
  316. /**
  317. * @brief Function for retrieving the enabled shortcuts.
  318. *
  319. * @return Flags of the currently enabled shortcuts.
  320. */
  321. __STATIC_INLINE uint32_t nrf_nfct_shorts_get(void);
  322. /**
  323. * @brief Function for setting shortcuts.
  324. *
  325. * @param[in] short_mask Shortcut mask.
  326. */
  327. __STATIC_INLINE void nrf_nfct_shorts_set(uint32_t short_mask);
  328. /**
  329. * @brief Function for enabling the selected interrupts.
  330. *
  331. * @param[in] int_mask Interrupt mask.
  332. */
  333. __STATIC_INLINE void nrf_nfct_int_enable(uint32_t int_mask);
  334. /**
  335. * @brief Function for retrieving the state of the selected interrupts.
  336. *
  337. * @param[in] int_mask Interrupt mask.
  338. *
  339. * @retval true If any of the selected interrupts is enabled.
  340. * @retval false If none of the selected interrupts is enabled.
  341. */
  342. __STATIC_INLINE bool nrf_nfct_int_enable_check(uint32_t int_mask);
  343. /**
  344. * @brief Function for retrieving the information about enabled interrupts.
  345. *
  346. * @return The flags of the enabled interrupts.
  347. */
  348. __STATIC_INLINE uint32_t nrf_nfct_int_enable_get(void);
  349. /**
  350. * @brief Function for disabling the selected interrupts.
  351. *
  352. * @param[in] int_mask Interrupt mask.
  353. */
  354. __STATIC_INLINE void nrf_nfct_int_disable(uint32_t int_mask);
  355. /**
  356. * @brief Function for getting the NFCT error status.
  357. *
  358. * @return The NFCT error status flags, defined in @ref nrf_nfct_error_status_t.
  359. */
  360. __STATIC_INLINE uint32_t nrf_nfct_error_status_get(void);
  361. /**
  362. * @brief Function for clearing the NFCT error status.
  363. *
  364. * @param[in] error_flag Error flags to be cleared, defined in @ref nrf_nfct_error_status_t.
  365. */
  366. __STATIC_INLINE void nrf_nfct_error_status_clear(uint32_t error_flag);
  367. /**
  368. * @brief Function for getting the NFC frame reception status.
  369. *
  370. * @return The flags of the NFC frame reception status, defined in @ref nrf_nfct_rx_frame_status_t.
  371. */
  372. __STATIC_INLINE uint32_t nrf_nfct_rx_frame_status_get(void);
  373. /**
  374. * @brief Function for clearing the NFC frame reception status.
  375. *
  376. * @param[in] framestatus_flags Status flags to be cleared, defined in @ref nrf_nfct_rx_frame_status_t.
  377. */
  378. __STATIC_INLINE void nrf_nfct_rx_frame_status_clear(uint32_t framestatus_flags);
  379. #if defined(NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  380. /**
  381. * @brief Function for getting the NFC tag state.
  382. *
  383. * @retval NRF_NFCT_TAG_STATE_DISABLED NFC tag is disabled.
  384. * @retval NRF_NFCT_TAG_STATE_RAMP_UP NFC tag is ramping up.
  385. * @retval NRF_NFCT_TAG_STATE_IDLE NFC tag is activated and idle.
  386. * @retval NRF_NFCT_TAG_STATE_RECEIVE NFC tag is receiving data.
  387. * @retval NRF_NFCT_TAG_STATE_FRAME_DELAY Frame Delay Timer of the NFC tag is counting ticks
  388. * since the last symbol of the last received frame.
  389. * @retval NRF_NFCT_TAG_STATE_TRANSMIT NFC tag is transmitting data.
  390. */
  391. __STATIC_INLINE nrf_nfct_tag_state_t nrf_nfct_tag_state_get(void);
  392. #endif // defined(NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  393. #if defined (NFCT_SLEEPSTATE_SLEEPSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  394. /**
  395. * @brief Function for getting the NFC tag sleep state during the automatic collision resolution.
  396. *
  397. * @details The returned value is the last state before the autimatic collision resolution started.
  398. *
  399. * @retval NRF_NFCT_SLEEP_STATE_IDLE NFC tag was in IDLE state before the automatic collision resolution started.
  400. * @retval NRF_NFCT_SLEEP_STATE_SLEEP_A NFC tag was in SLEEP_A state before the automatic collision resolution started.
  401. */
  402. __STATIC_INLINE nrf_nfct_sleep_state_t nrf_nfct_sleep_state_get(void);
  403. #endif // defined (NFCT_SLEEPSTATE_SLEEPSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  404. /**
  405. * @brief Function for getting the status of the external NFC field detection.
  406. *
  407. * @return The NFC field detection status. Status bits can be checked by using @ref nrf_nfct_field_state_t.
  408. */
  409. __STATIC_INLINE uint8_t nrf_nfct_field_status_get(void);
  410. /**
  411. * @brief Function for getting the minimum Frame Delay Time value.
  412. *
  413. * @details This is the minimum value for Frame Delay Timer. It controls the shortest time between
  414. * the last symbol of the last received frame and the start of the transmission of a new TX frame.
  415. *
  416. *
  417. * @return The minimum Frame Delay Time value in 13.56-MHz clock ticks.
  418. */
  419. __STATIC_INLINE uint16_t nrf_nfct_frame_delay_min_get(void);
  420. /**
  421. * @brief Function for setting the minimum Frame Delay Time value.
  422. *
  423. * @details This is the minimum value for Frame Delay Timer. It controls the shortest time between
  424. * the last symbol of the last received frame and the start of the transmission of a new TX frame.
  425. *
  426. * @param[in] frame_delay_min Minimum Frame Delay Time value in 13.56-MHz clock ticks.
  427. */
  428. __STATIC_INLINE void nrf_nfct_frame_delay_min_set(uint16_t frame_delay_min);
  429. /**
  430. * @brief Function for getting the maximum Frame Delay Time value.
  431. *
  432. * @details This is the maximum value for Frame Delay Timer. It controls the longest time between
  433. * the last symbol of the last received frame and the start of the transmission of a new TX frame.
  434. * If no transmission starts before the Frame Delay Timer timeout,
  435. * @ref NRF_NFCT_ERROR_FRAMEDELAYTIMEOUT_MASK is set.
  436. *
  437. * @return The maximum Frame Delay Time value in 13.56-MHz clock ticks.
  438. */
  439. __STATIC_INLINE uint32_t nrf_nfct_frame_delay_max_get(void);
  440. /**
  441. * @brief Function for setting the maximum Frame Delay Time value.
  442. *
  443. * @details This is the maximum value for Frame Delay Timer. It controls the longest time between
  444. * the last symbol of the last received frame and the start of the transmission of a new TX frame.
  445. * If no transmission starts before the Frame Delay Timer timeout,
  446. * @ref NRF_NFCT_ERROR_FRAMEDELAYTIMEOUT_MASK is set.
  447. *
  448. * @param[in] frame_delay_max Maximum Frame Delay Time value in 13.56-MHz clock ticks.
  449. */
  450. __STATIC_INLINE void nrf_nfct_frame_delay_max_set(uint32_t frame_delay_max);
  451. /**
  452. * @brief Function for getting the Frame Delay Mode configuration.
  453. *
  454. * @return The configured Frame Delay Mode.
  455. */
  456. __STATIC_INLINE nrf_nfct_frame_delay_mode_t nrf_nfct_frame_delay_mode_get(void);
  457. /**
  458. * @brief Function for setting the NFC Frame Delay Mode configuration.
  459. *
  460. * @param[in] frame_delay_mode Frame Delay Mode configuration.
  461. */
  462. __STATIC_INLINE void nrf_nfct_frame_delay_mode_set(nrf_nfct_frame_delay_mode_t frame_delay_mode);
  463. /**
  464. * @brief Function for getting the pointer to the NFCT RX/TX buffer.
  465. *
  466. * @return The configured pointer to the receive or transmit buffer.
  467. */
  468. __STATIC_INLINE uint8_t * nrf_nfct_rxtx_buffer_get(void);
  469. /**
  470. * @brief Function for setting the the NFCT RX/TX buffer (address and maximum length).
  471. *
  472. * @note Buffer for the NFC RX/TX data is used by EasyDMA and must be located in RAM.
  473. *
  474. * @param[in] p_rxtx_buf Pointer to the receive or transmit buffer.
  475. * @param[in] max_txrx_len Maximum receive or transmit length in bytes (size of the RAM buffer for EasyDMA).
  476. */
  477. __STATIC_INLINE void nrf_nfct_rxtx_buffer_set(uint8_t * p_rxtx_buf,
  478. uint16_t max_txrx_len);
  479. /**
  480. * @brief Function for getting the NFCT RX/TX maximum buffer length.
  481. *
  482. * @return The configured maximum receive or transmit length in bytes (size of the RX/TX buffer for EasyDMA).
  483. */
  484. __STATIC_INLINE uint16_t nrf_nfct_max_rxtx_length_get(void);
  485. /**
  486. * @brief Function for getting the flags for NFC frame transmission configuration.
  487. *
  488. * @return The flags of the NFCT frame transmission configuration, defined in @ref nrf_nfct_tx_frame_config_t.
  489. */
  490. __STATIC_INLINE uint8_t nrf_nfct_tx_frame_config_get(void);
  491. /**
  492. * @brief Function for setting up the flags of the NFC frame transmission configuration.
  493. *
  494. * @param[in] flags Flags for NFCT TX configuration. Use @ref nrf_nfct_tx_frame_config_t for setting.
  495. */
  496. __STATIC_INLINE void nrf_nfct_tx_frame_config_set(uint8_t flags);
  497. /**
  498. * @brief Function for getting the length of the configured transmission frame.
  499. *
  500. * @note NFC frames do not have to consist of full bytes only, therefore data amount for transmission
  501. * is configured in number of bits.
  502. *
  503. * @return Number of bits to be sent excluding CRC, parity, SoF, and EoF.
  504. */
  505. __STATIC_INLINE uint16_t nrf_nfct_tx_bits_get(void);
  506. /**
  507. * @brief Function for setting up the NFC frame transmission.
  508. *
  509. * @details Set the number of TX bits excluding CRC, parity, SoF, and EoF.
  510. *
  511. * @note Source of data for transmission is set by using @ref nrf_nfct_rxtx_buffer_set.
  512. * @note NFC frames do not have to consist of full bytes only, therefore data amount for transmission
  513. * is configured in number of bits.
  514. *
  515. * @param[in] tx_bits Overall number of bits to be sent.
  516. */
  517. __STATIC_INLINE void nrf_nfct_tx_bits_set(uint16_t tx_bits);
  518. /**
  519. * @brief Function for getting the flags of the NFC frame reception configuration.
  520. *
  521. * @return The flags for NFCT frame reception configuration, defined in @ref nrf_nfct_rx_frame_config_t.
  522. */
  523. __STATIC_INLINE uint8_t nrf_nfct_rx_frame_config_get(void);
  524. /**
  525. * @brief Function for setting up the NFC frame reception.
  526. *
  527. * @note Destination for the received data is set using @ref nrf_nfct_rxtx_buffer_set.
  528. *
  529. * @param[in] flags NFCT RX configuration flags. Use @ref nrf_nfct_rx_frame_config_t for setting
  530. * the desired configuration.
  531. */
  532. __STATIC_INLINE void nrf_nfct_rx_frame_config_set(uint8_t flags);
  533. /**
  534. * @brief Function for getting the number of bits received from the NFC poller.
  535. *
  536. * @param[in] crc_excluded Flag for excluding CRC size from calculation.
  537. *
  538. * @return Number of received bits including or excluding CRC, and excluding parity and SoF/EoF framing.
  539. */
  540. __STATIC_INLINE uint16_t nrf_nfct_rx_bits_get(bool crc_excluded);
  541. /**
  542. * @brief Function for getting the NFCID1 (NFC tag identifier).
  543. *
  544. * @note This function always returns the full configuration of the NFCID1 setting (10 bytes), regardless
  545. * of the NFCID1 size. The NFCID1 size can be configured using @ref nrf_nfct_sensres_nfcid1_size_set or
  546. * @ref nrf_nfct_nfcid1_set.
  547. *
  548. * @param[out] p_nfcid1_buf Pointer to a buffer for the NDFCID1 parameter. The NFCID1 values are in
  549. * little endian order, that is: |NFCID1_3RD_LAST|NFCID1_2ND_LAST|NFCID1_LAST|.
  550. *
  551. * @return Configured NFCID1 length
  552. */
  553. __STATIC_INLINE nrf_nfct_sensres_nfcid1_size_t nrf_nfct_nfcid1_get(uint8_t * p_nfcid1_buf);
  554. /**
  555. * @brief Function for setting the NFCID1 (NFC tag identifier).
  556. *
  557. * @note This function also configures the NFCIDSIZE field in the SENSRES register of the NRF_NFCT peripheral.
  558. *
  559. * @param[in] p_nfcid1_buf Pointer to the buffer with NDFCID1 bytes.
  560. * @param[in] nfcid1_size Size of the NFCID1 in bytes.
  561. */
  562. __STATIC_INLINE void nrf_nfct_nfcid1_set(uint8_t const * p_nfcid1_buf,
  563. nrf_nfct_sensres_nfcid1_size_t nfcid1_size);
  564. #if defined (NFCT_AUTOCOLRESCONFIG_MODE_Msk) || defined(__NRFX_DOXYGEN__)
  565. /**
  566. * @brief Function for getting the setting for the automatic collision resolution.
  567. *
  568. * @details The automatic collision resolution mechanism as defined in ISO 14443-3 and NFC Forum
  569. * Digital Protocol Technical Specification 2.0, section 6.
  570. *
  571. * @retval true If automatic collision resolution is enabled.
  572. * @retval false If automatic collision resolution is disabled.
  573. */
  574. __STATIC_INLINE bool nrf_nfct_autocolres_is_enabled(void);
  575. /**
  576. * @brief Function for enabling the automatic collision resolution.
  577. *
  578. * @details The automatic collision resolution mechanism as defined in ISO 14443-3 and NFC Forum
  579. * Digital Protocol Technical Specification 2.0, section 6.
  580. */
  581. __STATIC_INLINE void nrf_nfct_autocolres_enable(void);
  582. /**
  583. * @brief Function for disabling the automatic collision resolution.
  584. *
  585. * @details The automatic collision resolution mechanism as defined in ISO 14443-3 and NFC Forum
  586. * Digital Protocol Technical Specification 2.0, section 6.
  587. */
  588. __STATIC_INLINE void nrf_nfct_autocolres_disable(void);
  589. #endif // defined (NFCT_AUTOCOLRESCONFIG_MODE_Msk) || defined(__NRFX_DOXYGEN__)
  590. /**
  591. * @brief Function for getting the NFCID1 size from the SENS_RES frame configuration.
  592. *
  593. * @details The SENS_RES frame is handled automatically by the NFCT hardware.
  594. *
  595. * @return NFCID1 (tag identifier) size.
  596. */
  597. __STATIC_INLINE nrf_nfct_sensres_nfcid1_size_t nrf_nfct_sensres_nfcid1_size_get(void);
  598. /**
  599. * @brief Function for setting the NFCID1 (tag identifier) size.field in the SENS_RES frame
  600. * configuration.
  601. *
  602. * @note The SENS_RES frame is handled automatically by the NFCT hardware.
  603. *
  604. * @param[in] nfcid1_size NFCID1 (tag identifier) size.
  605. *
  606. * @sa nrf_nfct_nfcid1_set()
  607. */
  608. __STATIC_INLINE void nrf_nfct_sensres_nfcid1_size_set(nrf_nfct_sensres_nfcid1_size_t nfcid1_size);
  609. /**
  610. * @brief Function for getting the Bit Frame SDD field from the SENS_RES frame configuration.
  611. *
  612. * @details The SENS_RES frame is handled automatically by the NFCT hardware.
  613. *
  614. * @return The Bit Frame SDD field configuration.
  615. */
  616. __STATIC_INLINE nrf_nfct_sensres_bit_frame_sdd_t nrf_nfct_sensres_bit_frame_sdd_get(void);
  617. /**
  618. * @brief Function for setting the Bit Frame SDD field in the SENS_RES frame configuration.
  619. *
  620. * @note The SENS_RES frame is handled automatically by the NFCT hardware.
  621. *
  622. * @param[in] bit_frame_sdd The Bit Frame SDD field configuration.
  623. */
  624. __STATIC_INLINE void nrf_nfct_sensres_bit_frame_sdd_set(nrf_nfct_sensres_bit_frame_sdd_t bit_frame_sdd);
  625. /**
  626. * @brief Function for getting the Platform Config field from the SENS_RES frame configuration.
  627. *
  628. * @details The SENS_RES frame is handled automatically by the NFCT hardware.
  629. *
  630. * @return The Platform Config field configuration.
  631. */
  632. __STATIC_INLINE nrf_nfct_sensres_platform_config_t nrf_nfct_sensres_platform_config_get(void);
  633. /**
  634. * @brief Function for setting the Platform Config field in the SENS_RES frame configuration.
  635. *
  636. * @note The SENS_RES frame is handled automatically by the NFCT hardware.
  637. *
  638. * @param[in] platform_config The Platform Config field configuration.
  639. */
  640. __STATIC_INLINE void nrf_nfct_sensres_platform_config_set(nrf_nfct_sensres_platform_config_t platform_config);
  641. /**
  642. * @brief Function for checking the CASCADE bit of the SEL_RES frame.
  643. *
  644. * @details The CASCADE bit in the SEL_RES register is handled automatically by the NFCT hardware
  645. * and indicates the status of the NFCID1 read operation to the NFC poller according to
  646. * the NFC Forum Digital Protocol Speficiation 2.0, section 6.8.2.
  647. *
  648. * @retval true If NFCID1 read procedure is not complete.
  649. * @retval false If NFCID1 read procedure is complete.
  650. */
  651. __STATIC_INLINE bool nrf_nfct_selsres_cascade_check(void);
  652. /**
  653. * @brief Function for getting the Protocol field in the SEL_RES frame.
  654. *
  655. * @details The SEL_RES frame is handled automatically by the NFCT hardware.
  656. *
  657. * @return Value of the Protocol field in the SEL_RES frame.
  658. */
  659. __STATIC_INLINE nrf_nfct_selres_protocol_t nrf_nfct_selsres_protocol_get(void);
  660. /**
  661. * @brief Function for setting the Protocol field in the SEL_RES frame configuration.
  662. *
  663. * @details The SEL_RES frame is handled automatically by the NFCT hardware.
  664. *
  665. * @param[in] sel_res_protocol Value of the Protocol field in the SEL_RES frame.
  666. */
  667. __STATIC_INLINE void nrf_nfct_selres_protocol_set(nrf_nfct_selres_protocol_t sel_res_protocol);
  668. #ifndef SUPPRESS_INLINE_IMPLEMENTATION
  669. __STATIC_INLINE void nrf_nfct_task_trigger(nrf_nfct_task_t task)
  670. {
  671. *((volatile uint32_t *)((uint8_t *)NRF_NFCT + (uint32_t)task)) = 1UL;
  672. }
  673. __STATIC_INLINE uint32_t nrf_nfct_task_address_get(nrf_nfct_task_t task)
  674. {
  675. return (uint32_t)((uint8_t *)NRF_NFCT + (uint32_t)task);
  676. }
  677. __STATIC_INLINE void nrf_nfct_event_clear(nrf_nfct_event_t event)
  678. {
  679. *((volatile uint32_t *)((uint8_t *)NRF_NFCT + (uint32_t)event)) = 0UL;
  680. __DSB();
  681. }
  682. __STATIC_INLINE bool nrf_nfct_event_check(nrf_nfct_event_t event)
  683. {
  684. return (bool)*(volatile const uint32_t *)((uint8_t *)NRF_NFCT + (uint32_t)event);
  685. }
  686. __STATIC_INLINE uint32_t nrf_nfct_event_address_get(nrf_nfct_event_t event)
  687. {
  688. return (uint32_t)((uint8_t *)NRF_NFCT + (uint32_t)event);
  689. }
  690. __STATIC_INLINE void nrf_nfct_shorts_enable(uint32_t short_mask)
  691. {
  692. NRF_NFCT->SHORTS |= short_mask;
  693. }
  694. __STATIC_INLINE void nrf_nfct_shorts_disable(uint32_t short_mask)
  695. {
  696. NRF_NFCT->SHORTS &= ~short_mask;
  697. }
  698. __STATIC_INLINE uint32_t nrf_nfct_shorts_get(void)
  699. {
  700. return NRF_NFCT->SHORTS;
  701. }
  702. __STATIC_INLINE void nrf_nfct_shorts_set(uint32_t short_mask)
  703. {
  704. NRF_NFCT->SHORTS = short_mask;
  705. }
  706. __STATIC_INLINE void nrf_nfct_int_enable(uint32_t int_mask)
  707. {
  708. NRF_NFCT->INTENSET = int_mask;
  709. }
  710. __STATIC_INLINE bool nrf_nfct_int_enable_check(uint32_t int_mask)
  711. {
  712. return (bool)(NRF_NFCT->INTENSET & int_mask);
  713. }
  714. __STATIC_INLINE uint32_t nrf_nfct_int_enable_get(void)
  715. {
  716. return NRF_NFCT->INTENSET;
  717. }
  718. __STATIC_INLINE void nrf_nfct_int_disable(uint32_t int_mask)
  719. {
  720. NRF_NFCT->INTENCLR = int_mask;
  721. }
  722. __STATIC_INLINE uint32_t nrf_nfct_error_status_get(void)
  723. {
  724. return NRF_NFCT->ERRORSTATUS;
  725. }
  726. __STATIC_INLINE void nrf_nfct_error_status_clear(uint32_t error_flags)
  727. {
  728. NRF_NFCT->ERRORSTATUS = error_flags;
  729. }
  730. __STATIC_INLINE uint32_t nrf_nfct_rx_frame_status_get(void)
  731. {
  732. return NRF_NFCT->FRAMESTATUS.RX;
  733. }
  734. __STATIC_INLINE void nrf_nfct_rx_frame_status_clear(uint32_t framestatus_flags)
  735. {
  736. NRF_NFCT->FRAMESTATUS.RX = framestatus_flags;
  737. }
  738. #if defined(NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  739. __STATIC_INLINE nrf_nfct_tag_state_t nrf_nfct_tag_state_get(void)
  740. {
  741. return (nrf_nfct_tag_state_t)((NRF_NFCT->NFCTAGSTATE & NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk) >>
  742. NFCT_NFCTAGSTATE_NFCTAGSTATE_Pos);
  743. }
  744. #endif // defined(NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  745. #if defined (NFCT_SLEEPSTATE_SLEEPSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  746. __STATIC_INLINE nrf_nfct_sleep_state_t nrf_nfct_sleep_state_get(void)
  747. {
  748. return (nrf_nfct_sleep_state_t)((NRF_NFCT->SLEEPSTATE & NFCT_SLEEPSTATE_SLEEPSTATE_Msk) >>
  749. NFCT_SLEEPSTATE_SLEEPSTATE_Pos);
  750. }
  751. #endif // defined (NFCT_SLEEPSTATE_SLEEPSTATE_Msk) || defined(__NRFX_DOXYGEN__)
  752. __STATIC_INLINE uint8_t nrf_nfct_field_status_get(void)
  753. {
  754. return (uint8_t)(NRF_NFCT->FIELDPRESENT);
  755. }
  756. __STATIC_INLINE uint16_t nrf_nfct_frame_delay_min_get(void)
  757. {
  758. return (uint16_t)((NRF_NFCT->FRAMEDELAYMIN & NFCT_FRAMEDELAYMIN_FRAMEDELAYMIN_Msk) >>
  759. NFCT_FRAMEDELAYMIN_FRAMEDELAYMIN_Pos);
  760. }
  761. __STATIC_INLINE void nrf_nfct_frame_delay_min_set(uint16_t frame_delay_min)
  762. {
  763. NRF_NFCT->FRAMEDELAYMIN =
  764. ((uint32_t)frame_delay_min << NFCT_FRAMEDELAYMIN_FRAMEDELAYMIN_Pos) &
  765. NFCT_FRAMEDELAYMIN_FRAMEDELAYMIN_Msk;
  766. }
  767. __STATIC_INLINE uint32_t nrf_nfct_frame_delay_max_get(void)
  768. {
  769. return (NRF_NFCT->FRAMEDELAYMAX & NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Msk) >>
  770. NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Pos;
  771. }
  772. __STATIC_INLINE void nrf_nfct_frame_delay_max_set(uint32_t frame_delay_max)
  773. {
  774. NRF_NFCT->FRAMEDELAYMAX =
  775. ((uint32_t)frame_delay_max << NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Pos) &
  776. NFCT_FRAMEDELAYMAX_FRAMEDELAYMAX_Msk;
  777. }
  778. __STATIC_INLINE nrf_nfct_frame_delay_mode_t nrf_nfct_frame_delay_mode_get(void)
  779. {
  780. return (nrf_nfct_frame_delay_mode_t)(NRF_NFCT->FRAMEDELAYMODE &
  781. NFCT_FRAMEDELAYMODE_FRAMEDELAYMODE_Msk);
  782. }
  783. __STATIC_INLINE void nrf_nfct_frame_delay_mode_set(nrf_nfct_frame_delay_mode_t frame_delay_mode)
  784. {
  785. NRF_NFCT->FRAMEDELAYMODE = (uint32_t)frame_delay_mode;
  786. }
  787. __STATIC_INLINE uint8_t * nrf_nfct_rxtx_buffer_get(void)
  788. {
  789. return (uint8_t *)(NRF_NFCT->PACKETPTR);
  790. }
  791. __STATIC_INLINE void nrf_nfct_rxtx_buffer_set(uint8_t * p_rxtx_buf,
  792. uint16_t max_txrx_len)
  793. {
  794. NRF_NFCT->PACKETPTR = (uint32_t)p_rxtx_buf;
  795. NRF_NFCT->MAXLEN = ((uint32_t)max_txrx_len << NFCT_MAXLEN_MAXLEN_Pos) &
  796. NFCT_MAXLEN_MAXLEN_Msk;
  797. }
  798. __STATIC_INLINE uint16_t nrf_nfct_max_rxtx_length_get(void)
  799. {
  800. return (uint16_t)((NRF_NFCT->MAXLEN & NFCT_MAXLEN_MAXLEN_Msk) >> NFCT_MAXLEN_MAXLEN_Pos);
  801. }
  802. __STATIC_INLINE uint8_t nrf_nfct_tx_frame_config_get(void)
  803. {
  804. return (uint8_t)(NRF_NFCT->TXD.FRAMECONFIG);
  805. }
  806. __STATIC_INLINE void nrf_nfct_tx_frame_config_set(uint8_t flags)
  807. {
  808. NRF_NFCT->TXD.FRAMECONFIG = flags;
  809. }
  810. __STATIC_INLINE uint16_t nrf_nfct_tx_bits_get(void)
  811. {
  812. return (uint16_t)(NRF_NFCT->TXD.AMOUNT & (NFCT_TXD_AMOUNT_TXDATABITS_Msk |
  813. NFCT_TXD_AMOUNT_TXDATABYTES_Msk));
  814. }
  815. __STATIC_INLINE void nrf_nfct_tx_bits_set(uint16_t tx_bits)
  816. {
  817. NRF_NFCT->TXD.AMOUNT = (tx_bits & (NFCT_TXD_AMOUNT_TXDATABITS_Msk | NFCT_TXD_AMOUNT_TXDATABYTES_Msk));
  818. }
  819. __STATIC_INLINE uint8_t nrf_nfct_rx_frame_config_get(void)
  820. {
  821. return (uint8_t)(NRF_NFCT->RXD.FRAMECONFIG);
  822. }
  823. __STATIC_INLINE void nrf_nfct_rx_frame_config_set(uint8_t flags)
  824. {
  825. NRF_NFCT->RXD.FRAMECONFIG = flags;
  826. }
  827. __STATIC_INLINE uint16_t nrf_nfct_rx_bits_get(bool crc_excluded)
  828. {
  829. uint16_t rx_bits = NRF_NFCT->RXD.AMOUNT & (NFCT_RXD_AMOUNT_RXDATABITS_Msk |
  830. NFCT_RXD_AMOUNT_RXDATABYTES_Msk);
  831. return rx_bits - (crc_excluded ? (8u * NRF_NFCT_CRC_SIZE) : 0);
  832. }
  833. __STATIC_INLINE nrf_nfct_sensres_nfcid1_size_t nrf_nfct_nfcid1_get(uint8_t * p_nfcid1_buf)
  834. {
  835. uint32_t nfcid1_last = NRF_NFCT->NFCID1_LAST;
  836. nrf_nfct_sensres_nfcid1_size_t size =
  837. (nrf_nfct_sensres_nfcid1_size_t)(NRF_NFCT->SENSRES & NFCT_SENSRES_NFCIDSIZE_Msk);
  838. if (size != NRF_NFCT_SENSRES_NFCID1_SIZE_SINGLE)
  839. {
  840. uint32_t nfcid1_2nd_last = NRF_NFCT->NFCID1_2ND_LAST;
  841. if (size == NRF_NFCT_SENSRES_NFCID1_SIZE_TRIPLE)
  842. {
  843. uint32_t nfcid1_3rd_last = NRF_NFCT->NFCID1_3RD_LAST;
  844. *p_nfcid1_buf++ = (uint8_t)(nfcid1_3rd_last >> 16UL);
  845. *p_nfcid1_buf++ = (uint8_t)(nfcid1_3rd_last >> 8UL);
  846. *p_nfcid1_buf++ = (uint8_t)(nfcid1_3rd_last >> 0UL);
  847. }
  848. *p_nfcid1_buf++ = (uint8_t)(nfcid1_2nd_last >> 16UL);
  849. *p_nfcid1_buf++ = (uint8_t)(nfcid1_2nd_last >> 8UL);
  850. *p_nfcid1_buf++ = (uint8_t)(nfcid1_2nd_last >> 0UL);
  851. }
  852. *p_nfcid1_buf++ = (uint8_t)(nfcid1_last >> 24UL);
  853. *p_nfcid1_buf++ = (uint8_t)(nfcid1_last >> 16UL);
  854. *p_nfcid1_buf++ = (uint8_t)(nfcid1_last >> 8UL);
  855. *p_nfcid1_buf++ = (uint8_t)(nfcid1_last >> 0UL);
  856. return size;
  857. }
  858. __STATIC_INLINE void nrf_nfct_nfcid1_set(uint8_t const * p_nfcid1_buf,
  859. nrf_nfct_sensres_nfcid1_size_t nfcid1_size)
  860. {
  861. nrf_nfct_sensres_nfcid1_size_t size = (nfcid1_size == NRF_NFCT_SENSRES_NFCID1_SIZE_DEFAULT) ?
  862. NRF_NFCT_SENSRES_NFCID1_SIZE_DOUBLE : nfcid1_size;
  863. if (size != NRF_NFCT_SENSRES_NFCID1_SIZE_SINGLE)
  864. {
  865. if (size == NRF_NFCT_SENSRES_NFCID1_SIZE_TRIPLE)
  866. {
  867. NRF_NFCT->NFCID1_3RD_LAST = ((uint32_t)p_nfcid1_buf[0] << 16UL) |
  868. ((uint32_t)p_nfcid1_buf[1] << 8UL) |
  869. ((uint32_t)p_nfcid1_buf[2] << 0UL);
  870. p_nfcid1_buf += 3UL;
  871. }
  872. NRF_NFCT->NFCID1_2ND_LAST = ((uint32_t)p_nfcid1_buf[0] << 16UL) |
  873. ((uint32_t)p_nfcid1_buf[1] << 8UL) |
  874. ((uint32_t)p_nfcid1_buf[2] << 0UL);
  875. p_nfcid1_buf += 3UL;
  876. }
  877. NRF_NFCT->NFCID1_LAST = ((uint32_t)p_nfcid1_buf[0] << 24UL) |
  878. ((uint32_t)p_nfcid1_buf[1] << 16UL) |
  879. ((uint32_t)p_nfcid1_buf[2] << 8UL) |
  880. ((uint32_t)p_nfcid1_buf[3] << 0UL);
  881. NRF_NFCT->SENSRES = ((NRF_NFCT->SENSRES & ~NFCT_SENSRES_NFCIDSIZE_Msk) |
  882. (uint32_t)size);
  883. }
  884. #if defined (NFCT_AUTOCOLRESCONFIG_MODE_Msk) || defined(__NRFX_DOXYGEN__)
  885. __STATIC_INLINE bool nrf_nfct_autocolres_is_enabled(void)
  886. {
  887. return (NRF_NFCT->AUTOCOLRESCONFIG & NFCT_AUTOCOLRESCONFIG_MODE_Msk) ==
  888. (NFCT_AUTOCOLRESCONFIG_MODE_Enabled << NFCT_AUTOCOLRESCONFIG_MODE_Pos);
  889. }
  890. __STATIC_INLINE void nrf_nfct_autocolres_enable(void)
  891. {
  892. NRF_NFCT->AUTOCOLRESCONFIG =
  893. (NRF_NFCT->AUTOCOLRESCONFIG & ~NFCT_AUTOCOLRESCONFIG_MODE_Msk) |
  894. (NFCT_AUTOCOLRESCONFIG_MODE_Enabled << NFCT_AUTOCOLRESCONFIG_MODE_Pos);
  895. }
  896. __STATIC_INLINE void nrf_nfct_autocolres_disable(void)
  897. {
  898. NRF_NFCT->AUTOCOLRESCONFIG =
  899. (NRF_NFCT->AUTOCOLRESCONFIG & ~NFCT_AUTOCOLRESCONFIG_MODE_Msk) |
  900. (NFCT_AUTOCOLRESCONFIG_MODE_Disabled << NFCT_AUTOCOLRESCONFIG_MODE_Pos);
  901. }
  902. #endif // defined (NFCT_AUTOCOLRESCONFIG_MODE_Msk) || defined(__NRFX_DOXYGEN__)
  903. __STATIC_INLINE nrf_nfct_sensres_nfcid1_size_t nrf_nfct_sensres_nfcid1_size_get(void)
  904. {
  905. return (nrf_nfct_sensres_nfcid1_size_t)(NRF_NFCT->SENSRES & NFCT_SENSRES_NFCIDSIZE_Msk);
  906. }
  907. __STATIC_INLINE void nrf_nfct_sensres_nfcid1_size_set(nrf_nfct_sensres_nfcid1_size_t nfcid1_size)
  908. {
  909. NRF_NFCT->SENSRES = ((NRF_NFCT->SENSRES & ~(NFCT_SENSRES_NFCIDSIZE_Msk)) | (uint32_t)nfcid1_size);
  910. }
  911. __STATIC_INLINE nrf_nfct_sensres_bit_frame_sdd_t nrf_nfct_sensres_bit_frame_sdd_get(void)
  912. {
  913. return (nrf_nfct_sensres_bit_frame_sdd_t)(NRF_NFCT->SENSRES & NFCT_SENSRES_BITFRAMESDD_Msk);
  914. }
  915. __STATIC_INLINE void nrf_nfct_sensres_bit_frame_sdd_set(nrf_nfct_sensres_bit_frame_sdd_t bit_frame_sdd)
  916. {
  917. NRF_NFCT->SENSRES = ((NRF_NFCT->SENSRES & ~(NFCT_SENSRES_BITFRAMESDD_Msk)) | (uint32_t)bit_frame_sdd);
  918. }
  919. __STATIC_INLINE nrf_nfct_sensres_platform_config_t nrf_nfct_sensres_platform_config_get(void)
  920. {
  921. return (nrf_nfct_sensres_platform_config_t)(NRF_NFCT->SENSRES & NFCT_SENSRES_PLATFCONFIG_Msk);
  922. }
  923. __STATIC_INLINE void nrf_nfct_sensres_platform_config_set(nrf_nfct_sensres_platform_config_t platform_config)
  924. {
  925. NRF_NFCT->SENSRES = ((NRF_NFCT->SENSRES & ~(NFCT_SENSRES_PLATFCONFIG_Msk)) | (uint32_t)platform_config);
  926. }
  927. __STATIC_INLINE bool nrf_nfct_selsres_cascade_check(void)
  928. {
  929. return (bool)(NRF_NFCT->SELRES & NFCT_SELRES_CASCADE_Msk);
  930. }
  931. __STATIC_INLINE nrf_nfct_selres_protocol_t nrf_nfct_selsres_protocol_get(void)
  932. {
  933. return (nrf_nfct_selres_protocol_t)((NRF_NFCT->SELRES & NFCT_SELRES_PROTOCOL_Msk) >>
  934. NFCT_SELRES_PROTOCOL_Pos);
  935. }
  936. __STATIC_INLINE void nrf_nfct_selres_protocol_set(nrf_nfct_selres_protocol_t sel_res_protocol)
  937. {
  938. NRF_NFCT->SELRES = (NRF_NFCT->SELRES & ~NFCT_SELRES_PROTOCOL_Msk) |
  939. ((uint32_t)sel_res_protocol << NFCT_SELRES_PROTOCOL_Pos);
  940. }
  941. #endif /* SUPPRESS_INLINE_IMPLEMENTATION */
  942. /** @} */
  943. #ifdef __cplusplus
  944. }
  945. #endif
  946. #endif /* NRF_NFCT_H__ */