Kleidos API Search

In development. It changes without notice.

The SD card: mounting it for as long as an action lasts, formatting it, and settling it at boot, on the boards that have a slot.

Files

file src/hal/sd/sd_boot_settle.h
What the boot's settle of the SD slot came to: its states, their console tokens, the state a card-level initialization ends in, and when the slot is known empty (host-tested).
file src/hal/sd/sd_card.h
SD card mount/status helper over the ESP32 SPI bus.
file src/hal/sd/sd_mount_scope.h
The SD card mounted for one action, and unmounted when that action ends.

Classes

class kleidos::SdCard
Static facade for the on-board SD card slot. More about kleidos::SdCard
class kleidos::hal::sdcard::MountScope< Card >
Mount the card for one scope, and unmount it at the scope's end when this scope is the one that mounted it. More about kleidos::hal::sdcard::MountScope< Card >

Typedefs

usingkleidos::SdCardSession

Enumerations

enum class kleidos::hal::sdcard::BootSettle : uint8_t { kleidos::hal::sdcard::BootSettle::NotStarted, kleidos::hal::sdcard::BootSettle::Running, kleidos::hal::sdcard::BootSettle::Done, kleidos::hal::sdcard::BootSettle::NoCard, kleidos::hal::sdcard::BootSettle::Failed }
Where the boot's settle of the slot stands. More about kleidos::hal::sdcard::BootSettle
enum class kleidos::hal::sdcard::SlotFinding : uint8_t { kleidos::hal::sdcard::SlotFinding::Unknown , kleidos::hal::sdcard::SlotFinding::Empty , kleidos::hal::sdcard::SlotFinding::Card }
What one look at the slot found: the boot's settle or a mount. More about kleidos::hal::sdcard::SlotFinding

Functions

constexpr const char *kleidos::hal::sdcard::bootSettleName (BootSettle settle)
Console token of a settle state.
constexpr BootSettlekleidos::hal::sdcard::settleOutcome (kleidos::platform::sdfatfs::CardInit init)
The state a settle ends in, from what the card-level initialization did.
constexpr boolkleidos::hal::sdcard::settled (BootSettle settle)
Whether the slot is as a working boot leaves it, for good.
constexpr boolkleidos::hal::sdcard::cardFree (BootSettle settle)
Whether a card user may address the card now.
constexpr SlotFindingkleidos::hal::sdcard::findingOf (BootSettle settle)
What a settle's end says about the slot.
constexpr SlotFindingkleidos::hal::sdcard::findingOf (kleidos::platform::sdfatfs::MountOutcome outcome)
What a mount attempt's outcome says about the slot.
constexpr boolkleidos::hal::sdcard::knownEmptyAfter (bool knownEmpty, SlotFinding finding)
Whether the slot is known empty after one more look at it.

Variables

constexpr std::array< const char *, 5 >kleidos::hal::sdcard::kBootSettleNames
Console token of each BootSettle, in enumerator order (boot_settle=).

Typedef Documentation

SdCardSession #

using kleidos::SdCardSession

The card mounted for one action and unmounted when it ends, if the action mounted it (hal::sdcard::MountScope over SdCard). Every product card user holds one for the length of its action.

Enumeration Type Documentation

BootSettle #

enum class kleidos::hal::sdcard::BootSettle : uint8_t

Where the boot's settle of the slot stands.

Enumerator
NotStarted 

No settle this boot yet: the HAL starts it once the panel is up.

Running 

Addressing the slot now; no other card user may touch it.

Done 

A card identified and initialized, then let go: deselected, its supply on, nothing mounted.

NoCard 

No card completed its initialization: an empty slot, or a card that did not answer.

Failed 

Nothing reached the slot: the bus or the card's SPI device could not be set up, or the settle could not be started.

SlotFinding #

enum class kleidos::hal::sdcard::SlotFinding : uint8_t

What one look at the slot found: the boot's settle or a mount.

Enumerator
Unknown 

Nothing learned: the look did not reach the slot, or has not ended.

Empty 

No card answered: an empty slot (no board has a card-detect line, so a failed identification is how it is learned).

Card 

A card answered, whether or not its volume then mounted.

Function Documentation

bootSettleName() #

const char * kleidos::hal::sdcard::bootSettleName(BootSettle settle)
constexpr

Console token of a settle state.

Parameters
NameDirectionMeaning
settleinThe state.
Returns
Its token, or "na" for a value outside the enumeration.

cardFree() #

bool kleidos::hal::sdcard::cardFree(BootSettle settle)
constexpr

Whether a card user may address the card now.

Parameters
NameDirectionMeaning
settleinThe state.
Return values
ValueMeaning
trueNo settle is addressing the slot.
falseOne is (Running): the card driver serves one task at a time.

findingOf() [1/2] #

SlotFinding kleidos::hal::sdcard::findingOf(BootSettle settle)
constexpr

What a settle's end says about the slot.

Parameters
NameDirectionMeaning
settleinThe state.
Returns
Card for Done, Empty for NoCard, Unknown otherwise: a settle that sent nothing (Failed) or has not ended learned nothing.

findingOf() [2/2] #

SlotFinding kleidos::hal::sdcard::findingOf(kleidos::platform::sdfatfs::MountOutcome outcome)
constexpr

What a mount attempt's outcome says about the slot.

Parameters
NameDirectionMeaning
outcomeinHow the mount ended (sdfatfs::lastMountOutcome).
Returns
Card when a card identified (its volume mounted or not), Empty when none did, Unknown before any attempt.

knownEmptyAfter() #

bool kleidos::hal::sdcard::knownEmptyAfter(bool knownEmpty, SlotFinding finding)
constexpr

Whether the slot is known empty after one more look at it.

A look that found no card makes the slot known empty, and one that found a card clears it; a look that learned nothing leaves what was known. While the slot is known empty nothing addresses it on its own (a rail restore does not remount it, a card power-measurement run does not probe it or cycle its rail): with no card-detect line there is no event to wait for, and every such attempt could only fail. A user's own SD action still tries once, and a card it finds clears the knowledge.

Parameters
NameDirectionMeaning
knownEmptyinWhat was known before the look.
findinginWhat the look found.
Returns
What is known after it.

settled() #

bool kleidos::hal::sdcard::settled(BootSettle settle)
constexpr

Whether the slot is as a working boot leaves it, for good.

Parameters
NameDirectionMeaning
settleinThe state.
Return values
ValueMeaning
trueDone or NoCard: the settle ended, and it sent whatever was in the slot the whole initialization or found nothing to send it to.
falseIt has not ended (NotStarted, Running), or it could not reach the slot (Failed), which leaves a card as its supply left it.

settleOutcome() #

BootSettle kleidos::hal::sdcard::settleOutcome(kleidos::platform::sdfatfs::CardInit init)
constexpr

The state a settle ends in, from what the card-level initialization did.

Parameters
NameDirectionMeaning
initinHow sdfatfs::initializeCard ended.
Returns
Done for an initialized card (one mounted already is initialized too), NoCard when none completed its initialization, and Failed when nothing could be sent (or for a value outside the enumeration).