Embedded Artistry Framework
Embedded Systems C++ Framework
Namespaces | Classes | Typedefs | Enumerations
Framework Driver Infrastructure

Driver base classes & definitions. More...

Collaboration diagram for Framework Driver Infrastructure:

Namespaces

 embvm::clk
 Definitions, functions, and classes related to clock devices.
 
 embvm::comm
 Definitions, functions, and classes related to communication busses.
 
 embvm::gpio
 Definitions, functions, and classes related to GPIO devices.
 
 embvm
 Embedded framework core interfaces, classes, and definitions.
 
 embvm::i2c
 Definitions, functions, and classes related to I2C communication bus devices.
 
 embvm::led
 Definitions, functions, and classes related to LED devices.
 
 embvm::spi
 Definitions, functions, and classes related to SPI communication bus devices.
 
 embvm::tof
 Definitions, functions, and classes related to Time-of-Flight sensors.
 
 embvm::timer
 Definitions, functions, and classes related to Timer devices.
 

Classes

class  embvm::basicDisplay
 This class provides an interface for a basic 2-color display device. More...
 
class  embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >
 Base class interface for communication bus driver types (SPI, I2C, etc.). More...
 
class  embvm::DriverBase
 Virtual base class for framework drivers. More...
 
class  embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >
 DriverRegistry base class. More...
 

Typedefs

template<typename TLockType = embutil::nop_lock>
using embvm::DynamicDriverRegistry = DriverRegistry< 0, 0, TLockType >
 Declare a DriverRegistry that uses dynamic memory allocation. More...
 
template<const size_t TMaxSize = 32, const size_t TReturnSize = 4, typename TLockType = embutil::nop_lock>
using embvm::StaticDriverRegistry = DriverRegistry< TMaxSize, TReturnSize, TLockType >
 Declare a DriverRegistry that uses static memory allocation. More...
 
using embvm::DriverType_t = uint32_t
 Driver type used by framework interfaces. More...
 

Enumerations

enum  embvm::DriverType {
  embvm::Undefined = 0, embvm::GPIO, embvm::HARDWARE_TIMER, embvm::I2C,
  embvm::LED, embvm::SPI, embvm::SYSTEM_CLOCK, embvm::TIME_OF_FLIGHT,
  embvm::SOFTWARE_TIMER, embvm::TIMER, embvm::BASIC_DISPLAY, embvm::DRIVER_EXTENSION_START
}
 Default framework driver type definitions. More...
 

Detailed Description

Driver base classes & definitions.


Class Documentation

◆ embvm::basicDisplay

class embvm::basicDisplay

This class provides an interface for a basic 2-color display device.

The basicDisplay class defines common interfaces for basic 2-color display drivers, which can be LED or OLED.

Define an basic display driver

To create a basic display driver, derive from the basicDisplay object:

class ssd1306 final : public basicDisplay
{ ... };

Derived classes must implement the following functions:

Derived classes must also implement pure virtual embvm::DriverBase functions:

Turning on a dispay should be handled in the start_() function, and turning off the display should be handled in the stop_() function.

Using a basic display

The display is turned on by calling start(), and turned off by calling stop().

Most display functions update the screen buffer, which is the representation of the display buffer contents in local memory.

snprintf(tof_string_, 32, "ToF Range: %u mm\n", v);
screen0.printString(0, 0, tof_string_);
screen0.printString(0, 32, tof_mode_string_);

Changes to the screen buffer are not written to the display's hardware buffer until the display() function is called.

screen0.display();

The screen buffer can be updated incrementally. If clearing the entire buffer is desired, call the clear() function.

screen0.clear();
Inheritance diagram for embvm::basicDisplay:
Inheritance graph

Public Types

enum  invert : uint8_t { invert::normal = 0, invert::invert }
 Display color inversion options. More...
 
enum  mode : uint8_t { mode::normal = 0, mode::XOR }
 Set the drawing mode, if supported by the driver. More...
 
enum  color : uint8_t { color::black = 0, color::white }
 Basic displays have two pixel colors: black and white. More...
 
using coord_t = uint8_t
 Coordinate representation type. More...
 

Public Member Functions

virtual void clear () noexcept=0
 Clear the screen contents. More...
 
virtual void display () noexcept=0
 Flush the screen buffer contents to the hardware display buffer. More...
 
virtual void invert (invert inv) noexcept=0
 Invert the display color. More...
 
virtual void contrast (uint8_t contrast) noexcept=0
 Set contrast. More...
 
virtual void cursor (coord_t x, coord_t y) noexcept=0
 Set the cusor within the screen buffer. More...
 
void pixel (coord_t x, coord_t y) noexcept
 Draw a pixel in the screen buffer. More...
 
virtual void pixel (coord_t x, coord_t y, color c, mode m) noexcept=0
 Draw a pixel with a specific color and mode. More...
 
void line (coord_t x0, coord_t y0, coord_t x1, coord_t y1) noexcept
 Draw a line. More...
 
virtual void line (coord_t x0, coord_t y0, coord_t x1, coord_t y1, color c, mode m) noexcept=0
 Draw a line with a specific color and mode. More...
 
void lineH (coord_t x, coord_t y, uint8_t width) noexcept
 Draw a horizontal line. More...
 
void lineH (coord_t x, coord_t y, uint8_t width, color c, mode m) noexcept
 Draw a horizontal line with a specific color and mode. More...
 
void lineV (coord_t x, coord_t y, uint8_t height) noexcept
 Draw a vertical line. More...
 
void lineV (coord_t x, coord_t y, uint8_t height, color c, mode m) noexcept
 Draw a vertical line with a specific color and mode. More...
 
void rect (coord_t x, coord_t y, uint8_t width, uint8_t height) noexcept
 Draw a rectangle. More...
 
virtual void rect (coord_t x, coord_t y, uint8_t width, uint8_t height, color c, mode m) noexcept=0
 Draw a rectangle with a specific color and mode. More...
 
void rectFill (coord_t x, coord_t y, uint8_t width, uint8_t height) noexcept
 Draw a filled rectangle. More...
 
virtual void rectFill (coord_t x, coord_t y, uint8_t width, uint8_t height, color c, mode m) noexcept=0
 Draw a filled rectangle with a specific color and mode. More...
 
void circle (coord_t x, coord_t y, uint8_t radius) noexcept
 Draw a circle. More...
 
virtual void circle (coord_t x, coord_t y, uint8_t radius, color c, mode m) noexcept=0
 Draw a circle with a specific color and mode. More...
 
void circleFill (coord_t x, coord_t y, uint8_t radius) noexcept
 Draw a filled circle. More...
 
virtual void circleFill (coord_t x, coord_t y, uint8_t radius, color c, mode m) noexcept=0
 Draw a filled circle with a specific color and mode. More...
 
void drawChar (coord_t x, coord_t y, uint8_t character) noexcept
 Draw an ASCII character. More...
 
virtual void putchar (uint8_t c) noexcept=0
 Print a character on the display. More...
 
virtual void drawChar (coord_t x, coord_t y, uint8_t character, color c, mode m) noexcept=0
 Draw an ASCII character with a specific color and mode. More...
 
void printString (coord_t x, coord_t y, const char *str) noexcept
 Print a string on the display. More...
 
void printString (coord_t x, coord_t y, const char *str, size_t length) noexcept
 Print a string on the display. More...
 
virtual void drawBitmap (uint8_t *bitmap) noexcept=0
 Replace the screen buffer with a bitmap. More...
 
virtual uint8_t screenWidth () const noexcept=0
 Check the screen width. More...
 
virtual uint8_t screenHeight () const noexcept=0
 Check the screen height. More...
 
void drawColor (color c) noexcept
 Set color. More...
 
virtual void drawMode (mode m) noexcept
 Set draw mode. More...
 
virtual void scrollRight (coord_t start, coord_t stop) noexcept=0
 Enable right scrolling. More...
 
virtual void scrollLeft (coord_t start, coord_t stop) noexcept=0
 Enable left scrolling. More...
 
virtual void scrollVertRight (coord_t start, coord_t stop) noexcept=0
 
virtual void scrollVertLeft (coord_t start, coord_t stop) noexcept=0
 
virtual void scrollStop () noexcept=0
 Stop scrolling. More...
 
virtual void flipVertical (bool flip) noexcept=0
 Vertical flip. More...
 
