Kleidos API Search

In development. It changes without notice.

Topic

Board Bring-up

The start of a board's hardware and its update on each tick.

There is one implementation for the M5Stack boards and one for the LILYGO T-Deck. It finds the motion sensor, the keyboard's chip and the trackball, starts the display and the inputs, and puts to rest the chips no part of the firmware uses.

See also
Hardware Abstraction Layer, Board Description, Board Configurations

Files

file src/hal/bootstrap/bootstrap_m5stack.cpp
The bootstrap of hal_bootstrap.h for every board but the T-Deck.
file src/hal/bootstrap/bootstrap_tdeck.cpp
The T-Deck's bootstrap of hal_bootstrap.h.
file src/hal/bootstrap/bus_scan.h
Serial-log scans of the internal I2C bus.
file src/hal/bootstrap/hal_bootstrap.h
Variant hardware bootstrap and per-frame hardware polling.

Functions

voidkleidos::hal::m5diag::printRuntimeI2cScanForPins (const char *label, int sdaPin, int sclPin)
Scan the internal I2C bus on explicit pins and log results.
voidkleidos::hal::m5diag::printRuntimeI2cScan ()
Scan the internal I2C bus on the variant pins and log results.
voidkleidos::hal::beginConsole ()
Start the serial console at the build's rate.
voidkleidos::hal::begin ()
Initialize hardware (display, I2C, buttons, PMIC, peripherals).
voidkleidos::hal::update ()
Poll hardware state (buttons, touch, keyboard).
voidkleidos::hal::sampleButtons ()
Sample the board's buttons without consuming their edges.
voidkleidos::hal::initUI ()
Initialize the UI framework (no-op: the in-house UI library needs none).
voidkleidos::hal::updateUI ()
Tick the UI framework (no-op: the in-house UI library needs none).
voidkleidos::hal::deinitUI ()
Teardown the UI framework before deep sleep.

Function Documentation

begin() #

void kleidos::hal::begin()

Initialize hardware (display, I2C, buttons, PMIC, peripherals).

Every board but the T-Deck: brings up the board power hold, I2C bus, display panel, backlight, button inputs, and any optional peripherals. The T-Deck: I2C, display, GPIO peripheral power, keyboard, trackball, touch.

Called once from app_main before the FSM starts.

beginConsole() #

void kleidos::hal::beginConsole()

Start the serial console at the build's rate.

Called from setup() before anything logs, ahead of begin. A line logged before it leaves the console UART at ESP-IDF's own 115200, which a host reading a debug build's faster console cannot read (the factory reset's FACTORY_RESET: line, logged before the HAL is up, is the one the QA waits for). A no-op on a build with no console.

printRuntimeI2cScanForPins() #

void kleidos::hal::m5diag::printRuntimeI2cScanForPins(const char * label, int sdaPin, int sclPin)

Scan the internal I2C bus on explicit pins and log results.

Parameters
NameDirectionMeaning
labelinLabel string printed as the scan header.
sdaPininSDA GPIO number to use for the scan.
sclPininSCL GPIO number to use for the scan.

sampleButtons() #

void kleidos::hal::sampleButtons()

Sample the board's buttons without consuming their edges.

Run from the e-paper panel's BUSY waits, so a press made while a refresh holds the loop is still there on the next tick. Only the task that brought the HAL up (the loop task) samples; a call from any other task does nothing. A no-op on boards without polled buttons.

update() #

void kleidos::hal::update()

Poll hardware state (buttons, touch, keyboard).

Every board but the T-Deck: polls local board drivers and optional runtime services. The T-Deck: keyboard poll + backlight, touch poll.

Called once per loop() iteration from the UI task.