|
Embedded Artistry Framework
Embedded Systems C++ Framework
|
Drivers intended for use with simulator applications (run on host machine) More...
|
Modules | |
| Aardvark Adapter Drivers | |
| Aardvark Adapter drivers, usable for Simulator applications. | |
Classes | |
| class | embdrv::SimulatorSystemClock |
| Simulator system clock driver. More... | |
| class | embdrv::SimulatorTimer |
| Simulator timer driver. More... | |
Drivers intended for use with simulator applications (run on host machine)
| class embdrv::SimulatorSystemClock |
Simulator system clock driver.
This driver uses the std::chrono::steady_clock to represent a SystemClock driver for simulator applications.

Public Types | |
| using | spin_duration_t = std::chrono::duration< uint32_t, std::micro > |
| Default spin increment is microseconds. More... | |
| using | tick_duration_t = std::chrono::duration< uint64_t, std::micro > |
Public Member Functions | |
| SimulatorSystemClock () noexcept | |
| Create a generic simulator system clock. More... | |
| ~SimulatorSystemClock () noexcept final | |
| Default destructor. More... | |
| embvm::clk::freq_hz_t::rep | frequency () const noexcept final |
| Get the frequency of the system clock. More... | |
| tick_duration_t::rep | ticks () const noexcept final |
| Check the ticks elapsed since boot. More... | |
| void | spin (spin_duration_t::rep count) noexcept final |
| Spin the processor for the specified number of ticks. 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... | |
Static Public Member Functions | |
| static constexpr embvm::DriverType | type () noexcept |
| SystemClock Driver Type ID. More... | |
Protected 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... | |
Protected Attributes | |
| 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... | |
|
inherited |
Default spin increment is microseconds.
|
inherited |
|
inlinenoexcept |
Create a generic simulator system clock.
|
finalnoexcept |
Default destructor.
|
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_.
|
inlinefinalvirtualnoexcept |
Get the frequency of the system clock.
Implements embvm::clk::SystemClock.
|
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 |
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().
|
inlinefinalvirtualnoexcept |
Spin the processor for the specified number of ticks.
Derived classes must implement the spin() function.
| count | The number of ticks to spin the processor for. |
Implements embvm::clk::SystemClock.
References embvm::this_thread::sleep_for().
|
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().
|
inlinefinalprotectedvirtualnoexcept |
Derived classes override the start_ method to control driver-specific startup behavior.
(Template Method Pattern)
Implements embvm::clk::SystemClock.
|
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().
|
inlinefinalprotectedvirtualnoexcept |
Derived classes override the start_ method to control driver-specific startup behavior.
(Template Method Pattern)
Implements embvm::clk::SystemClock.
|
inlinefinalvirtualnoexcept |
Check the ticks elapsed since boot.
Derived classes must implement the ticks() function.
Implements embvm::clk::SystemClock.
|
inlinestaticnoexceptinherited |
|
protectedinherited |
Name of the driver instance.
Referenced by embvm::DriverBase::name(), and embvm::DriverBase::name_cstr().
|
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().
| class embdrv::SimulatorTimer |
Simulator timer driver.
This driver uses a thread object to simulate a timer with a callback.

