64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
#ifndef PORTABLE_NFC_SERVICE_H
|
|
#define PORTABLE_NFC_SERVICE_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define NFC_UID_MAX_BYTES 10
|
|
#define NFC_UID_STRING_MAX_LEN ((NFC_UID_MAX_BYTES * 2) + 1)
|
|
|
|
typedef enum {
|
|
NFC_STATUS_OK = 0,
|
|
NFC_STATUS_ERROR = -1,
|
|
NFC_STATUS_BAD_PARAM = -2,
|
|
NFC_STATUS_NOT_INITIALIZED = -3,
|
|
NFC_STATUS_ALREADY_STARTED = -4,
|
|
} nfc_status_t;
|
|
|
|
typedef struct {
|
|
uint8_t bytes[NFC_UID_MAX_BYTES];
|
|
uint8_t length;
|
|
char value[NFC_UID_STRING_MAX_LEN];
|
|
} nfc_uid_t;
|
|
|
|
typedef int (*nfc_can_poll_fn)(void *ctx);
|
|
typedef void (*nfc_uid_fn)(const nfc_uid_t *uid, void *ctx);
|
|
typedef void (*nfc_error_fn)(int status, void *ctx);
|
|
|
|
typedef struct {
|
|
nfc_can_poll_fn can_poll;
|
|
nfc_uid_fn on_uid;
|
|
nfc_error_fn on_error;
|
|
void *ctx;
|
|
} nfc_service_callbacks_t;
|
|
|
|
typedef struct {
|
|
uint8_t i2c_bus;
|
|
uint8_t i2c_fast_mode;
|
|
uint8_t i2c_slave_addr;
|
|
uint32_t reset_pin;
|
|
uint32_t irq_pin;
|
|
uint32_t task_stack_size;
|
|
uint32_t task_priority;
|
|
uint32_t debounce_ms;
|
|
uint32_t disallowed_poll_delay_ms;
|
|
uint32_t retry_poll_delay_ms;
|
|
uint8_t max_fail_count;
|
|
} nfc_service_config_t;
|
|
|
|
void nfc_service_default_config(nfc_service_config_t *config);
|
|
int nfc_service_init(const nfc_service_config_t *config,
|
|
const nfc_service_callbacks_t *callbacks);
|
|
int nfc_service_start(void);
|
|
int nfc_service_stop(void);
|
|
int nfc_service_is_started(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|