virtual void flipHorizontal (bool flip) noexcept=0
 Horizontal flip. 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 DriverBaseoperator++ () noexcept
 Increment operator is a no-op, but is used for iterator compatibility. More...
 

Static Public Member Functions

static constexpr embvm::DriverType type () noexcept
 Basic Display Driver Type ID. More...
 

Protected Member Functions

 basicDisplay () noexcept
 Default constructor. More...
 
 basicDisplay (const char *name) noexcept
 Construct an basicDisplay with a name. More...
 
 basicDisplay (const std::string &name) noexcept
 Construct an basicDisplay with a std::string name. More...
 
 basicDisplay (const std::string_view &name) noexcept
 Construct an basicDisplay with a std::string_view name. More...
 
void start_ () noexcept override=0
 Derived classes override the start_ method to control driver-specific startup behavior. More...
 
void stop_ () noexcept override=0
 Derived classes override the start_ method to control driver-specific startup behavior. More...
 
 ~basicDisplay () noexcept override
 Default destructor. More...
 

Protected Attributes

mode mode_ = mode::normal
 The current display mode setting. More...
 
color color_ = color::black
 The current display color setting. 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...
 

Member Typedef Documentation

◆ coord_t

Coordinate representation type.

Member Enumeration Documentation

◆ color

Basic displays have two pixel colors: black and white.

Enumerator
black 
white 

◆ invert

Display color inversion options.

Enumerator
normal 

Use the default display color setting.

invert 

Invert the display colors.

◆ mode

Set the drawing mode, if supported by the driver.

Enumerator
normal 

Either sets or clears a pixel as requested, overwriting the value set in the screen buffer.

XOR 

The pixel output in the screen buffer will be an XOR of the current value and the input value.

Constructor & Destructor Documentation

◆ basicDisplay() [1/4]

embvm::basicDisplay::basicDisplay ( )
inlineprotectednoexcept

Default constructor.

Initializes the basicDisplay instance with a generic name.

◆ basicDisplay() [2/4]

embvm::basicDisplay::basicDisplay ( const char *  name)
inlineprotectednoexcept

Construct an basicDisplay with a name.

Initializes the basicDisplay instance with a name.

Parameters
nameThe name of the display instance. basicDisplay() uses a std::string_view, so a std::string must remain valid

◆ basicDisplay() [3/4]

embvm::basicDisplay::basicDisplay ( const std::string &  name)
inlineprotectednoexcept

Construct an basicDisplay with a std::string name.

Initializes the basicDisplay instance with a name.

Parameters
nameThe name of the display instance. basicDisplay() uses a std::string_view, so the std::string must remain valid

◆ basicDisplay() [4/4]

embvm::basicDisplay::basicDisplay ( const std::string_view &  name)
inlineprotectednoexcept

Construct an basicDisplay with a std::string_view name.

Initializes the basicDisplay instance with a name.

Parameters
nameThe name of the display instance.

◆ ~basicDisplay()

embvm::basicDisplay::~basicDisplay ( )
overrideprotecteddefaultnoexcept

Default destructor.

Member Function Documentation

◆ circle() [1/2]

void embvm::basicDisplay::circle ( coord_t  x,
coord_t  y,
uint8_t  radius 
)
inlinenoexcept

Draw a circle.

Draw a circle with center (x,y) and the specified radius using the configured color setting and draw mode in the screen buffer. Only the boundary of the circle will be drawn.

Parameters
xX-coorindate for the center of the circle.
yY-coordinate for the center of the circle.
radiusThe radius of the circle.

References color_, and mode_.

◆ circle() [2/2]

virtual void embvm::basicDisplay::circle ( coord_t  x,
coord_t  y,
uint8_t  radius,
color  c,
mode  m 
)
pure virtualnoexcept

Draw a circle with a specific color and mode.

Draw a circle with center (x,y) and the specified radius using a specific color setting and draw mode in the screen buffer. Only the boundary of the circle will be drawn.

Parameters
xX-coorindate for the center of the circle.
yY-coordinate for the center of the circle.
radiusThe radius of the circle.
cPixel color.
mMode used to update the screen buffer.

Implemented in embdrv::ssd1306.

◆ circleFill() [1/2]

void embvm::basicDisplay::circleFill ( coord_t  x,
coord_t  y,
uint8_t  radius 
)
inlinenoexcept

Draw a filled circle.

Draw a filled circle with center (x,y) and the specified radius using the configured color setting and draw mode in the screen buffer. The interior of the circle will be filled with the specified color setting.

Parameters
xX-coorindate for the center of the circle.
yY-coordinate for the center of the circle.
radiusThe radius of the circle.

References color_, and mode_.

◆ circleFill() [2/2]

virtual void embvm::basicDisplay::circleFill ( coord_t  x,
coord_t  y,
uint8_t  radius,
color  c,
mode  m 
)
pure virtualnoexcept

Draw a filled circle with a specific color and mode.

Draw a filled circle with center (x,y) and the specified radius using a specific color setting and draw mode in the screen buffer. The interior of the circle will be filled with the specified color setting.

Parameters
xX-coorindate for the center of the circle.
yY-coordinate for the center of the circle.
radiusThe radius of the circle.
cPixel color.
mMode used to update the screen buffer.

Implemented in embdrv::ssd1306.

◆ clear()

virtual void embvm::basicDisplay::clear ( )
pure virtualnoexcept

Clear the screen contents.

Implemented in embdrv::ssd1306.

◆ contrast()

virtual void embvm::basicDisplay::contrast ( uint8_t  contrast)
pure virtualnoexcept

Set contrast.

Parameters
contrastTarget display contrast value, ranging from 0 to 255.

Implemented in embdrv::ssd1306.

◆ cursor()

virtual void embvm::basicDisplay::cursor ( coord_t  x,
coord_t  y 
)
pure virtualnoexcept

Set the cusor within the screen buffer.

Contents in the screen buffer are not modified by setting the cursor position.

Parameters
xX-coordinate of the cursor.
yY-coordinate of the cursor.

Implemented in embdrv::ssd1306.

Referenced by printString().

◆ display()

virtual void embvm::basicDisplay::display ( )
pure virtualnoexcept

Flush the screen buffer contents to the hardware display buffer.

Implemented in embdrv::ssd1306.

◆ drawBitmap()

virtual void embvm::basicDisplay::drawBitmap ( uint8_t bitmap)
pure virtualnoexcept

Replace the screen buffer with a bitmap.

Supply a bitmap to write to the screen buffer. If the size of the bitmap is less than the size of the screen buffer, the remainder of the screen buffer will not be modified.

Parameters
bitmapBitmap array which will be used to overwrite the screen buffer.

Implemented in embdrv::ssd1306.

◆ drawChar() [1/2]

void embvm::basicDisplay::drawChar ( coord_t  x,
coord_t  y,
uint8_t  character 
)
inlinenoexcept

Draw an ASCII character.

Draw an ASCII character using the configured color and draw mode with the upper left corner of the character located at (x,y).

Parameters
xX-coordinate representing the top-left of the character.
yY-coordinate representing the top-left of the character.
characterthe ASCII character to draw. Must be present in the font file. If the requested character is not present, nothing will be drawn on the screen buffer.

References color_, and mode_.

◆ drawChar() [2/2]

virtual void embvm::basicDisplay::drawChar ( coord_t  x,
coord_t  y,
uint8_t  character,
color  c,
mode  m 
)
pure virtualnoexcept

Draw an ASCII character with a specific color and mode.

Draw an ASCII character using a specific color and draw mode with the upper left corner of the character located at (x,y).

Parameters
xX-coordinate representing the top-left of the character.
yY-coordinate representing the top-left of the character.
characterthe ASCII character to draw. Must be present in the font file. If the requested character is not present, nothing will be drawn on the screen buffer.
cPixel color.
mMode used to update the screen buffer.

Implemented in embdrv::ssd1306.

◆ drawColor()

void embvm::basicDisplay::drawColor ( color  c)
inlinenoexcept

Set color.

Set the current draw's color. Only WHITE and BLACK available.

Parameters
cThe desired draw color setting.

References assert, black, color_, and white.

Referenced by embdrv::ssd1306::start_().

◆ drawMode()

virtual void embvm::basicDisplay::drawMode ( mode  m)
inlinevirtualnoexcept

Set draw mode.

Parameters
mDesired draw mode: NORM or XOR.

