cryptnox-sdk-esp32 1.0.0
ESP32 SDK for Cryptnox Hardware Wallet
Loading...
Searching...
No Matches
pn532.h File Reference

Low-level PN532 NFC controller driver for ESP-IDF (SPI and I²C). More...

#include <stdint.h>
#include <stdbool.h>
#include "driver/spi_master.h"
#include "driver/i2c_master.h"
Include dependency graph for pn532.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pn532_config_t
 Compile-time configuration passed to pn532_init. More...
struct  pn532_t
 Opaque-like runtime state for a single PN532 instance. More...

Macros

#define PN532_MIFARE_ISO14443A   (0x00U)
 Baud-rate selector for ISO 14443-A (Mifare) cards passed to pn532_read_passive_target_id.
#define PN532_MAX_APDU_LEN   (252U)
 Maximum APDU payload length accepted by pn532_send_apdu.
#define PN532_I2C_ADDRESS   (0x24U)
 7-bit I²C slave address of the PN532 (fixed in hardware).

Enumerations

enum  pn532_transport_t { PN532_TRANSPORT_SPI , PN532_TRANSPORT_I2C }
 Physical bus used to communicate with the PN532. More...

Functions

esp_err_t pn532_init (pn532_t *dev, const pn532_config_t *config)
 Initialise the PN532 and bring it to a ready state.
uint32_t pn532_get_firmware_version (pn532_t *dev)
 Query the PN532 firmware version.
bool pn532_sam_config (pn532_t *dev)
 Configure the PN532's Security Access Module (SAM).
uint32_t pn532_read_passive_target_id (pn532_t *dev, uint8_t cardbaudrate)
 Scan for a passive ISO 14443-A card and return its UID.
bool pn532_send_apdu (pn532_t *dev, const uint8_t *apdu, uint8_t apdu_len, uint8_t *response, uint16_t *response_len)
 Exchange a single ISO-DEP APDU with the currently selected card.
bool pn532_release_target (pn532_t *dev)
 Release the currently selected NFC target.

Detailed Description

Low-level PN532 NFC controller driver for ESP-IDF (SPI and I²C).

Provides a transport-agnostic C API for the NXP PN532 NFC controller. Both the ESP-IDF SPI master peripheral and the IDF v5.x I²C master API are supported; the active transport is selected at pn532_init time via pn532_config_t::transport.

Typical usage (SPI):

pn532_config_t cfg = {};
cfg.spi_host = SPI2_HOST;
cfg.pin_cs = 10;
cfg.skip_bus_init = true; // caller already called spi_bus_initialize()
pn532_t nfc;
ESP_ERROR_CHECK(pn532_init(&nfc, &cfg));
esp_err_t pn532_init(pn532_t *dev, const pn532_config_t *config)
Initialise the PN532 and bring it to a ready state.
Definition pn532.c:657
@ PN532_TRANSPORT_SPI
Definition pn532.h:77
Compile-time configuration passed to pn532_init.
Definition pn532.h:111
spi_host_device_t spi_host
Definition pn532.h:115
pn532_transport_t transport
Definition pn532.h:112
bool skip_bus_init
Definition pn532.h:120
Opaque-like runtime state for a single PN532 instance.
Definition pn532.h:141

Definition in file pn532.h.