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