References assert, mode_, normal, and XOR.

Referenced by embdrv::ssd1306::start_().

◆ DriverType()

constexpr embvm::DriverType_t embvm::DriverBase::DriverType ( ) const
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.

Returns
the registered driver type as a embvm::DriverType_t value

References embvm::DriverBase::type_.

◆ flipHorizontal()

virtual void embvm::basicDisplay::flipHorizontal ( bool  flip)
pure virtualnoexcept

Horizontal flip.

Flip the graphics on the display horizontally.

Parameters
flipTrue enables horizontal flip, false disables horizontal flip.

Implemented in embdrv::ssd1306.

◆ flipVertical()

virtual void embvm::basicDisplay::flipVertical ( bool  flip)
pure virtualnoexcept

Vertical flip.

Flip the graphics on the display vertically.

Parameters
flipTrue enables vertical flip, false disables vertical flip.

Implemented in embdrv::ssd1306.

◆ invert()

virtual void embvm::basicDisplay::invert ( invert  inv)
pure virtualnoexcept

Invert the display color.

The WHITE color of the display will turn to BLACK and the BLACK will turn to WHITE.

Parameters
invinvert::invert uses color inversion, invert::normal uses the display standard.

Implemented in embdrv::ssd1306.

◆ line() [1/2]

void embvm::basicDisplay::line ( coord_t  x0,
coord_t  y0,
coord_t  x1,
coord_t  y1 
)
inlinenoexcept

Draw a line.

Draw a line using the configured color setting and draw mode from (x0,y0) to (x1,y1) of the screen buffer.

Parameters
x0X-coordinate where the line originates.
y0Y-coordinate where the line originates.
x1X-coordinate where the line terminates.
y1Y-coordinate where the line terminates.

References color_, mode_, and x0.

Referenced by lineH(), and lineV().

◆ line() [2/2]

virtual void embvm::basicDisplay::line ( coord_t  x0,
coord_t  y0,
coord_t  x1,
coord_t  y1,
color  c,
mode  m 
)
pure virtualnoexcept

Draw a line with a specific color and mode.

Draw line with a specific color setting and draw mode from (x0,y0) to (x1,y1) of the screen buffer.

Parameters
x0X-coordinate where the line originates.
y0Y-coordinate where the line originates.
x1X-coordinate where the line terminates.
y1Y-coordinate where the line terminates.
cPixel color.
mMode used to update the screen buffer.

Implemented in embdrv::ssd1306.

◆ lineH() [1/2]

void embvm::basicDisplay::lineH ( coord_t  x,
coord_t  y,
uint8_t  width 
)
inlinenoexcept

Draw a horizontal line.

Draw a horizontal line using the configured color setting and draw mode from (x,y) to (x+width,y) in the screen buffer.

Parameters
xX-coordinate where the line originates.
yY-coordinate where the line originates.
widthLength of the line, in pixels. The line will terminate at coordinate (x+width, y).

References color_, and mode_.

◆ lineH() [2/2]

void embvm::basicDisplay::lineH ( coord_t  x,
coord_t  y,
uint8_t  width,
color  c,
mode  m 
)
inlinenoexcept

Draw a horizontal line with a specific color and mode.

Draw a horizontal line with a specific color setting and draw mode from (x,y) to (x+width,y) in the screen buffer.

Parameters
xX-coordinate where the line originates.
yY-coordinate where the line originates.
widthLength of the line, in pixels. The line will terminate at coordinate (x+width, y).
cPixel color.
mMode used to update the screen buffer.

References line().

◆ lineV() [1/2]

void embvm::basicDisplay::lineV ( coord_t  x,
coord_t  y,
uint8_t  height 
)
inlinenoexcept

Draw a vertical line.

Draw a vertical line using the configured color setting and draw mode from (x,y) to (x,y+height) in the screen buffer.

Parameters
xX-coordinate where the line originates.
yY-coordinate where the line originates.
heightLength of the line, in pixels. The line will terminate at coordinate (x, y+height).

References color_, and mode_.

◆ lineV() [2/2]

void embvm::basicDisplay::lineV ( coord_t  x,
coord_t  y,
uint8_t  height,
color  c,
mode  m 
)
inlinenoexcept

Draw a vertical line with a specific color and mode.

Draw a vertical line using a specific color setting and draw mode from (x,y) to (x,y+height) in the screen buffer.

Parameters
xX-coordinate where the line originates.
yY-coordinate where the line originates.
heightLength of the line, in pixels. The line will terminate at coordinate (x, y+height).
cPixel color.
mMode used to update the screen buffer.

References line().

◆ name()

constexpr const std::string_view& embvm::DriverBase::name ( ) const
inlinenoexceptinherited

Provides a string_view reference of the driver name.

Returns
std::string_view ref containing the driver name.

References embvm::DriverBase::name_.

◆ name_cstr()

constexpr const char* embvm::DriverBase::name_cstr ( ) const
inlinenoexceptinherited

Provides a c-string version of the driver name.

Returns
c-string containing the driver name

References embvm::DriverBase::name_.

◆ operator++()

virtual DriverBase& embvm::DriverBase::operator++ ( )
inlinevirtualnoexceptinherited

Increment operator is a no-op, but is used for iterator compatibility.

◆ pixel() [1/2]

void embvm::basicDisplay::pixel ( coord_t  x,
coord_t  y 
)
inlinenoexcept

Draw a pixel in the screen buffer.

Draw pixel using the configured color setting and draw mode in the screen buffer's x,y position.

Parameters
xX-coordinate of the pixel.
yY-coordinate of the pixel.

References color_, and mode_.

◆ pixel() [2/2]

virtual void embvm::basicDisplay::pixel ( coord_t  x,
coord_t  y,
color  c,
mode  m 
)
pure virtualnoexcept

Draw a pixel with a specific color and mode.

Draw a pixel at position (x,y) with a specific color setting and draw mode.

Parameters
xX-coordinate of the pixel.
yY-coordinate of the pixel.
cPixel color.
mMode used to update the screen buffer.

Implemented in embdrv::ssd1306.

◆ printString() [1/2]

void embvm::basicDisplay::printString ( coord_t  x,
coord_t  y,
const char *  str 
)
inlinenoexcept

Print a string on the display.

Parameters
xThe x-coordinate to start the string.
yThe y-coordinate to start the string.
strThe string to print to the display.

References strlen().

◆ printString() [2/2]

void embvm::basicDisplay::printString ( coord_t  x,
coord_t  y,
const char *  str,
size_t  length 
)
inlinenoexcept

Print a string on the display.

Parameters
xThe x-coordinate to start the string.
yThe y-coordinate to start the string.
strThe string to print to the display.
lengthThe number of characters in str.

References cursor(), length, and putchar().

◆ putchar()

virtual void embvm::basicDisplay::putchar ( uint8_t  c)
pure virtualnoexcept

Print a character on the display.

Parameters
cthe character to print to the display

Implemented in embdrv::ssd1306.

Referenced by printString().

◆ rect() [1/2]

void embvm::basicDisplay::rect ( coord_t  x,
coord_t  y,
uint8_t  width,
uint8_t  height 
)
inlinenoexcept

Draw a rectangle.

Draw a rectangle using the configured color setting and draw mode from (x,y) to (x+width,y+height) in the screen buffer. Only the boundary of the rectangle will be drawn.

Parameters
xX-coordinate where the rectangle originates.
yY-coordinate where the rectangle originates.
widthWidth of the rectangle, in pixels. The rectangle width spans from x to x+width.
heightHeight of the rectangle, in pixels. The rectangle height spans from y + y+height.

References color_, and mode_.

◆ rect() [2/2]

virtual void embvm::basicDisplay::rect ( coord_t  x,
coord_t  y,
uint8_t  width,
uint8_t  height,
color  c,
mode  m 
)
pure virtualnoexcept

Draw a rectangle with a specific color and mode.

Draw a rectangle with a specific color setting and draw mode from (x,y) to (x+width,y+height) in the screen buffer. Only the boundary of the rectangle will be drawn.

Parameters
xX-coordinate where the rectangle originates.
yY-coordinate where the rectangle originates.
widthWidth of the rectangle, in pixels. The rectangle width spans from x to x+width.
heightHeight of the rectangle, in pixels. The rectangle height spans from y + y+height.
cPixel color.
mMode used to update the screen buffer.