Public Member Functions | |
| SimulatorTimer () noexcept | |
| Create a simulator timer with default options. More... | |
| SimulatorTimer (embvm::timer::timer_period_t period, embvm::timer::config config=embvm::timer::config::oneshot) noexcept | |
| Create a timer and set configuration options. More... | |
| SimulatorTimer (embvm::timer::timer_period_t period, embvm::timer::cb_t cb, embvm::timer::config config=embvm::timer::config::oneshot) noexcept | |
| Create a timer and set configuration options and callback. More... | |
| SimulatorTimer (embvm::timer::timer_period_t period, embvm::timer::cb_t &&cb, embvm::timer::config config=embvm::timer::config::oneshot) noexcept | |
| Create a timer and set configuration options and callback. More... | |
| ~SimulatorTimer () noexcept final | |
| Destructor, which cleans up the timer thread. More... | |
| void | registerCallback (const embvm::timer::cb_t &cb) noexcept final |
| Register a timer callback. More... | |
| void | registerCallback (embvm::timer::cb_t &&cb) noexcept final |
| Register a timer callback. More... | |
| embvm::timer::timer_period_t | count () const noexcept final |
| Read the current timer count. More... | |
| void | enableInterrupts () noexcept final |
| void | disableInterrupts () noexcept final |
| timer_period_t | period () const noexcept |
| Get the current timer period. More... | |
| timer_period_t | period (timer_period_t period) noexcept |
| Set the timer period. More... | |
| virtual void | restart (const timer_period_t period) noexcept |
| Restart the timer with a specific period. More... | |
| void | restart (const timer_period_t::rep period) noexcept |
| Restart the timer with a specific period. More... | |
| void | restart () noexcept |
| Restart the timer with the currently configured period. More... | |
| virtual timer::state | state () const noexcept |
| Check the state of the timer. More... | |
| virtual timer::config | config () const noexcept |
| Check the configuration of the timer. More... | |
| virtual timer::config | config (timer::config c) noexcept |
| Set the timer configuration. More... | |
| void | start () noexcept |
| Start the driver. More... | |
| void | stop () noexcept |
| Stop 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... | |
| void | setBottomHalfDispatcher (const embutil::IRQDispatcherFunc_t &dispatcher) noexcept |
| template<typename TCallback > | |
| void | invokeCallback (TCallback &cb) noexcept |
| template<typename TCallback , typename... TArgs> | |
| void | invokeCallback (TCallback &cb, TArgs &... args) noexcept |
Static Public Member Functions | |
| static constexpr embvm::DriverType | type () noexcept |
| Timer Driver Type ID. More... | |
Protected Attributes | |
| timer_period_t | period_ {0} |
| The configured timer period. More... | |
| timer::state | state_ = timer::state::stopped |
| The current state of the timer. More... | |
| timer::config | config_ = timer::config::oneshot |
| The timer configuratoin. 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... | |
| embutil::IRQDispatcherFunc_t | dispatcher_ |
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 | timer_thread () noexcept |
| Thread which simulates a timer. More... | |
Private Attributes | |
| std::thread | timer_thread_ |
| embvm::timer::cb_t | cb_ |
| std::atomic< bool > | quit_ = false |
| std::mutex | mutex_ |
| std::condition_variable | cv_ |
| embvm::timer::timer_period_t | time_base_ {0} |
|
inlinenoexcept |
Create a simulator timer with default options.
References embvm::timer::Timer::config_, embvm::timer::oneshot, and embvm::timer::Timer::period_.
|
inlineexplicitnoexcept |
Create a timer and set configuration options.
| period | The desired timer period. |
| config | The desired timer configuration (oneshot or periodic). |
References embvm::timer::Timer::config(), embvm::timer::Timer::config_, embvm::timer::Timer::period(), and embvm::timer::Timer::period_.
|
inlineexplicitnoexcept |
Create a timer and set configuration options and callback.
| period | The desired timer period. |
| cb | The callback function to invoke when the timer expires. |
| config | The desired timer configuration (oneshot or periodic). |
References embvm::timer::Timer::config(), embvm::timer::Timer::config_, embvm::timer::Timer::period(), and embvm::timer::Timer::period_.
|
inlineexplicitnoexcept |
Create a timer and set configuration options and callback.
| period | The desired timer period. |
| cb | The callback function to invoke when the timer expires. |
| config | The desired timer configuration (oneshot or periodic). |
References embvm::timer::Timer::config(), embvm::timer::Timer::config_, embvm::timer::Timer::period(), and embvm::timer::Timer::period_.
|
finalnoexcept |
Destructor, which cleans up the timer thread.
References embvm::this_thread::sleep_for(), and embvm::DriverBase::stop().
|
inlinevirtualnoexceptinherited |
Check the configuration of the timer.
References embvm::timer::Timer::config_.
Referenced by SimulatorTimer().
|
inlinevirtualnoexceptinherited |
Set the timer configuration.
| c | The desired timer configuration (periodic or oneshot). |
References embvm::timer::Timer::config_.
|
inlinefinalvirtualnoexcept |
Read the current timer count.
Implements embvm::timer::Timer.
References time_base_.
|
finalvirtualnoexcept |
Implements embvm::HALDriverBase.
|
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_.
|
finalvirtualnoexcept |
Implements embvm::HALDriverBase.
|
inlinenoexceptinherited |
References embvm::HALDriverBase::dispatcher_.
Referenced by timer_thread(), and nRFi2cMaster< NordicTWIM0, nRFPinID< 0, 27 >, nRFPinID< 0, 26 > >::twim_callback_().
|
inlinenoexceptinherited |
References embvm::HALDriverBase::dispatcher_.
|
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 timer period.
References embvm::timer::Timer::period_.
Referenced by embvm::timer::Timer::period(), embvm::timer::Timer::restart(), and SimulatorTimer().
|
inlinenoexceptinherited |
Set the timer period.
If the timer is currently running, this call has no effect. Use restart() instead.
| period | the desired timer period. |
References embvm::timer::Timer::period(), and embvm::timer::Timer::period_.
|
inlinefinalvirtualnoexcept |
Register a timer callback.
The timer callback function is called whenever the timer expires.
Derived classes must implement this function. Derived classes can choose to support either a single callback or multiple callbacks.
| cb | A callback to invoke when the timer expires. |
Implements embvm::timer::Timer.
References cb_.
|
inlinefinalvirtualnoexcept |
Register a timer callback.
The timer callback function is called whenever the timer expires.
Derived classes must implement this function. Derived classes can choose to support either a single callback or multiple callbacks.
| cb | A callback to invoke when the timer expires. |
Implements embvm::timer::Timer.
References cb_.
|
inlinevirtualnoexceptinherited |
Restart the timer with a specific period.
| period | The desired timer period to reset the timer to use. Accepts a std::chrono value. |
References embvm::timer::Timer::period(), embvm::timer::Timer::period_, embvm::DriverBase::start(), and embvm::DriverBase::stop().
|
inlinenoexceptinherited |
Restart the timer with a specific period.
| period | The desired timer period to reset the timer to use. Accepts an integral count representing the period in microseonds. |
References embvm::timer::Timer::period(), and embvm::timer::Timer::restart().
|
inlinenoexceptinherited |
Restart the timer with the currently configured period.
References embvm::timer::Timer::period_.
Referenced by embvm::timer::Timer::restart().
|
inlinenoexceptinherited |
References embvm::HALDriverBase::dispatcher_.
Referenced by BlinkySimulatorHWPlatform::init_(), and FWDemoSimulatorHWPlatform::init_().
|
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().
|
finalprivatevirtualnoexcept |
Derived classes override the start_ method to control driver-specific startup behavior.
(Template Method Pattern)
Implements embvm::timer::Timer.
References embvm::timer::armed, mutex_, quit_, embvm::timer::Timer::state_, time_base_, timer_thread(), and timer_thread_.
|
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_().
|
inlinevirtualnoexceptinherited |
Check the state of the timer.
References embvm::timer::Timer::state_.
|
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 ~SimulatorTimer().
|
finalprivatevirtualnoexcept |
Derived classes override the start_ method to control driver-specific startup behavior.
(Template Method Pattern)
Implements embvm::timer::Timer.
References cv_, mutex_, quit_, embvm::timer::Timer::state_, embvm::timer::stopped, and timer_thread_.
|
privatenoexcept |
Thread which simulates a timer.
We sleep the thread for the requested period using a std::condition_variable::wait_for(). When the timer expires, we call the callback. We can also be notified early to cancel the timer.
References cb_, embvm::timer::Timer::config_, cv_, embvm::timer::expired, embvm::HALDriverBase::invokeCallback(), mutex_, embvm::timer::Timer::period_, embvm::timer::periodic, quit_, and embvm::timer::Timer::state_.
Referenced by start_().
|
inlinestaticnoexceptinherited |
|
private |
Referenced by registerCallback(), and timer_thread().
|
protectedinherited |
The timer configuratoin.
Referenced by embvm::timer::Timer::config(), SimulatorTimer(), and timer_thread().
|
private |
Referenced by stop_(), and timer_thread().
|
protectedinherited |
|
private |
Referenced by start_(), stop_(), and timer_thread().
|
protectedinherited |
Name of the driver instance.
Referenced by embvm::DriverBase::name(), and embvm::DriverBase::name_cstr().
|
protectedinherited |
The configured timer period.
Referenced by embvm::timer::Timer::period(), embvm::timer::Timer::restart(), SimulatorTimer(), and timer_thread().
Referenced by start_(), stop_(), and timer_thread().
|
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 |
The current state of the timer.
Referenced by start_(), embvm::timer::Timer::state(), stop_(), and timer_thread().
|
private |
|
protectedinherited |
Type ID of the driver instance.
Referenced by embvm::DriverBase::DriverType().
1.8.15