GPS Device
Loading...
Searching...
No Matches
io.c File Reference

This module implements a digital IO module. More...

#include "io.h"
#include "configuration.h"
#include "err.h"
#include "init.h"
#include "log.h"
#include "modules.h"
#include "stm32f401re_gpio.h"
#include "cmd.h"
#include "common.h"
Include dependency graph for io.c:

Go to the source code of this file.

Classes

struct  io_handle_s
 Internal structure representing a single IO instance. More...
struct  internal_state_s
 Internal state of the SysTick driver. More...

Functions

static ERR_te io_cmd_w_handler (uint32_t argc, char **argv)
 CLI handler for the "w" command. Writes a logic level to a named IO pin.
static ERR_te io_cmd_r_handler (uint32_t argc, char **argv)
 CLI handler for the "r" command. Reads and logs the logic level of a named IO pin.
static ERR_te io_cmd_info_handler (uint32_t argc, char **argv)
 CLI handler for the "info" command. Logs the name and GPIO mode of all active IO handles.
ERR_te io_init_subsys (void)
 Initializes the IO subsystem.
ERR_te io_deinit_subsys (void)
 Deinitializes the IO subsystem.
ERR_te io_start_subsys (void)
 Starts the IO subsystem.
ERR_te io_stop_subsys (void)
 Stops the IO subsystem.
ERR_te io_init_handle (IO_CFG_ts *io_cfg, IO_HANDLE_ts **io_handle_o)
 Initializes and registers an IO handle.
ERR_te io_deinit_handle (IO_HANDLE_ts const *io_handle)
 Deinitializes an IO handle.
ERR_te io_write (IO_HANDLE_ts *io_handle, PIN_STATUS_te pin_status)
 Writes a logic level to an IO pin.
ERR_te io_read (IO_HANDLE_ts const *io_handle, PIN_STATUS_te *pin_status_o)
 Reads the current logic level of an IO pin.

Variables

static struct internal_state_s internal_state
 Singleton instance of the IO subsystem internal state.
static CMD_INFO_ts io_cmds []
 Table of CLI commands registered by the IO subsystem.
static CMD_CLIENT_INFO_ts io_cmd_client_info
 Registration descriptor passed to the command subsystem.

Detailed Description

This module implements a digital IO module.

Author
github.com/Baksi675
Date
2026-01-20

Definition in file io.c.

Variable Documentation

◆ internal_state

struct internal_state_s internal_state
static

Singleton instance of the IO subsystem internal state.

Definition at line 68 of file io.c.

◆ io_cmds

CMD_INFO_ts io_cmds[]
static
Initial value:
= {
{
.name = "w",
.help = "Writes to an IO pin, usage: io w <name> <1|0>",
.handler = io_cmd_w_handler
},
{
.name = "r",
.help = "Reads from an IO pin, usage: io r <name>",
.handler = io_cmd_r_handler
},
{
.name = "info",
.help = "Shows IO information, usage: io info",
}
}
static ERR_te io_cmd_w_handler(uint32_t argc, char **argv)
CLI handler for the "w" command. Writes a logic level to a named IO pin.
Definition io.c:392
static ERR_te io_cmd_info_handler(uint32_t argc, char **argv)
CLI handler for the "info" command. Logs the name and GPIO mode of all active IO handles.
Definition io.c:524
static ERR_te io_cmd_r_handler(uint32_t argc, char **argv)
CLI handler for the "r" command. Reads and logs the logic level of a named IO pin.
Definition io.c:463

Table of CLI commands registered by the IO subsystem.

Registered with the command subsystem via io_cmd_client_info during io_init_subsys.

Definition at line 82 of file io.c.

82 {
83 {
84 .name = "w",
85 .help = "Writes to an IO pin, usage: io w <name> <1|0>",
86 .handler = io_cmd_w_handler
87 },
88 {
89 .name = "r",
90 .help = "Reads from an IO pin, usage: io r <name>",
91 .handler = io_cmd_r_handler
92 },
93 {
94 .name = "info",
95 .help = "Shows IO information, usage: io info",
96 .handler = io_cmd_info_handler
97 }
98};

◆ io_cmd_client_info

CMD_CLIENT_INFO_ts io_cmd_client_info
static
Initial value:
= {
.cmds_ptr = io_cmds,
.num_cmds = sizeof(io_cmds) / sizeof(io_cmds[0]),
.name = "io",
.log_level_ptr = &internal_state.log_level
}
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
static CMD_INFO_ts io_cmds[]
Table of CLI commands registered by the IO subsystem.
Definition io.c:82

Registration descriptor passed to the command subsystem.

Bundles the command table, its size, the subsystem name prefix used on the CLI, and a pointer to the runtime log-level variable.

Definition at line 107 of file io.c.

107 {
108 .cmds_ptr = io_cmds,
109 .num_cmds = sizeof(io_cmds) / sizeof(io_cmds[0]),
110 .name = "io",
111 .log_level_ptr = &internal_state.log_level
112};