|
Embedded Artistry Framework
Embedded Systems C++ Framework
|
#include <active_spi.hpp>

Public Member Functions | |
| activeMaster (embvm::spi::master &m) noexcept | |
| ~activeMaster ()=default | |
| void | process_ (ao_storage pair) noexcept |
| virtual void | configure (spi::baud_t baud) noexcept |
| Configure the SPI bus. More... | |
| spi::mode | mode () const noexcept |
| Get the current SPI bus mode. More... | |
| spi::mode | mode (spi::mode mode) noexcept |
| Set the SPI bus mode. More... | |
| spi::order | order () const noexcept |
| Get the current SPI bus byte order. More... | |
| spi::order | order (spi::order order) noexcept |
| Set the SPI bus byte order. More... | |
| void | start () noexcept |
| Start the driver. More... | |
| void | stop () noexcept |
| Stop the driver. More... | |
| void | restart () noexcept |
| Restart the driver. More... | |
| type_safe::boolean | started () const noexcept |
| Check if the driver has been started. More... | |
| constexpr embvm::DriverType_t | DriverType () const noexcept |
| Returns the registered type ID of the driver. More... | |
| constexpr const std::string_view & | name () const noexcept |
| Provides a string_view reference of the driver name. More... | |
| constexpr const char * | name_cstr () const noexcept |
| Provides a c-string version of the driver name. More... | |
| virtual DriverBase & | operator++ () noexcept |
| Increment operator is a no-op, but is used for iterator compatibility. More... | |
| size_t | queuedCount () const noexcept |
| Get the number of operations in the queue. More... | |
| bool | enqueue (embvm::spi::ao_storage t) noexcept |
| Add an operation to the queue. More... | |
| void | shutdown () noexcept |
| Shutdown the active object. More... | |
Static Public Member Functions | |
| static constexpr embvm::DriverType | type () noexcept |
| SPI Driver Type ID. More... | |
Protected Member Functions | |
| embvm::comm::status | transfer_ (const spi::op_t &op, const cb_t &cb) noexcept override=0 |
Protected Attributes | |
| spi::mode | mode_ = spi::mode::mode0 |
| Stores the active SPI mode configuration. More... | |
| spi::order | order_ = spi::order::msbFirst |
| Stores the active SPI byte ordering. More... | |
| type_safe::boolean | started_ = false |
| Tracks the driver state. More... | |
| const std::string_view | name_ |
| Name of the driver instance. More... | |
| const embvm::DriverType_t | type_ |
| Type ID of the driver instance. More... | |
Private Types | |
| using | ao_base = embutil::activeObject< activeMaster, ao_storage, TQueueSize, TLock, TCond > |
Private Member Functions | |
| void | start_ () noexcept final |
| Derived classes override the start_ method to control driver-specific startup behavior. More... | |
| void | stop_ () noexcept final |
| Derived classes override the start_ method to control driver-specific startup behavior. More... | |
| void | configure_ () noexcept final |
| Configure the SPI bus for operation. More... | |
| void | setMode_ (embvm::spi::mode mode) noexcept final |
| Set the SPI bus mode. More... | |
| void | setOrder_ (embvm::spi::order order) noexcept final |
| Set the SPI bus byte order. More... | |
| embvm::spi::status | transfer_ (const embvm::spi::op_t &op, const embvm::spi::master::cb_t &cb) noexcept final |
| embvm::spi::baud_t | baudrate_ (embvm::spi::baud_t baud) noexcept final |
Private Attributes | |
| embvm::spi::master & | m_ |
|
private |
|
inlineexplicitnoexcept |
|
default |
|
inlinefinalprivatevirtualnoexcept |
Implements embvm::spi::master.
References embvm::spi::activeMaster< TQueueSize, TLock, TCond >::m_.
|
inlinevirtualnoexceptinherited |
Configure the SPI bus.
Configures the SPI bus for operation and sets the target baud rate.
Derived classes must implement the configure_() function to set up the target hardware.
| baud | The target baudrate, in Hz. TODO: Tolerance - allowed relative tolerance for the resulting baudrate |
References embvm::spi::master::configure_().
|
inlinefinalprivatevirtualnoexcept |
Configure the SPI bus for operation.
This function is implemented by the derived class. It is responsible for configuring the target hardware for operation.
Implements embvm::spi::master.
|
inlinenoexceptinherited |
Returns the registered type ID of the driver.
When using DriverBase interfaces, clients can retrieve the registered driver type in order to up-cast to the correct interface.
The type is returned as a embvm::DriverType_t rather than a embvm::DriverType enum to work with custom user-defined types. Enforcing a embvm::DriverType return value would prevent clients from defining and using their own custom types.
References embvm::DriverBase::type_.
|
inlinenoexceptinherited |
Add an operation to the queue.
This function can be called directly, or by functions internal to the activeObject. For example, the "transfer" API enqueues transfer operations.
This function is marked noexcept because we want the program to terminate if an exception results from this call. For example, the underlying queue may throw on push.
| t | The operation data object to enqueue for later processing. |
|
inlinenoexceptinherited |
Get the current SPI bus mode.
References embvm::spi::master::mode_.
Referenced by embvm::spi::master::mode(), and embvm::spi::activeMaster< TQueueSize, TLock, TCond >::setMode_().
Set the SPI bus mode.
Derived classes must implement the setMode_() function, which is reponsible for configuring the target hardware.
| mode | The desired SPI bus mode. |
References embvm::spi::master::mode(), embvm::spi::master::mode_, and embvm::spi::master::setMode_().
|
inlinenoexceptinherited |
Provides a string_view reference of the driver name.
std::string_view ref containing the driver name. References embvm::DriverBase::name_.
|
inlinenoexceptinherited |
Provides a c-string version of the driver name.
References embvm::DriverBase::name_.
|
inlinevirtualnoexceptinherited |
Increment operator is a no-op, but is used for iterator compatibility.
|
inlinenoexceptinherited |
Get the current SPI bus byte order.
References embvm::spi::master::order_.
Referenced by embvm::spi::master::order(), and embvm::spi::activeMaster< TQueueSize, TLock, TCond >::setOrder_().
|
inlinenoexceptinherited |
Set the SPI bus byte order.
Derived classes must implement the setOrder_() function, which is reponsible for configuring the target hardware.
| order | The desired byte ordering. |
References embvm::spi::master::order(), embvm::spi::master::order_, and embvm::spi::master::setOrder_().
|
inlinenoexcept |
|
inlinenoexceptinherited |
Get the number of operations in the queue.
|
inlinenoexceptinherited |
Restart the driver.
Calls stop() and then start() on the driver. If the driver is not started, then it will be started after the start() function is invoked.
References embvm::DriverBase::start(), and embvm::DriverBase::stop().
|
inlinefinalprivatevirtualnoexcept |
Set the SPI bus mode.
This function is implemented by the derived class. It is responsible for configuring the target hardware to use the new mode.
| mode | The desired byte ordering. |
Implements embvm::spi::master.
References embvm::spi::activeMaster< TQueueSize, TLock, TCond >::m_, and embvm::spi::master::mode().
|
inlinefinalprivatevirtualnoexcept |
Set the SPI bus byte order.
This function is implemented by the derived class. It is responsible for configuring the target hardware to use the new byte ordering.
| order | The desired byte ordering. |
Implements embvm::spi::master.
References embvm::spi::activeMaster< TQueueSize, TLock, TCond >::m_, and embvm::spi::master::order().
|
inlinenoexceptinherited |
Shutdown the active object.
Call this function in the parent class destructor to stop the AO thread operation before destroying the parent class. This will prevent memory access problems due to race conidtions during destruction.
This function is marked noexcept because we want the program to terminate if an exception results from this call.
The shutdown process is permanent and cannot be reversed without recreating the object.
|
inlinenoexceptinherited |
Start the driver.
If the driver is not started, call the start_() function defined by the derived class. (Template Method Pattern)
References embvm::DriverBase::start_(), and embvm::DriverBase::started_.
Referenced by NRF52DongleHWPlatform::init_(), NRF52DKHWPlatform::init_(), BlinkySimulatorHWPlatform::init_(), FWDemoSimulatorHWPlatform::init_(), FrameworkDemoSimPlatform::initHWPlatform_(), embvm::DriverBase::restart(), embvm::timer::Timer::restart(), embvm::spi::activeMaster< TQueueSize, TLock, TCond >::start_(), embvm::i2c::activeMaster< 128 >::start_(), embdrv::aardvarkSPIMaster::start_(), embdrv::aardvarkI2CMaster::start_(), embdrv::aardvarkGPIOInput< 4 >::start_(), embdrv::vl53l1x::start_(), embdrv::aardvarkGPIOOutput< 5 >::start_(), BlinkySimulatorHWPlatform::startBlink(), and FWDemoSimulatorHWPlatform::startLEDTimer().
|
inlinefinalprivatevirtualnoexcept |
Derived classes override the start_ method to control driver-specific startup behavior.
(Template Method Pattern)
Implements embvm::spi::master.
References embvm::spi::activeMaster< TQueueSize, TLock, TCond >::m_, and embvm::DriverBase::start().
|
inlinenoexceptinherited |
Check if the driver has been started.
true if the driver is running (started), false if not running (stopped). References embvm::DriverBase::started_.
Referenced by embdrv::aardvarkSPIMaster::configure_(), embdrv::aardvarkGPIOInput< 4 >::get(), embdrv::aardvarkGPIOOutput< 5 >::set(), embdrv::vl53l1x::start_(), embdrv::aardvarkAdapter::start_(), and embdrv::aardvarkAdapter::stop_().
|
inlinenoexceptinherited |
Stop the driver.
If the driver has been started, call the stop_() function defined by the derived class. (Template Method Pattern)
References embvm::DriverBase::started_, and embvm::DriverBase::stop_().
Referenced by embvm::DriverBase::restart(), embvm::timer::Timer::restart(), embvm::spi::activeMaster< TQueueSize, TLock, TCond >::stop_(), embvm::i2c::activeMaster< 128 >::stop_(), embdrv::aardvarkSPIMaster::stop_(), embdrv::aardvarkI2CMaster::stop_(), embdrv::aardvarkGPIOInput< 4 >::stop_(), embdrv::aardvarkGPIOOutput< 5 >::stop_(), FWDemoSimulatorHWPlatform::~FWDemoSimulatorHWPlatform(), and embdrv::SimulatorTimer::~SimulatorTimer().
|
inlinefinalprivatevirtualnoexcept |
Derived classes override the start_ method to control driver-specific startup behavior.
(Template Method Pattern)
Implements embvm::spi::master.
References embvm::spi::activeMaster< TQueueSize, TLock, TCond >::m_, and embvm::DriverBase::stop().
|
inlinefinalprivatenoexcept |
|
overrideprotectedpure virtualnoexceptinherited |
|
inlinestaticnoexceptinherited |
|
private |
Referenced by embvm::spi::activeMaster< TQueueSize, TLock, TCond >::baudrate_(), embvm::spi::activeMaster< TQueueSize, TLock, TCond >::process_(), embvm::spi::activeMaster< TQueueSize, TLock, TCond >::setMode_(), embvm::spi::activeMaster< TQueueSize, TLock, TCond >::setOrder_(), embvm::spi::activeMaster< TQueueSize, TLock, TCond >::start_(), and embvm::spi::activeMaster< TQueueSize, TLock, TCond >::stop_().
|
protectedinherited |
Stores the active SPI mode configuration.
Referenced by embdrv::aardvarkSPIMaster::configure_(), and embvm::spi::master::mode().
|
protectedinherited |
Name of the driver instance.
Referenced by embvm::DriverBase::name(), and embvm::DriverBase::name_cstr().
|
protectedinherited |
Stores the active SPI byte ordering.
Referenced by embdrv::aardvarkSPIMaster::configure_(), and embvm::spi::master::order().
|
protectedinherited |
Tracks the driver state.
True if the driver has been started, false if it has been stopped or not yet started.
Referenced by embvm::DriverBase::start(), embvm::DriverBase::started(), and embvm::DriverBase::stop().
|
protectedinherited |
Type ID of the driver instance.
Referenced by embvm::DriverBase::DriverType().
1.8.15