12#include "configuration.h"
34 char name[CONFIG_IO_MAX_NAME_LEN];
85 .help =
"Writes to an IO pin, usage: io w <name> <1|0>",
90 .help =
"Reads from an IO pin, usage: io r <name>",
95 .help =
"Shows IO information, usage: io info",
141 "io_init_subsys: cmd_register error"
149 "io_init_subsys: subsys initialized"
166 "io_deinit_subsys: subsys is not initialized or not stopped"
174 "io_deinit_subsys: subsys deinitialized"
188 "io_start_subsys: subsys started"
195 "io_start_subsys: subsys not initialized or already started"
212 "io_stop_subsys: subsys stopped"
219 "io_stop_subsys: subsys not initialized or already already stopped"
234 "io_init_handle: subsystem out of memory space"
242 for(uint32_t i = 0; i < CONFIG_IO_MAX_OBJECTS; i++) {
258 "io_init_handle: io handle %s initialized",
275 "io_deinit_handle: no such handle to deinitialize"
281 for(uint32_t i = 0; i < CONFIG_IO_MAX_OBJECTS; i++) {
290 for(uint32_t j = 0; j < name_len; j++) {
301 "io_deinit_handle: io handle %s deinitialized",
308 if(i == CONFIG_IO_MAX_OBJECTS - 1) {
312 "io_deinit_handle: no such handle to deinitialize"
335 "io_write: subsystem not initialized or started"
356 "io_read: subsystem not initialized or started"
399 "io_cmd_w_handler: invalid arguments"
404 for(uint32_t i = 0; i < CONFIG_IO_MAX_OBJECTS; i++) {
406 if(
str_cmp(argv[3],
"0") ==
true ||
407 str_cmp(argv[3],
"off") ==
true) {
414 else if(
str_cmp(argv[3],
"1") ==
true ||
415 str_cmp(argv[3],
"on") ==
true) {
426 "io_cmd_w_handler: invalid arguments"
436 "io_cmd_w_handler: invalid arguments"
470 "io_cmd_r_handler: invalid arguments"
475 for(uint32_t i = 0; i < CONFIG_IO_MAX_OBJECTS; i++) {
487 "io_cmd_r_handler: %s pin status: %d",
499 "io_cmd_r_handler: invalid arguments"
529 "io_cmd_info_handler: invalid arguments"
537 for(uint32_t i = 0; i < CONFIG_IO_MAX_OBJECTS; i++) {
542 "name: %s, mode: %d",
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
Command subsystem public API.
Common utility module public API.
System-wide error code definitions.
ERR_te cmd_deregister(CMD_CLIENT_INFO_ts const *cmd_client_info)
Deregisters a client from the command subsystem.
ERR_te cmd_register(CMD_CLIENT_INFO_ts *cmd_client_info)
Registers a client with the command subsystem.
bool str_cmp(const char *str1, const char *str2)
Compares two null-terminated strings for equality.
int str_cpy(char *str_to, const char *str_from, uint32_t len)
Copies a null-terminated string into a destination buffer.
uint32_t get_str_len(char const *str)
Returns the length of a string, excluding the null terminator.
int txt_cpy(char *txt_to, const char *txt_from, uint32_t len)
Copies a fixed-length block of text into a destination buffer.
PIN_STATUS_te
Represents the logical level of a GPIO pin.
ERR_te
Standard return type used by all public API functions.
@ ERR_UNINITIALZIED_OBJECT
@ ERR_DEINITIALIZATION_FAILURE
@ ERR_MODULE_ALREADY_INITIALIZED
ERR_te init_log(void)
Initializes the logging subsystem.
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_info_handler(uint32_t argc, char **argv)
CLI handler for the "info" command. Logs the name and GPIO mode of all active IO handles.
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.
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_write(IO_HANDLE_ts *io_handle, PIN_STATUS_te pin_status)
Writes a logic level to an IO pin.
ERR_te io_stop_subsys(void)
Stops the IO subsystem.
ERR_te io_deinit_subsys(void)
Deinitializes the IO subsystem.
ERR_te io_deinit_handle(IO_HANDLE_ts const *io_handle)
Deinitializes an IO handle.
ERR_te io_start_subsys(void)
Starts the IO subsystem.
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.
ERR_te io_init_subsys(void)
Initializes the IO subsystem.
struct io_handle_s IO_HANDLE_ts
Opaque handle representing an IO instance.
#define LOG_ERROR(subsys, lvl, fmt,...)
#define LOG_INFO(subsys, lvl, fmt,...)
LOG_LEVEL_te
Log severity levels, in ascending order of severity.
MODULES_te
Identifies a subsystem for use in logging and CLI output.
PIN_STATUS_te gpio_read(GPIO_REGDEF_ts const *gpio_port, uint8_t gpio_pin)
Reads the current logic level of a GPIO input pin.
void gpio_write(GPIO_REGDEF_ts *gpio_port, uint8_t gpio_pin, PIN_STATUS_te pin_status)
Drives a GPIO output pin high or low.
void gpio_init(GPIO_CFG_ts *gpio_cfg)
Initializes a GPIO pin according to the given configuration.
Common initialization public API.
static CMD_CLIENT_INFO_ts io_cmd_client_info
Registration descriptor passed to the command subsystem.
static CMD_INFO_ts io_cmds[]
Table of CLI commands registered by the IO subsystem.
Digital IO module public API.
Log subsystem public API.
System module identifier definitions.
STM32F401RE GPIO driver public API.
Describes a subsystem client registering with the command module.
Describes a single command exposed by a client.
Configuration structure for initializing a GPIO pin.
Configuration structure for initializing an IO handle.
char name[CONFIG_IO_MAX_NAME_LEN]
GPIO_CFG_ts * gpio_handle
Internal state of the SysTick driver.
IO_HANDLE_ts ios[CONFIG_IO_MAX_OBJECTS]
Internal structure representing a single IO instance.
char name[CONFIG_IO_MAX_NAME_LEN]