Implemented in embdrv::ssd1306.

◆ rectFill() [1/2]

void embvm::basicDisplay::rectFill ( coord_t  x,
coord_t  y,
uint8_t  width,
uint8_t  height 
)
inlinenoexcept

Draw a filled rectangle.

Draw a filled rectangle using the configured color setting and draw mode from (x,y) to (x+width,y+height) in the screen buffer. The interior of the rectangle will be filled with the configured color setting.

Parameters
xX-coordinate where the rectangle originates.
yY-coordinate where the rectangle originates.
widthWidth of the rectangle, in pixels. The rectangle width spans from x to x+width.
heightHeight of the rectangle, in pixels. The rectangle height spans from y + y+height.

References color_, and mode_.

◆ rectFill() [2/2]

virtual void embvm::basicDisplay::rectFill ( coord_t  x,
coord_t  y,
uint8_t  width,
uint8_t  height,
color  c,
mode  m 
)
pure virtualnoexcept

Draw a filled rectangle with a specific color and mode.

Draw a filled rectangle using a specific color setting and draw mode from (x,y) to (x+width,y+height) in the screen buffer. The interior of the rectangle will be filled with the specified color setting.

Parameters
xX-coordinate where the rectangle originates.
yY-coordinate where the rectangle originates.
widthWidth of the rectangle, in pixels. The rectangle width spans from x to x+width.
heightHeight of the rectangle, in pixels. The rectangle height spans from y + y+height.
cPixel color.
mMode used to update the screen buffer.

Implemented in embdrv::ssd1306.

◆ restart()

void embvm::DriverBase::restart ( )
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().

◆ screenHeight()

virtual uint8_t embvm::basicDisplay::screenHeight ( ) const
pure virtualnoexcept

Check the screen height.

The drived class must implement this function.

Returns
The height of the screen in pixels.

Implemented in embdrv::ssd1306.

◆ screenWidth()

virtual uint8_t embvm::basicDisplay::screenWidth ( ) const
pure virtualnoexcept

Check the screen width.

The drived class must implement this function.

Returns
The width of the screen in pixels.

Implemented in embdrv::ssd1306.

◆ scrollLeft()

virtual void embvm::basicDisplay::scrollLeft ( coord_t  start,
coord_t  stop 
)
pure virtualnoexcept

Enable left scrolling.

Set row start to row stop on the display to scroll left.

Parameters
startThe start row index.
stopThe stop row index.
Precondition
Scrolling is not enabled, stop < start.
Postcondition
The display is scrolling to the left.

Implemented in embdrv::ssd1306.

◆ scrollRight()

virtual void embvm::basicDisplay::scrollRight ( coord_t  start,
coord_t  stop 
)
pure virtualnoexcept

Enable right scrolling.

Set row start to row stop on the display to scroll right.

Parameters
startThe start row index.
stopThe stop row index.
Precondition
Scrolling is not enabled, start < stop.
Postcondition
The display is scrolling to the right.

Implemented in embdrv::ssd1306.

◆ scrollStop()

virtual void embvm::basicDisplay::scrollStop ( )
pure virtualnoexcept

Stop scrolling.

Stop the scrolling of graphics on the display.

Implemented in embdrv::ssd1306.

◆ scrollVertLeft()

virtual void embvm::basicDisplay::scrollVertLeft ( coord_t  start,
coord_t  stop 
)
pure virtualnoexcept

Implemented in embdrv::ssd1306.

◆ scrollVertRight()

virtual void embvm::basicDisplay::scrollVertRight ( coord_t  start,
coord_t  stop 
)
pure virtualnoexcept

Implemented in embdrv::ssd1306.

◆ start()

◆ start_()

void embvm::basicDisplay::start_ ( )
overrideprotectedpure virtualnoexcept

Derived classes override the start_ method to control driver-specific startup behavior.

(Template Method Pattern)

Implements embvm::DriverBase.

Implemented in embdrv::ssd1306.

◆ started()

type_safe::boolean embvm::DriverBase::started ( ) const
inlinenoexceptinherited

Check if the driver has been started.

Returns
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_().

◆ stop()

◆ stop_()

void embvm::basicDisplay::stop_ ( )
overrideprotectedpure virtualnoexcept

Derived classes override the start_ method to control driver-specific startup behavior.

(Template Method Pattern)

Implements embvm::DriverBase.

Implemented in embdrv::ssd1306.

◆ type()

static constexpr embvm::DriverType embvm::basicDisplay::type ( )
inlinestaticnoexcept

Basic Display Driver Type ID.

Returns
Basic Display type ID.

References embvm::BASIC_DISPLAY.

Member Data Documentation

◆ color_

color embvm::basicDisplay::color_ = color::black
protected

The current display color setting.

Referenced by circle(), circleFill(), drawChar(), drawColor(), line(), lineH(), lineV(), pixel(), rect(), and rectFill().

◆ mode_

mode embvm::basicDisplay::mode_ = mode::normal
protected

The current display mode setting.

Referenced by circle(), circleFill(), drawChar(), drawMode(), line(), lineH(), lineV(), pixel(), rect(), and rectFill().

◆ name_

const std::string_view embvm::DriverBase::name_
protectedinherited

Name of the driver instance.

Referenced by embvm::DriverBase::name(), and embvm::DriverBase::name_cstr().

◆ started_

type_safe::boolean embvm::DriverBase::started_ = false
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().

◆ type_

const embvm::DriverType_t embvm::DriverBase::type_
protectedinherited

Type ID of the driver instance.

Referenced by embvm::DriverBase::DriverType().

◆ embvm::commBus

class embvm::commBus

template<typename TOperation, typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
class embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >

Base class interface for communication bus driver types (SPI, I2C, etc.).

This class defines common interfaces and types for communication bus drivers, such as SPI, I2C, I2S.

Implementing a Communication Bus Driver

To implement your own communication bus driver, derive from this class using template parameters that represent the implementation of your bus type. For example:

namespace spi {
static constexpr size_t SPI_MASTER_REQD_STATIC_FUNCTION_SIZE = (sizeof(void*) * 12);
using baud_t = uint32_t;
struct op_t
{
uint8_t* tx_buffer;
uint8_t* rx_buffer;
size_t length;
};
using cb_t = stdext::inplace_function<void(op_t)>;
};
{ ... }

Derived classes must implement the following pure virtual functions to complete comm bus behavior:

Derived classes may implement additional functionality, especially related to initialization and configuration of the bus. However, all exchange of data should be handled within the transfer() function.

Note: Derived classes are responsible for calling callback() once a transfer is completed.

Using a Communication Bus Driver

Communication busses are based around the concept of a transfer(). A transfer operation is defined using the TOperation type.

To initiate a transfer, you need to define a TOperation object. Because the framework uses asynchronous transfers, a callback function (cb_t) is also needed so the completion and result of the transfer can be reported. The callback can be any functor.

The TOperation object and the callback function are passed into transfer(). When the operation completes, the derived driver will invoke callback() with a copy of the TOperation object and th resulting status.

Communication bus drivers are non-copyable and non-moveable.

Template Parameters
TOperationDefines the operation type for the bus. This type represents the data that will be enqueued by the driver and used to carry out a transfer. The operation is also passed to a callback upon completion of a transfer. The operation type is often a structure, for example: ``` struct op_t { uint8_t* tx_buffer; uint8_t* rx_buffer; size_t length; comm::status status; }; ```
TBaudrateThe baudrate storage type. The baudrate type defaults to uint32_t. Baudrate can be set to another type, such as embvm::i2c::baud, which is an enum class.
TDispatchFunctorSizeThe storage space for statically-allocated functor objects. This template parameter is used in the TDispatchFunctor declaration. This can be made larger if required by the storage needs for your status/callback type.
TStatusThe comm bus status type. Defaults to comm::status, but can be overridden to support custom bus statuses.

Public Types

using cb_t = stdext::inplace_function< void(TOperation, TStatus)>
 Represents the type of the callback operation. More...
 
using DispatcherFunc = stdext::inplace_function< void(TDispatchFunctor &&)>
 Alias for the dispatcher function's storage type. More...
 

Public Member Functions

 commBus () noexcept
 Default constructor. More...
 
 commBus (TBaudrate baud) noexcept
 Construct the bus with a baudrate. More...
 
 commBus (TBaudrate baud, DispatcherFunc dispatcher) noexcept
 Construct the bus with a baudrate and dispatcher. More...
 
 commBus (const commBus &)=delete
 Deleted copy constructor. More...
 
