LibDriver NTAG21X
Loading...
Searching...
No Matches
driver_ntag21x.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_NTAG21X_H
38#define DRIVER_NTAG21X_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
76
86
97
108
117
128
143
147typedef struct ntag21x_handle_s
148{
149 uint8_t (*contactless_init)(void);
150 uint8_t (*contactless_deinit)(void);
151 uint8_t (*contactless_transceiver)(uint8_t *in_buf, uint8_t in_len,
152 uint8_t *out_buf, uint8_t *out_len);
153 void (*delay_ms)(uint32_t ms);
154 void (*debug_print)(const char *const fmt, ...);
155 uint8_t type;
156 uint8_t inited;
157 uint8_t end_page;
159
175
179
186
193#define DRIVER_NTAG21X_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
194
201#define DRIVER_NTAG21X_LINK_CONTACTLESS_INIT(HANDLE, FUC) (HANDLE)->contactless_init = FUC
202
209#define DRIVER_NTAG21X_LINK_CONTACTLESS_DEINIT(HANDLE, FUC) (HANDLE)->contactless_deinit = FUC
210
217#define DRIVER_NTAG21X_LINK_CONTACTLESS_TRANSCEIVER(HANDLE, FUC) (HANDLE)->contactless_transceiver = FUC
218
225#define DRIVER_NTAG21X_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
226
233#define DRIVER_NTAG21X_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
234
238
245
254uint8_t ntag21x_info(ntag21x_info_t *info);
255
266uint8_t ntag21x_init(ntag21x_handle_t *handle);
267
278uint8_t ntag21x_deinit(ntag21x_handle_t *handle);
279
293uint8_t ntag21x_request(ntag21x_handle_t *handle, ntag21x_type_t *type);
294
308uint8_t ntag21x_wake_up(ntag21x_handle_t *handle, ntag21x_type_t *type);
309
320uint8_t ntag21x_halt(ntag21x_handle_t *handle);
321
335uint8_t ntag21x_anticollision_cl1(ntag21x_handle_t *handle, uint8_t id[4]);
336
350uint8_t ntag21x_anticollision_cl2(ntag21x_handle_t *handle, uint8_t id[4]);
351
365uint8_t ntag21x_select_cl1(ntag21x_handle_t *handle, uint8_t id[4]);
366
380uint8_t ntag21x_select_cl2(ntag21x_handle_t *handle, uint8_t id[4]);
381
396
411uint8_t ntag21x_read_four_pages(ntag21x_handle_t *handle, uint8_t start_page, uint8_t data[16]);
412
427uint8_t ntag21x_read_page(ntag21x_handle_t *handle, uint8_t page, uint8_t data[4]);
428
449uint8_t ntag21x_fast_read_page(ntag21x_handle_t *handle, uint8_t start_page, uint8_t stop_page, uint8_t *data, uint16_t *len);
450
465uint8_t ntag21x_compatibility_write_page(ntag21x_handle_t *handle, uint8_t page, uint8_t data[4]);
466
481uint8_t ntag21x_write_page(ntag21x_handle_t *handle, uint8_t page, uint8_t data[4]);
482
496uint8_t ntag21x_read_counter(ntag21x_handle_t *handle, uint32_t *cnt);
497
511uint8_t ntag21x_read_signature(ntag21x_handle_t *handle, uint8_t signature[32]);
512
526uint8_t ntag21x_get_serial_number(ntag21x_handle_t *handle, uint8_t number[7]);
527
543
557uint8_t ntag21x_set_password(ntag21x_handle_t *handle, uint8_t pwd[4]);
558
572uint8_t ntag21x_set_pack(ntag21x_handle_t *handle, uint8_t pack[2]);
573
589uint8_t ntag21x_authenticate(ntag21x_handle_t *handle, uint8_t pwd[4], uint8_t pack[2]);
590
633uint8_t ntag21x_set_dynamic_lock(ntag21x_handle_t *handle, uint8_t lock[3]);
634
648uint8_t ntag21x_get_dynamic_lock(ntag21x_handle_t *handle, uint8_t lock[3]);
649
668uint8_t ntag21x_set_static_lock(ntag21x_handle_t *handle, uint8_t lock[2]);
669
683uint8_t ntag21x_get_static_lock(ntag21x_handle_t *handle, uint8_t lock[2]);
684
697
710
723
736
749
762
774uint8_t ntag21x_set_mirror_page(ntag21x_handle_t *handle, uint8_t page);
775
787uint8_t ntag21x_get_mirror_page(ntag21x_handle_t *handle, uint8_t *page);
788
800uint8_t ntag21x_set_protect_start_page(ntag21x_handle_t *handle, uint8_t page);
801
813uint8_t ntag21x_get_protect_start_page(ntag21x_handle_t *handle, uint8_t *page);
814
828
842
855uint8_t ntag21x_set_authenticate_limitation(ntag21x_handle_t *handle, uint8_t limit);
856
868uint8_t ntag21x_get_authenticate_limitation(ntag21x_handle_t *handle, uint8_t *limit);
869
873
880
893uint8_t ntag21x_transceiver(ntag21x_handle_t *handle, uint8_t *in_buf, uint8_t in_len, uint8_t *out_buf, uint8_t *out_len);
894
898
902
903#ifdef __cplusplus
904}
905#endif
906
907#endif
ntag21x_type_t
ntag21x type enumeration definition
ntag21x_capability_container_t
ntag21x capability container enumeration definition
uint8_t ntag21x_anticollision_cl1(ntag21x_handle_t *handle, uint8_t id[4])
ntag21x anti collision cl1
uint8_t ntag21x_set_dynamic_lock(ntag21x_handle_t *handle, uint8_t lock[3])
ntag21x set the dynamic lock
struct ntag21x_handle_s ntag21x_handle_t
ntag21x handle structure definition
uint8_t ntag21x_halt(ntag21x_handle_t *handle)
ntag21x halt
uint8_t ntag21x_set_pack(ntag21x_handle_t *handle, uint8_t pack[2])
ntag21x set the pack
ntag21x_access_t
ntag21x access enumeration definition
uint8_t ntag21x_wake_up(ntag21x_handle_t *handle, ntag21x_type_t *type)
ntag21x wake up
uint8_t ntag21x_read_signature(ntag21x_handle_t *handle, uint8_t signature[32])
ntag21x read the signature
uint8_t ntag21x_get_static_lock(ntag21x_handle_t *handle, uint8_t lock[2])
ntag21x get the static lock
uint8_t ntag21x_read_counter(ntag21x_handle_t *handle, uint32_t *cnt)
ntag21x read the counter
uint8_t ntag21x_authenticate(ntag21x_handle_t *handle, uint8_t pwd[4], uint8_t pack[2])
ntag21x authenticate
uint8_t ntag21x_fast_read_page(ntag21x_handle_t *handle, uint8_t start_page, uint8_t stop_page, uint8_t *data, uint16_t *len)
ntag21x fast read page
uint8_t ntag21x_get_dynamic_lock(ntag21x_handle_t *handle, uint8_t lock[3])
ntag21x get the dynamic lock
uint8_t ntag21x_get_mirror(ntag21x_handle_t *handle, ntag21x_mirror_t *mirror)
ntag21x get the mirror
uint8_t ntag21x_get_protect_start_page(ntag21x_handle_t *handle, uint8_t *page)
ntag21x get the start page of protection
uint8_t ntag21x_select_cl2(ntag21x_handle_t *handle, uint8_t id[4])
ntag21x select cl2
uint8_t ntag21x_compatibility_write_page(ntag21x_handle_t *handle, uint8_t page, uint8_t data[4])
ntag21x compatibility write page
uint8_t ntag21x_request(ntag21x_handle_t *handle, ntag21x_type_t *type)
ntag21x request
uint8_t ntag21x_get_version(ntag21x_handle_t *handle, ntag21x_version_t *version)
ntag21x get the version
uint8_t ntag21x_get_serial_number(ntag21x_handle_t *handle, uint8_t number[7])
ntag21x get the serial number
uint8_t ntag21x_set_mirror_byte(ntag21x_handle_t *handle, ntag21x_mirror_byte_t byte)
ntag21x set the mirror byte
uint8_t ntag21x_read_four_pages(ntag21x_handle_t *handle, uint8_t start_page, uint8_t data[16])
ntag21x read four pages
uint8_t ntag21x_deinit(ntag21x_handle_t *handle)
close the chip
uint8_t ntag21x_set_static_lock(ntag21x_handle_t *handle, uint8_t lock[2])
ntag21x set the static lock
ntag21x_modulation_mode_t
ntag21x modulation mode enumeration definition
uint8_t ntag21x_get_mirror_byte(ntag21x_handle_t *handle, ntag21x_mirror_byte_t *byte)
ntag21x get the mirror byte
uint8_t ntag21x_set_protect_start_page(ntag21x_handle_t *handle, uint8_t page)
ntag21x set the start page of protection
uint8_t ntag21x_info(ntag21x_info_t *info)
get chip information
uint8_t ntag21x_write_page(ntag21x_handle_t *handle, uint8_t page, uint8_t data[4])
ntag21x write page
uint8_t ntag21x_get_authenticate_limitation(ntag21x_handle_t *handle, uint8_t *limit)
ntag21x get the authenticate limitation
uint8_t ntag21x_get_mirror_page(ntag21x_handle_t *handle, uint8_t *page)
ntag21x get the mirror page
struct ntag21x_info_s ntag21x_info_t
ntag21x information structure definition
uint8_t ntag21x_init(ntag21x_handle_t *handle)
initialize the chip
uint8_t ntag21x_set_mirror(ntag21x_handle_t *handle, ntag21x_mirror_t mirror)
ntag21x set the mirror
ntag21x_mirror_byte_t
ntag21x mirror byte enumeration definition
uint8_t ntag21x_read_page(ntag21x_handle_t *handle, uint8_t page, uint8_t data[4])
ntag21x read page
uint8_t ntag21x_set_access(ntag21x_handle_t *handle, ntag21x_access_t access, ntag21x_bool_t enable)
ntag21x enable or disable access
uint8_t ntag21x_anticollision_cl2(ntag21x_handle_t *handle, uint8_t id[4])
ntag21x anti collision cl2
uint8_t ntag21x_get_capability_container(ntag21x_handle_t *handle, ntag21x_capability_container_t *container)
ntag21x get the capability container
uint8_t ntag21x_get_access(ntag21x_handle_t *handle, ntag21x_access_t access, ntag21x_bool_t *enable)
ntag21x get the access status
uint8_t ntag21x_set_password(ntag21x_handle_t *handle, uint8_t pwd[4])
ntag21x set the password
uint8_t ntag21x_set_authenticate_limitation(ntag21x_handle_t *handle, uint8_t limit)
ntag21x set the authenticate limitation
uint8_t ntag21x_select_cl1(ntag21x_handle_t *handle, uint8_t id[4])
ntag21x select cl1
ntag21x_bool_t
ntag21x bool enumeration definition
uint8_t ntag21x_get_modulation_mode(ntag21x_handle_t *handle, ntag21x_modulation_mode_t *mode)
ntag21x get the modulation mode
struct ntag21x_version_s ntag21x_version_t
ntag21x version structure definition
ntag21x_mirror_t
ntag21x mirror enumeration definition
uint8_t ntag21x_set_mirror_page(ntag21x_handle_t *handle, uint8_t page)
ntag21x set the mirror page
uint8_t ntag21x_set_modulation_mode(ntag21x_handle_t *handle, ntag21x_modulation_mode_t mode)
ntag21x set the modulation mode
@ NTAG21X_TYPE_INVALID
@ NTAG21X_TYPE_213_5_6
@ NTAG21X_CAPABILITY_CONTAINER_144_BYTE_NTAG213
@ NTAG21X_CAPABILITY_CONTAINER_496_BYTE_NTAG215
@ NTAG21X_CAPABILITY_CONTAINER_872_BYTE_NTAG216
@ NTAG21X_ACCESS_NFC_COUNTER_PASSWORD_PROTECTION
@ NTAG21X_ACCESS_READ_PROTECTION
@ NTAG21X_ACCESS_USER_CONF_PROTECTION
@ NTAG21X_ACCESS_NFC_COUNTER
@ NTAG21X_MODULATION_MODE_STRONG
@ NTAG21X_MODULATION_MODE_NORMAL
@ NTAG21X_MIRROR_BYTE_1
@ NTAG21X_MIRROR_BYTE_0
@ NTAG21X_MIRROR_BYTE_3
@ NTAG21X_MIRROR_BYTE_2
@ NTAG21X_BOOL_TRUE
@ NTAG21X_BOOL_FALSE
@ NTAG21X_MIRROR_NFC_COUNTER_ASCII
@ NTAG21X_MIRROR_UID_ASCII
@ NTAG21X_MIRROR_NO_ASCII
@ NTAG21X_MIRROR_UID_NFC_COUNTER_ASCII
uint8_t ntag21x_transceiver(ntag21x_handle_t *handle, uint8_t *in_buf, uint8_t in_len, uint8_t *out_buf, uint8_t *out_len)
transceiver data
ntag21x handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* contactless_deinit)(void)
uint8_t(* contactless_transceiver)(uint8_t *in_buf, uint8_t in_len, uint8_t *out_buf, uint8_t *out_len)
uint8_t(* contactless_init)(void)
ntag21x information structure definition
uint32_t driver_version
char manufacturer_name[32]
ntag21x version structure definition
uint8_t minor_product_version
uint8_t major_product_version