SatCat5
cfg_spi.h
1 // Copyright 2023-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 // Generic SPI interface
6 
7 #pragma once
8 
9 #include <satcat5/types.h>
10 
11 namespace satcat5 {
12  namespace cfg {
16  public:
17  virtual void spi_done(unsigned nread, const u8* rbytes) = 0;
18  protected:
19  ~SpiEventListener() {}
20  };
21 
26  class SpiGeneric {
27  public:
29  virtual bool busy() = 0;
30 
34  virtual bool exchange(
35  u8 devidx, const u8* wrdata, u8 rwbytes,
36  satcat5::cfg::SpiEventListener* callback = 0) = 0;
37 
41  virtual bool query(
42  u8 devidx, const u8* wrdata, u8 wrbytes, u8 rdbytes,
43  satcat5::cfg::SpiEventListener* callback = 0) = 0;
44  };
45  }
46 }
SPI Event Handler callback for use with SpiGeneric.
Definition: cfg_spi.h:15
Polymorphic API for a generic SPI interface.
Definition: cfg_spi.h:26
virtual bool busy()=0
Is the SPI controller currently busy?
virtual bool exchange(u8 devidx, const u8 *wrdata, u8 rwbytes, satcat5::cfg::SpiEventListener *callback=0)=0
Queue an exchange transaction (simultaneous write+read).
virtual bool query(u8 devidx, const u8 *wrdata, u8 wrbytes, u8 rdbytes, satcat5::cfg::SpiEventListener *callback=0)=0
Queue a query transaction (write, read, or write-then-read).
Basic type aliases and prototypes used throughout SatCat5.