const commBusoperator= (const commBus &)=delete
 Deleted copy assignment operator. More...
 
 commBus (commBus &&)=delete
 Deleted move constructor. More...
 
commBusoperator= (commBus &&)=delete
 Deleted move assignment operator. More...
 
virtual TStatus transfer (TOperation &op, const cb_t &cb=nullptr) noexcept
 Initiate a bus transfer. More...
 
TStatus busStatus () const noexcept
 Get the current bus status. More...
 
TBaudrate baudrate () const noexcept
 Get the current baudrate. More...
 
TBaudrate baudrate (TBaudrate baud) noexcept
 Set a new baudrate. More...
 

Protected Member Functions

virtual ~commBus ()=default
 Default destructor. More...
 
void callback (const TOperation &op, TStatus status, const cb_t &cb) noexcept
 Handle callbacks. More...
 
virtual TStatus transfer_ (const TOperation &op, const cb_t &callback) noexcept=0
 The derived comm class's transfer implementation. More...
 
virtual TBaudrate baudrate_ (TBaudrate baud) noexcept=0
 The drived comm class's baudrate update implementation. More...
 

Protected Attributes

TStatus bus_status_
 Stores the current bus status. More...
 
TBaudrate baud_
 Stores the currently configured baudrate. More...
 
const DispatcherFunc dispatcher_
 Stores a function which callbacks will be dispatched to. More...
 

Private Types

using TDispatchFunctor = stdext::inplace_function< void(), TDispatchFunctorSize >
 The functor declaration which will be used in declaring a DispatcherFunc. More...
 

Member Typedef Documentation

◆ cb_t

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
using embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::cb_t = stdext::inplace_function<void(TOperation, TStatus)>

Represents the type of the callback operation.

◆ DispatcherFunc

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
using embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::DispatcherFunc = stdext::inplace_function<void(TDispatchFunctor&&)>

Alias for the dispatcher function's storage type.

◆ TDispatchFunctor

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
using embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::TDispatchFunctor = stdext::inplace_function<void(), TDispatchFunctorSize>
private

The functor declaration which will be used in declaring a DispatcherFunc.

This represents the statucally-allocated functor that stores a std::bind of the callback, operation, and status.

Constructor & Destructor Documentation

◆ commBus() [1/5]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::commBus ( )
inlinenoexcept

Default constructor.

Initializes the comm bus status.

References embvm::comm::ok.

◆ commBus() [2/5]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::commBus ( TBaudrate  baud)
inlineexplicitnoexcept

Construct the bus with a baudrate.

Initializes the comm bus status and sets the baudrate to a default value.

Parameters
baudThe default baudrate for the bus.

◆ commBus() [3/5]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::commBus ( TBaudrate  baud,
DispatcherFunc  dispatcher 
)
inlineexplicitnoexcept

Construct the bus with a baudrate and dispatcher.

Initializes the comm bus status and sets the baudrate to a default value. Also sets the dispatcher function, which will forward callbacks to a different thread of control.

Parameters
baudThe default baudrate for the bus.
dispatcherThe functor which callbacks will be dispatched to. This will often be paired with a dispatch queue. Example:
spi0(115200, dispatch.getBoundDispatch());

◆ commBus() [4/5]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::commBus ( const commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus > &  )
delete

Deleted copy constructor.

◆ commBus() [5/5]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::commBus ( commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus > &&  )
delete

Deleted move constructor.

◆ ~commBus()

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
virtual embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::~commBus ( )
protectedvirtualdefault

Default destructor.

Member Function Documentation

◆ baudrate() [1/2]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
TBaudrate embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::baudrate ( ) const
inlinenoexcept

Get the current baudrate.

Returns
The currently configured baudrate.

◆ baudrate() [2/2]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
TBaudrate embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::baudrate ( TBaudrate  baud)
inlinenoexcept

Set a new baudrate.

Since each comm bus driver is different, the baudrate update request is forwarded to the derived class, which must implement the pure virtual function baudrate_().

TODO: tolerance check

Parameters
baudThe new baudrate for the bus.
Returns
The baudrate the bus is configured to use. The returned baudrate may not match the input under the following conditions:
  • Input baudrate was invalid (no update)
  • Input baudrate was rounded by the bus driver

◆ baudrate_()

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
virtual TBaudrate embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::baudrate_ ( TBaudrate  baud)
protectedpure virtualnoexcept

The drived comm class's baudrate update implementation.

Derived classes override this baudrate function to handle baudrate change requests.

Parameters
baudThe new baudrate for the bus.
Returns
The baudrate the bus is configured to use. The returned baudrate may not match the input under the following conditions:
  • Input baudrate was invalid (no update)
  • Input baudrate was rounded by the bus driver

◆ busStatus()

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
TStatus embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::busStatus ( ) const
inlinenoexcept

Get the current bus status.

Returns
The current bus status.

◆ callback()

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
void embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::callback ( const TOperation &  op,
TStatus  status,
const cb_t cb 
)
inlineprotectednoexcept

Handle callbacks.

Invokes callback functions, either by pushing to a dispatch thread or by directly invoking the callback on the same thread of control.

Parameters
opThe operation which was completed. This will be passed to the callback.
statusThe result of the operation.
cbThe callback function to invoke.

◆ operator=() [1/2]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
const commBus& embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::operator= ( const commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus > &  )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
commBus& embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::operator= ( commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus > &&  )
delete

Deleted move assignment operator.

◆ transfer()

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
virtual TStatus embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::transfer ( TOperation &  op,
const cb_t cb = nullptr 
)
inlinevirtualnoexcept

Initiate a bus transfer.

Initiates a transfer of information across a comm bus. The transfer function should handle read, write, and read-write operations. Other operations may also be supported by derived classes.

The transfer request is forwarded the derived class, which must implement the pure virtual function transfer_().

This call should not block. Transfer requests are asynchronous and are not guaranteed to return immediately with a result.

If the derived driver class returns a status code other than TStatus::enqueued or TStatus::busy, the callback will be immediately invoked. If the operation was enqueued, the final status will be reported when the callback is called.

Parameters
opA bus transfer is defined by an operation (op). The derived class will use the data supplied in the op to configure the bus and transfer the data.
cbOptional callback parameter. When set, the callback will be invoked upon completion of the transfer.
Returns
The status of the bus transfer.

◆ transfer_()

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
virtual TStatus embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::transfer_ ( const TOperation &  op,
const cb_t callback 
)
protectedpure virtualnoexcept

The derived comm class's transfer implementation.

Derived classes override this transfer function to handle specific transfer operations for each device.

Callback is passed in for drivers which enqueue operations or use AO model. The base class handles the callback, so there is no need to worry about invoking the callback from a client driver.

Just mark your callback (void)callback if you aren't using it.

To indicate that a transfer has been enqueued for later processing, return TStatus::enqueued

Member Data Documentation

◆ baud_

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
TBaudrate embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::baud_
protected

Stores the currently configured baudrate.

◆ bus_status_

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
TStatus embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::bus_status_
protected

Stores the current bus status.

◆ dispatcher_

template<typename TOperation , typename TBaudrate = uint32_t, size_t TDispatchFunctorSize = sizeof(void*) * 4, typename TStatus = comm::status>
const DispatcherFunc embvm::commBus< TOperation, TBaudrate, TDispatchFunctorSize, TStatus >::dispatcher_
protected

Stores a function which callbacks will be dispatched to.

The dispatcher function receives callbacks and ops and executes them on a separate thread of control from the caller of callback().

If no dispatcher is configured by the user, the callback will be executed in the same thread of control.

◆ embvm::DriverBase

class embvm::DriverBase

Virtual base class for framework drivers.

All framework drivers should include this class in their inheritance tree. The DriverBase provides common interfaces which apply to all drivers. Use of the DriverBase class also handles automatic registration/unregistration with the platform's DriverRegistry. Registration/unregistration occurs during construction/destruction.

Derived classes must override the following functions:

Inheritance diagram for embvm::DriverBase:
Inheritance graph

Public Member Functions

 DriverBase (const DriverBase &)=delete
 Deleted copy constructor. More...
 
