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