23 #ifndef TRANSCEIVER_H_ 24 #define TRANSCEIVER_H_ 43 nfc_framing_target_mode_detector,
44 nfc_framing_target_a_106,
45 nfc_framing_target_b_106,
46 nfc_framing_target_f_212,
47 nfc_framing_target_f_424,
49 nfc_framing_initiator_a_106,
50 nfc_framing_initiator_b_106,
51 nfc_framing_initiator_f_212,
52 nfc_framing_initiator_f_424,
54 typedef enum __nfc_framing nfc_framing_t;
57 unsigned int nfc_type1 : 1;
58 unsigned int nfc_type2 : 1;
59 unsigned int nfc_type3 : 1;
60 unsigned int nfc_iso_dep_a : 1;
61 unsigned int nfc_iso_dep_b : 1;
62 unsigned int nfc_nfc_dep_a : 1;
63 unsigned int nfc_nfc_dep_f_212 : 1;
64 unsigned int nfc_nfc_dep_f_424 : 1;
69 unsigned int bail_at_first_target : 1;
70 unsigned int bail_at_first_tech : 1;
77 typedef void (*set_crc_fn_t)(
nfc_transceiver_t *pTransceiver,
bool crcOut,
bool crcIn);
79 typedef void (*set_transceive_options_fn_t)(
nfc_transceiver_t *pTransceiver,
bool transmit,
bool receive,
bool repoll);
80 typedef void (*set_transceive_framing_fn_t)(
nfc_transceiver_t *pTransceiver, nfc_framing_t framing);
84 typedef void (*set_last_byte_length_fn_t)(
nfc_transceiver_t *pTransceiver,
size_t lastByteLength);
86 typedef void (*set_first_byte_align_fn_t)(
nfc_transceiver_t *pTransceiver,
size_t firstByteAlign);
93 set_protocols_fn_t set_protocols;
96 set_timeout_fn_t set_timeout;
97 set_transceive_options_fn_t set_transceive_options;
98 set_transceive_framing_fn_t set_transceive_framing;
99 set_write_fn_t set_write;
100 get_read_fn_t get_read;
101 set_last_byte_length_fn_t set_last_byte_length;
102 get_last_byte_length_fn_t get_last_byte_length;
103 set_first_byte_align_fn_t set_first_byte_align;
104 transceive_fn_t transceive;
121 uint8_t application_data[4];
122 uint8_t protocol_info[3];
141 #define MUNFC_MAX_REMOTE_TARGETS 4 145 bool initiator_ntarget;
146 nfc_info_t remote_targets[MUNFC_MAX_REMOTE_TARGETS];
147 size_t remote_targets_count;
163 pTransceiver->fn->set_protocols(pTransceiver, initiators, targets, options);
166 static inline void transceiver_poll(
nfc_transceiver_t *pTransceiver, transceiver_cb_t cb,
void *pUserData)
168 pTransceiver->cb = cb;
169 pTransceiver->pUserData = pUserData;
170 pTransceiver->fn->poll(pTransceiver);
173 static inline void transceiver_set_crc(
nfc_transceiver_t *pTransceiver,
bool crcOut,
bool crcIn)
175 pTransceiver->fn->set_crc(pTransceiver, crcOut, crcIn);
178 static inline void transceiver_set_timeout(
nfc_transceiver_t *pTransceiver,
int timeout)
180 pTransceiver->fn->set_timeout(pTransceiver, timeout);
183 static inline void transceiver_set_transceive_options(
nfc_transceiver_t *pTransceiver,
bool transmit,
bool receive,
bool repoll)
185 pTransceiver->fn->set_transceive_options(pTransceiver, transmit, receive, repoll);
188 static inline void transceiver_set_transceive_framing(
nfc_transceiver_t *pTransceiver, nfc_framing_t framing)
190 pTransceiver->fn->set_transceive_framing(pTransceiver, framing);
195 pTransceiver->fn->set_write(pTransceiver, pWriteBuf);
200 return pTransceiver->fn->get_read(pTransceiver);
203 static inline size_t transceiver_get_last_byte_length(
nfc_transceiver_t *pTransceiver)
205 return pTransceiver->fn->get_last_byte_length(pTransceiver);
208 static inline void transceiver_set_last_byte_length(
nfc_transceiver_t *pTransceiver,
size_t lastByteLength)
210 pTransceiver->fn->set_last_byte_length(pTransceiver, lastByteLength);
213 static inline void transceiver_set_first_byte_align(
nfc_transceiver_t *pTransceiver,
size_t firstByteAlign)
215 pTransceiver->fn->set_first_byte_align(pTransceiver, firstByteAlign);
218 static inline void nfc_transceiver_transceive(
nfc_transceiver_t *pTransceiver, transceiver_cb_t cb,
void *pUserData)
220 pTransceiver->cb = cb;
221 pTransceiver->pUserData = pUserData;
222 pTransceiver->fn->transceive(pTransceiver);
227 pTransceiver->fn->abort(pTransceiver);
232 pTransceiver->fn->close(pTransceiver);
235 static inline bool transceiver_is_initiator_mode(
nfc_transceiver_t *pTransceiver)
237 return pTransceiver->initiator_ntarget;
242 return pTransceiver->active_tech;
247 return &pTransceiver->scheduler;
250 static inline const nfc_info_t *transceiver_get_remote_target_info(
nfc_transceiver_t *pTransceiver,
size_t number)
252 if (number > pTransceiver->remote_targets_count) {
255 return &pTransceiver->remote_targets[number];
258 static inline size_t transceiver_get_remote_targets_count(
nfc_transceiver_t *pTransceiver)
260 return pTransceiver->remote_targets_count;
265 pTransceiver->fn->sleep(pTransceiver, sleep);
int nfc_err_t
Type for NFC errors.
static void sleep(void)
Send the microcontroller to sleep.