const DriverBaseoperator= (const DriverBase &)=delete
 Deleted copy assignment operator. More...
 
 DriverBase (DriverBase &&)=delete
 Deleted move constructor. More...
 
DriverBaseoperator= (DriverBase &&)=delete
 Deleted move assignment operator. 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 DriverBaseoperator++ () noexcept
 Increment operator is a no-op, but is used for iterator compatibility. More...
 

Protected Member Functions

 DriverBase (const char *name, embvm::DriverType_t c=embvm::DriverType::Undefined) noexcept
 Construct a DriverBase with a C-string name. More...
 
 DriverBase (const std::string &name, embvm::DriverType_t c=embvm::DriverType::Undefined) noexcept
 Construct a DriverBase with a std::string name. More...
 
 DriverBase (const std::string_view &name, embvm::DriverType_t c=embvm::DriverType::Undefined) noexcept
 Construct a DriverBase with a std::string_view name. More...
 
virtual ~DriverBase () noexcept
 Destructor. More...
 
virtual void start_ () noexcept=0
 Derived classes override the start_ method to control driver-specific startup behavior. More...
 
virtual void stop_ () noexcept=0
 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...
 

Constructor & Destructor Documentation

◆ DriverBase() [1/5]

embvm::DriverBase::DriverBase ( const char *  name,
embvm::DriverType_t  c = embvm::DriverType::Undefined 
)
protectednoexcept

Construct a DriverBase with a C-string name.

The DriverBase constructor handles automatic registration with the DriverRegistry.

Parameters
nameThe name of the device driver instance
cThe device type

References embvm::VirtualPlatformBase< BlinkyDemoPlatform< THWPlatform, TDriverRegistry >, TDriverRegistry >::registerDriver().

◆ DriverBase() [2/5]

embvm::DriverBase::DriverBase ( const std::string &  name,
embvm::DriverType_t  c = embvm::DriverType::Undefined 
)
protectednoexcept

Construct a DriverBase with a std::string name.

The DriverBase constructor handles automatic registration with the DriverRegistry

Parameters
nameThe name of the device driver instance. Note: DriverBase() uses a std::string_view, so the std::string must remain valid
cThe device type

References embvm::VirtualPlatformBase< BlinkyDemoPlatform< THWPlatform, TDriverRegistry >, TDriverRegistry >::registerDriver().

◆ DriverBase() [3/5]

embvm::DriverBase::DriverBase ( const std::string_view &  name,
embvm::DriverType_t  c = embvm::DriverType::Undefined 
)
protectednoexcept

Construct a DriverBase with a std::string_view name.

The DriverBase constructor handles automatic registration with the DriverRegistry

Parameters
nameThe name of the device driver instance. Note: DriverBase() uses a std::string_view, so the std::string_view must remain valid
cThe device type

References embvm::VirtualPlatformBase< BlinkyDemoPlatform< THWPlatform, TDriverRegistry >, TDriverRegistry >::registerDriver().

◆ DriverBase() [4/5]

embvm::DriverBase::DriverBase ( const DriverBase )
delete

Deleted copy constructor.

◆ DriverBase() [5/5]

embvm::DriverBase::DriverBase ( DriverBase &&  )
delete

Deleted move constructor.

◆ ~DriverBase()

embvm::DriverBase::~DriverBase ( )
protectedvirtualnoexcept

Member Function Documentation

◆ DriverType()

constexpr embvm::DriverType_t embvm::DriverBase::DriverType ( ) const
inlinenoexcept

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.

Returns
the registered driver type as a embvm::DriverType_t value

References type_.

◆ name()

constexpr const std::string_view& embvm::DriverBase::name ( ) const
inlinenoexcept

Provides a string_view reference of the driver name.

Returns
std::string_view ref containing the driver name.

References name_.

◆ name_cstr()

constexpr const char* embvm::DriverBase::name_cstr ( ) const
inlinenoexcept

Provides a c-string version of the driver name.

Returns
c-string containing the driver name

References name_.

◆ operator++()

virtual DriverBase& embvm::DriverBase::operator++ ( )
inlinevirtualnoexcept

Increment operator is a no-op, but is used for iterator compatibility.

◆ operator=() [1/2]

const DriverBase& embvm::DriverBase::operator= ( const DriverBase )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

DriverBase& embvm::DriverBase::operator= ( DriverBase &&  )
delete

Deleted move assignment operator.

◆ restart()

void embvm::DriverBase::restart ( )
inlinenoexcept

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 start(), and stop().

◆ start()

◆ start_()

virtual void embvm::DriverBase::start_ ( )
protectedpure virtualnoexcept

Derived classes override the start_ method to control driver-specific startup behavior.

(Template Method Pattern)

Implemented in embvm::basicDisplay, embvm::i2c::master, embvm::gpio::inputOutput< TPull >, embvm::spi::master, embvm::gpio::output, embvm::timer::Timer, embvm::tof::sensor, embvm::gpio::input< TPull >, embvm::gpio::input< embvm::gpio::pull::pullup >, embvm::gpio::input< embvm::gpio::pull::none >, embvm::led::gpio< TActiveHigh >, embdrv::aardvarkAdapter, embdrv::aardvarkGPIOOutput< TPinID >, embdrv::aardvarkGPIOOutput< 5 >, embdrv::vl53l1x, embvm::gpio::base< TDir >, embvm::gpio::base< gpio::direction::in >, embvm::gpio::base< gpio::direction::inout >, embvm::gpio::base< gpio::direction::out >, embvm::led::base, embdrv::ssd1306, embdrv::SimulatorTimer, test::spiTestDriver, embvm::clk::SystemClock, test::i2cTestDriver, embdrv::aardvarkGPIOInput< TPinID, TPull >, embdrv::aardvarkGPIOInput< 3 >, embdrv::aardvarkGPIOInput< 4 >, nRFGPIOOutput< TPort, TPin >, nRFGPIOOutput< 1, 9 >, nRFGPIOOutput< 0, 16 >, nRFGPIOOutput< 0, 8 >, nRFGPIOOutput< 0, 14 >, nRFGPIOOutput< 0, 6 >, nRFGPIOOutput< 0, 15 >, nRFGPIOOutput< 0, 12 >, nRFGPIOOutput< 0, 13 >, embdrv::aardvarkI2CMaster, embdrv::aardvarkSPIMaster, nRFi2cMaster< TTWIIndex, TSclPin, TSdaPin, TBlocking >, nRFi2cMaster< NordicTWIM0, nRFPinID< 0, 27 >, nRFPinID< 0, 26 > >, embdrv::SimulatorSystemClock, embvm::i2c::activeMaster< TQueueSize, TLock, TCond >, embvm::i2c::activeMaster< 128 >, embvm::spi::activeMaster< TQueueSize, TLock, TCond >, test::TestDriverBase, test::UnitTestGPIOInputWithPullup, nRF51i2cMaster_Blocking< TTWIIndex, TSclPin, TSdaPin >, and test::UnitTestGPIOInput.

Referenced by start().

◆ started()

type_safe::boolean embvm::DriverBase::started ( ) const
inlinenoexcept

Check if the driver has been started.

Returns
true if the driver is running (started), false if not running (stopped).

References started_.

Referenced by embdrv::aardvarkSPIMaster::configure_(), embdrv::aardvarkGPIOInput< 4 >::get(), embdrv::aardvarkGPIOOutput< 5 >::set(), embdrv::vl53l1x::start_(), embdrv::aardvarkAdapter::start_(), and embdrv::aardvarkAdapter::stop_().

◆ stop()

◆ stop_()

virtual void embvm::DriverBase::stop_ ( )
protectedpure virtualnoexcept

Derived classes override the start_ method to control driver-specific startup behavior.

(Template Method Pattern)

