Flipper Zero Firmware
Loading...
Searching...
No Matches
furi_hal_nfc.h
Go to the documentation of this file.
1
18#pragma once
19
20#include <stdint.h>
21#include <stddef.h>
22#include <stdbool.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
31#define FURI_HAL_NFC_CARRIER_HZ (13560000UL)
32
36#define FURI_HAL_NFC_EVENT_WAIT_FOREVER (0xFFFFFFFFU)
37
58
72
82
95
105
112
122
133
143
153
164
171
178
185
192
201
209
216
224FuriHalNfcError furi_hal_nfc_poller_tx(const uint8_t* tx_data, size_t tx_bits);
225
236FuriHalNfcError furi_hal_nfc_poller_rx(uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits);
237
245FuriHalNfcError furi_hal_nfc_listener_tx(const uint8_t* tx_data, size_t tx_bits);
246
257FuriHalNfcError furi_hal_nfc_listener_rx(uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits);
258
267
276
285
294
304
313
320
326void furi_hal_nfc_timer_fwt_start(uint32_t time_fc);
327
332
338void furi_hal_nfc_timer_block_tx_start(uint32_t time_fc);
339
345void furi_hal_nfc_timer_block_tx_start_us(uint32_t time_us);
346
351
358
359/*
360 * Technology-specific functions.
361 *
362 * In a perfect world, this would not be necessary.
363 * However, the current implementation employs NFC hardware that partially implements
364 * certain protocols (e.g. ISO14443-3A), thus requiring methods to access such features.
365 */
366
367/******************* Iso14443a specific API *******************/
368
372typedef enum {
373 FuriHalNfcaShortFrameAllReq,
374 FuriHalNfcaShortFrameSensReq,
376
384
391FuriHalNfcError furi_hal_nfc_iso14443a_tx_sdd_frame(const uint8_t* tx_data, size_t tx_bits);
392
404 furi_hal_nfc_iso14443a_rx_sdd_frame(uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits);
405
417 furi_hal_nfc_iso14443a_poller_tx_custom_parity(const uint8_t* tx_data, size_t tx_bits);
418
431 uint8_t* uid,
432 uint8_t uid_len,
433 uint8_t* atqa,
434 uint8_t sak);
435
445 const uint8_t* tx_data,
446 const uint8_t* tx_parity,
447 size_t tx_bits);
448
454
467 const uint8_t* idm,
468 const uint8_t idm_len,
469 const uint8_t* pmm,
470 const uint8_t pmm_len);
471
472#ifdef __cplusplus
473}
474#endif
FuriHalNfcError furi_hal_nfc_iso14443a_listener_set_col_res_data(uint8_t *uid, uint8_t uid_len, uint8_t *atqa, uint8_t sak)
Set ISO14443 (Type A) collision resolution parameters in listener mode.
Definition furi_hal_nfc_iso14443a.c:213
FuriHalNfcError furi_hal_nfc_iso14443a_poller_trx_short_frame(FuriHalNfcaShortFrame frame)
Transmit ISO14443 (Type A) short frame in poller mode.
Definition furi_hal_nfc_iso14443a.c:131
FuriHalNfcError furi_hal_nfc_listener_sleep(void)
Go to sleep in listener mode.
Definition furi_hal_nfc.c:597
FuriHalNfcError furi_hal_nfc_low_power_mode_stop(void)
Configure the NFC hardware to exit the low-power mode.
Definition furi_hal_nfc.c:301
FuriHalNfcError furi_hal_nfc_iso14443a_poller_tx_custom_parity(const uint8_t *tx_data, size_t tx_bits)
Transmit ISO14443 (Type A) frame with custom parity bits in poller mode.
Definition furi_hal_nfc_iso14443a.c:184
FuriHalNfcError furi_hal_nfc_acquire(void)
Exclusively take over the NFC HAL and associated hardware.
Definition furi_hal_nfc.c:259
FuriHalNfcError furi_hal_nfc_poller_tx(const uint8_t *tx_data, size_t tx_bits)
Transmit data in poller mode.
Definition furi_hal_nfc.c:523
FuriHalNfcError furi_hal_nfc_iso15693_listener_tx_sof(void)
Send ISO15693 SOF in listener mode.
Definition furi_hal_nfc_iso15693.c:403
FuriHalNfcError furi_hal_nfc_field_detect_stop(void)
Disable field (carrier) detection by the NFC hardware.
Definition furi_hal_nfc.c:430
void furi_hal_nfc_timer_block_tx_start_us(uint32_t time_us)
Start block transmit (frame delay) timer.
Definition furi_hal_nfc_timer.c:219
FuriHalNfcError furi_hal_nfc_iso14443a_rx_sdd_frame(uint8_t *rx_data, size_t rx_data_size, size_t *rx_bits)
Receive ISO14443 (Type A) SDD frame in poller mode.
Definition furi_hal_nfc_iso14443a.c:171
FuriHalNfcError furi_hal_nfc_felica_listener_set_sensf_res_data(const uint8_t *idm, const uint8_t idm_len, const uint8_t *pmm, const uint8_t pmm_len)
Set FeliCa collision resolution parameters in listener mode.
Definition furi_hal_nfc_felica.c:160
FuriHalNfcError furi_hal_nfc_set_mode(FuriHalNfcMode mode, FuriHalNfcTech tech)
Configure the NFC HAL to work in a particular mode.
Definition furi_hal_nfc.c:348
void furi_hal_nfc_timer_block_tx_start(uint32_t time_fc)
Start block transmit (frame delay) timer.
Definition furi_hal_nfc_timer.c:215
FuriHalNfcEvent
Enumeration of possible NFC HAL events.
Definition furi_hal_nfc.h:41
@ FuriHalNfcEventRxStart
Reception has started.
Definition furi_hal_nfc.h:48
@ FuriHalNfcEventTimerBlockTxExpired
Transmission block timer has expired.
Definition furi_hal_nfc.h:52
@ FuriHalNfcEventListenerActive
Reader has issued a wake-up command.
Definition furi_hal_nfc.h:45
@ FuriHalNfcEventRxEnd
Reception has ended.
Definition furi_hal_nfc.h:49
@ FuriHalNfcEventFieldOff
External field (carrier) has been lost.
Definition furi_hal_nfc.h:44
@ FuriHalNfcEventCollision
A collision has occurred.
Definition furi_hal_nfc.h:50
@ FuriHalNfcEventOscOn
Oscillator has been started.
Definition furi_hal_nfc.h:42
@ FuriHalNfcEventTimerFwtExpired
Frame wait timer has expired.
Definition furi_hal_nfc.h:51
@ FuriHalNfcEventTimeout
No events have occurred in a specified time period.
Definition furi_hal_nfc.h:53
@ FuriHalNfcEventAbortRequest
User has requested to abort current operation.
Definition furi_hal_nfc.h:55
@ FuriHalNfcEventTxStart
Transmission has started.
Definition furi_hal_nfc.h:46
@ FuriHalNfcEventTxEnd
Transmission has ended.
Definition furi_hal_nfc.h:47
@ FuriHalNfcEventFieldOn
External field (carrier) has been detected.
Definition furi_hal_nfc.h:43
FuriHalNfcEvent furi_hal_nfc_listener_wait_event(uint32_t timeout_ms)
Wait for an NFC HAL event in listener mode.
Definition furi_hal_nfc.c:546
FuriHalNfcError furi_hal_nfc_reset_mode(void)
Reset the NFC HAL to its default (unconfigured) state.
Definition furi_hal_nfc.c:376
void furi_hal_nfc_timer_fwt_stop(void)
Stop frame wait timeout timer.
Definition furi_hal_nfc_timer.c:211
FuriHalNfcError furi_hal_nfc_low_power_mode_start(void)
Configure the NFC hardware to enter the low-power mode.
Definition furi_hal_nfc.c:283
void furi_hal_nfc_timer_block_tx_stop(void)
Stop block transmit (frame delay) timer.
Definition furi_hal_nfc_timer.c:223
FuriHalNfcError furi_hal_nfc_listener_tx(const uint8_t *tx_data, size_t tx_bits)
Transmit data in listener mode.
Definition furi_hal_nfc.c:553
FuriHalNfcError furi_hal_nfc_trx_reset(void)
Reset communication.
Definition furi_hal_nfc.c:589
bool furi_hal_nfc_field_is_present(void)
Check if the reader field (carrier) was detected by the NFC hardware.
Definition furi_hal_nfc.c:442
bool furi_hal_nfc_timer_block_tx_is_running(void)
Check whether block transmit (frame delay) timer is running.
Definition furi_hal_nfc_timer.c:227
FuriHalNfcError furi_hal_nfc_field_detect_start(void)
Enable field (carrier) detection by the NFC hardware.
Definition furi_hal_nfc.c:416
FuriHalNfcaShortFrame
Enumeration of ISO14443 (Type A) short frame types.
Definition furi_hal_nfc.h:372
FuriHalNfcEvent furi_hal_nfc_poller_wait_event(uint32_t timeout_ms)
Wait for an NFC HAL event in poller mode.
Definition furi_hal_nfc.c:539
FuriHalNfcError furi_hal_nfc_iso14443a_listener_tx_custom_parity(const uint8_t *tx_data, const uint8_t *tx_parity, size_t tx_bits)
Transmit ISO14443 (Type A) frame with custom parity bits in listener mode.
Definition furi_hal_nfc_iso14443a.c:278
FuriHalNfcError furi_hal_nfc_iso14443a_tx_sdd_frame(const uint8_t *tx_data, size_t tx_bits)
Transmit ISO14443 (Type A) SDD frame in poller mode.
Definition furi_hal_nfc_iso14443a.c:162
FuriHalNfcError furi_hal_nfc_listener_idle(void)
Go to idle in listener mode.
Definition furi_hal_nfc.c:606
FuriHalNfcMode
Enumeration of possible NFC HAL operating modes.
Definition furi_hal_nfc.h:76
@ FuriHalNfcModeNum
Special value equal to the operating modes count.
Definition furi_hal_nfc.h:80
@ FuriHalNfcModePoller
Configure NFC HAL to operate as a poller.
Definition furi_hal_nfc.h:77
@ FuriHalNfcModeListener
Configure NFC HAL to operate as a listener.
Definition furi_hal_nfc.h:78
FuriHalNfcTech
Enumeration of supported NFC technologies.
Definition furi_hal_nfc.h:86
@ FuriHalNfcTechIso14443b
Configure NFC HAL to use the ISO14443 (type B) technology.
Definition furi_hal_nfc.h:88
@ FuriHalNfcTechInvalid
Special value indicating the unconfigured state.
Definition furi_hal_nfc.h:93
@ FuriHalNfcTechFelica
Configure NFC HAL to use the FeliCa technology.
Definition furi_hal_nfc.h:90
@ FuriHalNfcTechIso14443a
Configure NFC HAL to use the ISO14443 (type A) technology.
Definition furi_hal_nfc.h:87
@ FuriHalNfcTechNum
Special value equal to the supported technologies count.
Definition furi_hal_nfc.h:92
@ FuriHalNfcTechIso15693
Configure NFC HAL to use the ISO15693 technology.
Definition furi_hal_nfc.h:89
FuriHalNfcError furi_hal_nfc_abort(void)
Manually emit the FuriHalNfcEventAbortRequest event.
Definition furi_hal_nfc_event.c:34
FuriHalNfcError furi_hal_nfc_event_start(void)
Enable generation of NFC HAL events.
Definition furi_hal_nfc_event.c:9
FuriHalNfcError furi_hal_nfc_listener_enable_rx(void)
Enable reception in listener mode.
Definition furi_hal_nfc.c:615
FuriHalNfcError furi_hal_nfc_poller_field_on(void)
Enable field (carrier) generation by the NFC hardware.
Definition furi_hal_nfc.c:457
FuriHalNfcError furi_hal_nfc_is_hal_ready(void)
Check whether the NFC HAL was properly initialised and is ready.
Definition furi_hal_nfc.c:49
void furi_hal_nfc_timer_fwt_start(uint32_t time_fc)
Start frame wait timeout timer.
Definition furi_hal_nfc_timer.c:207
FuriHalNfcError furi_hal_nfc_event_stop(void)
Disable generation of NFC HAL events.
Definition furi_hal_nfc_event.c:18
FuriHalNfcError furi_hal_nfc_poller_rx(uint8_t *rx_data, size_t rx_data_size, size_t *rx_bits)
Receive data in poller mode.
Definition furi_hal_nfc.c:531
FuriHalNfcError
Enumeration of possible NFC HAL errors.
Definition furi_hal_nfc.h:62
@ FuriHalNfcErrorNone
No error has occurred.
Definition furi_hal_nfc.h:63
@ FuriHalNfcErrorBufferOverflow
Receive buffer was too small for the received data.
Definition furi_hal_nfc.h:68
@ FuriHalNfcErrorDataFormat
Cannot parse a frame due to unexpected/invalid data.
Definition furi_hal_nfc.h:70
@ FuriHalNfcErrorCommunication
NFC hardware did not respond or responded unexpectedly.
Definition furi_hal_nfc.h:65
@ FuriHalNfcErrorIncompleteFrame
Not enough data was received to parse a valid frame.
Definition furi_hal_nfc.h:69
@ FuriHalNfcErrorOscillator
Oscillator failed to start.
Definition furi_hal_nfc.h:66
@ FuriHalNfcErrorCommunicationTimeout
NFC hardware did not respond in time.
Definition furi_hal_nfc.h:67
@ FuriHalNfcErrorBusy
The communication bus is busy.
Definition furi_hal_nfc.h:64
FuriHalNfcError furi_hal_nfc_listener_rx(uint8_t *rx_data, size_t rx_data_size, size_t *rx_bits)
Receive data in listener mode.
Definition furi_hal_nfc.c:577
FuriHalNfcError furi_hal_nfc_release(void)
Release the exclusive lock and make the NFC HAL available for others.
Definition furi_hal_nfc.c:273
FuriHalNfcError furi_hal_nfc_init(void)
Initialise the NFC HAL and associated hardware.
Definition furi_hal_nfc.c:71