LibDriver EM4100
Loading...
Searching...
No Matches
driver_em4100_card_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static em4100_handle_t gs_handle;
41
49uint8_t em4100_card_test(void)
50{
51 uint8_t res;
52 uint8_t id[5];
53 uint8_t times;
54 em4100_info_t info;
55
56 /* link function */
63
64 /* get information */
65 res = em4100_info(&info);
66 if (res != 0)
67 {
68 em4100_interface_debug_print("em4100: get info failed.\n");
69
70 return 1;
71 }
72 else
73 {
74 /* print chip info */
75 em4100_interface_debug_print("em4100: chip is %s.\n", info.chip_name);
76 em4100_interface_debug_print("em4100: manufacturer is %s.\n", info.manufacturer_name);
77 em4100_interface_debug_print("em4100: interface is %s.\n", info.interface);
78 em4100_interface_debug_print("em4100: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
79 em4100_interface_debug_print("em4100: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
80 em4100_interface_debug_print("em4100: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
81 em4100_interface_debug_print("em4100: max current is %0.2fmA.\n", info.max_current_ma);
82 em4100_interface_debug_print("em4100: max temperature is %0.1fC.\n", info.temperature_max);
83 em4100_interface_debug_print("em4100: min temperature is %0.1fC.\n", info.temperature_min);
84 }
85
86 /* start card test */
87 em4100_interface_debug_print("em4100: start card test.\n");
88
89 /* init */
90 res = em4100_init(&gs_handle);
91 if (res != 0)
92 {
93 em4100_interface_debug_print("em4100: init failed.\n");
94
95 return 1;
96 }
97
98 times = 3;
99 while (times != 0)
100 {
101 /* try to read */
102 res = em4100_read(&gs_handle, id);
103 if (res == 0)
104 {
105 (void)em4100_print(&gs_handle, id);
106
107 break;
108 }
109
111 times--;
112 }
113
114 /* finish card test */
115 em4100_interface_debug_print("em4100: finish card test.\n");
116 (void)em4100_deinit(&gs_handle);
117
118 return 0;
119}
driver em4100 card test header file
uint8_t em4100_deinit(em4100_handle_t *handle)
close the chip
struct em4100_info_s em4100_info_t
em4100 information structure definition
uint8_t em4100_info(em4100_info_t *info)
get chip's information
uint8_t em4100_init(em4100_handle_t *handle)
initialize the chip
struct em4100_handle_s em4100_handle_t
em4100 handle structure definition
uint8_t em4100_print(em4100_handle_t *handle, uint8_t buf[5])
print id
uint8_t em4100_read(em4100_handle_t *handle, uint8_t id[5])
read data
void em4100_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t em4100_interface_contactless_deinit(void)
interface contactless deinit
uint8_t em4100_interface_contactless_init(void)
interface contactless init
uint8_t em4100_interface_contactless_read(uint32_t clock_div, uint8_t *buf, uint16_t len)
interface contactless read
void em4100_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t em4100_card_test(void)
card test
float temperature_max
float supply_voltage_max_v
uint32_t driver_version
float temperature_min
char manufacturer_name[32]
float supply_voltage_min_v
char interface[8]
char chip_name[32]