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_spi_master.h"
74#define NFC6_CONTROL_SEND_COMMAND 0x00
75#define NFC6_CONTROL_READ_DATA 0x02
76#define NFC6_CONTROL_POLL_READY 0x03
77#define NFC6_CONTROL_RESET_DEVICE 0x01
78#define NFC6_CONTROL_POLL_READY_FLAG 0x08
84#define NFC6_CMD_IDN 0x01
85#define NFC6_CMD_PROTOCOL_SELECT 0x02
86#define NFC6_CMD_POLL_FIELD 0x03
87#define NFC6_CMD_SEND_RECV 0x04
88#define NFC6_CMD_LISTEN 0x05
89#define NFC6_CMD_SEND 0x06
90#define NFC6_CMD_IDLE 0x07
91#define NFC6_CMD_RD_REG 0x08
92#define NFC6_CMD_WR_REG 0x09
93#define NFC6_CMD_SUB_FREQ_RES 0x0B
94#define NFC6_CMD_AC_FILTER 0x0D
95#define NFC6_CMD_ECHO 0x55
113#define NFC6_RSP_FIXED_BYTES 0x80
114#define NFC6_RSP_FIXED_BYTES_MASK 0x8F
115#define NFC6_RSP_LONG_FRAME_MASK 0x60
116#define NFC6_RSP_OK 0x00
117#define NFC6_RSP_ECHO 0x55
118#define NFC6_RSP_MAX_DATA_LEN 528u
119#define NFC6_RSP_READY_TIMEOUT_MS 5000ul
125#define NFC6_IDLE_CMD_LENGTH 14
126#define NFC6_IDLE_CMD_WU_SOURCE 0x03
127#define NFC6_IDLE_CMD_ENTER_CTRL_L 0xA1
128#define NFC6_IDLE_CMD_ENTER_CTRL_H 0x00
129#define NFC6_IDLE_CMD_WU_CTRL_L 0xF8
130#define NFC6_IDLE_CMD_WU_CTRL_H 0x01
131#define NFC6_IDLE_CMD_LEAVE_CTRL_L 0x18
132#define NFC6_IDLE_CMD_LEAVE_CTRL_H 0x00
133#define NFC6_IDLE_CMD_WU_PERIOD 0x20
134#define NFC6_IDLE_CMD_OSC_START 0x60
135#define NFC6_IDLE_CMD_DAC_START 0x60
136#define NFC6_IDLE_CMD_DAC_DATA_L 0x00
137#define NFC6_IDLE_CMD_DAC_DATA_H 0x00
138#define NFC6_IDLE_CMD_DAC_DATA_H_MIN 0x00
139#define NFC6_IDLE_CMD_DAC_DATA_H_MAX 0xFC
140#define NFC6_IDLE_CMD_SWINGS_CNT 0x3F
141#define NFC6_IDLE_CMD_MAX_SLEEP 0x01
142#define NFC6_IDLE_RSP_TIMEOUT 0x01
143#define NFC6_IDLE_RSP_TAG_DETECT 0x02
144#define NFC6_IDLE_RSP_LENGTH 1
145#define NFC6_IDLE_CALIB_START 0x80
151#define NFC6_PROTOCOL_FIELD_OFF 0
152#define NFC6_PROTOCOL_ISO_15693 1
153#define NFC6_PROTOCOL_ISO_14443A 2
154#define NFC6_PROTOCOL_ISO_14443B 3
155#define NFC6_PROTOCOL_FELICA 4
161#define NFC6_TAG_UID_RSP_MAX_DATA_LEN 10
162#define NFC6_TAG_UID_MAX_LEN 7
163#define NFC6_MIFARE_REQA 0x26
164#define NFC6_MIFARE_REQA_LEN 0x07
165#define NFC6_MIFARE_WUPA 0x52
166#define NFC6_MIFARE_CL1 0x93
167#define NFC6_MIFARE_CL2 0x95
168#define NFC6_MIFARE_ANTICOLLISION 0x20
169#define NFC6_MIFARE_ANTICOLLISION_LEN 0x08
170#define NFC6_MIFARE_SELECT 0x70
171#define NFC6_MIFARE_CASCADE_TAG 0x88
172#define NFC6_MIFARE_READ 0x30
173#define NFC6_MIFARE_WRITE 0xA0
183#define NFC6_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
184#define NFC6_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
202#define NFC6_MAP_MIKROBUS( cfg, mikrobus ) \
203 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
204 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
205 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
206 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
207 cfg.irq_in = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
208 cfg.irq_out = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t nfc6_init(nfc6_t *ctx, nfc6_cfg_t *cfg)
NFC 6 initialization function.
err_t nfc6_select_protocol(nfc6_t *ctx, uint8_t protocol)
NFC 6 select protocol function.
err_t nfc6_send_command(nfc6_t *ctx, uint8_t cmd, uint8_t *data_in, uint8_t len)
NFC 6 send command function.
err_t nfc6_poll_ready_irq(nfc6_t *ctx)
NFC 6 poll ready irq function.
void nfc6_pulse_irq_in(nfc6_t *ctx)
NFC 6 pulse irq in function.
err_t nfc6_reset_device(nfc6_t *ctx)
NFC 6 reset device function.
uint8_t nfc6_get_irq_out_pin(nfc6_t *ctx)
NFC 6 get irq out pin function.
void nfc6_cfg_setup(nfc6_cfg_t *cfg)
NFC 6 configuration object setup function.
void nfc6_set_irq_in_pin(nfc6_t *ctx, uint8_t state)
NFC 6 set irq in pin function.
err_t nfc6_default_cfg(nfc6_t *ctx)
NFC 6 default configuration function.
err_t nfc6_check_command_echo(nfc6_t *ctx)
NFC 6 check command echo function.
err_t nfc6_read_mifare_tag_uid(nfc6_t *ctx, uint8_t *tag_uid, uint8_t *tag_uid_len)
NFC 6 read MIFARE tag UID function.
err_t nfc6_read_data(nfc6_t *ctx, uint8_t *data_out, uint16_t buffer_size, uint16_t *rx_len)
NFC 6 read data function.
err_t nfc6_calibrate_device(nfc6_t *ctx)
NFC 6 calibrate device function.
err_t nfc6_poll_ready(nfc6_t *ctx)
NFC 6 poll ready function.
nfc6_return_value_t
NFC 6 Click return value data.
Definition nfc6.h:262
@ NFC6_ERROR
Definition nfc6.h:264
@ NFC6_OK
Definition nfc6.h:263
This file contains SPI specific macros, functions, etc.
NFC 6 Click configuration object.
Definition nfc6.h:239
pin_name_t irq_in
Definition nfc6.h:247
spi_master_chip_select_polarity_t cs_polarity
Definition nfc6.h:253
pin_name_t sck
Definition nfc6.h:243
spi_master_mode_t spi_mode
Definition nfc6.h:252
pin_name_t mosi
Definition nfc6.h:242
uint32_t spi_speed
Definition nfc6.h:251
pin_name_t miso
Definition nfc6.h:241
pin_name_t irq_out
Definition nfc6.h:248
pin_name_t cs
Definition nfc6.h:244
NFC 6 Click context object.
Definition nfc6.h:218
digital_in_t irq_out
Definition nfc6.h:223
spi_master_t spi
Definition nfc6.h:226
digital_out_t irq_in
Definition nfc6.h:220
pin_name_t chip_select
Definition nfc6.h:228
uint8_t cal_dac_data_h
Definition nfc6.h:230