Kleidos API Search

In development. It changes without notice.

Topic

Board Description

The record of a board's hardware, where it is registered, and how often a chip that has to be polled is read.

  • BoardDef holds a pointer to each part of a board, or none where the board lacks it.
  • The registration gives the rest of the firmware the one record of the board it was built for.
  • hal::PollPeriod says when a value that the loop polls is due.

The board's constants are in Build Configuration, and the I2C bus inside it in I2C Bus.

See also
Hardware Abstraction Layer, Board Bring-up, Board Configurations

Files

file src/hal/board/board_def.h
Aggregate of pointers to every hardware-subsystem interface.
file src/hal/board/board_registry.h
Global registration point for the active variant's BoardDef.
file src/hal/board/poll_period.h
How often a chip is read for a value the main loop polls.

Namespaces

namespace kleidos::hal
The board hardware abstraction the application calls instead of a chip driver.

Classes

struct kleidos::BoardDef
Variant hardware description: identity plus subsystem interface pointers. More about kleidos::BoardDef
class kleidos::hal::PollPeriod
Says when a polled read is due: the first time, then once per period. More about kleidos::hal::PollPeriod
struct kleidos::TouchReading
One reading of a pointer, judged as a screen sees it. More about kleidos::TouchReading

Macros

#defineREGISTER_BOARD(def)
Register a static BoardDef with the board registry at file scope.

Typedefs

usingkleidos::ImuManager
The IMU interface, by name only: a caller that dereferences BoardDef::imu includes imu_manager.h.

Functions

template<auto Slot>
constexpr ButtonInput *kleidos::thirdButtonSlot ()
Compile-time-checked third-button slot for a BoardDef initializer.
voidkleidos::hal::board::registerBoard (const BoardDef *def)
Record the active board definition.
const BoardDef &kleidos::hal::board::get ()
Get the active board descriptor.

Variables

constexpr uint32_tkleidos::hal::kLatchedPowerKeyPollMs
constexpr uint32_tkleidos::hal::kLevelPowerKeyPollMs
constexpr uint32_tkleidos::hal::kIdleTouchPollMs
Period between two reads of a touch panel that reported no contact, ms.
constexpr uint32_tkleidos::hal::kFrameTouchPollMs

Macro Definition Documentation

REGISTER_BOARD #

#define REGISTER_BOARD(def)

Register a static BoardDef with the board registry at file scope.

Expands to an anonymous-namespace helper with a static instance whose constructor calls board::registerBoard. Place at file scope in the variant's board_<name>.cpp (typically the last statement).

static const BoardDef kBoard = { // see BoardDef fields };
REGISTER_BOARD( kBoard );
Parameters
NameMeaning
defIdentifier (or address) of a BoardDef with static storage duration in the current translation unit.

Function Documentation

get() #

const BoardDef & kleidos::hal::board::get()

Get the active board descriptor.

Returns
Reference to the registered board; halts via an infinite loop if no board was registered (the firmware cannot continue without one).

registerBoard() #

void kleidos::hal::board::registerBoard(const BoardDef * def)

Record the active board definition.

Called from the file-scope static initialiser installed by REGISTER_BOARD. Idempotent for the same def; the second registration replaces the first (so linking two board factories for the same DEVICE_ID is a build error caught at link time, not a runtime surprise).

Parameters
NameDirectionMeaning
definPointer to the board descriptor to register (must outlive the program — typically a static const BoardDef in board_<name>.cpp).

thirdButtonSlot() #

template<auto Slot>
ButtonInput * kleidos::thirdButtonSlot()
constexpr

Compile-time-checked third-button slot for a BoardDef initializer.

BoardDef::btnC is a runtime pointer, so nothing structurally stops a board factory from wiring a third button the variant never declared — or omitting one it did, which would leave a VAULT_MENU_VIEW_WIDE board with a tab grammar (A-hold / C-hold) it cannot produce. Routing the slot through this helper makes the wiring and HAS_THIRD_BUTTON the same fact: they are compared in the very translation unit that owns the wiring, so they cannot drift.

Template Parameters
NameMeaning
SlotAddress of this board's third-button input, or nullptr.
Returns
Slot as a ButtonInput*.

Variable Documentation

kFrameTouchPollMs #

uint32_t kleidos::hal::kFrameTouchPollMs
inlineconstexpr

Least time between two reads of a touch panel from inside a frame the loop task paints, its blit included, ms (display::setFramePoll): a usual tap (50-100 ms on the glass) spans five or more of them.

kLatchedPowerKeyPollMs #

uint32_t kleidos::hal::kLatchedPowerKeyPollMs
inlineconstexpr

Period between two reads of a power key the PMIC latches, ms: a click locks at most this long after it was made.

kLevelPowerKeyPollMs #

uint32_t kleidos::hal::kLevelPowerKeyPollMs
inlineconstexpr

Period between two reads of a power key read as a level, ms: short enough that the briefest deliberate click spans two reads.