39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
73#define MAGICRFID_OPCODE_VERSION 0x03
74#define MAGICRFID_OPCODE_SET_BAUD_RATE 0x06
75#define MAGICRFID_OPCODE_READ_TAG_ID_SINGLE 0x21
76#define MAGICRFID_OPCODE_READ_TAG_ID_MULTIPLE 0x22
77#define MAGICRFID_OPCODE_WRITE_TAG_ID 0x23
78#define MAGICRFID_OPCODE_WRITE_TAG_DATA 0x24
79#define MAGICRFID_OPCODE_KILL_TAG 0x26
80#define MAGICRFID_OPCODE_READ_TAG_DATA 0x28
81#define MAGICRFID_OPCODE_CLEAR_TAG_ID_BUFFER 0x2A
82#define MAGICRFID_OPCODE_MULTI_PROTOCOL_TAG_OP 0x2F
83#define MAGICRFID_OPCODE_GET_READ_TX_POWER 0x62
84#define MAGICRFID_OPCODE_GET_WRITE_TX_POWER 0x64
85#define MAGICRFID_OPCODE_GET_POWER_MODE 0x68
86#define MAGICRFID_OPCODE_GET_READER_OPTIONAL_PARAMS 0x6A
87#define MAGICRFID_OPCODE_GET_PROTOCOL_PARAM 0x6B
88#define MAGICRFID_OPCODE_SET_ANTENNA_PORT 0x91
89#define MAGICRFID_OPCODE_SET_TAG_PROTOCOL 0x93
90#define MAGICRFID_OPCODE_SET_READ_TX_POWER 0x92
91#define MAGICRFID_OPCODE_SET_WRITE_TX_POWER 0x94
92#define MAGICRFID_OPCODE_SET_REGION 0x97
93#define MAGICRFID_OPCODE_SET_READER_OPTIONAL_PARAMS 0x9A
94#define MAGICRFID_OPCODE_SET_PROTOCOL_PARAM 0x9B
100#define MAGICRFID_REGION_INDIA 0x04
101#define MAGICRFID_REGION_JAPAN 0x05
102#define MAGICRFID_REGION_CHINA 0x06
103#define MAGICRFID_REGION_EUROPE 0x08
104#define MAGICRFID_REGION_KOREA 0x09
105#define MAGICRFID_REGION_AUSTRALIA 0x0B
106#define MAGICRFID_REGION_NEWZEALAND 0x0C
107#define MAGICRFID_REGION_NORTHAMERICA 0x0D
108#define MAGICRFID_REGION_OPEN 0xFF
114#define MAGICRFID_TAG_PROTOCOL_NONE 0x00
115#define MAGICRFID_TAG_PROTOCOL_ISO180006B 0x03
116#define MAGICRFID_TAG_PROTOCOL_GEN2 0x05
117#define MAGICRFID_TAG_PROTOCOL_ISO180006B_UCODE 0x06
118#define MAGICRFID_TAG_PROTOCOL_IPX64 0x07
119#define MAGICRFID_TAG_PROTOCOL_IPX256 0x08
120#define MAGICRFID_TAG_PROTOCOL_ATA 0x1D
126#define MAGICRFID_NORMAL_DELAY_TIME 50
127#define MAGICRFID_LONG_DELAY_TIME 100
128#define MAGICRFID_TIMEOUT_MS 3000
134#define MAGICRFID_HEADER 0xFF
135#define MAGICRFID_COMMAND_MAX_DATA_LEN 250
136#define MAGICRFID_RESPONSE_MAX_DATA_LEN 248
137#define MAGICRFID_EPC_MAX_DATA_LEN 16
144#define MAGICRFID_TX_DRV_BUFFER_SIZE 255
145#define MAGICRFID_RX_DRV_BUFFER_SIZE 255
163#define MAGICRFID_MAP_MIKROBUS( cfg, mikrobus ) \
164 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
165 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
166 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS )
#define MAGICRFID_RESPONSE_MAX_DATA_LEN
Definition magicrfid.h:136
#define MAGICRFID_EPC_MAX_DATA_LEN
Definition magicrfid.h:137
#define MAGICRFID_TX_DRV_BUFFER_SIZE
Magic RFID driver buffer size.
Definition magicrfid.h:144
#define MAGICRFID_RX_DRV_BUFFER_SIZE
Definition magicrfid.h:145
#define MAGICRFID_COMMAND_MAX_DATA_LEN
Definition magicrfid.h:135
void magicrfid_send_command(magicrfid_t *ctx, magicrfid_command_t cmd)
Magic RFID send command function.
void magicrfid_set_antenna_port(magicrfid_t *ctx)
Magic RFID turn on antenna port function.
uint32_t magicrfid_parse_tag_freq(magicrfid_response_t rsp)
Parse Tag Freq value.
void magicrfid_set_read_power(magicrfid_t *ctx, uint16_t power_setting)
Magic RFID set read function power.
void magicrfid_default_cfg(magicrfid_t *ctx)
Magic RFID default configuration function.
void magicrfid_parse_tag_epc(magicrfid_response_t rsp, magicrfid_epc_t *epc)
Parse Tag EPC bytes.
void magicrfid_set_baud_rate(magicrfid_t *ctx, uint32_t baud_rate)
Magic RFID set baud rate function.
void magicrfid_set_region(magicrfid_t *ctx, uint8_t region)
Magic RFID set region function.
err_t magicrfid_generic_write(magicrfid_t *ctx, uint8_t *data_buf, uint16_t len)
Magic RFID data writing function.
err_t magicrfid_get_response(magicrfid_t *ctx, magicrfid_response_t *rsp)
Magic RFID get response function.
void magicrfid_start_reading(magicrfid_t *ctx)
Magic RFID enable reading function.
err_t magicrfid_init(magicrfid_t *ctx, magicrfid_cfg_t *cfg)
Magic RFID initialization function.
void magicrfid_set_tag_protocol(magicrfid_t *ctx, uint8_t protocol)
Magic RFID set protocol function.
void magicrfid_clear_buffers(magicrfid_t *ctx)
Magic RFID clear buffers function.
int8_t magicrfid_parse_tag_rssi(magicrfid_response_t rsp)
Parse Tag RSSI value.
void magicrfid_set_reader_config(magicrfid_t *ctx, uint8_t option1, uint8_t option2)
Magic RFID set reader configuration function.
void magicrfid_set_write_power(magicrfid_t *ctx, uint16_t power_setting)
Magic RFID set write function power.
err_t magicrfid_generic_read(magicrfid_t *ctx, uint8_t *data_buf, uint16_t max_len)
Magic RFID data reading function.
void magicrfid_cfg_setup(magicrfid_cfg_t *cfg)
Magic RFID configuration object setup function.
void magicrfid_device_reset(magicrfid_t *ctx)
Magic RFID device reset function.
magicrfid_return_value_t
Magic RFID Click return value data.
Definition magicrfid.h:254
@ MAGICRFID_OK
Definition magicrfid.h:255
@ MAGICRFID_ERROR
Definition magicrfid.h:256
Magic RFID Click configuration object.
Definition magicrfid.h:194
uint32_t baud_rate
Definition magicrfid.h:203
bool uart_blocking
Definition magicrfid.h:204
uart_data_bits_t data_bit
Definition magicrfid.h:205
pin_name_t tx_pin
Definition magicrfid.h:197
pin_name_t rx_pin
Definition magicrfid.h:196
uart_stop_bits_t stop_bit
Definition magicrfid.h:207
pin_name_t en
Definition magicrfid.h:200
uart_parity_t parity_bit
Definition magicrfid.h:206
Magic RFID Click command object.
Definition magicrfid.h:216
uint8_t opcode
Definition magicrfid.h:218
uint8_t data_len
Definition magicrfid.h:217
Magic RFID Click EPC data object.
Definition magicrfid.h:241
uint16_t epc_pc
Definition magicrfid.h:243
uint8_t data_len
Definition magicrfid.h:242
uint16_t epc_crc
Definition magicrfid.h:245
Magic RFID Click response object.
Definition magicrfid.h:228
uint16_t status
Definition magicrfid.h:231
uint8_t opcode
Definition magicrfid.h:230
uint8_t data_len
Definition magicrfid.h:229
Magic RFID Click context object.
Definition magicrfid.h:176
uart_t uart
Definition magicrfid.h:181
digital_out_t en
Definition magicrfid.h:178