Embedded Artistry Framework
Embedded Systems C++ Framework
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
FWDemoSimulatorHWPlatform Class Reference

Framework Demo Simulator Hardware Platform. More...

#include <fwdemo_simulator_hw_platform.hpp>

Inheritance diagram for FWDemoSimulatorHWPlatform:
Inheritance graph

Public Types

using TimerHandle_t = TimerManager_t::TimerHandle
 

Public Member Functions

 FWDemoSimulatorHWPlatform () noexcept
 Default constructor. More...
 
 ~FWDemoSimulatorHWPlatform () noexcept
 Default destructor. More...
 
void init_ () noexcept
 
void initProcessor_ () noexcept
 
void soft_reset_ () noexcept
 
void hard_reset_ () noexcept
 
void startLEDTimer () noexcept
 Start the LED timer. More...
 
TimerHandle_t allocateTimer () noexcept
 Allocate a software timer. More...
 
embvm::tof::sensortof0_inst () noexcept
 Get the tof0 Instance. More...
 
embvm::led::baseled0_inst () noexcept
 Get the led0 Instance. More...
 
embvm::basicDisplayscreen0_inst () noexcept
 Get the screen0 Instance. More...
 
embvm::tof::mode readAndSetToFMode () noexcept
 Sets the ToF mode based on GPIO input. More...
 
constexpr const std::string_view & name () const noexcept
 Returns the Virtual HW Platform's name. More...
 
constexpr const char * name_cstr () const noexcept
 Returns the platform name as a cstring for C API compatibility. More...
 
void initProcessor () noexcept
 Initialize the processor. More...
 
void init () noexcept
 Initialize the hardware platform. More...
 
void soft_reset () noexcept
 Perform a soft reset of the system (chip reset) More...
 
void hard_reset () noexcept
 Perform a hard reset of the system (power cycle) More...
 
void shutdown () noexcept
 Shutdown the system. More...
 

Static Public Member Functions

static void earlyInitHook_ () noexcept
 
static void earlyInitHook () noexcept
 Perform any special initialization steps. More...
 

Private Types

using PlatformBase = embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >
 
using TimerManager_t = embvm::TimerManager< 0, std::mutex >
 

Private Attributes

embutil::InterruptQueue< std::mutex > irq_bottom_half_
 
embdrv::SimulatorSystemClock sysclock
 
embdrv::aardvarkAdapter aardvark {embdrv::aardvarkMode::GpioI2C}
 
embdrv::aardvarkI2CMaster i2c0 {aardvark}
 
embdrv::aardvarkGPIOOutput< 5 > gpio5 {aardvark}
 
embdrv::aardvarkGPIOInput< 4 > gpio4 {aardvark}
 
embdrv::aardvarkGPIOInput< 3 > gpio3 {aardvark}
 
embvm::led::gpioActiveHigh led0 {gpio5}
 
embdrv::vl53l1x tof0 {i2c0, SPARKFUN_VL53L1X_ADDR}
 
embdrv::ssd1306 screen0 {i2c0, SPARKFUN_SSD1306_ADDR}
 
embdrv::SimulatorTimer timer0
 
TimerManager_t tm_ {timer0}
 
TimerHandle_t led_sw_timer_handle
 
SimulatorProcessor processor
 

Detailed Description

Framework Demo Simulator Hardware Platform.

This implements an OSX-based hardware platform which provides the functionality needed for our framework demo.

I2C support is provided using an aardvark adapter. Higher-level device drivers utilize the Aardvark I2C interface, enabling them to work on a host machine.

To the application layer, this hardware is just as good as embedded hardware!

Our configuration sports:

The hardware platform also provides a timer manager (using timer1), which provides any number of software timers to be derived from it.

Member Typedef Documentation

◆ PlatformBase

◆ TimerHandle_t

using FWDemoSimulatorHWPlatform::TimerHandle_t = TimerManager_t::TimerHandle

◆ TimerManager_t

Constructor & Destructor Documentation

◆ FWDemoSimulatorHWPlatform()

FWDemoSimulatorHWPlatform::FWDemoSimulatorHWPlatform ( )
inlinenoexcept

Default constructor.

◆ ~FWDemoSimulatorHWPlatform()

FWDemoSimulatorHWPlatform::~FWDemoSimulatorHWPlatform ( )
noexcept

Default destructor.

Turn off the screen & led before exiting the program

References screen0, and embvm::DriverBase::stop().

Member Function Documentation

