ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
st25r_spi.cpp
Go to the documentation of this file.
1#include "st25r_spi.h"
2#include "esphome/core/log.h"
3
5
6ESPHOME_LOG_TAG(TAG, "st25r_spi");
7
9 this->spi_setup();
11}
12
15 LOG_PIN(" CS Pin: ", this->cs_);
16}
17
18uint8_t ST25RSpi::read_register(uint8_t reg) {
19 this->enable();
20 if (reg & 0x40) {
21 this->write_byte(0xFB); // Space B prefix
22 }
23 this->write_byte(0x40 | (reg & 0x3F));
24 uint8_t value = this->read_byte();
25 this->disable();
26 return value;
27}
28
29void ST25RSpi::write_register(uint8_t reg, uint8_t value) {
30 this->enable();
31 if (reg & 0x40) {
32 this->write_byte(0xFB); // Space B prefix
33 }
34 this->write_byte(reg & 0x3F);
35 this->write_byte(value);
36 this->disable();
37}
38
39void ST25RSpi::write_command(uint8_t command) {
40 this->enable();
41 this->write_byte(command);
42 this->disable();
43}
44
45void ST25RSpi::write_fifo(const uint8_t *data, size_t len) {
46 this->enable();
47 this->write_byte(0x80);
48 this->write_array(data, len);
49 this->disable();
50}
51
52void ST25RSpi::read_fifo(uint8_t *data, size_t len) {
53 this->enable();
54 this->write_byte(0x9F);
55 this->read_array(data, len);
56 this->disable();
57}
58
59} // namespace esphome::st25r_spi
void dump_config() override
Definition st25r.cpp:382
void setup() override
Definition st25r.cpp:46
void read_fifo(uint8_t *data, size_t len) override
Definition st25r_spi.cpp:52
uint8_t read_register(uint8_t reg) override
Definition st25r_spi.cpp:18
void write_register(uint8_t reg, uint8_t value) override
Definition st25r_spi.cpp:29
void write_command(uint8_t command) override
Definition st25r_spi.cpp:39
void dump_config() override
Definition st25r_spi.cpp:13
void write_fifo(const uint8_t *data, size_t len) override
Definition st25r_spi.cpp:45
ESPHOME_LOG_TAG(TAG, "st25r_spi")
const void size_t len
Definition hal.h:68