furi-hal-nfc.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * @file furi-hal-nfc.h
  3. * NFC HAL API
  4. */
  5. #pragma once
  6. #include <rfal_nfc.h>
  7. #include <st_errno.h>
  8. #include <stdbool.h>
  9. #include <stdint.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. #define FURI_HAL_NFC_UID_MAX_LEN 10
  14. /** Init nfc
  15. */
  16. void furi_hal_nfc_init();
  17. /** Check if nfc worker is busy
  18. *
  19. * @return true if busy
  20. */
  21. bool furi_hal_nfc_is_busy();
  22. /** NFC field on
  23. */
  24. void furi_hal_nfc_field_on();
  25. /** NFC field off
  26. */
  27. void furi_hal_nfc_field_off();
  28. /** NFC start sleep
  29. */
  30. void furi_hal_nfc_start_sleep();
  31. /** NFC stop sleep
  32. */
  33. void furi_hal_nfc_exit_sleep();
  34. /** NFC poll
  35. *
  36. * @param dev_list pointer to rfalNfcDevice buffer
  37. * @param dev_cnt pointer device count
  38. * @param timeout timeout in ms
  39. * @param deactivate deactivate flag
  40. *
  41. * @return true on success
  42. */
  43. bool furi_hal_nfc_detect(rfalNfcDevice** dev_list, uint8_t* dev_cnt, uint32_t timeout, bool deactivate);
  44. /** NFC listen
  45. *
  46. * @param uid pointer to uid buffer
  47. * @param uid_len uid length
  48. * @param atqa pointer to atqa
  49. * @param sak sak
  50. * @param activate_after_sak activate after sak flag
  51. * @param timeout timeout in ms
  52. *
  53. * @return true on success
  54. */
  55. bool furi_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sak, bool activate_after_sak, uint32_t timeout);
  56. /** Get first command from reader after activation in emulation mode
  57. *
  58. * @param rx_buff pointer to receive buffer
  59. * @param rx_len receive buffer length
  60. *
  61. * @return true on success
  62. */
  63. bool furi_hal_nfc_get_first_frame(uint8_t** rx_buff, uint16_t** rx_len);
  64. /** NFC data exchange
  65. *
  66. * @param tx_buff transmit buffer
  67. * @param tx_len transmit buffer length
  68. * @param rx_buff receive buffer
  69. * @param rx_len receive buffer length
  70. * @param deactivate deactivate flag
  71. *
  72. * @return ST ReturnCode
  73. */
  74. ReturnCode furi_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t** rx_buff, uint16_t** rx_len, bool deactivate);
  75. ReturnCode furi_hal_nfc_raw_bitstream_exchange(uint8_t* tx_buff, uint16_t tx_bit_len, uint8_t** rx_buff, uint16_t** rx_bit_len, bool deactivate);
  76. /** NFC deactivate and start sleep
  77. */
  78. void furi_hal_nfc_deactivate();
  79. #ifdef __cplusplus
  80. }
  81. #endif