1
0
mirror of https://github.com/whowechina/aic_pico.git synced 2024-12-11 04:16:01 +01:00
aic_pico/firmware/include/nfc.h

77 lines
1.8 KiB
C
Raw Normal View History

2024-04-23 04:49:30 +02:00
/*
* NFC Operations
* WHowe <github.com/whowechina>
*
*/
#ifndef NFC_H
#define NFC_H
#include <stdint.h>
#include <stdbool.h>
#include "hardware/i2c.h"
#include "hardware/spi.h"
typedef enum {
NFC_CARD_NONE = 0,
NFC_CARD_MIFARE,
NFC_CARD_FELICA,
NFC_CARD_VICINITY,
} nfc_card_type;
const char *nfc_card_name(nfc_card_type card_type);
typedef void (*nfc_wait_loop_t)();
typedef struct {
nfc_card_type card_type;
uint16_t len;
union {
uint8_t uid[8];
uint8_t idm[8];
};
uint8_t pmm[8];
uint8_t syscode[2];
} nfc_card_t;
2024-04-30 02:51:51 +02:00
typedef struct {
bool debug;
2024-05-28 06:20:20 +02:00
bool pn5180_tx_tweak;
2024-04-30 02:51:51 +02:00
} nfc_runtime_t;
extern nfc_runtime_t nfc_runtime;
2024-04-23 04:49:30 +02:00
/* should init or attach i2c and spi port before init */
void nfc_attach_i2c(i2c_inst_t *port);
void nfc_attach_spi(spi_inst_t *port, uint8_t rst, uint8_t nss, uint8_t busy);
void nfc_init_i2c(i2c_inst_t *port, uint8_t scl, uint8_t sda, uint32_t freq);
void nfc_init_spi(spi_inst_t *port, uint8_t miso, uint8_t sck, uint8_t mosi,
uint8_t rst, uint8_t nss, uint8_t busy);
void nfc_init();
/* should be called only after init */
void nfc_set_wait_loop(nfc_wait_loop_t loop);
2024-05-28 06:20:20 +02:00
void nfc_pn5180_tx_tweak(bool enable);
2024-04-23 04:49:30 +02:00
void nfc_rf_field(bool on);
nfc_card_t nfc_detect_card();
nfc_card_t nfc_detect_card_ex(bool mifare, bool felica, bool vicinity);
void display_card(const nfc_card_t *card);
const char *nfc_module_name();
2024-05-21 06:58:47 +02:00
const char *nfc_module_version();
2024-04-23 04:49:30 +02:00
bool nfc_mifare_auth(const uint8_t uid[4], uint8_t block_id, uint8_t key_id, const uint8_t *key);
bool nfc_mifare_read(uint8_t block_id, uint8_t block_data[16]);
2024-04-23 14:47:50 +02:00
bool nfc_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
void nfc_select(int phase);
2024-04-27 16:24:27 +02:00
void nfc_deselect();
2024-04-23 04:49:30 +02:00
#endif