nrf_nfct.h 44 KB

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