Implemented in embvm::basicDisplay, embvm::i2c::master, embvm::gpio::inputOutput< TPull >, embvm::spi::master, embvm::gpio::output, embvm::timer::Timer, embvm::tof::sensor, embvm::gpio::input< TPull >, embvm::gpio::input< embvm::gpio::pull::pullup >, embvm::gpio::input< embvm::gpio::pull::none >, embvm::led::gpio< TActiveHigh >, embdrv::aardvarkGPIOOutput< TPinID >, embdrv::aardvarkGPIOOutput< 5 >, embdrv::aardvarkAdapter, embdrv::vl53l1x, embvm::gpio::base< TDir >, embvm::gpio::base< gpio::direction::in >, embvm::gpio::base< gpio::direction::inout >, embvm::gpio::base< gpio::direction::out >, embvm::led::base, embdrv::ssd1306, embdrv::SimulatorTimer, test::spiTestDriver, embvm::clk::SystemClock, test::i2cTestDriver, embdrv::aardvarkGPIOInput< TPinID, TPull >, embdrv::aardvarkGPIOInput< 3 >, embdrv::aardvarkGPIOInput< 4 >, nRFi2cMaster< TTWIIndex, TSclPin, TSdaPin, TBlocking >, nRFi2cMaster< NordicTWIM0, nRFPinID< 0, 27 >, nRFPinID< 0, 26 > >, nRFGPIOOutput< TPort, TPin >, nRFGPIOOutput< 1, 9 >, nRFGPIOOutput< 0, 16 >, nRFGPIOOutput< 0, 8 >, nRFGPIOOutput< 0, 14 >, nRFGPIOOutput< 0, 6 >, nRFGPIOOutput< 0, 15 >, nRFGPIOOutput< 0, 12 >, nRFGPIOOutput< 0, 13 >, embdrv::aardvarkI2CMaster, embdrv::aardvarkSPIMaster, embdrv::SimulatorSystemClock, embvm::i2c::activeMaster< TQueueSize, TLock, TCond >, embvm::i2c::activeMaster< 128 >, nRF51i2cMaster_Blocking< TTWIIndex, TSclPin, TSdaPin >, embvm::spi::activeMaster< TQueueSize, TLock, TCond >, test::TestDriverBase, test::UnitTestGPIOInputWithPullup, and test::UnitTestGPIOInput.

Referenced by stop().

Member Data Documentation

◆ name_

const std::string_view embvm::DriverBase::name_
protected

Name of the driver instance.

Referenced by name(), and name_cstr().

◆ started_

type_safe::boolean embvm::DriverBase::started_ = false
protected

Tracks the driver state.

True if the driver has been started, false if it has been stopped or not yet started.

Referenced by start(), started(), and stop().

◆ type_

const embvm::DriverType_t embvm::DriverBase::type_
protected

Type ID of the driver instance.

Referenced by DriverType().

◆ embvm::DriverRegistry

class embvm::DriverRegistry

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
class embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >

DriverRegistry base class.

DriverRegistry provides a common DriverRegistry interface that supports both static and dynamic memory allocation styles. Whether dynamic or static memory is used is determined at compile-time by the template arguments.

Two convenience definitions are supplied below: DynamicDriverRegistry and StaticDriverRegistry<> These types should be used to declare DriverRegistry instances for your platform rather than directly using DriverRegistry. They are more expressive and will be easier for readers to understand.

Only one DriverRegistry should be defined for each platform & program.

Template Parameters
TMaxSizespecifies the maximum number of drivers that can be stored. A value of '0' indicates that dynamic memory should be used.
TReturnSizespecifies the maximum number of drivers that can be returned by find_all() A value of '0' indicates no limit (dynamic memory)
TLockTypeThe type of lock to use with DriverRegistry. Defaults to embutil::nop_lock, which does not perform any actual locking. If you are using this DriverRegistry in a multi-threaded program and are worried about locking, you can change this to another type such as std::mutex or an interrupt_lock.

Public Member Functions

 DriverRegistry ()=default
 Default constructor. More...
 
 ~DriverRegistry () noexcept=default
 Default destructor. More...
 
 DriverRegistry (const DriverRegistry &)=delete
 Deleted copy constructor. More...
 
const DriverRegistryoperator= (const DriverRegistry &)=delete
 Deleted copy assignment operator. More...
 
 DriverRegistry (DriverRegistry &&)=delete
 Deleted move constructor. More...
 
DriverRegistryoperator= (DriverRegistry &&)=delete
 Deleted move assignment operator. More...
 
size_t count () const noexcept
 Get the registered driver count. More...
 
size_t capacity () const noexcept
 Get the capacity of the registry. More...
 
void add (const TKey name, embvm::DriverBase *driver) noexcept
 Register a driver. More...
 
void remove (const TKey name, embvm::DriverBase *driver) noexcept
 Unregister a driver. More...
 
auto find (const TKey name) noexcept
 Find a driver by name. More...
 
auto find (DriverType_t dtype) noexcept
 Find a driver by type. More...
 
template<class TDriverClass >
auto find () noexcept
 Find a driver by type and return casted interface pointer. More...
 
template<class TDriverClass >
auto find (const TKey name) noexcept
 Find a driver by name and return casted interface pointer. More...
 
template<typename TReturn = std::list<embvm::DriverBase*>>
auto find_all (DriverType_t dtype) noexcept -> std::enable_if_t<!TReturnSize, TReturn >
 Find all drivers with a given type (dynamic memory). More...
 
template<typename TReturn = etl::list<embvm::DriverBase*, TReturnSize>>
auto find_all (DriverType_t dtype) noexcept -> std::enable_if_t<(TReturnSize > 0), TReturn >
 Find all drivers with a given type (static memory). More...
 
template<class TDriverClass , typename TReturn = std::list<embvm::DriverBase*>>
auto find_all () noexcept -> std::enable_if_t<!TReturnSize, TReturn >
 Find all drivers with a given type and return casted interface pointers (dynamic memory). More...
 
template<class TDriverClass , typename TReturn = etl::list<embvm::DriverBase*, TReturnSize>>
auto find_all () noexcept -> std::enable_if_t<(TReturnSize > 0), TReturn >
 Find all drivers with a given type and return casted interface pointers (static memory). More...
 

Private Types

using TKey = const char *
 
using TListType = typename std::conditional<(TMaxSize==0), embutil::DynamicInstanceList< embvm::DriverBase, TKey >, embutil::StaticInstanceList< embvm::DriverBase, TMaxSize, TKey > >::type
 

Private Attributes

TListType list_
 
TLockType lock_
 

Member Typedef Documentation

◆ TKey

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
using embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::TKey = const char*
private

◆ TListType

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
using embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::TListType = typename std::conditional< (TMaxSize == 0), embutil::DynamicInstanceList<embvm::DriverBase, TKey>, embutil::StaticInstanceList<embvm::DriverBase, TMaxSize, TKey> >::type
private

Constructor & Destructor Documentation

◆ DriverRegistry() [1/3]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::DriverRegistry ( )
default

Default constructor.

◆ ~DriverRegistry()

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::~DriverRegistry ( )
defaultnoexcept

Default destructor.

◆ DriverRegistry() [2/3]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::DriverRegistry ( const DriverRegistry< TMaxSize, TReturnSize, TLockType > &  )
delete

Deleted copy constructor.

◆ DriverRegistry() [3/3]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::DriverRegistry ( DriverRegistry< TMaxSize, TReturnSize, TLockType > &&  )
delete

Deleted move constructor.

Member Function Documentation

◆ add()

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
void embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::add ( const TKey  name,
embvm::DriverBase driver 
)
inlinenoexcept

Register a driver.

Adds a driver to the DriverRegistry.

Parameters
nameThe name of the driver instance being added. Name is used as a key during lookups.
driverPointer to the embvm::DriverBase object. A pointer is used because there are any number of potential derived classes which will be tracked. To prevent slicing, a pointer to the base class is stored.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_, and embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::lock_.

◆ capacity()

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
size_t embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::capacity ( ) const
inlinenoexcept

Get the capacity of the registry.

The capacity represents the total number of drivers which may be registered.

Returns
the capacity of the driver registry.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_.

◆ count()

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
size_t embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::count ( ) const
inlinenoexcept

Get the registered driver count.

Returns
the number of drivers currently registered.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_.