◆ allocateTimer()

TimerHandle_t FWDemoSimulatorHWPlatform::allocateTimer ( )
inlinenoexcept

Allocate a software timer.

Allocates a software timer from the underlying timer manager. A handle is returned, which the user can use to configure the timer according to their wishes.

Returns
handle to a software timer object

References embvm::TimerManager< TMaxTimers, TLock, TTimeUnit, TTimeoutCallback, TTimerDevice >::allocate(), and tm_.

Referenced by FrameworkDemoSimPlatform::startBlink().

◆ earlyInitHook()

static void embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::earlyInitHook ( )
inlinestaticnoexceptinherited

Perform any special initialization steps.

The earlyInitHook_() function must be implemented by the derived class as a static function.

These functions run before the C Run-time setup functions are called, and normal functionality (e.g. OS concepts) are not available.

Early initialization steps represent any super early code that needs to execute. For example, DRAM might need to be initialized before the boot process can relocate memory to its proper location in memory.

These functions are declared static to prevent you from easily using drivers within their confines

◆ earlyInitHook_()

static void FWDemoSimulatorHWPlatform::earlyInitHook_ ( )
inlinestaticnoexcept

◆ hard_reset()

void embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::hard_reset ( )
inlinenoexceptinherited

Perform a hard reset of the system (power cycle)

The hard_reset_() function must be implemented by the derived class.

A hard reset is intended to perform a full power cycle of the system.

Platforms which do not support a hard reset should default to calling soft_reset().

◆ hard_reset_()

void FWDemoSimulatorHWPlatform::hard_reset_ ( )
noexcept

References soft_reset_().

◆ init()

void embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::init ( )
inlinenoexceptinherited

Initialize the hardware platform.

The init_() function must be implemented by the derived class.

Perform any hardware platform initialization steps, such as preparing peripherals for use, setting up callbacks, etc.

◆ init_()

void FWDemoSimulatorHWPlatform::init_ ( )
noexcept

◆ initProcessor()

void embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::initProcessor ( )
inlinenoexceptinherited

Initialize the processor.

The initProcessor_() function must be implemented by the derived class.

Perform any steps necessary for initializing the processor & processor peripheral devices for use.

Note that this is only intended to be processor initialization. Platform initialization nis handled by the init() function.

This function will likely invoke the VirtualProcessor::init() function, but the order and actual initialization process is left to the derived class.

◆ initProcessor_()

void FWDemoSimulatorHWPlatform::initProcessor_ ( )
noexcept

◆ led0_inst()

embvm::led::base& FWDemoSimulatorHWPlatform::led0_inst ( )
inlinenoexcept

Get the led0 Instance.

You don't always need find_driver() in the DriverRegistry. You can directly return a base-class reference from the hardware platform. This saves time from doing a lookup.

It is important to return the base class, since that is how we keep our applications decoupled from the underlying hardware. Returning the actual ToF sensor class will enable coupling to the underlying harware.

Returns
a reference to the led0 instance, as the base class type.

References led0.

Referenced by FrameworkDemoSimPlatform::startBlink().

◆ name()

constexpr const std::string_view& embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::name ( ) const
inlinenoexceptinherited

Returns the Virtual HW Platform's name.

◆ name_cstr()

constexpr const char* embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::name_cstr ( ) const
inlinenoexceptinherited

Returns the platform name as a cstring for C API compatibility.

◆ readAndSetToFMode()

embvm::tof::mode FWDemoSimulatorHWPlatform::readAndSetToFMode ( )
noexcept

Sets the ToF mode based on GPIO input.

Reads the mode GPIO and updates the ToF mode based on the setting.

Returns
the ToF mode setting read from HW

References embdrv::aardvarkGPIOInput< TPinID, TPull >::get(), gpio3, gpio4, logdebug, embdrv::vl53l1x::mode(), and tof0.

Referenced by FrameworkDemoSimPlatform::updateToFMode().

◆ screen0_inst()

embvm::basicDisplay& FWDemoSimulatorHWPlatform::screen0_inst ( )
inlinenoexcept

Get the screen0 Instance.

You don't always need find_driver() in the DriverRegistry. You can directly return a base-class reference from the hardware platform. This saves time from doing a lookup.

It is important to return the base class, since that is how we keep our applications decoupled from the underlying hardware. Returning the actual ToF sensor class will enable coupling to the underlying harware.

Returns
a reference to the screen0 instance, as the base class type.

