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