◆ find() [1/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find ( const TKey  name)
inlinenoexcept

Find a driver by name.

Performs a driver lookup by name. If the driver is found, the embvm::DriverBase for that object will be returned to the user. If no driver is found, an empty object will be returned.

If multiple objects are registered with the same name, the first one found will be returned.

Parameters
nameThe name of the driver instance to search for.
Returns
an type_safe::optional_ref to the embvm::DriverBase object. If the driver was not found, the optional_ref will be empty. The caller must cast to the appropriate type.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_.

◆ find() [2/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find ( DriverType_t  dtype)
inlinenoexcept

Find a driver by type.

Performs a driver lookup by type. If the driver is found, the embvm::DriverBase for that object will be returned to the user. If no driver is found, an empty object will be returned.

If multiple objects are registered with the same type, the first one found will be returned.

Parameters
dtypeThe type of the driver instance to search for.
Returns
an type_safe::optional_ref to the embvm::DriverBase object. If the driver was not found, the optional_ref will be empty.

References dtype, and embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_.

◆ find() [3/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
template<class TDriverClass >
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find ( )
inlinenoexcept

Find a driver by type and return casted interface pointer.

Performs a driver lookup by type. If the driver is found, the embvm::DriverBase will be casted to the requested driver interface. If no driver is found, an empty object will be returned.

To perform the lookup, the requested driver classes's type() static member function will be used.

If multiple objects are registered with the same type, the first one found will be returned.

Template Parameters
TDriverClassThe class of driver being requested (embvm::i2c::master, SystemClock).
Returns
an type_safe::optional_ref to the embvm::DriverBase object. If the driver was not found, the optional_ref will be empty.

References type.

Referenced by embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find().

◆ find() [4/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
template<class TDriverClass >
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find ( const TKey  name)
inlinenoexcept

Find a driver by name and return casted interface pointer.

Performs a driver lookup by name. If the driver is found, the embvm::DriverBase will be casted to the requested driver interface. If no driver is found, an empty object will be returned.

If multiple objects are registered with the same name, the first one found will be returned.

Template Parameters
TDriverClassThe class of driver being requested (embvm::i2c::master, SystemClock).
Parameters
nameThe name of the driver instance to search for.
Returns
an type_safe::optional_ref to the embvm::DriverBase object. If the driver was not found, the optional_ref will be empty.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find().

◆ find_all() [1/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
template<typename TReturn = std::list<embvm::DriverBase*>>
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find_all ( DriverType_t  dtype) -> std::enable_if_t<!TReturnSize, TReturn>
inlinenoexcept

Find all drivers with a given type (dynamic memory).

Performs a driver lookup by type and creates a list of all drivers found with the matching type. If no driver is found, an empty list will be returned.

Template Parameters
TReturnThe return type provided to the caller. Most users do not need to change the type.
Parameters
dtypeThe type of the driver instance to search for.
Returns
a TReturn type (default std::list) of pointers to Dembvm::DriverBase objects with the requested driver type. An empty list will be returned if no drivers are found.

References dtype, embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_, and t.

◆ find_all() [2/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
template<typename TReturn = etl::list<embvm::DriverBase*, TReturnSize>>
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find_all ( DriverType_t  dtype) -> std::enable_if_t<(TReturnSize > 0), TReturn>
inlinenoexcept

Find all drivers with a given type (static memory).

Performs a driver lookup by type and creates a list of all drivers found with the matching type. If no driver is found, an empty list will be returned.

Template Parameters
TReturnThe return type provided to the caller. Most users do not need to change the type.
Parameters
dtypeThe type of the driver instance to search for.
Returns
a TReturn type (default etl::list) of pointers to Dembvm::DriverBase objects with the requested driver type. An empty list will be returned if no drivers are found.

References dtype, embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_, and t.

◆ find_all() [3/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
template<class TDriverClass , typename TReturn = std::list<embvm::DriverBase*>>
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find_all ( ) -> std::enable_if_t<!TReturnSize, TReturn>
inlinenoexcept

Find all drivers with a given type and return casted interface pointers (dynamic memory).

Performs a driver lookup by type and creates a list of all drivers found with the matching type. If no driver is found, an empty list will be returned.

To perform the lookup, the requested driver classes's type() static member function will be used.

Template Parameters
TDriverClassThe class of driver being requested (embvm::i2c::master, SystemClock).
TReturnThe return type provided to the caller. Most users do not need to change the type.
Returns
a TReturn type (default std::list) of pointers to Dembvm::DriverBase objects with the requested driver type. An empty list will be returned if no drivers are found.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_, t, and type.

◆ find_all() [4/4]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
template<class TDriverClass , typename TReturn = etl::list<embvm::DriverBase*, TReturnSize>>
auto embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::find_all ( ) -> std::enable_if_t<(TReturnSize > 0), TReturn>
inlinenoexcept

Find all drivers with a given type and return casted interface pointers (static memory).

Performs a driver lookup by type and creates a list of all drivers found with the matching type. If no driver is found, an empty list will be returned.

To perform the lookup, the requested driver classes's type() static member function will be used.

Template Parameters
TDriverClassThe class of driver being requested (embvm::i2c::master, SystemClock).
TReturnThe return type provided to the caller. Most users do not need to change the type.
Returns
a TReturn type (default etl::list) of pointers to Dembvm::DriverBase objects with the requested driver type. An empty list will be returned if no drivers are found.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_, t, and type.

◆ operator=() [1/2]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
const DriverRegistry& embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::operator= ( const DriverRegistry< TMaxSize, TReturnSize, TLockType > &  )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
DriverRegistry& embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::operator= ( DriverRegistry< TMaxSize, TReturnSize, TLockType > &&  )
delete

Deleted move assignment operator.

◆ remove()

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
void embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::remove ( const TKey  name,
embvm::DriverBase driver 
)
inlinenoexcept

Unregister a driver.

Removes a driver from the DriverRegistry.

Parameters
nameThe name of the driver instance being removed.
driverPointer to the embvm::DriverBase object being removed.

References embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::list_, and embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::lock_.

Member Data Documentation

◆ list_

◆ lock_

template<const size_t TMaxSize, const size_t TReturnSize, typename TLockType = embutil::nop_lock>
TLockType embvm::DriverRegistry< TMaxSize, TReturnSize, TLockType >::lock_
private

Typedef Documentation

◆ DriverType_t

using embvm::DriverType_t = typedef uint32_t

Driver type used by framework interfaces.

The driver type ID is stored as a uint32_t rather than a DriverType to work with custom user-defined types. Enforcing a DriverType return value would prevent clients from defining and using their own custom types enums and would create template headaches.

◆ DynamicDriverRegistry

template<typename TLockType = embutil::nop_lock>
using embvm::DynamicDriverRegistry = typedef DriverRegistry<0, 0, TLockType>

Declare a DriverRegistry that uses dynamic memory allocation.

A DynamicDriverRegistry utilizes dynamic memory allocation and can grow to the limit that memory allows. This type is useful for host-based simulation platforms, as well as embedded platforms which allow dynamic memory allocation.

Template Parameters
TLockTypeThe type of lock to use with DynamicDriverRegistry. See DriverRegistry for more information.

◆ StaticDriverRegistry

template<const size_t TMaxSize = 32, const size_t TReturnSize = 4, typename TLockType = embutil::nop_lock>
using embvm::StaticDriverRegistry = typedef DriverRegistry<TMaxSize, TReturnSize, TLockType>

Declare a DriverRegistry that uses static memory allocation.

The size and memory allocation of the StaticDriverRegistry is known at compile-time. No dynamic memory allocations are used.

In addition, the number of drivers returned by the find_all() function is fixed.

Template Parameters
TMaxSizespecifies the maximum number of drivers that can be stored
TReturnSizespecifies the maximum number of drivers that can be returned by find_all()
TLockTypeThe type of lock to use with StaticDriverRegistry. See DriverRegistry for more information.

Enumeration Type Documentation

◆ DriverType

Default framework driver type definitions.

Default framework driver type definitions. These definitions are defined because the framework provides driver interfaces for these types. Additional types can be defined by clients as needed.

To add your own driver types, create an enum in your project code and use DRIVER_EXTENSION_START as the first value

Enumerator
Undefined 

The type of the driver is undefined, no assumptions can be made about it.

GPIO 

Represents a GPIO peripheral.

HARDWARE_TIMER 

Represents a hardware timer peripheral.

I2C 

Represents an I2C communication bus.

LED 

Represents an LED driver.

SPI 

Represents a SPI communication bus.

SYSTEM_CLOCK 

Represents a master system clock, which can be a hardware device or software interface.

TIME_OF_FLIGHT 

Represents a Time of Flight Range-finding sensor.

SOFTWARE_TIMER 

Represents a software timer.

TIMER 

Represents a hardware timer.

BASIC_DISPLAY 

Represents a basic display without a range of colors, such as a small 2-color OLED display.

DRIVER_EXTENSION_START 

To extend with your own driver types, start the count using this value.