Console (console)#
- group console
Interactive serial monitor (minimon) for board bring-up.
For an overview, see Console.
rcsw/console/minimon.h#
Minimon, an interactive serial monitor for board bring-up.
Defines
-
MINIMON_CMD_MAX_ARGS#
Maximum number of arguments a command may accept.
-
MINIMON_CMD_MAX_NAMELEN#
Maximum length of a command name string, including null terminator.
Typedefs
-
typedef void (*vfp_t)(void)#
Pointer to a
void(void)function, e.g. ajumptarget.
Enums
Functions
-
void minimon_init(const struct minimon_config *config)#
Initialize the monitor.
Must be called before minimon_start(). Registers the command set, IRQ callbacks, and stream callbacks.
configmay be NULL to use defaults (built-in commands only, help on start, no IRQ callbacks, no stream1).- Parameters:
config – Initialization parameters, or NULL for defaults.
-
void minimon_start(void) __attribute__((noreturn))#
Start the monitor loop.
Reads commands from stream0, parses and validates their syntax, and dispatches them to the appropriate hook. A command is matched by its exact name or alias. Never returns, though control may be transferred elsewhere via the
jumpcommand.Negative values from stdio_getchar() (and from stream1’s getchar during
load) are treated as “no character available yet” and ignored, so a polling driver may return -1 when its receive buffer is empty.
-
struct minimon_irq_callbacks#
- #include <rcsw/console/minimon.h>
Optional interrupt-related callbacks.
Used only by the
jumpcommand: before branching, it callsclear_alland thenmask_all(each if non-NULL), so the jump target starts with no interrupts pending or enabled.
-
struct minimon_stream_callbacks#
- #include <rcsw/console/minimon.h>
Character I/O callbacks for a stream.
-
struct minimon_config#
- #include <rcsw/console/minimon.h>
Initialization parameters for minimon_init().
Public Members
-
struct minimon_irq_callbacks irqcb#
Optional interrupt callbacks. May be zero-initialized if not needed.
-
struct minimon_stream_callbacks stream1#
Optional stream1 callbacks for
loadandsendcommands.If both callbacks are set, stream0 is used exclusively for interactive I/O and stream1 for data transfer. If they are NULL (zero-initialized), both use stream0 and
load/sendsuppress progress output.
-
const struct minimon_cmd *cmds#
Array of custom commands to register, or NULL if none.
Custom commands are registered in addition to (or instead of, if minimon_config::include_builtin is false) the built-in command set. Nothing is copied: the monitor uses the array in place, so it and the strings it points to must stay valid for as long as the monitor runs (typically a
staticconsttable). There is no limit on the number of commands.
-
size_t n_cmds#
Number of entries in minimon_config::cmds. Ignored if it is NULL.
-
bool include_builtin#
If true, include the built-in commands (read, write, jump, load, send). The HELP command is always included regardless.
-
bool help_on_start#
If true, print the full help menu when minimon_start() is called. Useful to disable when there are many commands and you want the startup output to remain concise.
-
struct minimon_irq_callbacks irqcb#
-
union minimon_cmd_arg#
- #include <rcsw/console/minimon.h>
A single argument passed to a minimon_cmd, i.e. what was actually passed, as opposed to minimon_cmd_param, which describes what is expected.
-
struct minimon_cmd_param#
- #include <rcsw/console/minimon.h>
Descriptor for one parameter of a minimon_cmd.
Defines what the command expects; contrast with minimon_cmd_arg, which holds what was actually passed.
Public Members
-
const char *name#
Parameter name, shown in help.
-
enum minimon_param_type type#
How the argument is parsed.
-
const char *short_help#
One-line help.
-
const char *long_help#
Detailed help.
-
bool required#
If false,
dfltis used when omitted.
-
union minimon_cmd_arg dflt#
Default for an optional parameter.
-
const char *name#
-
struct minimon_cmd#
- #include <rcsw/console/minimon.h>
A command the monitor can execute: its name, help string, execution function, etc.
Public Members
-
const char *name#
The name of the command.
-
const char *alias#
A short form alias of the command. Must be a substring of minimon_cmd::name.
-
const char *help#
The help string for the command. Should not terminate with a period, and consist only of a single sentence.
-
void (*hook)(const char *cmdname, const union minimon_cmd_arg *args)#
Command implementation function.
Called by the monitor with the matched command name and an array of MINIMON_CMD_MAX_ARGS arguments, in the order defined by minimon_cmd::config. Read
args[i].num for a MINIMON_PARAM_UINT32 parameter andargs[i].s for a MINIMON_PARAM_STR parameter. Omitted optional arguments hold their minimon_cmd_param::dflt, and unused slots are zeroed. Addresses are 32-bit numbers; convert with(T*)(uintptr_t)num. The same hook may be registered for multiple commands; usecmdnameto distinguish them.argsis only valid for the duration of the call.
-
struct minimon_cmd_param config[4]#
Array of parameter definitions for the command.
-
const char *name#
-
struct minimon#
- #include <rcsw/console/minimon.h>
Bare-metal interactive monitor for board bring-up and hardware validation.
Minimon reads commands from a serial stream (stream0), executes them, and prints results back. It has no dynamic memory requirements and no OS dependencies, making it suitable for use before an RTOS or memory allocator is initialized.
Streams#
Minimon uses up to two streams:
stream0 — always stdio_putchar() / stdio_getchar(). Used for interactive user input and output.
stream1 — optional; provided via minimon_config::stream1. If supplied, the
loadandsendcommands use stream1 for data transfer and print progress to stream0. If omitted,loadandsendshare stream0 and suppress progress output.
Custom Commands#
To add commands beyond the built-ins, populate an array of minimon_cmd structs and pass it via minimon_config::cmds and minimon_config::n_cmds to minimon_init(). Set minimon_config::include_builtin to true to retain the standard command set alongside your custom ones, or false to replace it entirely (the HELP command is always included regardless).
Each minimon_cmd specifies a name, an optional short alias, a help string, a minimon_cmd::hook function pointer, and up to MINIMON_CMD_MAX_ARGS parameter descriptors. The hook receives the command name and the parsed arguments as an array of minimon_cmd_arg; see minimon_cmd::hook.
Note
The struct itself is the monitor’s internal state (one instance, inside RCSW); applications configure it through minimon_init().
Public Members
-
struct minimon_config cfg#
The configuration passed to minimon_init() (or the defaults, if NULL was passed). minimon_config::cmds is used in place; minimon_config::n_cmds is 0 if it is NULL.
-
struct minimon_stream_callbacks stream0#
Always stdio_putchar() / stdio_getchar().
-
size_t n_builtin_cmds#
Built-ins in use: all of them, or just HELP.