References screen0.

Referenced by FrameworkDemoSimPlatform::initHWPlatform_().

◆ shutdown()

void embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::shutdown ( )
inlinenoexceptinherited

Shutdown the system.

The shutdown_() function must be implemented by the derived class.

If your platform supports shutdown capability, take the proper steps to initiate a shutdown.

If the platform does not support shutdown capability, implement your shutdown_() function as an assert to notify users trying to call this API. You could also leave the shutdown_() function undefined. Anyone who calls the shutdown() function on a platform with an undefined shutdown_() function will encounter a compiler error.

The shutdown function is not expected to return.

◆ soft_reset()

void embvm::VirtualHwPlatformBase< FWDemoSimulatorHWPlatform >::soft_reset ( )
inlinenoexceptinherited

Perform a soft reset of the system (chip reset)

The soft_reset_() function must be implemnted by the derived class.

A soft reset is intended to reset the program to the beginning without performing a full power cycle.

A good strategy is to just call virtual processor's reset() function, if one is provided.

◆ soft_reset_()

void FWDemoSimulatorHWPlatform::soft_reset_ ( )
inlinenoexcept

Referenced by hard_reset_().

◆ startLEDTimer()

void FWDemoSimulatorHWPlatform::startLEDTimer ( )
inlinenoexcept

Start the LED timer.

References embvm::DriverBase::start(), and timer0.

Referenced by FrameworkDemoSimPlatform::startBlink().

◆ tof0_inst()

embvm::tof::sensor& FWDemoSimulatorHWPlatform::tof0_inst ( )
inlinenoexcept

Get the tof0 Instance.

You don't always need find_driver() in the DriverRegistry. You can directly return a base-class reference from the hardware platform. This saves time from doing a lookup.

It is important to return the base class, since that is how we keep our applications decoupled from the underlying hardware. Returning the actual ToF sensor class will enable coupling to the underlying harware.

Returns
a reference to the tof0 instance, as the base class type.

References tof0.

Referenced by FrameworkDemoSimPlatform::init_(), and FrameworkDemoSimPlatform::initHWPlatform_().

Member Data Documentation

◆ aardvark

embdrv::aardvarkAdapter FWDemoSimulatorHWPlatform::aardvark {embdrv::aardvarkMode::GpioI2C}
private

◆ gpio3

embdrv::aardvarkGPIOInput<3> FWDemoSimulatorHWPlatform::gpio3 {aardvark}
private

Referenced by init_(), and readAndSetToFMode().

◆ gpio4

embdrv::aardvarkGPIOInput<4> FWDemoSimulatorHWPlatform::gpio4 {aardvark}
private

Referenced by init_(), and readAndSetToFMode().

◆ gpio5

embdrv::aardvarkGPIOOutput<5> FWDemoSimulatorHWPlatform::gpio5 {aardvark}
private

◆ i2c0

embdrv::aardvarkI2CMaster FWDemoSimulatorHWPlatform::i2c0 {aardvark}
private

Referenced by init_().

◆ irq_bottom_half_

embutil::InterruptQueue<std::mutex> FWDemoSimulatorHWPlatform::irq_bottom_half_
private

Referenced by init_().

◆ led0

embvm::led::gpioActiveHigh FWDemoSimulatorHWPlatform::led0 {gpio5}
private

Referenced by init_(), and led0_inst().

◆ led_sw_timer_handle

TimerHandle_t FWDemoSimulatorHWPlatform::led_sw_timer_handle
private

◆ processor

SimulatorProcessor FWDemoSimulatorHWPlatform::processor
private

Referenced by initProcessor_().

◆ screen0

embdrv::ssd1306 FWDemoSimulatorHWPlatform::screen0 {i2c0, SPARKFUN_SSD1306_ADDR}
private

◆ sysclock

embdrv::SimulatorSystemClock FWDemoSimulatorHWPlatform::sysclock
private

◆ timer0

embdrv::SimulatorTimer FWDemoSimulatorHWPlatform::timer0
private

Referenced by init_(), and startLEDTimer().

◆ tm_

TimerManager_t FWDemoSimulatorHWPlatform::tm_ {timer0}
private

Referenced by allocateTimer().

◆ tof0

embdrv::vl53l1x FWDemoSimulatorHWPlatform::tof0 {i2c0, SPARKFUN_VL53L1X_ADDR}
private

Referenced by readAndSetToFMode(), and tof0_inst().


The documentation for this class was generated from the following files: