31 explicit Spi(
const struct ove_spi_cfg &cfg) {
32#ifdef CONFIG_OVE_ZERO_HEAP
33 int err = ove_spi_init(&handle_, &storage_, &cfg);
35 int err = ove_spi_create(&handle_, &cfg);
37 OVE_STATIC_INIT_ASSERT(err == OVE_OK);
42#ifdef CONFIG_OVE_ZERO_HEAP
43 ove_spi_deinit(handle_);
45 ove_spi_destroy(handle_);
49 Spi(
const Spi &) =
delete;
50 Spi &operator=(
const Spi &) =
delete;
52#ifdef CONFIG_OVE_ZERO_HEAP
54 Spi &operator=(Spi &&) =
delete;
56 Spi(Spi &&o) noexcept : handle_(o.handle_) { o.handle_ =
nullptr; }
57 Spi &operator=(Spi &&o)
noexcept {
59 if (handle_) ove_spi_destroy(handle_);
67 [[nodiscard]]
int transfer(
const struct ove_spi_cs *cs,
68 const void *tx,
void *rx,
size_t len,
69 uint32_t timeout_ms = OVE_WAIT_FOREVER) {
70 return ove_spi_transfer(handle_, cs, tx, rx, len, timeout_ms);
73 [[nodiscard]]
int write(
const struct ove_spi_cs *cs,
74 const void *data,
size_t len,
75 uint32_t timeout_ms = OVE_WAIT_FOREVER) {
76 return ove_spi_write(handle_, cs, data, len, timeout_ms);
79 [[nodiscard]]
int read(
const struct ove_spi_cs *cs,
80 void *buf,
size_t len,
81 uint32_t timeout_ms = OVE_WAIT_FOREVER) {
82 return ove_spi_read(handle_, cs, buf, len, timeout_ms);
85 [[nodiscard]]
int transfer_seq(
const struct ove_spi_cs *cs,
86 const struct ove_spi_xfer *xfers,
87 unsigned int num_xfers,
88 uint32_t timeout_ms = OVE_WAIT_FOREVER) {
89 return ove_spi_transfer_seq(handle_, cs, xfers, num_xfers,
93 ove_spi_t native_handle()
const {
return handle_; }
96 ove_spi_t handle_ =
nullptr;
97#ifdef CONFIG_OVE_ZERO_HEAP
98 ove_spi_storage_t storage_{};
void write(const char *data, unsigned int len)
Writes a buffer of bytes to the console output.
Definition console.hpp:71
int read(const char *key, void *buf, size_t len, size_t *out)
Reads the value associated with a key from NVS.
Definition nvs.hpp:55
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:19
Common type definitions and concepts for the C++ wrapper layer.