K-FSW ec10f94
Modular flight software on Zephyr, for small satellites
Loading...
Searching...
No Matches
lastwords.h File Reference
#include <stdbool.h>
#include <stdint.h>

Data Structures

struct  kfsw_lastwords
 

Enumerations

enum  kfsw_lastwords_reason {
  KFSW_LASTWORDS_NONE = 0 , KFSW_LASTWORDS_COMMANDED = 1 , KFSW_LASTWORDS_BROWNOUT = 2 , KFSW_LASTWORDS_FATAL = 3 ,
  KFSW_LASTWORDS_STARVED = 4 , KFSW_LASTWORDS_UNKNOWN = 5
}
 

Functions

void kfsw_lastwords_write (enum kfsw_lastwords_reason reason, uint32_t detail, uint32_t uptime_ms, uint32_t boot_count)
 
bool kfsw_lastwords_take (struct kfsw_lastwords *record)
 
bool kfsw_lastwords_withdraw (enum kfsw_lastwords_reason reason)
 
const char * kfsw_lastwords_reason_name (enum kfsw_lastwords_reason reason)
 
int kfsw_lastwords_watch_supply (void)
 

Description

A note written before a restart, kept in RAM that start-up does not clear.

It survives a reset but not a power loss, and a magic number and a CRC validate it.

Enumeration Documentation

◆ kfsw_lastwords_reason

Reset reason.

Enumerator
KFSW_LASTWORDS_NONE 

No valid reset note.

KFSW_LASTWORDS_COMMANDED 

An operator or the ground asked for a restart.

KFSW_LASTWORDS_BROWNOUT 

The supply fell far enough for the detector to fire.

KFSW_LASTWORDS_FATAL 

A fatal error handler ran.

KFSW_LASTWORDS_STARVED 

Health stopped feeding the watchdog.

KFSW_LASTWORDS_UNKNOWN 

Restart without a more specific reason.

Function Documentation

◆ kfsw_lastwords_reason_name()

const char * kfsw_lastwords_reason_name ( enum kfsw_lastwords_reason  reason)

Human-readable name for a reason, for the shell and the log.

◆ kfsw_lastwords_take()

bool kfsw_lastwords_take ( struct kfsw_lastwords *  record)

Read the note and clear it.

Returns true when a valid note was found. Returns false without clearing the note if another operation owns it.

◆ kfsw_lastwords_watch_supply()

int kfsw_lastwords_watch_supply ( void  )

Start the supply voltage detector.

Returns 0 when a detector is armed, or -ENOTSUP when the SoC has none.

◆ kfsw_lastwords_withdraw()

bool kfsw_lastwords_withdraw ( enum kfsw_lastwords_reason  reason)

Clear the note if its reason matches.

Returns true when it was cleared. Returns false if another operation owns the record.

◆ kfsw_lastwords_write()

void kfsw_lastwords_write ( enum kfsw_lastwords_reason  reason,
uint32_t  detail,
uint32_t  uptime_ms,
uint32_t  boot_count 
)

Write a note without waiting, including from an interrupt.

A concurrent or nested operation is ignored while another owns the record. Sequential writes replace the previous note; there is no severity arbitration.