39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
75#define NFC4_REG_IO_CFG_1 0x00
76#define NFC4_REG_IO_CFG_2 0x01
77#define NFC4_REG_OP_CTRL 0x02
78#define NFC4_REG_MODE 0x03
79#define NFC4_REG_BIT_RATE 0x04
80#define NFC4_REG_ISO14443A_NFC 0x05
81#define NFC4_REG_ISO14443B 0x06
82#define NFC4_REG_ISO14443B_FELICA 0x07
83#define NFC4_REG_PASSIVE_TARGET 0x08
84#define NFC4_REG_STREAM_MODE 0x09
85#define NFC4_REG_AUX 0x0A
86#define NFC4_REG_RX_CFG_1 0x0B
87#define NFC4_REG_RX_CFG_2 0x0C
88#define NFC4_REG_RX_CFG_3 0x0D
89#define NFC4_REG_RX_CFG_4 0x0E
90#define NFC4_REG_MASK_RX_TIMER 0x0F
91#define NFC4_REG_NO_RESPONSE_TIMER_1 0x10
92#define NFC4_REG_NO_RESPONSE_TIMER_2 0x11
93#define NFC4_REG_TIMER_EMV_CTRL 0x12
94#define NFC4_REG_GPT_1 0x13
95#define NFC4_REG_GPT_2 0x14
96#define NFC4_REG_PPON2 0x15
97#define NFC4_REG_IRQ_MASK_MAIN 0x16
98#define NFC4_REG_IRQ_MASK_TIMER_NFC 0x17
99#define NFC4_REG_IRQ_MASK_ERROR_WUP 0x18
100#define NFC4_REG_IRQ_MASK_TARGET 0x19
101#define NFC4_REG_IRQ_MAIN 0x1A
102#define NFC4_REG_IRQ_TIMER_NFC 0x1B
103#define NFC4_REG_IRQ_ERROR_WUP 0x1C
104#define NFC4_REG_IRQ_TARGET 0x1D
105#define NFC4_REG_FIFO_STATUS_1 0x1E
106#define NFC4_REG_FIFO_STATUS_2 0x1F
107#define NFC4_REG_COLLISION_STATUS 0x20
108#define NFC4_REG_PASSIVE_TARGET_STATUS 0x21
109#define NFC4_REG_NUM_TX_BYTES_1 0x22
110#define NFC4_REG_NUM_TX_BYTES_2 0x23
111#define NFC4_REG_NFCIP1_BIT_RATE 0x24
112#define NFC4_REG_ADC_OUTPUT 0x25
113#define NFC4_REG_ANT_TUNE_1 0x26
114#define NFC4_REG_ANT_TUNE_2 0x27
115#define NFC4_REG_TX_DRIVER 0x28
116#define NFC4_REG_PT_MOD 0x29
117#define NFC4_REG_FIELD_THLD_ACT 0x2A
118#define NFC4_REG_FIELD_THLD_DEACT 0x2B
119#define NFC4_REG_REGULATOR_CTRL 0x2C
120#define NFC4_REG_RSSI_DISPLAY 0x2D
121#define NFC4_REG_GAIN_REDUCTION_STATE 0x2E
122#define NFC4_REG_CAP_SENSOR_CTRL 0x2F
123#define NFC4_REG_CAP_SENSOR_DISPLAY 0x30
124#define NFC4_REG_AUX_DISPLAY 0x31
125#define NFC4_REG_WUP_TIMER_CTRL 0x32
126#define NFC4_REG_AMPLITUDE_MEAS_CFG 0x33
127#define NFC4_REG_AMPLITUDE_MEAS_REF 0x34
128#define NFC4_REG_AMPLITUDE_MEAS_AA_DISPLAY 0x35
129#define NFC4_REG_AMPLITUDE_MEAS_DISPLAY 0x36
130#define NFC4_REG_PHASE_MEAS_CFG 0x37
131#define NFC4_REG_PHASE_MEAS_REF 0x38
132#define NFC4_REG_PHASE_MEAS_AA_DISPLAY 0x39
133#define NFC4_REG_PHASE_MEAS_DISPLAY 0x3A
134#define NFC4_REG_CAP_MEAS_CFG 0x3B
135#define NFC4_REG_CAP_MEAS_REF 0x3C
136#define NFC4_REG_CAP_MEAS_AA_DISPLAY 0x3D
137#define NFC4_REG_CAP_MEAS_DISPLAY 0x3E
138#define NFC4_REG_IC_IDENTITY 0x3F
144#define NFC4_REG_SPACE_B_MASK 0x40
145#define NFC4_REG_EMD_SUP_CFG 0x45
146#define NFC4_REG_SUBC_START_TIME 0x46
147#define NFC4_REG_P2P_RX_CFG 0x4B
148#define NFC4_REG_CORR_CFG_1 0x4C
149#define NFC4_REG_CORR_CFG_2 0x4D
150#define NFC4_REG_SQUELCH_TIMER 0x4F
151#define NFC4_REG_FIELD_ON_GT 0x55
152#define NFC4_REG_AUX_MOD 0x68
153#define NFC4_REG_TX_DRIVER_TIMING 0x69
154#define NFC4_REG_RES_AM_MOD 0x6A
155#define NFC4_REG_TX_DRIVER_TIMING_DISPLAY 0x6B
156#define NFC4_REG_REGULATOR_DISPLAY 0x6C
157#define NFC4_REG_OVERSHOOT_CFG_1 0x70
158#define NFC4_REG_OVERSHOOT_CFG_2 0x71
159#define NFC4_REG_UNDERSHOOT_CFG_1 0x72
160#define NFC4_REG_UNDERSHOOT_CFG_2 0x73
166#define NFC4_CMD_SET_DEFAULT 0xC1
167#define NFC4_CMD_STOP 0xC2
168#define NFC4_CMD_TRANSMIT_WITH_CRC 0xC4
169#define NFC4_CMD_TRANSMIT_WITHOUT_CRC 0xC5
170#define NFC4_CMD_TRANSMIT_REQA 0xC6
171#define NFC4_CMD_TRANSMIT_WUPA 0xC7
172#define NFC4_CMD_NFC_INITIAL_FIELD_ON 0xC8
173#define NFC4_CMD_NFC_RESPONSE_FIELD_ON 0xC9
174#define NFC4_CMD_GOTO_SENSE 0xCD
175#define NFC4_CMD_GOTO_SLEEP 0xCE
176#define NFC4_CMD_MASK_RECEIVE_DATA 0xD0
177#define NFC4_CMD_UNMASK_RECEIVE_DATA 0xD1
178#define NFC4_CMD_CHANGE_AM_MOD_STATE 0xD2
179#define NFC4_CMD_MEAS_AMPLITUDE 0xD3
180#define NFC4_CMD_RESET_RX_GAIN 0xD5
181#define NFC4_CMD_ADJUST_REGULATORS 0xD6
182#define NFC4_CMD_CALIBRATE_DRIVER_TIMING 0xD8
183#define NFC4_CMD_MEAS_PHASE 0xD9
184#define NFC4_CMD_CLEAR_RSSI 0xDA
185#define NFC4_CMD_CLEAR_FIFO 0xDB
186#define NFC4_CMD_TRANSPARENT_MODE 0xDC
187#define NFC4_CMD_CALIBRATE_CAP_SENSOR 0xDD
188#define NFC4_CMD_MEAS_CAPACITANCE 0xDE
189#define NFC4_CMD_MEAS_POWER_SUPPLY 0xDF
190#define NFC4_CMD_START_GP_TIMER 0xE0
191#define NFC4_CMD_START_WUP_TIMER 0xE1
192#define NFC4_CMD_START_MASK_RECEIVE_TIMER 0xE2
193#define NFC4_CMD_START_NO_RESPONSE_TIMER 0xE3
194#define NFC4_CMD_START_PPON2_TIMER 0xE4
195#define NFC4_CMD_STOP_NO_RESPONSE_TIMER 0xE8
196#define NFC4_CMD_SPACE_B_ACCESS 0xFB
197#define NFC4_CMD_TEST_ACCESS 0xFC
215#define NFC4_MODE_REG_WRITE 0x00
216#define NFC4_MODE_REG_READ 0x40
217#define NFC4_MODE_FIFO_LOAD 0x80
218#define NFC4_MODE_PT_MEM_LOAD_A_CFG 0xA0
219#define NFC4_MODE_PT_MEM_LOAD_F_CFG 0xA8
220#define NFC4_MODE_PT_MEM_LOAD_TSN_DATA 0xAC
221#define NFC4_MODE_PT_MEM_READ 0xBF
222#define NFC4_MODE_FIFO_READ 0x9F
223#define NFC4_MODE_DIRECT_COMMAND 0xC0
229#define NFC4_IC_TYPE_CODE 0x05
230#define NFC4_IC_REVISION_CODE_MASK 0x07
236#define NFC4_IRQ_MASK_ALL 0xFFFFFFFF
237#define NFC4_IRQ_MASK_NONE 0x00000000
238#define NFC4_IRQ_MASK_OSC 0x00000080
239#define NFC4_IRQ_MASK_FWL 0x00000040
240#define NFC4_IRQ_MASK_RXS 0x00000020
241#define NFC4_IRQ_MASK_RXE 0x00000010
242#define NFC4_IRQ_MASK_TXE 0x00000008
243#define NFC4_IRQ_MASK_COL 0x00000004
244#define NFC4_IRQ_MASK_RX_REST 0x00000002
245#define NFC4_IRQ_MASK_RFU 0x00000001
246#define NFC4_IRQ_MASK_DCT 0x00008000
247#define NFC4_IRQ_MASK_NRE 0x00004000
248#define NFC4_IRQ_MASK_GPE 0x00002000
249#define NFC4_IRQ_MASK_EON 0x00001000
250#define NFC4_IRQ_MASK_EOF 0x00000800
251#define NFC4_IRQ_MASK_CAC 0x00000400
252#define NFC4_IRQ_MASK_CAT 0x00000200
253#define NFC4_IRQ_MASK_NFCT 0x00000100
254#define NFC4_IRQ_MASK_CRC 0x00800000
255#define NFC4_IRQ_MASK_PAR 0x00400000
256#define NFC4_IRQ_MASK_ERR2 0x00200000
257#define NFC4_IRQ_MASK_ERR1 0x00100000
258#define NFC4_IRQ_MASK_WT 0x00080000
259#define NFC4_IRQ_MASK_WAM 0x00040000
260#define NFC4_IRQ_MASK_WPH 0x00020000
261#define NFC4_IRQ_MASK_WCAP 0x00010000
262#define NFC4_IRQ_MASK_PPON2 0x80000000
263#define NFC4_IRQ_MASK_SL_WL 0x40000000
264#define NFC4_IRQ_MASK_APON 0x20000000
265#define NFC4_IRQ_MASK_RXE_PTA 0x10000000
266#define NFC4_IRQ_MASK_WU_F 0x08000000
267#define NFC4_IRQ_MASK_RFU2 0x04000000
268#define NFC4_IRQ_MASK_WU_A_X 0x02000000
269#define NFC4_IRQ_MASK_WU_A 0x01000000
275#define NFC4_TEST_REG_INDICATOR 0x0080
276#define NFC4_ANALOG_CONFIG_LUT_NOT_FOUND 0xFF
277#define NFC4_ANALOG_CONFIG_BITRATE_MASK 0x00F0
278#define NFC4_ANALOG_CONFIG_DIRECTION_MASK 0x000F
279#define NFC4_ANALOG_CONFIG_BITRATE_SHIFT 4
280#define NFC4_ANALOG_CONFIG_DIRECTION_SHIFT 0
281#define NFC4_ANALOG_CONFIG_POLL 0x0000
282#define NFC4_ANALOG_CONFIG_LISTEN 0x8000
283#define NFC4_ANALOG_CONFIG_TECH_CHIP 0x0000
284#define NFC4_ANALOG_CONFIG_TECH_NFCA 0x0100
285#define NFC4_ANALOG_CONFIG_BITRATE_COMMON 0x0000
286#define NFC4_ANALOG_CONFIG_BITRATE_106 0x0010
287#define NFC4_ANALOG_CONFIG_TX 0x0001
288#define NFC4_ANALOG_CONFIG_RX 0x0002
289#define NFC4_ANALOG_CONFIG_ANTICOL 0x0003
290#define NFC4_ANALOG_CONFIG_CHIP_INIT 0x0000
291#define NFC4_ANALOG_CONFIG_CHIP_DEINIT 0x0001
292#define NFC4_ANALOG_CONFIG_CHIP_FIELD_ON 0x0002
293#define NFC4_ANALOG_CONFIG_CHIP_FIELD_OFF 0x0003
294#define NFC4_ANALOG_CONFIG_CHIP_POLL_COMMON 0x0008
300#define NFC4_1FC_IN_4096FC 4096U
301#define NFC4_1FC_IN_512FC 512U
302#define NFC4_1FC_IN_64FC 64U
303#define NFC4_1FC_IN_8FC 8U
304#define NFC4_US_IN_MS 1000U
305#define NFC4_1MS_IN_1FC 13560U
306#define NFC4_BITS_IN_BYTE 8U
307#define NFC4_CRC_LEN 2U
309#define NFC4_RFAL_CONV_1FC_TO_64FC( T ) ( uint32_t ) ( ( uint32_t ) ( T ) / NFC4_1FC_IN_64FC )
311#define NFC4_RFAL_CONV_64FC_TO_1FC( T ) ( uint32_t ) ( ( uint32_t ) ( T ) * NFC4_1FC_IN_64FC )
313#define NFC4_RFAL_CONV_BITS_TO_BYTES( N ) ( uint16_t ) ( ( ( uint16_t ) ( N )+ ( NFC4_BITS_IN_BYTE-1U ) ) \
314 / ( NFC4_BITS_IN_BYTE ) )
316#define NFC4_RFAL_CONV_BYTES_TO_BITS( N ) ( uint32_t ) ( ( uint32_t) ( N ) * ( NFC4_BITS_IN_BYTE ) )
318#define NFC4_RFAL_CONV_1FC_TO_4096FC( T ) ( uint32_t ) ( ( uint32_t) ( T ) / NFC4_1FC_IN_4096FC )
320#define NFC4_RFAL_CONV_4096FC_TO_1FC( T ) ( uint32_t ) ( ( uint32_t) ( T ) * NFC4_1FC_IN_4096FC )
322#define NFC4_RFAL_CONV_1FC_TO_MS( T ) ( uint32_t ) ( ( uint32_t) ( T ) / NFC4_1MS_IN_1FC )
324#define NFC4_RFAL_CONV_MS_TO_1FC( T ) ( uint32_t ) ( ( uint32_t) ( T ) * NFC4_1MS_IN_1FC )
326#define NFC4_FWT_NONE 0xFFFFFFFFU
328#define NFC4_FWT_ADJUSTMENT 64U
330#define NFC4_FWT_A_ADJUSTMENT (512U + 64U)
332#define NFC4_NRT_MAX_1FC NFC4_RFAL_CONV_4096FC_TO_1FC( 0xFFFFU )
334#define NFC4_MRT_MIN_1FC NFC4_RFAL_CONV_64FC_TO_1FC( 0x0004U )
336#define NFC4_NRT_DISABLED 0U
338#define NFC4_NRT_MAX 0xFFFFU
340#define NFC4_RFAL_CALC_NUM_BYTES( NBITS ) ( ( ( uint32_t )( NBITS ) + 7U ) / 8U )
355#define NFC4_RFAL_CREATE_BYTE_FLAGS_TX_RX_CONTEXT( CTX, TB, TBL, RB, RBL, RDL, FL, T ) \
356 ( CTX ).tx_buf = ( uint8_t* ) ( TB ); \
357 ( CTX ).tx_buf_len = ( uint16_t) NFC4_RFAL_CONV_BYTES_TO_BITS ( TBL ); \
358 ( CTX ).rx_buf = ( uint8_t* ) ( RB ); \
359 ( CTX ).rx_buf_len = ( uint16_t ) NFC4_RFAL_CONV_BYTES_TO_BITS ( RBL ); \
360 ( CTX ).rx_rcvd_len = ( uint16_t* ) ( RDL ); \
361 ( CTX ).flags = ( uint32_t ) ( FL ); \
362 ( CTX ).fwt = ( uint32_t ) ( T );
368#define NFC4_NFCA_CASCADE_1_UID_LEN 4U
369#define NFC4_NFCA_CASCADE_2_UID_LEN 7U
370#define NFC4_NFCA_CASCADE_3_UID_LEN 10U
371#define NFC4_NFC_MAX_DEVICES 5U
372#define NFC4_THLD_DO_NOT_SET 0xFFU
377#define NFC4_NFCA_FDTMIN 1620U
380#define NFC4_RFAL_NFCA_CLN2_SEL_CMD( CL ) ( uint8_t )( ( uint8_t )( NFC4_NFCA_CMD_SEL_CL1 ) + ( 2U * ( CL ) ) )
383#define NFC4_RFAL_NFCA_SEL_PAR( NBY, NBI ) ( uint8_t )( ( ( ( NBY ) << 4U ) & 0xF0U ) | ( ( NBI ) &0x0FU ) )
384#define NFC4_RFAL_NFCA_NFC_ID_LEN_2CL( LEN ) ( ( LEN ) / 5U )
385#define NFC4_NFCA_SLP_FWT NFC4_RFAL_CONV_MS_TO_1FC ( 1 )
386#define NFC4_NFCA_SLP_CMD 0x50U
387#define NFC4_NFCA_SLP_BYTE2 0x00U
388#define NFC4_NFCA_SLP_CMD_POS 0U
389#define NFC4_NFCA_SLP_BYTE2_POS 1U
390#define NFC4_NFCA_SDD_CT 0x88U
391#define NFC4_NFCA_SDD_CT_LEN 1U
392#define NFC4_NFCA_SLP_REQ_LEN 2U
393#define NFC4_NFCA_SEL_CMD_LEN 1U
394#define NFC4_NFCA_SEL_PAR_LEN 1U
395#define NFC4_NFCA_SEL_SELPAR NFC4_RFAL_NFCA_SEL_PAR( 7U, 0U )
396#define NFC4_NFCA_BCC_LEN 1U
397#define NFC4_NFCA_SDD_REQ_LEN ( NFC4_NFCA_SEL_CMD_LEN + NFC4_NFCA_SEL_PAR_LEN )
398#define NFC4_NFCA_SDD_RES_LEN ( NFC4_NFCA_CASCADE_1_UID_LEN + NFC4_NFCA_BCC_LEN )
399#define NFC4_NFCA_N_RETRANS 2U
400#define NFC4_ISO14443A_SDD_RES_LEN 5U
402#define NFC4_TXRX_FLAGS_DEFAULT ( ( uint32_t ) NFC4_TXRX_FLAGS_CRC_TX_AUTO | ( uint32_t ) NFC4_TXRX_FLAGS_CRC_RX_REMV | \
403 ( uint32_t ) NFC4_TXRX_FLAGS_NFCIP1_OFF | ( uint32_t ) NFC4_TXRX_FLAGS_AGC_ON | \
404 ( uint32_t ) NFC4_TXRX_FLAGS_PAR_RX_REMV | ( uint32_t ) NFC4_TXRX_FLAGS_PAR_TX_AUTO | \
405 ( uint32_t ) NFC4_TXRX_FLAGS_NFCV_FLAG_AUTO )
411#define NFC4_FIFO_DEPTH 512U
412#define NFC4_FIFO_STATUS_REG1 0U
413#define NFC4_FIFO_STATUS_REG2 1U
414#define NFC4_FIFO_STATUS_INVALID 0xFFU
415#define NFC4_FIFO_IN_WL 200U
416#define NFC4_FIFO_OUT_WL ( NFC4_FIFO_DEPTH - NFC4_FIFO_IN_WL )
423#define MAX(a, b) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
424#define MIN(a, b) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
426#define EXIT_ON_ERR( r, f ) \
428 if ( NFC4_RFAL_ERR_NONE != ( r ) ) \
437#define NFC4_IO_CFG_1_SINGLE ( 1U << 7 )
438#define NFC4_IO_CFG_1_RFO2 ( 1U << 6 )
439#define NFC4_IO_CFG_1_I2C_THD1 ( 1U << 5 )
440#define NFC4_IO_CFG_1_I2C_THD0 ( 1U << 4 )
441#define NFC4_IO_CFG_1_I2C_THD_MASK ( 3U << 4 )
442#define NFC4_IO_CFG_1_I2C_THD_SHIFT ( 4U )
443#define NFC4_IO_CFG_1_RFU ( 1U << 3 )
444#define NFC4_IO_CFG_1_OUT_CL1 ( 1U << 2 )
445#define NFC4_IO_CFG_1_OUT_CL0 ( 1U << 1 )
446#define NFC4_IO_CFG_1_OUT_CL_DISABLED ( 3U << 1 )
447#define NFC4_IO_CFG_1_OUT_CL_13_56MHZ ( 2U << 1 )
448#define NFC4_IO_CFG_1_OUT_CL_4_78MHZ ( 1U << 1 )
449#define NFC4_IO_CFG_1_OUT_CL_3_39MHZ ( 0U << 1 )
450#define NFC4_IO_CFG_1_OUT_CL_MASK ( 3U << 1 )
451#define NFC4_IO_CFG_1_OUT_CL_SHIFT ( 1U )
452#define NFC4_IO_CFG_1_LF_CLK_OFF ( 1U << 0 )
453#define NFC4_IO_CFG_1_LF_CLK_OFF_ON ( 1U << 0 )
454#define NFC4_IO_CFG_1_LF_CLK_OFF_OFF ( 0U << 0 )
456#define NFC4_IO_CFG_2_SUP3V ( 1U << 7 )
457#define NFC4_IO_CFG_2_SUP3V_3V ( 1U << 7 )
458#define NFC4_IO_CFG_2_SUP3V_5V ( 0U << 7 )
459#define NFC4_IO_CFG_2_VSPD_OFF ( 1U << 6 )
460#define NFC4_IO_CFG_2_AAT_EN ( 1U << 5 )
461#define NFC4_IO_CFG_2_MISO_PD2 ( 1U << 4 )
462#define NFC4_IO_CFG_2_MISO_PD1 ( 1U << 3 )
463#define NFC4_IO_CFG_2_IO_DRV_LVL ( 1U << 2 )
464#define NFC4_IO_CFG_2_SLOW_UP ( 1U << 0 )
466#define NFC4_ISO14443A_NFC_NO_TX_PAR ( 1U << 7 )
467#define NFC4_ISO14443A_NFC_NO_TX_PAR_OFF ( 0U << 7 )
468#define NFC4_ISO14443A_NFC_NO_RX_PAR ( 1U << 6 )
469#define NFC4_ISO14443A_NFC_NO_RX_PAR_OFF ( 0U << 6 )
470#define NFC4_ISO14443A_NFC_NFC_F0 ( 1U << 5 )
471#define NFC4_ISO14443A_NFC_NFC_F0_OFF ( 0U << 5 )
472#define NFC4_ISO14443A_NFC_P_LEN3 ( 1U << 4 )
473#define NFC4_ISO14443A_NFC_P_LEN2 ( 1U << 3 )
474#define NFC4_ISO14443A_NFC_P_LEN1 ( 1U << 2 )
475#define NFC4_ISO14443A_NFC_P_LEN0 ( 1U << 1 )
476#define NFC4_ISO14443A_NFC_P_LEN_MASK ( 0xFU << 1 )
477#define NFC4_ISO14443A_NFC_P_LEN_SHIFT ( 1U )
478#define NFC4_ISO14443A_NFC_ANTCL ( 1U << 0 )
480#define NFC4_RX_CFG_2_DEMOD_MODE ( 1U << 7 )
481#define NFC4_RX_CFG_2_AMD_SEL ( 1U << 6 )
482#define NFC4_RX_CFG_2_AMD_SEL_MIXER ( 1U << 6 )
483#define NFC4_RX_CFG_2_AMD_SEL_PEAK ( 0U << 6 )
484#define NFC4_RX_CFG_2_SQM_DYN ( 1U << 5 )
485#define NFC4_RX_CFG_2_PULZ_61 ( 1U << 4 )
486#define NFC4_RX_CFG_2_AGC_EN ( 1U << 3 )
487#define NFC4_RX_CFG_2_AGC_M ( 1U << 2 )
488#define NFC4_RX_CFG_2_AGC_ALG ( 1U << 1 )
489#define NFC4_RX_CFG_2_AGC6_3 ( 1U << 0 )
491#define NFC4_OP_CTRL_EN ( 1U << 7 )
492#define NFC4_OP_CTRL_RX_EN ( 1U << 6 )
493#define NFC4_OP_CTRL_RX_CHN ( 1U << 5 )
494#define NFC4_OP_CTRL_RX_MAN ( 1U << 4 )
495#define NFC4_OP_CTRL_TX_EN ( 1U << 3 )
496#define NFC4_OP_CTRL_WU ( 1U << 2 )
497#define NFC4_OP_CTRL_EN_FD_C1 ( 1U << 1 )
498#define NFC4_OP_CTRL_EN_FD_C0 ( 1U << 0 )
499#define NFC4_OP_CTRL_EN_FD_EFD_OFF ( 0U << 0 )
500#define NFC4_OP_CTRL_EN_FD_MANUAL_EFD_CA ( 1U << 0 )
501#define NFC4_OP_CTRL_EN_FD_MANUAL_EFD_PDT ( 2U << 0 )
502#define NFC4_OP_CTRL_EN_FD_AUTO_EFD ( 3U << 0 )
503#define NFC4_OP_CTRL_EN_FD_SHIFT ( 0U )
504#define NFC4_OP_CTRL_EN_FD_MASK ( 3U << 0 )
506#define NFC4_NFCIP1_BIT_RATE_NFC_RFU1 ( 1U << 7 )
507#define NFC4_NFCIP1_BIT_RATE_NFC_RFU0 ( 1U << 6 )
508#define NFC4_NFCIP1_BIT_RATE_NFC_RATE1 ( 1U << 5 )
509#define NFC4_NFCIP1_BIT_RATE_NFC_RATE0 ( 1U << 4 )
510#define NFC4_NFCIP1_BIT_RATE_NFC_RATE_MASK ( 0x3U << 4 )
511#define NFC4_NFCIP1_BIT_RATE_NFC_RATE_SHIFT ( 4U )
512#define NFC4_NFCIP1_BIT_RATE_PPT2_ON ( 1U << 3 )
513#define NFC4_NFCIP1_BIT_RATE_GPT_ON ( 1U << 2 )
514#define NFC4_NFCIP1_BIT_RATE_NRT_ON ( 1U << 1 )
515#define NFC4_NFCIP1_BIT_RATE_MRT_ON ( 1U << 0 )
517#define NFC4_AUX_DISPLAY_A_CHA ( 1U << 7 )
518#define NFC4_AUX_DISPLAY_EFD_O ( 1U << 6 )
519#define NFC4_AUX_DISPLAY_TX_ON ( 1U << 5 )
520#define NFC4_AUX_DISPLAY_OSC_OK ( 1U << 4 )
521#define NFC4_AUX_DISPLAY_RX_ON ( 1U << 3 )
522#define NFC4_AUX_DISPLAY_RX_ACT ( 1U << 2 )
523#define NFC4_AUX_DISPLAY_EN_PEER ( 1U << 1 )
524#define NFC4_AUX_DISPLAY_EN_AC ( 1U << 0 )
526#define NFC4_FIFO_STATUS2_FIFO_B9 ( 1U << 7 )
527#define NFC4_FIFO_STATUS2_FIFO_B8 ( 1U << 6 )
528#define NFC4_FIFO_STATUS2_FIFO_B_MASK ( 3U << 6 )
529#define NFC4_FIFO_STATUS2_FIFO_B_SHIFT ( 6U )
530#define NFC4_FIFO_STATUS2_FIFO_UNF ( 1U << 5 )
531#define NFC4_FIFO_STATUS2_FIFO_OVR ( 1U << 4 )
532#define NFC4_FIFO_STATUS2_FIFO_LB2 ( 1U << 3 )
533#define NFC4_FIFO_STATUS2_FIFO_LB1 ( 1U << 2 )
534#define NFC4_FIFO_STATUS2_FIFO_LB0 ( 1U << 1 )
535#define NFC4_FIFO_STATUS2_FIFO_LB_MASK ( 7U << 1 )
536#define NFC4_FIFO_STATUS2_FIFO_LB_SHIFT ( 1U )
537#define NFC4_FIFO_STATUS2_NP_LB ( 1U << 0 )
539#define NFC4_MODE_TARG ( 1U << 7 )
540#define NFC4_MODE_TARG_TARG ( 1U << 7 )
541#define NFC4_MODE_TARG_INIT ( 0U << 7 )
542#define NFC4_MODE_OM3 ( 1U << 6 )
543#define NFC4_MODE_OM2 ( 1U << 5 )
544#define NFC4_MODE_OM1 ( 1U << 4 )
545#define NFC4_MODE_OM0 ( 1U << 3 )
546#define NFC4_MODE_OM_BPSK_STREAM ( 0xFU << 3 )
547#define NFC4_MODE_OM_SUBCARRIER_STREAM ( 0xEU << 3 )
548#define NFC4_MODE_OM_TOPAZ ( 0x4U << 3 )
549#define NFC4_MODE_OM_FELICA ( 0x3U << 3 )
550#define NFC4_MODE_OM_ISO14443B ( 0x2U << 3 )
551#define NFC4_MODE_OM_ISO14443A ( 0x1U << 3 )
552#define NFC4_MODE_OM_TARG_NFCA ( 0x1U << 3 )
553#define NFC4_MODE_OM_TARG_NFCB ( 0x2U << 3 )
554#define NFC4_MODE_OM_TARG_NFCF ( 0x4U << 3 )
555#define NFC4_MODE_OM_TARG_NFCIP ( 0x7U << 3 )
556#define NFC4_MODE_OM_NFC ( 0x0U << 3 )
557#define NFC4_MODE_OM_MASK ( 0xFU << 3 )
558#define NFC4_MODE_OM_SHIFT ( 3U )
559#define NFC4_MODE_TR_AM ( 1U << 2 )
560#define NFC4_MODE_TR_AM_OOK ( 0U << 2 )
561#define NFC4_MODE_TR_AM_AM ( 1U << 2 )
562#define NFC4_MODE_NFC_AR1 ( 1U << 1 )
563#define NFC4_MODE_NFC_AR0 ( 1U << 0 )
564#define NFC4_MODE_NFC_AR_OFF ( 0U << 0 )
565#define NFC4_MODE_NFC_AR_AUTO_RX ( 1U << 0 )
566#define NFC4_MODE_NFC_AR_EOF ( 2U << 0 )
567#define NFC4_MODE_NFC_AR_RFU ( 3U << 0 )
568#define NFC4_MODE_NFC_AR_MASK ( 3U << 0 )
569#define NFC4_MODE_NFC_AR_SHIFT ( 0U )
571#define NFC4_BIT_RATE_TXRATE_106 ( 0x0U << 4 )
572#define NFC4_BIT_RATE_TXRATE_212 ( 0x1U << 4 )
573#define NFC4_BIT_RATE_TXRATE_424 ( 0x2U << 4 )
574#define NFC4_BIT_RATE_TXRATE_848 ( 0x3U << 4 )
575#define NFC4_BIT_RATE_TXRATE_MASK ( 0x3U << 4 )
576#define NFC4_BIT_RATE_TXRATE_SHIFT ( 4U )
577#define NFC4_BIT_RATE_RXRATE_106 ( 0x0U << 0 )
578#define NFC4_BIT_RATE_RXRATE_212 ( 0x1U << 0 )
579#define NFC4_BIT_RATE_RXRATE_424 ( 0x2U << 0 )
580#define NFC4_BIT_RATE_RXRATE_848 ( 0x3U << 0 )
581#define NFC4_BIT_RATE_RXRATE_MASK ( 0x3U << 0 )
582#define NFC4_BIT_RATE_RXRATE_SHIFT ( 0U )
584#define NFC4_AUX_MOD_DIS_REG_AM ( 1U << 7 )
585#define NFC4_AUX_MOD_LM_EXT_POL ( 1U << 6 )
586#define NFC4_AUX_MOD_LM_EXT ( 1U << 5 )
587#define NFC4_AUX_MOD_LM_DRI ( 1U << 4 )
588#define NFC4_AUX_MOD_RES_AM ( 1U << 3 )
589#define NFC4_AUX_MOD_RFU2 ( 1U << 2 )
590#define NFC4_AUX_MOD_RFU1 ( 1U << 1 )
591#define NFC4_AUX_MOD_RFU0 ( 1U << 0 )
593#define NFC4_PASSIVE_TARGET_FDEL_3 ( 1U << 7 )
594#define NFC4_PASSIVE_TARGET_FDEL_2 ( 1U << 6 )
595#define NFC4_PASSIVE_TARGET_FDEL_1 ( 1U << 5 )
596#define NFC4_PASSIVE_TARGET_FDEL_0 ( 1U << 4 )
597#define NFC4_PASSIVE_TARGET_FDEL_MASK ( 0xFU << 4 )
598#define NFC4_PASSIVE_TARGET_FDEL_SHIFT ( 4U )
599#define NFC4_PASSIVE_TARGET_D_AC_AP2P ( 1U << 3 )
600#define NFC4_PASSIVE_TARGET_D_212_424_1R ( 1U << 2 )
601#define NFC4_PASSIVE_TARGET_RFU ( 1U << 1 )
602#define NFC4_PASSIVE_TARGET_D_106_AC_A ( 1U << 0 )
604#define NFC4_PT_MOD_PTM_RES3 ( 1U << 7 )
605#define NFC4_PT_MOD_PTM_RES2 ( 1U << 6 )
606#define NFC4_PT_MOD_PTM_RES1 ( 1U << 5 )
607#define NFC4_PT_MOD_PTM_RES0 ( 1U << 4 )
608#define NFC4_PT_MOD_PTM_RES_MASK ( 0xFU << 4 )
609#define NFC4_PT_MOD_PTM_RES_SHIFT ( 4U )
610#define NFC4_PT_MOD_PT_RES3 ( 1U << 3 )
611#define NFC4_PT_MOD_PT_RES2 ( 1U << 2 )
612#define NFC4_PT_MOD_PT_RES1 ( 1U << 1 )
613#define NFC4_PT_MOD_PT_RES0 ( 1U << 0 )
614#define NFC4_PT_MOD_PT_RES_MASK ( 0xFU << 0 )
615#define NFC4_PT_MOD_PT_RES_SHIFT ( 0U )
617#define NFC4_EMD_SUP_CFG_EMD_EMV ( 1U << 7 )
618#define NFC4_EMD_SUP_CFG_EMD_EMV_ON ( 1U << 7 )
619#define NFC4_EMD_SUP_CFG_EMD_EMV_OFF ( 0U << 7 )
620#define NFC4_EMD_SUP_CFG_RX_START_EMV ( 1U << 6 )
621#define NFC4_EMD_SUP_CFG_RX_START_EMV_ON ( 1U << 6 )
622#define NFC4_EMD_SUP_CFG_RX_START_EMV_OFF ( 0U << 6 )
623#define NFC4_EMD_SUP_CFG_RFU1 ( 1U << 5 )
624#define NFC4_EMD_SUP_CFG_RFU0 ( 1U << 4 )
625#define NFC4_EMD_SUP_CFG_EMD_THLD3 ( 1U << 3 )
626#define NFC4_EMD_SUP_CFG_EMD_THLD2 ( 1U << 2 )
627#define NFC4_EMD_SUP_CFG_EMD_THLD1 ( 1U << 1 )
628#define NFC4_EMD_SUP_CFG_EMD_THLD0 ( 1U << 0 )
629#define NFC4_EMD_SUP_CFG_EMD_THLD_MASK ( 0xFU << 0 )
630#define NFC4_EMD_SUP_CFG_EMD_THLD_SHIFT ( 0U )
632#define NFC4_AUX_NO_CRC_RX ( 1U << 7 )
633#define NFC4_AUX_RFU ( 1U << 6 )
634#define NFC4_AUX_NFC_ID1 ( 1U << 5 )
635#define NFC4_AUX_NFC_ID0 ( 1U << 4 )
636#define NFC4_AUX_NFC_ID_7BYTES ( 1U << 4 )
637#define NFC4_AUX_NFC_ID_4BYTES ( 0U << 4 )
638#define NFC4_AUX_NFC_ID_MASK ( 3U << 4 )
639#define NFC4_AUX_NFC_ID_SHIFT ( 4U )
640#define NFC4_AUX_MFAZ_CL90 ( 1U << 3 )
641#define NFC4_AUX_DIS_CORR ( 1U << 2 )
642#define NFC4_AUX_DIS_CORR_COHERENT ( 1U << 2 )
643#define NFC4_AUX_DIS_CORR_CORRELATOR ( 0U << 2 )
644#define NFC4_AUX_NFC_N1 ( 1U << 1 )
645#define NFC4_AUX_NFC_N0 ( 1U << 0 )
646#define NFC4_AUX_NFC_N_MASK ( 3U << 0 )
647#define NFC4_AUX_NFC_N_SHIFT ( 0U )
649#define NFC4_TIMER_EMV_CONTROL_GPTC2 ( 1U << 7 )
650#define NFC4_TIMER_EMV_CONTROL_GPTC1 ( 1U << 6 )
651#define NFC4_TIMER_EMV_CONTROL_GPTC0 ( 1U << 5 )
652#define NFC4_TIMER_EMV_CONTROL_GPTC_NO_TRIGGER ( 0U << 5 )
653#define NFC4_TIMER_EMV_CONTROL_GPTC_ERX ( 1U << 5 )
654#define NFC4_TIMER_EMV_CONTROL_GPTC_SRX ( 2U << 5 )
655#define NFC4_TIMER_EMV_CONTROL_GPTC_ETX_NFC ( 3U << 5 )
656#define NFC4_TIMER_EMV_CONTROL_GPTC_MASK ( 7U << 5 )
657#define NFC4_TIMER_EMV_CONTROL_GPTC_SHIFT ( 5U )
658#define NFC4_TIMER_EMV_CONTROL_RFU ( 1U << 4 )
659#define NFC4_TIMER_EMV_CONTROL_MRT_STEP ( 1U << 3 )
660#define NFC4_TIMER_EMV_CONTROL_MRT_STEP_512 ( 1U << 3 )
661#define NFC4_TIMER_EMV_CONTROL_MRT_STEP_64 ( 0U << 3 )
662#define NFC4_TIMER_EMV_CONTROL_NRT_NFC ( 1U << 2 )
663#define NFC4_TIMER_EMV_CONTROL_NRT_NFC_ON ( 1U << 2 )
664#define NFC4_TIMER_EMV_CONTROL_NRT_NFC_OFF ( 0U << 2 )
665#define NFC4_TIMER_EMV_CONTROL_NRT_EMV ( 1U << 1 )
666#define NFC4_TIMER_EMV_CONTROL_NRT_EMV_ON ( 1U << 1 )
667#define NFC4_TIMER_EMV_CONTROL_NRT_EMV_OFF ( 0U << 1 )
668#define NFC4_TIMER_EMV_CONTROL_NRT_STEP ( 1U << 0 )
669#define NFC4_TIMER_EMV_CONTROL_NRT_STEP_64FC ( 0U << 0 )
670#define NFC4_TIMER_EMV_CONTROL_NRT_STEP_4096_FC ( 1U << 0 )
672#define NFC4_COLLISION_STATUS_C_BYTE3 ( 1U << 7 )
673#define NFC4_COLLISION_STATUS_C_BYTE2 ( 1U << 6 )
674#define NFC4_COLLISION_STATUS_C_BYTE1 ( 1U << 5 )
675#define NFC4_COLLISION_STATUS_C_BYTE0 ( 1U << 4 )
676#define NFC4_COLLISION_STATUS_C_BYTE_MASK ( 0x FU << 4 )
677#define NFC4_COLLISION_STATUS_C_BYTE_SHIFT ( 4U )
678#define NFC4_COLLISION_STATUS_C_BIT2 ( 1U << 3 )
679#define NFC4_COLLISION_STATUS_C_BIT1 ( 1U << 2 )
680#define NFC4_COLLISION_STATUS_C_BIT0 ( 1U << 1 )
681#define NFC4_COLLISION_STATUS_C_PB ( 1U << 0 )
682#define NFC4_COLLISION_STATUS_C_BIT_MASK ( 3U << 1 )
683#define NFC4_COLLISION_STATUS_C_BIT_SHIFT ( 1U )
685#define NFC4_CORR_CFG_1_CORR_S7 ( 1U << 7 )
686#define NFC4_CORR_CFG_1_CORR_S6 ( 1U << 6 )
687#define NFC4_CORR_CFG_1_CORR_S5 ( 1U << 5 )
688#define NFC4_CORR_CFG_1_CORR_S4 ( 1U << 4 )
689#define NFC4_CORR_CFG_1_CORR_S3 ( 1U << 3 )
690#define NFC4_CORR_CFG_1_CORR_S2 ( 1U << 2 )
691#define NFC4_CORR_CFG_1_CORR_S1 ( 1U << 1 )
692#define NFC4_CORR_CFG_1_CORR_S0 ( 1U << 0 )
694#define NFC4_TX_DRIVER_AM_MOD3 ( 1U << 7 )
695#define NFC4_TX_DRIVER_AM_MOD2 ( 1U << 6 )
696#define NFC4_TX_DRIVER_AM_MOD1 ( 1U << 5 )
697#define NFC4_TX_DRIVER_AM_MOD0 ( 1U << 4 )
698#define NFC4_TX_DRIVER_AM_MOD_5PERCENT ( 0x0U << 4 )
699#define NFC4_TX_DRIVER_AM_MOD_6PERCENT ( 0x1U << 4 )
700#define NFC4_TX_DRIVER_AM_MOD_7PERCENT ( 0x2U << 4 )
701#define NFC4_TX_DRIVER_AM_MOD_8PERCENT ( 0x3U << 4 )
702#define NFC4_TX_DRIVER_AM_MOD_9PERCENT ( 0x4U << 4 )
703#define NFC4_TX_DRIVER_AM_MOD_10PERCENT ( 0x5U << 4 )
704#define NFC4_TX_DRIVER_AM_MOD_11PERCENT ( 0x6U << 4 )
705#define NFC4_TX_DRIVER_AM_MOD_12PERCENT ( 0x7U << 4 )
706#define NFC4_TX_DRIVER_AM_MOD_13PERCENT ( 0x8U << 4 )
707#define NFC4_TX_DRIVER_AM_MOD_14PERCENT ( 0x9U << 4 )
708#define NFC4_TX_DRIVER_AM_MOD_15PERCENT ( 0xAU << 4 )
709#define NFC4_TX_DRIVER_AM_MOD_17PERCENT ( 0xBU << 4 )
710#define NFC4_TX_DRIVER_AM_MOD_19PERCENT ( 0xCU << 4 )
711#define NFC4_TX_DRIVER_AM_MOD_22PERCENT ( 0xDU << 4 )
712#define NFC4_TX_DRIVER_AM_MOD_26PERCENT ( 0xEU << 4 )
713#define NFC4_TX_DRIVER_AM_MOD_40PERCENT ( 0xFU << 4 )
714#define NFC4_TX_DRIVER_AM_MOD_MASK ( 0xFU << 4 )
715#define NFC4_TX_DRIVER_AM_MOD_SHIFT ( 4U )
716#define NFC4_TX_DRIVER_D_RES3 ( 1U << 3 )
717#define NFC4_TX_DRIVER_D_RES2 ( 1U << 2 )
718#define NFC4_TX_DRIVER_D_RES1 ( 1U << 1 )
719#define NFC4_TX_DRIVER_D_RES0 ( 1U << 0 )
720#define NFC4_TX_DRIVER_D_RES_MASK ( 0xFU << 0 )
721#define NFC4_TX_DRIVER_D_RES_SHIFT ( 0U )
723#define NFC4_FIELD_THLD_ACT_TRG_L2A ( 1U << 6 )
724#define NFC4_FIELD_THLD_ACT_TRG_L1A ( 1U << 5 )
725#define NFC4_FIELD_THLD_ACT_TRG_L0A ( 1U << 4 )
726#define NFC4_FIELD_THLD_ACT_TRG_75MV ( 0x0U << 4 )
727#define NFC4_FIELD_THLD_ACT_TRG_105MV ( 0x1U << 4 )
728#define NFC4_FIELD_THLD_ACT_TRG_150MV ( 0x2U << 4 )
729#define NFC4_FIELD_THLD_ACT_TRG_205MV ( 0x3U << 4 )
730#define NFC4_FIELD_THLD_ACT_TRG_290MV ( 0x4U << 4 )
731#define NFC4_FIELD_THLD_ACT_TRG_400MV ( 0x5U << 4 )
732#define NFC4_FIELD_THLD_ACT_TRG_560MV ( 0x6U << 4 )
733#define NFC4_FIELD_THLD_ACT_TRG_800MV ( 0x7U << 4 )
734#define NFC4_FIELD_THLD_ACT_TRG_MASK ( 7U << 4 )
735#define NFC4_FIELD_THLD_ACT_TRG_SHIFT ( 4U )
736#define NFC4_FIELD_THLD_ACT_RFE_T3A ( 1U << 3 )
737#define NFC4_FIELD_THLD_ACT_RFE_T2A ( 1U << 2 )
738#define NFC4_FIELD_THLD_ACT_RFE_T1A ( 1U << 1 )
739#define NFC4_FIELD_THLD_ACT_RFE_T0A ( 1U << 0 )
740#define NFC4_FIELD_THLD_ACT_RFE_75MV ( 0x0U << 0 )
741#define NFC4_FIELD_THLD_ACT_RFE_105MV ( 0x1U << 0 )
742#define NFC4_FIELD_THLD_ACT_RFE_150MV ( 0x2U << 0 )
743#define NFC4_FIELD_THLD_ACT_RFE_205MV ( 0x3U << 0 )
744#define NFC4_FIELD_THLD_ACT_RFE_290MV ( 0x4U << 0 )
745#define NFC4_FIELD_THLD_ACT_RFE_400MV ( 0x5U << 0 )
746#define NFC4_FIELD_THLD_ACT_RFE_560MV ( 0x6U << 0 )
747#define NFC4_FIELD_THLD_ACT_RFE_800MV ( 0x7U << 0 )
748#define NFC4_FIELD_THLD_ACT_RFE_25MV ( 0x8U << 0 )
749#define NFC4_FIELD_THLD_ACT_RFE_33MV ( 0x9U << 0 )
750#define NFC4_FIELD_THLD_ACT_RFE_47MV ( 0xAU << 0 )
751#define NFC4_FIELD_THLD_ACT_RFE_64MV ( 0xBU << 0 )
752#define NFC4_FIELD_THLD_ACT_RFE_90MV ( 0xCU << 0 )
753#define NFC4_FIELD_THLD_ACT_RFE_125MV ( 0xDU << 0 )
754#define NFC4_FIELD_THLD_ACT_RFE_175MV ( 0xEU << 0 )
755#define NFC4_FIELD_THLD_ACT_RFE_250MV ( 0xFU << 0 )
756#define NFC4_FIELD_THLD_ACT_RFE_MASK ( 0xFU << 0 )
757#define NFC4_FIELD_THLD_ACT_RFE_SHIFT ( 0U )
759#define NFC4_FIELD_THLD_DEACT_TRG_L2D ( 1U << 6 )
760#define NFC4_FIELD_THLD_DEACT_TRG_L1D ( 1U << 5 )
761#define NFC4_FIELD_THLD_DEACT_TRG_L0D ( 1U << 4 )
762#define NFC4_FIELD_THLD_DEACT_TRG_75MV ( 0x0U << 4 )
763#define NFC4_FIELD_THLD_DEACT_TRG_105MV ( 0x1U << 4 )
764#define NFC4_FIELD_THLD_DEACT_TRG_150MV ( 0x2U << 4 )
765#define NFC4_FIELD_THLD_DEACT_TRG_205MV ( 0x3U << 4 )
766#define NFC4_FIELD_THLD_DEACT_TRG_290MV ( 0x4U << 4 )
767#define NFC4_FIELD_THLD_DEACT_TRG_400MV ( 0x5U << 4 )
768#define NFC4_FIELD_THLD_DEACT_TRG_560MV ( 0x6U << 4 )
769#define NFC4_FIELD_THLD_DEACT_TRG_800MV ( 0x7U << 4 )
770#define NFC4_FIELD_THLD_DEACT_TRG_MASK ( 7U << 4 )
771#define NFC4_FIELD_THLD_DEACT_TRG_SHIFT ( 4U )
772#define NFC4_FIELD_THLD_DEACT_RFE_T3D ( 1U << 3 )
773#define NFC4_FIELD_THLD_DEACT_RFE_T2D ( 1U << 2 )
774#define NFC4_FIELD_THLD_DEACT_RFE_T1D ( 1U << 1 )
775#define NFC4_FIELD_THLD_DEACT_RFE_T0D ( 1U << 0 )
776#define NFC4_FIELD_THLD_DEACT_RFE_75MV ( 0x0U << 0 )
777#define NFC4_FIELD_THLD_DEACT_RFE_105MV ( 0x1U << 0 )
778#define NFC4_FIELD_THLD_DEACT_RFE_150MV ( 0x2U << 0 )
779#define NFC4_FIELD_THLD_DEACT_RFE_205MV ( 0x3U << 0 )
780#define NFC4_FIELD_THLD_DEACT_RFE_290MV ( 0x4U << 0 )
781#define NFC4_FIELD_THLD_DEACT_RFE_400MV ( 0x5U << 0 )
782#define NFC4_FIELD_THLD_DEACT_RFE_560MV ( 0x6U << 0 )
783#define NFC4_FIELD_THLD_DEACT_RFE_800MV ( 0x7U << 0 )
784#define NFC4_FIELD_THLD_DEACT_RFE_25MV ( 0x8U << 0 )
785#define NFC4_FIELD_THLD_DEACT_RFE_33MV ( 0x9U << 0 )
786#define NFC4_FIELD_THLD_DEACT_RFE_47MV ( 0xAU << 0 )
787#define NFC4_FIELD_THLD_DEACT_RFE_64MV ( 0xBU << 0 )
788#define NFC4_FIELD_THLD_DEACT_RFE_90MV ( 0xCU << 0 )
789#define NFC4_FIELD_THLD_DEACT_RFE_125MV ( 0xDU << 0 )
790#define NFC4_FIELD_THLD_DEACT_RFE_175MV ( 0xEU << 0 )
791#define NFC4_FIELD_THLD_DEACT_RFE_250MV ( 0xFU << 0 )
792#define NFC4_FIELD_THLD_DEACT_RFE_MASK ( 0xFU << 0 )
793#define NFC4_FIELD_THLD_DEACT_RFE_SHIFT ( 0U )
795#define NFC4_REGULATOR_CTRL_REG_S ( 1U << 7 )
796#define NFC4_REGULATOR_CTRL_REGE_3 ( 1U << 6 )
797#define NFC4_REGULATOR_CTRL_REGE_2 ( 1U << 5 )
798#define NFC4_REGULATOR_CTRL_REGE_1 ( 1U << 4 )
799#define NFC4_REGULATOR_CTRL_REGE_0 ( 1U << 3 )
800#define NFC4_REGULATOR_CTRL_REGE_MASK ( 0xFU << 3 )
801#define NFC4_REGULATOR_CTRL_REGE_SHIFT ( 3U )
802#define NFC4_REGULATOR_CTRL_MPSV2 ( 2U << 2 )
803#define NFC4_REGULATOR_CTRL_MPSV1 ( 1U << 1 )
804#define NFC4_REGULATOR_CTRL_MPSV0 ( 1U << 0 )
805#define NFC4_REGULATOR_CTRL_MPSV_VDD ( 0U )
806#define NFC4_REGULATOR_CTRL_MPSV_VDD_A ( 1U )
807#define NFC4_REGULATOR_CTRL_MPSV_VDD_D ( 2U )
808#define NFC4_REGULATOR_CTRL_MPSV_VDD_RF ( 3U )
809#define NFC4_REGULATOR_CTRL_MPSV_VDD_AM ( 4U )
810#define NFC4_REGULATOR_CTRL_RFU ( 5U )
811#define NFC4_REGULATOR_CTRL_RFU1 ( 6U )
812#define NFC4_REGULATOR_CTRL_RFU2 ( 7U )
813#define NFC4_REGULATOR_CTRL_MPSV_MASK ( 7U )
814#define NFC4_REGULATOR_CTRL_MPSV_SHIFT ( 0U )
821#define NFC4_SET_DEV_ADDR 0x50
831#define NFC4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
832#define NFC4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
850#define NFC4_MAP_MIKROBUS( cfg, mikrobus ) \
851 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
852 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
853 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
854 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
855 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
856 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
857 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
885 const uint8_t *analog_config_table;
886 uint16_t analog_config_table_size;
913 uint16_t* rx_rcvd_len;
971 uint16_t bytes_total;
972 uint16_t bytes_written;
993 uint8_t anticollision_info;
994 uint8_t platform_info;
1014 uint8_t nfc_id1_len;
1053 uint8_t sel_dev_idx;
1058 bool is_oper_ongoing;
1099 uint8_t* nfc_id1_len;
1100 uint8_t cascade_lvl;
1102 uint8_t bytes_tx_rx;
1158 uint8_t i2c_address;
1161 spi_master_mode_t spi_mode;
1162 spi_master_chip_select_polarity_t cs_polarity;
#define NFC4_NFCA_CASCADE_3_UID_LEN
Definition nfc4.h:377
#define NFC4_NFC_MAX_DEVICES
Definition nfc4.h:378
#define NFC4_NFCA_CASCADE_1_UID_LEN
NFC 4 Click RFAL NFC macros.
Definition nfc4.h:375
#define NFC4_NFCA_SLP_REQ_LEN
Definition nfc4.h:401
err_t nfc4_write_fifo(nfc4_t *ctx, uint8_t *data_in, uint16_t len)
NFC 4 write fifo function.
err_t nfc4_read_fifo(nfc4_t *ctx, uint8_t *data_out, uint16_t len)
NFC 4 read fifo function.
err_t nfc4_get_mifare_tag_uid(nfc4_t *ctx, uint8_t *uid, uint8_t *uid_len)
NFC 4 get mifare tag UID function.
err_t nfc4_check_chip_id(nfc4_t *ctx, uint8_t *revision)
NFC 4 check chip ID function.
uint32_t nfc4_wait_for_interrupt(nfc4_t *ctx, uint32_t mask, uint32_t timeout)
NFC 4 wait for interrupt function.
err_t nfc4_send_direct_command_with_result(nfc4_t *ctx, uint8_t cmd, uint8_t result_reg, uint32_t timeout, uint8_t *result)
NFC 4 send direct command with result function.
err_t nfc4_write_test_register(nfc4_t *ctx, uint8_t reg, uint8_t data_in)
NFC 4 write test register function.
void nfc4_cfg_setup(nfc4_cfg_t *cfg)
NFC 4 configuration object setup function.
err_t nfc4_check_for_received_interrupts(nfc4_t *ctx)
NFC 4 check for received interrupts function.
err_t nfc4_modify_register_bits(nfc4_t *ctx, uint8_t reg, uint8_t clr_mask, uint8_t set_mask)
NFC 4 modify register bits function.
err_t nfc4_disable_interrupt(nfc4_t *ctx, uint32_t mask)
NFC 4 disable interrupt function.
uint32_t nfc4_get_interrupt(nfc4_t *ctx, uint32_t mask)
NFC 4 get interrupt function.
void nfc4_drv_interface_selection(nfc4_cfg_t *cfg, nfc4_drv_t drv_sel)
NFC 4 driver interface setup function.
err_t nfc4_generic_read(nfc4_t *ctx, uint8_t reg, uint8_t *data_out, uint16_t len)
NFC 4 data reading function.
err_t nfc4_modify_test_register_bits(nfc4_t *ctx, uint8_t reg, uint8_t clr_mask, uint8_t set_mask)
NFC 4 modify test register bits function.
err_t nfc4_write_register(nfc4_t *ctx, uint8_t reg, uint8_t data_in)
NFC 4 write register function.
err_t nfc4_generic_write(nfc4_t *ctx, uint8_t reg, uint8_t *data_in, uint16_t len)
NFC 4 data writing function.
err_t nfc4_measure_voltage(nfc4_t *ctx, uint8_t mpsv_src, uint16_t *res_mv)
NFC 4 measure voltage function.
err_t nfc4_default_cfg(nfc4_t *ctx)
NFC 4 default configuration function.
err_t nfc4_clear_interrupts(nfc4_t *ctx)
NFC 4 clear interrupts function.
err_t nfc4_write_multiple_registers(nfc4_t *ctx, uint8_t reg, uint8_t *data_in, uint16_t len)
NFC 4 write multiple registers function.
err_t nfc4_enable_osc(nfc4_t *ctx)
NFC 4 enable oscillator and regulator function.
err_t nfc4_init(nfc4_t *ctx, nfc4_cfg_t *cfg)
NFC 4 initialization function.
err_t nfc4_read_test_register(nfc4_t *ctx, uint8_t reg, uint8_t *data_out)
NFC 4 read test register function.
err_t nfc4_read_register(nfc4_t *ctx, uint8_t reg, uint8_t *data_out)
NFC 4 read register function.
err_t nfc4_read_multiple_registers(nfc4_t *ctx, uint8_t reg, uint8_t *data_out, uint16_t len)
NFC 4 read multiple registers function.
err_t nfc4_enable_interrupt(nfc4_t *ctx, uint32_t mask)
NFC 4 enable interrupt function.
uint8_t nfc4_get_irq_pin(nfc4_t *ctx)
NFC 4 get irq pin function.
err_t nfc4_send_direct_command(nfc4_t *ctx, uint8_t cmd)
NFC 4 send direct command function.
err_t nfc4_set_register_bits(nfc4_t *ctx, uint8_t reg, uint8_t set_mask)
NFC 4 set register bits function.
err_t nfc4_clear_register_bits(nfc4_t *ctx, uint8_t reg, uint8_t clr_mask)
NFC 4 clear register bits function.
nfc4_rfal_transceive_state_t
NFC 4 Click rfal transceive states enum.
Definition nfc4.h:933
@ NFC4_TXRX_STATE_RX_READ_DATA
Definition nfc4.h:954
@ NFC4_TXRX_STATE_TX_IDLE
Definition nfc4.h:938
@ NFC4_TXRX_STATE_RX_IDLE
Definition nfc4.h:948
@ NFC4_TXRX_STATE_TX_WAIT_GT
Definition nfc4.h:939
@ NFC4_TXRX_STATE_TX_DONE
Definition nfc4.h:945
@ NFC4_TXRX_STATE_RX_WAIT_EOF
Definition nfc4.h:955
@ NFC4_TXRX_STATE_TX_WAIT_WL
Definition nfc4.h:942
@ NFC4_TXRX_STATE_RX_READ_FIFO
Definition nfc4.h:952
@ NFC4_TXRX_STATE_RX_FAIL
Definition nfc4.h:957
@ NFC4_TXRX_STATE_RX_WAIT_EON
Definition nfc4.h:949
@ NFC4_TXRX_STATE_RX_WAIT_RXE
Definition nfc4.h:951
@ NFC4_TXRX_STATE_TX_WAIT_FDT
Definition nfc4.h:940
@ NFC4_TXRX_STATE_TX_TRANSMIT
Definition nfc4.h:941
@ NFC4_TXRX_STATE_RX_ERR_CHECK
Definition nfc4.h:953
@ NFC4_TXRX_STATE_START
Definition nfc4.h:936
@ NFC4_TXRX_STATE_TX_RELOAD_FIFO
Definition nfc4.h:943
@ NFC4_TXRX_STATE_TX_WAIT_TXE
Definition nfc4.h:944
@ NFC4_TXRX_STATE_TX_FAIL
Definition nfc4.h:946
@ NFC4_TXRX_STATE_RX_WAIT_RXS
Definition nfc4.h:950
@ NFC4_TXRX_STATE_IDLE
Definition nfc4.h:934
@ NFC4_TXRX_STATE_RX_DONE
Definition nfc4.h:956
@ NFC4_TXRX_STATE_INIT
Definition nfc4.h:935
nfc4_rfal_nfc_state_t
NFC 4 Click RFAL NFC state enum.
Definition nfc4.h:1045
@ NFC4_NFC_STATE_IDLE
Definition nfc4.h:1047
@ NFC4_NFC_STATE_NOTINIT
Definition nfc4.h:1046
@ NFC4_NFC_STATE_DEACTIVATION
Definition nfc4.h:1052
@ NFC4_NFC_STATE_ACTIVATED
Definition nfc4.h:1051
@ NFC4_NFC_STATE_POLL_COLAVOIDANCE
Definition nfc4.h:1049
@ NFC4_NFC_STATE_POLL_ACTIVATION
Definition nfc4.h:1050
@ NFC4_NFC_STATE_START_DISCOVERY
Definition nfc4.h:1048
nfc4_nfca_cmd_value_t
NFC 4 Click SDD_REQ (Select) request Cascade Level command values.
Definition nfc4.h:1304
@ NFC4_NFCA_CMD_SEL_CL3
Definition nfc4.h:1307
@ NFC4_NFCA_CMD_SEL_CL1
Definition nfc4.h:1305
@ NFC4_NFCA_CMD_SEL_CL2
Definition nfc4.h:1306
nfc4_col_res_state_t
NFC 4 Click Colission Resolution states enum.
Definition nfc4.h:1088
@ NFC4_NFCA_CR_DONE
Definition nfc4.h:1092
@ NFC4_NFCA_CR_SEL
Definition nfc4.h:1091
@ NFC4_NFCA_CR_SDD
Definition nfc4.h:1090
@ NFC4_NFCA_CR_CL
Definition nfc4.h:1089
nfc4_nfca_sel_value_t
NFC 4 Click SDD_REQ (Select) Cascade Levels values.
Definition nfc4.h:1293
@ NFC4_NFCA_SEL_CASCADE_L3
Definition nfc4.h:1296
@ NFC4_NFCA_SEL_CASCADE_L2
Definition nfc4.h:1295
@ NFC4_NFCA_SEL_CASCADE_L1
Definition nfc4.h:1294
err_t(* nfc4_master_io_t)(struct nfc4_s *, uint8_t, uint8_t *, uint16_t)
NFC 4 Click driver interface.
Definition nfc4.h:886
struct nfc4_s nfc4_t
NFC 4 Click context object.
nfc4_rfal_14443a_short_frame_cmd_t
NFC 4 Click RFAL ISO 14443A Short Frame Command values.
Definition nfc4.h:1283
@ NFC4_14443A_SHORTFRAME_CMD_WUPA
Definition nfc4.h:1284
@ NFC4_14443A_SHORTFRAME_CMD_REQA
Definition nfc4.h:1285
nfc4_rfal_return_value_t
NFC 4 Click RFAL library return value data.
Definition nfc4.h:1193
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE_01
Definition nfc4.h:1236
@ NFC4_RFAL_ERR_MEM_CORRUPT
Definition nfc4.h:1208
@ NFC4_RFAL_ERR_RELEASE_REQ
Definition nfc4.h:1226
@ NFC4_RFAL_ERR_MAX_RERUNS
Definition nfc4.h:1229
@ NFC4_RFAL_ERR_INTERNAL
Definition nfc4.h:1206
@ NFC4_RFAL_ERR_INVALID_HANDLE
Definition nfc4.h:1234
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE
Definition nfc4.h:1235
@ NFC4_RFAL_ERR_DISABLED
Definition nfc4.h:1230
@ NFC4_RFAL_ERR_PROTO
Definition nfc4.h:1205
@ NFC4_RFAL_ERR_CRC
Definition nfc4.h:1216
@ NFC4_RFAL_ERR_PARAM
Definition nfc4.h:1201
@ NFC4_RFAL_ERR_NOMSG
Definition nfc4.h:1200
@ NFC4_RFAL_ERR_SEMANTIC
Definition nfc4.h:1214
@ NFC4_RFAL_ERR_AGAIN
Definition nfc4.h:1207
@ NFC4_RFAL_ERR_FRAMING
Definition nfc4.h:1203
@ NFC4_RFAL_ERR_RF_COLLISION
Definition nfc4.h:1224
@ NFC4_RFAL_ERR_NOT_IMPLEMENTED
Definition nfc4.h:1209
@ NFC4_RFAL_ERR_NOTUNIQUE
Definition nfc4.h:1218
@ NFC4_RFAL_ERR_BUSY
Definition nfc4.h:1196
@ NFC4_RFAL_ERR_PC_CORRUPT
Definition nfc4.h:1210
@ NFC4_RFAL_ERR_NOMEM
Definition nfc4.h:1195
@ NFC4_RFAL_ERR_OVERRUN
Definition nfc4.h:1204
@ NFC4_RFAL_ERR_SYSTEM
Definition nfc4.h:1202
@ NFC4_RFAL_ERR_IO
Definition nfc4.h:1197
@ NFC4_RFAL_ERR_WRONG_STATE
Definition nfc4.h:1228
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE_04
Definition nfc4.h:1239
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE_03
Definition nfc4.h:1238
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE_02
Definition nfc4.h:1237
@ NFC4_RFAL_ERR_FIFO
Definition nfc4.h:1221
@ NFC4_RFAL_ERR_NOTFOUND
Definition nfc4.h:1217
@ NFC4_RFAL_ERR_REQUEST
Definition nfc4.h:1199
@ NFC4_RFAL_ERR_LINK_LOSS
Definition nfc4.h:1232
@ NFC4_RFAL_ERR_WRITE
Definition nfc4.h:1220
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE_07
Definition nfc4.h:1242
@ NFC4_RFAL_ERR_NONE
Definition nfc4.h:1194
@ NFC4_RFAL_ERR_IGNORE
Definition nfc4.h:1213
@ NFC4_RFAL_ERR_PAR
Definition nfc4.h:1222
@ NFC4_RFAL_ERR_DONE
Definition nfc4.h:1223
@ NFC4_RFAL_ERR_HW_MISMATCH
Definition nfc4.h:1231
@ NFC4_RFAL_ERR_SLEEP_REQ
Definition nfc4.h:1227
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE_06
Definition nfc4.h:1241
@ NFC4_RFAL_ERR_INCOMPLETE_BYTE_05
Definition nfc4.h:1240
@ NFC4_RFAL_ERR_SYNTAX
Definition nfc4.h:1215
@ NFC4_RFAL_ERR_HW_OVERRUN
Definition nfc4.h:1225
@ NFC4_RFAL_ERR_TIMEOUT
Definition nfc4.h:1198
@ NFC4_RFAL_ERR_SEND
Definition nfc4.h:1212
@ NFC4_RFAL_ERR_NOTSUPP
Definition nfc4.h:1219
nfc4_tx_rx_flags_value_t
NFC 4 Click TXRX flags values.
Definition nfc4.h:1251
@ NFC4_TXRX_FLAGS_PAR_RX_KEEP
Definition nfc4.h:1265
@ NFC4_TXRX_FLAGS_CRC_RX_KEEP
Definition nfc4.h:1254
@ NFC4_TXRX_FLAGS_PAR_TX_NONE
Definition nfc4.h:1269
@ NFC4_TXRX_FLAGS_AGC_ON
Definition nfc4.h:1263
@ NFC4_TXRX_FLAGS_PAR_TX_AUTO
Definition nfc4.h:1271
@ NFC4_TXRX_FLAGS_CRC_TX_MANUAL
Definition nfc4.h:1253
@ NFC4_TXRX_FLAGS_NFCV_FLAG_AUTO
Definition nfc4.h:1274
@ NFC4_TXRX_FLAGS_NFCIP1_OFF
Definition nfc4.h:1259
@ NFC4_TXRX_FLAGS_AGC_OFF
Definition nfc4.h:1261
@ NFC4_TXRX_FLAGS_CRC_TX_AUTO
Definition nfc4.h:1252
@ NFC4_TXRX_FLAGS_CRC_RX_REMV
Definition nfc4.h:1256
@ NFC4_TXRX_FLAGS_PAR_RX_REMV
Definition nfc4.h:1267
@ NFC4_TXRX_FLAGS_NFCIP1_ON
Definition nfc4.h:1257
@ NFC4_TXRX_FLAGS_NFCV_FLAG_MANUAL
Definition nfc4.h:1272
nfc4_drv_t
NFC 4 Click driver selector.
Definition nfc4.h:876
@ NFC4_DRV_SEL_SPI
Definition nfc4.h:877
@ NFC4_DRV_SEL_I2C
Definition nfc4.h:878
nfc4_return_value_t
NFC 4 Click return value data.
Definition nfc4.h:1182
@ NFC4_OK
Definition nfc4.h:1183
@ NFC4_ERROR
Definition nfc4.h:1184
This file contains SPI specific macros, functions, etc.
NFC 4 Click Struct for Analog Config Look Up Table Update.
Definition nfc4.h:893
NFC 4 Click Struct for Analog Config Reg Address Mask values.
Definition nfc4.h:905
NFC 4 Click configuration object.
Definition nfc4.h:1157
NFC 4 Click Colission Resolution context structure.
Definition nfc4.h:1100
NFC 4 Click RFAL FIFO structure.
Definition nfc4.h:978
NFC 4 Click RFAL NFC device structure.
Definition nfc4.h:1033
NFC 4 Click RFAL NFC structure.
Definition nfc4.h:1060
NFC 4 Click RFAL NFCA listen device structure.
Definition nfc4.h:1020
NFC 4 Click RFAL NFCA sel req structure.
Definition nfc4.h:1076
NFC 4 Click RFAL NFCA sel res structure.
Definition nfc4.h:1011
NFC 4 Click RFAL NFCA sens res structure.
Definition nfc4.h:1001
NFC 4 Click SLP_REQ (HLTA) format structure.
Definition nfc4.h:1315
NFC 4 Click RFAL NFC-A instance structure.
Definition nfc4.h:1121
NFC 4 Click RFAL structure.
Definition nfc4.h:990
NFC 4 Click rfal transceive context structure.
Definition nfc4.h:916
NFC 4 Click RFAL RX TX structure.
Definition nfc4.h:966
NFC 4 Click context object.
Definition nfc4.h:1130
nfc4_rfal_nfca_t nfca
Definition nfc4.h:1148
uint32_t int_status
Definition nfc4.h:1143
spi_master_t spi
Definition nfc4.h:1134
nfc4_master_io_t read_f
Definition nfc4.h:1141
digital_in_t irq
Definition nfc4.h:1131
nfc4_drv_t drv_sel
Definition nfc4.h:1138
i2c_master_t i2c
Definition nfc4.h:1133
nfc4_master_io_t write_f
Definition nfc4.h:1140
nfc4_rfal_t rfal
Definition nfc4.h:1146
uint8_t slave_address
Definition nfc4.h:1136
nfc4_analog_config_mgmt_t an_cfg_mgmt
Definition nfc4.h:1144
nfc4_rfal_nfc_t nfc_dev
Definition nfc4.h:1147
pin_name_t chip_select
Definition nfc4.h:1137