Go to the documentation of this file.
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"
73 #define NFC7I2C_NCI_PKT_MT_DATA 0x00
74 #define NFC7I2C_NCI_PKT_MT_CTRL_CMD 0x01
75 #define NFC7I2C_NCI_PKT_MT_CTRL_RSP 0x02
76 #define NFC7I2C_NCI_PKT_MT_CTRL_NTF 0x03
77 #define NFC7I2C_NCI_PKT_MT_SHIFT 5
78 #define NFC7I2C_NCI_PKT_MT_MASK 0xE0
79 #define NFC7I2C_NCI_PKT_PBF_COMPLETE 0x00
80 #define NFC7I2C_NCI_PKT_PBF_NOT_COMPLETE 0x01
81 #define NFC7I2C_NCI_PKT_PBF_SHIFT 4
82 #define NFC7I2C_NCI_PKT_PBF_MASK 0x10
83 #define NFC7I2C_NCI_PKT_CTRL_GID_MASK 0x0F
84 #define NFC7I2C_NCI_PKT_CTRL_OID_MASK 0x3F
85 #define NFC7I2C_NCI_PKT_DATA_CID_MASK 0x0F
86 #define NFC7I2C_NCI_PKT_DATA_RFU 0x00
92 #define NFC7I2C_NCI_GID_CORE 0x00
93 #define NFC7I2C_NCI_GID_RF_MGMT 0x01
94 #define NFC7I2C_NCI_GID_PROP 0x0F
100 #define NFC7I2C_NCI_OID_CORE_RESET 0x00
101 #define NFC7I2C_NCI_OID_CORE_INIT 0x01
102 #define NFC7I2C_NCI_OID_CORE_SET_CONFIG 0x02
103 #define NFC7I2C_NCI_OID_CORE_GET_CONFIG 0x03
104 #define NFC7I2C_NCI_OID_CORE_CONN_CREATE 0x04
105 #define NFC7I2C_NCI_OID_CORE_CONN_CLOSE 0x05
106 #define NFC7I2C_NCI_OID_CORE_CONN_CREDITS 0x06
107 #define NFC7I2C_NCI_OID_CORE_GEN_ERR_STAT 0x07
108 #define NFC7I2C_NCI_OID_CORE_INTF_ERR_STAT 0x08
109 #define NFC7I2C_NCI_OID_RF_DISCOVER_MAP 0x00
110 #define NFC7I2C_NCI_OID_RF_SET_ROUTING 0x01
111 #define NFC7I2C_NCI_OID_RF_GET_ROUTING 0x02
112 #define NFC7I2C_NCI_OID_RF_DISCOVER 0x03
113 #define NFC7I2C_NCI_OID_RF_DISCOVER_SELECT 0x04
114 #define NFC7I2C_NCI_OID_RF_INTF_ACTIVATED 0x05
115 #define NFC7I2C_NCI_OID_RF_DEACTIVATE 0x06
116 #define NFC7I2C_NCI_OID_RF_FIELD 0x07
117 #define NFC7I2C_NCI_OID_RF_T3T_POLLING 0x08
118 #define NFC7I2C_NCI_OID_RF_EE_ACTION 0x09
119 #define NFC7I2C_NCI_OID_RF_EE_DISCOVERY_REQ 0x0A
120 #define NFC7I2C_NCI_OID_RF_PARAMETER_UPDATE 0x0B
121 #define NFC7I2C_NCI_OID_PROP_SET_PWR_MODE 0x00
122 #define NFC7I2C_NCI_OID_PROP_ACT 0x02
123 #define NFC7I2C_NCI_OID_PROP_RF_PRES_CHECK 0x11
124 #define NFC7I2C_NCI_OID_PROP_RF_LPCD_TRACE 0x13
125 #define NFC7I2C_NCI_OID_PROP_RF_GET_TRANSIT 0x14
126 #define NFC7I2C_NCI_OID_PROP_TEST_PRBS 0x30
127 #define NFC7I2C_NCI_OID_PROP_TEST_ANTENNA 0x3D
145 #define NFC7I2C_NCI_CORE_RESET_KEEP_CFG 0x00
146 #define NFC7I2C_NCI_CORE_RESET_RESET_CFG 0x01
147 #define NFC7I2C_NCI_CORE_RESET_NTF_NCI_VER_20 0x20
148 #define NFC7I2C_NCI_CORE_INIT_FEATURE_DIS 0x00
149 #define NFC7I2C_NCI_CORE_STANDBY_DISABLE 0x00
150 #define NFC7I2C_NCI_CORE_STANDBY_ENABLE 0x01
151 #define NFC7I2C_NCI_CORE_STANDBY_AUTO 0x02
157 #define NFC7I2C_NCI_STAT_OK 0x00
158 #define NFC7I2C_NCI_STAT_REJECTED 0x01
159 #define NFC7I2C_NCI_STAT_RF_FRAME_CORRUPTED 0x02
160 #define NFC7I2C_NCI_STAT_FAILED 0x03
161 #define NFC7I2C_NCI_STAT_NOT_INITIALIZED 0x04
162 #define NFC7I2C_NCI_STAT_SYNTAX_ERROR 0x05
163 #define NFC7I2C_NCI_STAT_SEMANTIC_ERROR 0x06
164 #define NFC7I2C_NCI_STAT_UNK_GID 0x07
165 #define NFC7I2C_NCI_STAT_UNK_OID 0x08
166 #define NFC7I2C_NCI_STAT_INVALID_PARAM 0x09
167 #define NFC7I2C_NCI_STAT_MSG_SIZE_EXCEEDED 0x0A
168 #define NFC7I2C_NCI_STAT_DISC_ALRDY_STARTED 0xA0
169 #define NFC7I2C_NCI_STAT_DISC_T_ACT_FAILED 0xA1
170 #define NFC7I2C_NCI_STAT_DISC_TEAR_DOWN 0xA2
171 #define NFC7I2C_NCI_STAT_RF_TX_ERROR 0xB0
172 #define NFC7I2C_NCI_STAT_RF_PROTOCOL_ERROR 0xB1
173 #define NFC7I2C_NCI_STAT_RF_TIMEOUT_ERROR 0xB2
179 #define NFC7I2C_NCI_RF_TECH_PASSIVE_POLL_NFC_A 0x00
180 #define NFC7I2C_NCI_RF_TECH_PASSIVE_POLL_NFC_B 0x01
181 #define NFC7I2C_NCI_RF_TECH_PASSIVE_POLL_NFC_F 0x02
182 #define NFC7I2C_NCI_RF_TECH_PASSIVE_POLL_15693 0x06
183 #define NFC7I2C_NCI_RF_EXE_EVERY_DISC_PERIOD 0x01
189 #define NFC7I2C_NCI_RF_PROT_UNDETERMINED 0x00
190 #define NFC7I2C_NCI_RF_PROT_T1T 0x01
191 #define NFC7I2C_NCI_RF_PROT_T2T 0x02
192 #define NFC7I2C_NCI_RF_PROT_T3T 0x03
193 #define NFC7I2C_NCI_RF_PROT_ISODEP 0x04
194 #define NFC7I2C_NCI_RF_PROT_NFCDEP 0x05
195 #define NFC7I2C_NCI_RF_PROT_T5T 0x06
196 #define NFC7I2C_NCI_RF_PROT_MIFARE 0x80
202 #define NFC7I2C_NCI_RF_INTF_UNDETERMINED 0x00
203 #define NFC7I2C_NCI_RF_INTF_FRAME 0x01
204 #define NFC7I2C_NCI_RF_INTF_ISODEP 0x02
205 #define NFC7I2C_NCI_RF_INTF_NFCDEP 0x03
206 #define NFC7I2C_NCI_RF_INTF_TAGCMD 0x80
207 #define NFC7I2C_NCI_RF_MAP_POLL_MODE 0x01
213 #define NFC7I2C_NCI_RF_DEACTIVATE_IDLE 0x00
214 #define NFC7I2C_NCI_RF_DEACTIVATE_SLEEP 0x01
215 #define NFC7I2C_NCI_RF_DEACTIVATE_SLEEP_AF 0x02
216 #define NFC7I2C_NCI_RF_DEACTIVATE_DISCOVERY 0x03
222 #define NFC7I2C_NCI_RF_CONN_ID_STATIC 0x00
223 #define NFC7I2C_NCI_RF_CONN_ID_1 0x01
224 #define NFC7I2C_NCI_RF_CONN_ID_2 0x02
225 #define NFC7I2C_NCI_RF_DISC_MORE_NTF_FOLLOW 0x02
231 #define NFC7I2C_T1T_CMD_RID 0x78
232 #define NFC7I2C_T1T_CMD_RALL 0x00
233 #define NFC7I2C_T1T_CMD_READ 0x01
234 #define NFC7I2C_T1T_CMD_WRITE_E 0x53
235 #define NFC7I2C_T1T_CMD_WRITE_NE 0x1A
236 #define NFC7I2C_T1T_CMD_RSEG 0x10
237 #define NFC7I2C_T1T_CMD_READ8 0x02
238 #define NFC7I2C_T1T_CMD_WRITE_E8 0x54
239 #define NFC7I2C_T1T_CMD_WRITE_NE8 0x1B
245 #define NFC7I2C_T2T_CMD_READ 0x30
246 #define NFC7I2C_T2T_CMD_WRITE 0xA2
247 #define NFC7I2C_T2T_CMD_SECTOR_SELECT 0xC2
248 #define NFC7I2C_T2T_ACK 0x0A
254 #define NFC7I2C_T4T_RSP_COMPLETE_1 0x90
255 #define NFC7I2C_T4T_RSP_COMPLETE_2 0x00
256 #define NFC7I2C_T4T_CLA_NO_SECURE 0x00
257 #define NFC7I2C_T4T_INS_SELECT 0xA4
258 #define NFC7I2C_T4T_P1_SELECT_BY_NAME 0x04
259 #define NFC7I2C_T4T_P2_ONLY_OCCURANCE 0x00
260 #define NFC7I2C_T4T_LE_RSP_MAY_PRESENT 0x00
261 #define NFC7I2C_T4T_PPSE_APDU "2PAY.SYS.DDF01"
267 #define NFC7I2C_ISO15693_FLAG_DR_HIGH 0x02
268 #define NFC7I2C_ISO15693_CMD_READ_SINGLE 0x20
269 #define NFC7I2C_ISO15693_CMD_WRITE_SINGLE 0x21
270 #define NFC7I2C_ISO15693_RSP_OK 0x00
276 #define NFC7I2C_MFC_REQ_XCHG_DATA 0x10
277 #define NFC7I2C_MFC_REQ_SECTOR_SEL 0x32
278 #define NFC7I2C_MFC_REQ_AUTHENTICATE 0x40
279 #define NFC7I2C_MFC_KEY_SELECTOR_A_EMB 0x10
280 #define NFC7I2C_MFC_CMD_READ 0x30
281 #define NFC7I2C_MFC_CMD_WRITE 0xA0
282 #define NFC7I2C_MFC_ACK 0x0A
288 #define NFC7I2C_NCI_CORE_TOTAL_DURATION_510MS { 0x01, 0x00, 0x02, 0xFE, 0x01 }
289 #define NFC7I2C_NCI_CORE_TAG_DETECTOR_DIS { 0x01, 0xA0, 0x40, 0x01, 0x00 }
290 #define NFC7I2C_NCI_CORE_CLOCK_SEL_XTAL { 0x01, 0xA0, 0x03, 0x01, 0x08 }
291 #define NFC7I2C_NCI_CORE_PMU_IRQ_EN_TVDD_3V3 { 0x01, 0xA0, 0x0E, 0x0B, 0x11, 0x01, 0x01, 0x01, \
292 0x00, 0x00, 0x00, 0x10, 0x00, 0xD0, 0x0C }
293 #define NFC7I2C_NCI_CORE_RF_CONF { 0x09, \
294 0xA0, 0x0D, 0x03, 0x78, 0x0D, 0x02, \
295 0xA0, 0x0D, 0x03, 0x78, 0x14, 0x02, \
296 0xA0, 0x0D, 0x06, 0x4C, 0x44, 0x65, 0x09, 0x00, 0x00, \
297 0xA0, 0x0D, 0x06, 0x4C, 0x2D, 0x05, 0x35, 0x1E, 0x01, \
298 0xA0, 0x0D, 0x06, 0x82, 0x4A, 0x55, 0x07, 0x00, 0x07, \
299 0xA0, 0x0D, 0x06, 0x44, 0x44, 0x03, 0x04, 0xC4, 0x00, \
300 0xA0, 0x0D, 0x06, 0x46, 0x30, 0x50, 0x00, 0x18, 0x00, \
301 0xA0, 0x0D, 0x06, 0x48, 0x30, 0x50, 0x00, 0x18, 0x00, \
302 0xA0, 0x0D, 0x06, 0x4A, 0x30, 0x50, 0x00, 0x08, 0x00 }
308 #define NFC7I2C_MAX_NCI_FRAME_SIZE 258
309 #define NFC7I2C_TIMEOUT_INFINITE 0
310 #define NFC7I2C_TIMEOUT_100MS 100
311 #define NFC7I2C_TIMEOUT_1S 1000
312 #define NFC7I2C_TIMEOUT_2S 2000
319 #define NFC7I2C_DEVICE_ADDRESS_0 0x28
320 #define NFC7I2C_DEVICE_ADDRESS_1 0x29
321 #define NFC7I2C_DEVICE_ADDRESS_2 0x2A
322 #define NFC7I2C_DEVICE_ADDRESS_3 0x2B
340 #define NFC7I2C_MAP_MIKROBUS( cfg, mikrobus ) \
341 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
342 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
343 cfg.ven = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
344 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
355 uint8_t sens_res[ 2 ];
357 uint8_t nfc_id[ 10 ];
359 uint8_t sel_res[ 1 ];
372 uint8_t sens_res[ 12 ];
374 uint8_t attrib_res[ 17 ];
386 uint8_t sens_res[ 18 ];
479 uint8_t fw_version[ 3 ];
NFC 7 I2C Click discovered remote device properties information object.
Definition: nfc7i2c.h:407
err_t nfc7i2c_core_init(nfc7i2c_t *ctx)
NFC 7 I2C core init function.
uint8_t nfc_id_len
Definition: nfc7i2c.h:356
NFC 7 I2C Click configuration object.
Definition: nfc7i2c.h:489
err_t nfc7i2c_reader_act_next(nfc7i2c_t *ctx, nfc7i2c_rf_intf_t *rf_intf)
NFC 7 I2C reader activate next function.
err_t nfc7i2c_wait_discovery(nfc7i2c_t *ctx, nfc7i2c_rf_intf_t *rf_intf)
NFC 7 I2C wait discovery function.
NFC 7 I2C Click poll passive type V/ISO15693 object.
Definition: nfc7i2c.h:395
err_t nfc7i2c_tx(nfc7i2c_t *ctx, uint8_t *data_in, uint16_t len)
NFC 7 I2C TX function.
digital_in_t irq
Definition: nfc7i2c.h:465
nfc7i2c_rf_intf_info_bpp_t nfc_bpp
Definition: nfc7i2c.h:409
void nfc7i2c_disable_device(nfc7i2c_t *ctx)
NFC 7 I2C disable device function.
uint8_t protocol
Definition: nfc7i2c.h:422
err_t nfc7i2c_pkt_data_tx(nfc7i2c_t *ctx, nfc7i2c_pkt_data_t *pkt)
NFC 7 I2C packet data TX function.
uint8_t sens_res_len
Definition: nfc7i2c.h:385
err_t nfc7i2c_core_clock_sel(nfc7i2c_t *ctx)
NFC 7 I2C core clock sel function.
pin_name_t sda
Definition: nfc7i2c.h:491
err_t nfc7i2c_core_rf_config(nfc7i2c_t *ctx)
NFC 7 I2C core RF config function.
err_t nfc7i2c_pkt_ctrl_tx(nfc7i2c_t *ctx, nfc7i2c_pkt_ctrl_t *pkt)
NFC 7 I2C packet control TX function.
#define NFC7I2C_MAX_NCI_FRAME_SIZE
NFC 7 I2C timeout setting.
Definition: nfc7i2c.h:308
err_t nfc7i2c_start_discovery(nfc7i2c_t *ctx)
NFC 7 I2C start discovery function.
err_t nfc7i2c_core_tag_detector(nfc7i2c_t *ctx)
NFC 7 I2C core tag detector function.
NFC 7 I2C Click poll passive type B object.
Definition: nfc7i2c.h:370
uint8_t dsf_id
Definition: nfc7i2c.h:397
NFC 7 I2C Click context object.
Definition: nfc7i2c.h:460
uint8_t sens_res_len
Definition: nfc7i2c.h:371
err_t nfc7i2c_default_cfg(nfc7i2c_t *ctx)
NFC 7 I2C default configuration function.
NFC 7 I2C Click data packet object.
Definition: nfc7i2c.h:448
err_t nfc7i2c_pkt_ctrl_trx(nfc7i2c_t *ctx, nfc7i2c_pkt_ctrl_t *pkt)
NFC 7 I2C packet control TRX function.
uint8_t attrib_res_len
Definition: nfc7i2c.h:373
uint8_t more_tags
Definition: nfc7i2c.h:424
uint16_t rsp_len
Definition: nfc7i2c.h:477
err_t nfc7i2c_core_reset(nfc7i2c_t *ctx)
NFC 7 I2C core reset function.
digital_out_t ven
Definition: nfc7i2c.h:462
uint8_t intf
Definition: nfc7i2c.h:421
uint32_t i2c_speed
Definition: nfc7i2c.h:496
void nfc7i2c_presence_check(nfc7i2c_t *ctx, nfc7i2c_rf_intf_t *rf_intf)
NFC 7 I2C presence check function.
void nfc7i2c_cfg_setup(nfc7i2c_cfg_t *cfg)
NFC 7 I2C configuration object setup function.
uint8_t mode_tech
Definition: nfc7i2c.h:423
pin_name_t scl
Definition: nfc7i2c.h:490
NFC 7 I2C Click poll passive type F object.
Definition: nfc7i2c.h:383
void nfc7i2c_reset_device(nfc7i2c_t *ctx)
NFC 7 I2C reset device function.
uint8_t slave_address
Definition: nfc7i2c.h:471
uint8_t payload_len
Definition: nfc7i2c.h:438
void nfc7i2c_enable_device(nfc7i2c_t *ctx)
NFC 7 I2C enable device function.
err_t nfc7i2c_core_total_duration(nfc7i2c_t *ctx)
NFC 7 I2C core total duration function.
@ NFC7I2C_ERROR
Definition: nfc7i2c.h:508
err_t nfc7i2c_core_pmu(nfc7i2c_t *ctx)
NFC 7 I2C core PMU function.
err_t nfc7i2c_trx(nfc7i2c_t *ctx, uint8_t *data_in, uint16_t in_len, uint8_t *data_out, uint16_t *out_len)
NFC 7 I2C TRX function.
i2c_master_t i2c
Definition: nfc7i2c.h:468
uint8_t nfc7i2c_get_irq_pin(nfc7i2c_t *ctx)
NFC 7 I2C get IRQ pin function.
uint8_t oid
Definition: nfc7i2c.h:437
nfc7i2c_rf_intf_info_t info
Definition: nfc7i2c.h:425
@ NFC7I2C_OK
Definition: nfc7i2c.h:507
err_t nfc7i2c_map_rf_interface(nfc7i2c_t *ctx)
NFC 7 I2C map RF interface function.
err_t nfc7i2c_init(nfc7i2c_t *ctx, nfc7i2c_cfg_t *cfg)
NFC 7 I2C initialization function.
nfc7i2c_pkt_ctrl_t pkt_ctrl
Definition: nfc7i2c.h:473
err_t nfc7i2c_stop_discovery(nfc7i2c_t *ctx)
NFC 7 I2C stop discovery function.
err_t nfc7i2c_core_standby(nfc7i2c_t *ctx, uint8_t mode)
NFC 7 I2C core standby function.
uint8_t i2c_address
Definition: nfc7i2c.h:497
nfc7i2c_pkt_data_t pkt_data
Definition: nfc7i2c.h:474
NFC 7 I2C Click control packet object.
Definition: nfc7i2c.h:434
uint8_t rats_len
Definition: nfc7i2c.h:360
uint8_t msg_type
Definition: nfc7i2c.h:435
err_t nfc7i2c_config_settings(nfc7i2c_t *ctx)
NFC 7 I2C config settings function.
nfc7i2c_rf_intf_info_vpp_t nfc_vpp
Definition: nfc7i2c.h:411
NFC 7 I2C Click discovered remote device properties object.
Definition: nfc7i2c.h:420
nfc7i2c_return_value_t
NFC 7 I2C Click return value data.
Definition: nfc7i2c.h:506
uint8_t payload_len
Definition: nfc7i2c.h:450
NFC 7 I2C Click poll passive type A object.
Definition: nfc7i2c.h:354
err_t nfc7i2c_pkt_data_trx(nfc7i2c_t *ctx, nfc7i2c_pkt_data_t *pkt)
NFC 7 I2C packet data TRX function.
uint8_t afi
Definition: nfc7i2c.h:396
err_t nfc7i2c_reader_tag_cmd(nfc7i2c_t *ctx, nfc7i2c_pkt_data_t *pkt)
NFC 7 I2C reader tag cmd function.
pin_name_t ven
Definition: nfc7i2c.h:493
uint8_t gid
Definition: nfc7i2c.h:436
uint8_t bitrate
Definition: nfc7i2c.h:384
nfc7i2c_rf_intf_info_fpp_t nfc_fpp
Definition: nfc7i2c.h:410
err_t nfc7i2c_reader_re_act(nfc7i2c_t *ctx, nfc7i2c_rf_intf_t *rf_intf)
NFC 7 I2C reader reactivate next function.
uint8_t cid
Definition: nfc7i2c.h:449
uint8_t sel_res_len
Definition: nfc7i2c.h:358
pin_name_t irq
Definition: nfc7i2c.h:494
err_t nfc7i2c_pkt_ctrl_rx(nfc7i2c_t *ctx, nfc7i2c_pkt_ctrl_t *pkt, uint16_t timeout)
NFC 7 I2C packet control RX function.
nfc7i2c_rf_intf_info_app_t nfc_app
Definition: nfc7i2c.h:408
err_t nfc7i2c_rx(nfc7i2c_t *ctx, uint8_t *data_out, uint16_t *len, uint16_t timeout)
NFC 7 I2C RX function.
err_t nfc7i2c_pkt_data_rx(nfc7i2c_t *ctx, nfc7i2c_pkt_data_t *pkt, uint16_t timeout)
NFC 7 I2C packet data RX function.
uint8_t next_tag_protocol
Definition: nfc7i2c.h:480