Manages access to SPI hardware. More...
#include <Controller.h>
Classes | |
struct | Config |
Public Types | |
using | SelectDevice = void(*)(uint8_t chipSelect, bool active) |
Interrupt callback for custom Controllers. More... | |
Public Member Functions | |
virtual | ~Controller () |
void | begin () |
void | end () |
Disable HSPI controller. More... | |
void | onSelectDevice (SelectDevice callback) |
Set interrupt callback to use for manual CS control (PinSet::manual) or if CS pin is multiplexed. More... | |
virtual bool | startDevice (Device &dev, PinSet pinSet, uint8_t chipSelect) |
Assign a device to a CS# using a specific pin set. Only one device may be assigned to any CS. More... | |
virtual void | stopDevice (Device &dev) |
Release CS for a device. More... | |
void | configChanged (Device &dev) |
Devices call this method to tell the Controller about configuration changes. Internally, we just set a flag and update the register values when required. More... | |
uint32_t | setSpeed (Device &dev, uint32_t frequency) |
Set the clock for a given frequency. More... | |
uint32_t | getSpeed (Device &dev) const |
PinSet | getActivePinSet () const |
Protected Member Functions | |
virtual void | execute (Request &request) |
Protected Attributes | |
friend | Device |
Detailed Description
Manages access to SPI hardware.
Member Typedef Documentation
◆ SelectDevice
using HSPI::Controller::SelectDevice = void (*)(uint8_t chipSelect, bool active) |
Interrupt callback for custom Controllers.
- Parameters
-
chipSelect active true when transaction is about to start, false when completed
For manual CS (PinSet::manual) the actual CS GPIO must be asserted/de-asserted.
Expanding the SPI bus using a HC138 3:8 multiplexer, for example, can also be handled here, setting the GPIO address lines appropriately.
Constructor & Destructor Documentation
◆ ~Controller()
|
inlinevirtual |
Member Function Documentation
◆ begin()
void HSPI::Controller::begin | ( | ) |
◆ configChanged()
void HSPI::Controller::configChanged | ( | Device & | dev | ) |
Devices call this method to tell the Controller about configuration changes. Internally, we just set a flag and update the register values when required.
◆ end()
void HSPI::Controller::end | ( | ) |
◆ execute()
|
protectedvirtual |
◆ getActivePinSet()
|
inline |
◆ getSpeed()
uint32_t HSPI::Controller::getSpeed | ( | Device & | dev | ) | const |
◆ onSelectDevice()
|
inline |
Set interrupt callback to use for manual CS control (PinSet::manual) or if CS pin is multiplexed.
- Note
- Callback MUST be marked IRAM_ATTR
◆ setSpeed()
uint32_t HSPI::Controller::setSpeed | ( | Device & | dev, |
uint32_t | frequency | ||
) |
Set the clock for a given frequency.
- Parameters
-
dev frequency The requested clock frequency in Hz
- Return values
-
uint32_t The actual clock frequency selected
◆ startDevice()
|
virtual |
Assign a device to a CS# using a specific pin set. Only one device may be assigned to any CS.
Custom controllers should override this method to verify/configure chip selects, and also provide a callback (via onSelectDevice()
).
◆ stopDevice()
|
virtual |
Release CS for a device.
Member Data Documentation
◆ Device
|
protected |
The documentation for this class was generated from the following file: