18#include "configuration.h"
36 char name[CONFIG_BUTTON_MAX_NAME_LEN];
123 .help =
"Gets the pushed state, usage: button getpushed <button>",
128 .help =
"Gets the held state, usage: button getheld <button>",
133 .help =
"Shows button information, usage: button info",
181 "button_init_subsys: cmd_register error"
189 "button_init_subsys: subsys initialized"
206 "button_deinit_subsys: subsys is not initialized or not stopped"
214 "button_deinit_subsys: subsys deinitialized"
228 "button_start_subsys: subsys started"
235 "button_start_subsys: subsys not initialized or already started"
252 "button_stop_subsys: subsys stopped"
259 "button_stop_subsys: subsys not initialized or already already stopped"
274 "button_init_handle: subsys not initialized"
284 "button_init_handle: subsystem out of memory space"
294 "button_init_handle: invalid argument"
307 for(uint32_t i = 0; i < CONFIG_BUTTON_MAX_OBJECTS; i++) {
335 "button_init_handle: button handle %s initialized",
352 "button_deinit_handle: subsys not stopped"
361 "button_deinit_handle: no such handle to deinitialize"
367 for(uint32_t i = 0; i < CONFIG_BUTTON_MAX_OBJECTS; i++) {
380 "button_deinit_handle: io handle %s deinitialized",
387 if(i == CONFIG_BUTTON_MAX_OBJECTS - 1) {
391 "button_deinit_handle: no such handle to deinitialize"
407 "button_run_handle: subsystem not initialized or started"
416 if(button_handle->
pushed ==
false) {
418 pin_status ==
HIGH) ||
420 pin_status ==
LOW)) {
430 button_handle->
pushed =
true;
443 if(button_handle->
pushed ==
true && button_handle->
held ==
false) {
445 pin_status ==
HIGH) ||
447 pin_status ==
LOW)) {
457 button_handle->
held =
true;
470 if(button_handle->
pushed ==
true) {
472 pin_status ==
LOW) ||
474 pin_status ==
HIGH)) {
484 button_handle->
pushed =
false;
485 button_handle->
held =
false;
503 for(uint32_t i = 0; i < CONFIG_BUTTON_MAX_OBJECTS; i++) {
521 "button_get_pushed_state: handle not initialized or subsystem not started"
527 *pushed_state_o = button_handle->
pushed;
538 "button_get_held_state: handle not initialized or subsystem not started"
544 *held_state_o = button_handle->
held;
579 "button_getpushed_handler: invalid arguments"
584 for(uint32_t i = 0; i < CONFIG_BUTTON_MAX_OBJECTS; i++) {
595 "button_getpushed_handler: %s pushed state: %d",
607 "button_getpushed_handler: invalid arguments"
639 "button_getheld_handler: invalid arguments"
644 for(uint32_t i = 0; i < CONFIG_BUTTON_MAX_OBJECTS; i++) {
655 "button_getheld_handler: %s held state: %d",
667 "button_getheld_handler: invalid arguments"
697 "button_cmd_info_handler: invalid arguments"
704 for(uint32_t i = 0; i < CONFIG_BUTTON_MAX_OBJECTS; i++) {
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
Arm Cortex-M4 SysTick driver public API.
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.
PIN_STATUS_te
Represents the logical level of a GPIO pin.
uint32_t systick_get_ms(void)
Returns the number of milliseconds elapsed since SysTick was initialized.
ERR_te
Standard return type used by all public API functions.
@ ERR_UNINITIALZIED_OBJECT
@ ERR_DEINITIALIZATION_FAILURE
@ ERR_INITIALIZATION_FAILURE
ERR_te init_log(void)
Initializes the logging subsystem.
ERR_te init_systick(void)
Initializes the SysTick timer.
#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_init(GPIO_CFG_ts *gpio_cfg)
Initializes a GPIO pin according to the given configuration.
GPIO_PIN_te
GPIO pin number within a port (0–15).
@ GPIO_OUTPUT_TYPE_PUSHPULL
Common initialization 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.
GPIO_OUTPUT_TYPE_te output_type
GPIO peripheral register map.
Internal state of the SysTick driver.
struct button_handle_s buttons[CONFIG_BUTTON_MAX_OBJECTS]