LibDriver EM4100
Loading...
Searching...
No Matches
driver_em4100_basic.c
Go to the documentation of this file.
1
36
37#include "driver_em4100_basic.h"
38
39static em4100_handle_t gs_handle;
40
48uint8_t em4100_basic_init(void)
49{
50 uint8_t res;
51
52 /* link function */
59
60 /* init */
61 res = em4100_init(&gs_handle);
62 if (res != 0)
63 {
64 em4100_interface_debug_print("em4100: init failed.\n");
65
66 return 1;
67 }
68
69 return 0;
70}
71
80{
81 uint8_t res;
82
83 /* deinit */
84 res = em4100_deinit(&gs_handle);
85 if (res != 0)
86 {
87 return 1;
88 }
89
90 return 0;
91}
92
102uint8_t em4100_basic_search(uint8_t id[5], int32_t timeout)
103{
104 uint8_t res;
105
106 /* loop */
107 while (1)
108 {
109 /* request */
110 res = em4100_read(&gs_handle, id);
111 if (res == 0)
112 {
113 return 0;
114 }
115
116 /* delay */
118
119 /* check the timeout */
120 if (timeout < 0)
121 {
122 /* never timeout */
123 continue;
124 }
125 else
126 {
127 /* timeout */
128 if (timeout == 0)
129 {
130 return 1;
131 }
132 else
133 {
134 /* timout-- */
135 timeout--;
136 }
137 }
138 }
139}
140
149uint8_t em4100_basic_print(uint8_t id[5])
150{
151 if (em4100_print(&gs_handle, id) != 0)
152 {
153 return 1;
154 }
155
156 return 0;
157}
driver em4100 basic header file
uint8_t em4100_deinit(em4100_handle_t *handle)
close the chip
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
uint8_t em4100_basic_init(void)
basic example init
#define EM4100_BASIC_DEFAULT_SEARCH_DELAY_MS
em4100 basic example default definition
uint8_t em4100_basic_search(uint8_t id[5], int32_t timeout)
basic example search
uint8_t em4100_basic_print(uint8_t id[5])
basic example print
uint8_t em4100_basic_deinit(void)
basic example deinit
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