furi_hal_nfc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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(
  44. rfalNfcDevice** dev_list,
  45. uint8_t* dev_cnt,
  46. uint32_t timeout,
  47. bool deactivate);
  48. /** NFC listen
  49. *
  50. * @param uid pointer to uid buffer
  51. * @param uid_len uid length
  52. * @param atqa pointer to atqa
  53. * @param sak sak
  54. * @param activate_after_sak activate after sak flag
  55. * @param timeout timeout in ms
  56. *
  57. * @return true on success
  58. */
  59. bool furi_hal_nfc_listen(
  60. uint8_t* uid,
  61. uint8_t uid_len,
  62. uint8_t* atqa,
  63. uint8_t sak,
  64. bool activate_after_sak,
  65. uint32_t timeout);
  66. /** Get first command from reader after activation in emulation mode
  67. *
  68. * @param rx_buff pointer to receive buffer
  69. * @param rx_len receive buffer length
  70. *
  71. * @return true on success
  72. */
  73. bool furi_hal_nfc_get_first_frame(uint8_t** rx_buff, uint16_t** rx_len);
  74. /** NFC data exchange
  75. *
  76. * @param tx_buff transmit buffer
  77. * @param tx_len transmit buffer length
  78. * @param rx_buff receive buffer
  79. * @param rx_len receive buffer length
  80. * @param deactivate deactivate flag
  81. *
  82. * @return ST ReturnCode
  83. */
  84. ReturnCode furi_hal_nfc_data_exchange(
  85. uint8_t* tx_buff,
  86. uint16_t tx_len,
  87. uint8_t** rx_buff,
  88. uint16_t** rx_len,
  89. bool deactivate);
  90. ReturnCode furi_hal_nfc_raw_bitstream_exchange(
  91. uint8_t* tx_buff,
  92. uint16_t tx_bit_len,
  93. uint8_t** rx_buff,
  94. uint16_t** rx_bit_len,
  95. bool deactivate);
  96. /** NFC deactivate and start sleep
  97. */
  98. void furi_hal_nfc_deactivate();
  99. #ifdef __cplusplus
  100. }
  101. #endif