ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
pn7160.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace esphome::pn7160 {
6
7static constexpr uint8_t PMU_CFG[] = {
8 0x01, // Number of parameters
9 0xA0,
10 0x0E, // ext. tag
11 11, // length
12 0x11, // IRQ Enable: PVDD + temp sensor IRQs
13 0x01, // RFU
14 0x01, // Power and Clock Configuration, device on (CFG1)
15 0x01, // Power and Clock Configuration, device off (CFG1)
16 0x00, // RFU
17 0x00, // DC-DC 0
18 0x00, // DC-DC 1
19 // 0x14, // TXLDO (3.3V / 4.75V)
20 // 0xBB, // TXLDO (4.7V / 4.7V)
21 0xFF, // TXLDO (5.0V / 5.0V)
22 0x00, // RFU
23 0xD0, // TXLDO check
24 0x0C, // RFU
25};
26
27static constexpr uint8_t RF_LISTEN_MODE_ROUTING_CONFIG[] = {0x00, // "more" (another message is coming)
28 2, // number of table entries
29 0x01, // type = protocol-based
30 3, // length
31 0, // DH NFCEE ID, a static ID representing the DH-NFCEE
32 0x07, // power state
33 nfc::PROT_ISODEP, // protocol
34 0x00, // type = technology-based
35 3, // length
36 0, // DH NFCEE ID, a static ID representing the DH-NFCEE
37 0x07, // power state
38 nfc::TECH_PASSIVE_NFCA}; // technology
39
40class PN7160 : public pn71xx::PN71xx {
41 public:
42 void setup() override;
43 void dump_config() override;
44
45 void set_dwl_req_pin(GPIOPin *dwl_req_pin) { this->dwl_req_pin_ = dwl_req_pin; }
46 void set_wkup_req_pin(GPIOPin *wkup_req_pin) { this->wkup_req_pin_ = wkup_req_pin; }
47
48 protected:
49 void prepare_reset() override;
50 uint8_t verify_reset(nfc::NciMessage &rx, bool reset_config) override;
51 uint8_t process_init_response(nfc::NciMessage &rx) override;
52 std::span<const uint8_t> pmu_config() const override { return PMU_CFG; }
53 std::span<const uint8_t> listen_mode_routing_config() const override { return RF_LISTEN_MODE_ROUTING_CONFIG; }
54
57};
58
59} // namespace esphome::pn7160
One NCI packet, held in a fixed buffer so building and reading messages never allocates.
Definition nci_message.h:16
void dump_config() override
Definition pn7160.cpp:20
void prepare_reset() override
Definition pn7160.cpp:31
void set_wkup_req_pin(GPIOPin *wkup_req_pin)
Definition pn7160.h:46
void setup() override
Definition pn7160.cpp:10
GPIOPin * wkup_req_pin_
Definition pn7160.h:56
uint8_t verify_reset(nfc::NciMessage &rx, bool reset_config) override
Definition pn7160.cpp:39
std::span< const uint8_t > pmu_config() const override
Definition pn7160.h:52
GPIOPin * dwl_req_pin_
Definition pn7160.h:55
uint8_t process_init_response(nfc::NciMessage &rx) override
Definition pn7160.cpp:68
std::span< const uint8_t > listen_mode_routing_config() const override
Definition pn7160.h:53
void set_dwl_req_pin(GPIOPin *dwl_req_pin)
Definition pn7160.h:45
Common driver for the NXP PN71xx family of NCI NFC controllers.
Definition pn71xx.h:156