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 NFC2_RF_DISCOVER_MAP_CMD 0x00
74#define NFC2_RF_DISCOVER_MAP_RSP 0x00
75#define NFC2_RF_SET_LISTEN_MODE_ROUTING_CMD 0x01
76#define NFC2_RF_SET_LISTEN_MODE_ROUTING_RSP 0x01
77#define NFC2_RF_GET_LISTEN_MODE_ROUTING_CMD 0x02
78#define NFC2_RF_GET_LISTEN_MODE_ROUTING_RSP 0x02
79#define NFC2_RF_GET_LISTEN_MODE_ROUTING_NTF 0x02
80#define NFC2_RF_DISCOVER_CMD 0x03
81#define NFC2_RF_DISCOVER_RSP 0x03
82#define NFC2_RF_DISCOVER_NTF 0x03
83#define NFC2_RF_DISCOVER_SELECT_CMD 0x04
84#define NFC2_RF_DISCOVER_SELECT_RSP 0x04
85#define NFC2_RF_INTF_ACTIVATED_NTF 0x05
86#define NFC2_RF_DEACTIVATE_CMD 0x06
87#define NFC2_RF_DEACTIVATE_RSP 0x06
88#define NFC2_RF_DEACTIVATE_NTF 0x06
89#define NFC2_RF_FIELD_INFO_NTF 0x07
90#define NFC2_RF_T3T_POLLING_CMD 0x08
91#define NFC2_RF_T3T_POLLING_RSP 0x08
92#define NFC2_RF_T3T_POLLING_NTF 0x08
93#define NFC2_RF_NFCEE_ACTION_NTF 0x09
94#define NFC2_RF_NFCEE_DISCOVERY_REQ_NTF 0x0A
95#define NFC2_RF_PARAMETER_UPDATE_CMD 0x0B
96#define NFC2_RF_PARAMETER_UPDATE_RSP 0x0B
98#define NFC2_NFCEE_DISCOVER_CMD 0x00
99#define NFC2_NFCEE_DISCOVER_RSP 0x00
100#define NFC2_NFCEE_DISCOVER_NTF 0x00
101#define NFC2_NFCEE_MODE_SET_CMD 0x01
102#define NFC2_NFCEE_MODE_SET_RSP 0x01
104#define NFC2_NCI_PROPRIETARY_ACT_CMD 0x02
105#define NFC2_NCI_PROPRIETARY_ACT_RSP 0x02
106#define NFC2_RESET_KEEP_CONFIG 0x00
107#define NFC2_RESET_CLEAR_CONFIG 0x01
113#define NFC2_STATUS_OK 0x00
114#define NFC2_STATUS_REJECTED 0x01
115#define NFC2_STATUS_RF_FRAME_CORRUPTED 0x02
116#define NFC2_STATUS_FAILED 0x03
117#define NFC2_STATUS_NOT_INITIALIZED 0x04
118#define NFC2_STATUS_SYNTAX_ERROR 0x05
119#define NFC2_STATUS_SEMANTIC_ERROR 0x06
121#define NFC2_STATUS_INVALID_PARAM 0x09
122#define NFC2_STATUS_MESSAGE_SIZE_EXCEEDED 0x0A
124#define NFC2_DISCOVERY_ALREADY_STARTED 0xA0
125#define NFC2_DISCOVERY_TARGET_ACTIVATION_FAILED 0xA1
126#define NFC2_DISCOVERY_TEAR_DOWN 0xA2
128#define NFC2_RF_TRANSMISSION_ERROR 0xB0
129#define NFC2_RF_PROTOCOL_ERROR 0xB1
130#define NFC2_RF_TIMEOUT_ERROR 0xB2
132#define NFC2_NFCEE_INTERFACE_ACTIVATION_FAILED 0xC0
133#define NFC2_NFCEE_TRANSMISSION_ERROR 0xC1
134#define NFC2_NFCEE_PROTOCOL_ERROR 0xC2
135#define NFC2_NFCEE_TIMEOUT_ERROR 0xC3
137#define NFC2_NFC_RF_TECHNOLOGY_A 0x00
138#define NFC2_NFC_RF_TECHNOLOGY_B 0x01
139#define NFC2_NFC_RF_TECHNOLOGY_F 0x02
140#define NFC2_NFC_RF_TECHNOLOGY_15693 0x03
146#define NFC2_NFC_A_PASSIVE_POLL_MODE 0x00
147#define NFC2_NFC_B_PASSIVE_POLL_MODE 0x01
148#define NFC2_NFC_F_PASSIVE_POLL_MODE 0x02
149#define NFC2_NFC_A_ACTIVE_POLL_MODE 0x03
150#define NFC2_NFC_F_ACTIVE_POLL_MODE 0x05
151#define NFC2_NFC_15693_PASSIVE_POLL_MODE 0x06
153#define NFC2_NFC_A_PASSIVE_LISTEN_MODE 0x80
154#define NFC2_NFC_B_PASSIVE_LISTEN_MODE 0x81
155#define NFC2_NFC_F_PASSIVE_LISTEN_MODE 0x82
156#define NFC2_NFC_A_ACTIVE_LISTEN_MODE 0x83
157#define NFC2_NFC_F_ACTIVE_LISTEN_MODE 0x85
158#define NFC2_NFC_15693_PASSIVE_LISTEN_MODE 0x86
164#define NFC2_PROTOCOL_UNDETERMINED 0x00
165#define NFC2_PROTOCOL_T1T 0x01
166#define NFC2_PROTOCOL_T2T 0x02
167#define NFC2_PROTOCOL_T3T 0x03
168#define NFC2_PROTOCOL_ISO_DEP 0x04
169#define NFC2_PROTOCOL_NFC_DEP 0x05
171#define NFC2_NFCEE_DIRECT_RF_INTERFACE 0x00
172#define NFC2_FRAME_RF_INTERFACE 0x01
173#define NFC2_ISO_DEP_RF_INTERFACE 0x02
174#define NFC2_NFC_DEP_RF_INTERFACE 0x03
180#define NFC2_APDU 0x00
181#define NFC2_HCI_ACCES 0x01
182#define NFC2_TYPE_3_TAG_COMMAND_SET 0x02
183#define NFC2_TRANSPARENT 0x03
189#define NFC2_NFC_BIT_RATE_106 0x00
190#define NFC2_NFC_BIT_RATE_212 0x01
191#define NFC2_NFC_BIT_RATE_424 0x02
192#define NFC2_NFC_BIT_RATE_848 0x03
193#define NFC2_NFC_BIT_RATE_1695 0x04
194#define NFC2_NFC_BIT_RATE_3390 0x05
195#define NFC2_NFC_BIT_RATE_6780 0x06
201#define NFC2_IRQ_STATE_LOW 0x00
202#define NFC2_IRQ_STATE_HIGH 0x01
208#define NFC2_GROUP_ID_CORE 0x00
209#define NFC2_GROUP_ID_RF_MANAGEMENT 0x01
210#define NFC2_GROUP_ID_NFC_MANAGEMENT 0x02
211#define NFC2_GROUP_ID_PROPRIETARY 0x0F
217#define NFC2_CORE_RESET_CMD 0x00
218#define NFC2_CORE_RESET_RSP 0x00
219#define NFC2_CORE_RESET_NTF 0x00
220#define NFC2_CORE_INIT_CMD 0x01
221#define NFC2_CORE_INIT_RSP 0x01
222#define NFC2_CORE_SET_CONFIG_CMD 0x02
223#define NFC2_CORE_SET_CONFIG_RSP 0x02
224#define NFC2_CORE_GET_CONFIG_CMD 0x03
225#define NFC2_CORE_GET_CONFIG_RSP 0x03
226#define NFC2_CORE_CONN_CREATE_CMD 0x04
227#define NFC2_CORE_CONN_CREATE_RSP 0x04
228#define NFC2_CORE_CONN_CLOSE_CMD 0x05
229#define NFC2_CORE_CONN_CLOSE_RSP 0x05
230#define NFC2_CORE_CONN_CREDITS_NTF 0x06
231#define NFC2_CORE_GENERIC_ERROR_NTF 0x07
232#define NFC2_CORE_INTERFACE_ERROR_NTF 0x08
239#define NFC2_I2C_ADDR_0 0x28
240#define NFC2_I2C_ADDR_1 0x29
241#define NFC2_I2C_ADDR_2 0x2A
242#define NFC2_I2C_ADDR_3 0x2B
260#define NFC2_MAP_MIKROBUS( cfg, mikrobus ) \
261 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
262 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
263 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
264 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
317 uint8_t payload[ 256 ];
330 uint8_t payload[ 256 ];
void nfc2_default_cfg(nfc2_t *ctx, control_packet_t *ctrl_pck)
NFC 2 default configuration function.
void nfc2_core_set_protocol_config(nfc2_t *ctx)
Set protocol configuration function.
void nfc2_cmd_core_reset(nfc2_t *ctx)
Core reset command function.
void nfc2_cmd_start_discovery(nfc2_t *ctx)
Start discovery command function.
err_t nfc2_generic_write(nfc2_t *ctx, uint8_t *p_tx_data, uint8_t n_bytes)
NFC 2 I2C writing function.
void nfc2_write_ctrl_packet_data(nfc2_t *ctx, control_packet_t ctrl_pck)
Write control packet data function.
uint8_t nfc2_get_data(nfc2_t *ctx, uint8_t *p_rx_data)
Get data function.
void nfc2_read_ctrl_packet_data(nfc2_t *ctx, control_packet_t *ctrl_pck)
Read control packet data function.
void nfc2_init_core(nfc2_t *ctx)
Core initialization command function.
void nfc2_cmd_authenticate_sector(nfc2_t *ctx, uint8_t sel_sect_addr)
Authenticate sector command function.
void nfc2_core_set_default_config(nfc2_t *ctx)
Set default configuration function.
void nfc2_hw_reset(nfc2_t *ctx)
HW reset function.
void nfc2_cmd_core_init(nfc2_t *ctx)
Core init command function.
void nfc2_cmd_test_procedure(nfc2_t *ctx)
NFC test procedure command function.
uint8_t nfc2_check_irq(nfc2_t *ctx)
Check IRQ ststus function.
err_t nfc2_init(nfc2_t *ctx, nfc2_cfg_t *cfg)
NFC 2 initialization function.
void nfc2_cfg_setup(nfc2_cfg_t *cfg)
NFC 2 configuration object setup function.
void nfc2_core_reset(nfc2_t *ctx)
Core reset command function.
void nfc2_activate_rmt_mifare_card(nfc2_t *ctx)
Activate remote mifare card command function.
err_t nfc2_generic_read(nfc2_t *ctx, uint8_t *p_rx_h_data, uint8_t *p_rx_p_data)
NFC 2 I2C reading function.
void nfc2_cmd_disable_standby_mode(nfc2_t *ctx)
Disable standby mode command function.
void nfc2_cmd_antenna_test(nfc2_t *ctx, uint8_t sel_ant)
Antenna test function.
void nfc2_cmd_card_disconnected(nfc2_t *ctx)
Card disconnected command function.
nfc2_return_value_t
NFC 2 Click return value data.
Definition nfc2.h:338
@ NFC2_ERROR
Definition nfc2.h:340
@ NFC2_OK
Definition nfc2.h:339
NFC 2 Click control packet object.
Definition nfc2.h:311
uint8_t pck_bound_flag
Definition nfc2.h:313
uint8_t payload_length
Definition nfc2.h:316
uint8_t opcode_ident
Definition nfc2.h:315
uint8_t message_type
Definition nfc2.h:312
uint8_t group_ident
Definition nfc2.h:314
NFC 2 Click data packet object.
Definition nfc2.h:325
uint8_t pck_bound_flag
Definition nfc2.h:327
uint8_t conn_ident
Definition nfc2.h:328
uint8_t payload_length
Definition nfc2.h:329
uint8_t message_type
Definition nfc2.h:326
NFC 2 Click configuration object.
Definition nfc2.h:294
uint32_t i2c_speed
Definition nfc2.h:301
pin_name_t scl
Definition nfc2.h:295
pin_name_t int_pin
Definition nfc2.h:299
pin_name_t sda
Definition nfc2.h:296
pin_name_t rst
Definition nfc2.h:298
uint8_t i2c_address
Definition nfc2.h:302
NFC 2 Click context object.
Definition nfc2.h:274
digital_in_t int_pin
Definition nfc2.h:279
i2c_master_t i2c
Definition nfc2.h:282
digital_out_t rst
Definition nfc2.h:276
uint8_t slave_address
Definition nfc2.h:285