mikrokontrollersystemer-pro.../prosjekt.X/command-handler.h

66 lines
1.8 KiB
C
Raw Normal View History

/*
* File: command-handler.h
* Author: Sebastian H. Gabrielli
*
* Created on March 6, 2024, 12:43 PM
*/
#ifndef COMMAND_HANDLER_H
#define COMMAND_HANDLER_H
#ifdef __cplusplus
extern "C" {
#endif
// Enum of all valid command types
typedef enum {
WRITE_CHANGE, // Change the configuration
READ_CONFIG, // Read, and print the current configuration
READ_VOLTAGE, // Read, and print a voltage
READ_TERMPERATURE, // Read, and print the temperature
READ_FAN_SPEED, // Read, and print the current fan speed
READ_BULK_FAN_SPEED, // Read, and print the stored back fan speed data
CLEAR_BULK_FAN_SPEED, // Clear the buffer of stored fan speed data
UNKNOWN_COMMAND // An unrecognized command has been sent
} command_t;
// Enum of all valid voltage sources
typedef enum {
SRC_INTERNAL, // Internal volage
SRC_EXTRNAL, // External voltage
SRC_NONE // No voltage source selected
} src_voltage_t;
// Enum of all valid config options
// TODO: Move into config header file
typedef enum {
CNF_NONE, // No config option
} config_option_t;
// Enum of all valid fans
// TODO: Consider moving into it's own fan page
typedef enum {
FAN1, // The first fan
FAN2, // The second fan
FAN_NONE // No fan
} fans_t;
// Struct with command context
typedef struct {
command_t command; // The command to execute
src_voltage_t src_voltage; // The selected voltage source
config_option_t conf; // The configuration option to cange
} command_context_t;
// Parses the input string and outputs one of the valid commands
command_context_t parse_command(char *command_str);
// Routes the provided command to the appropriate function to handle it
void route_command(command_context_t command);
#ifdef __cplusplus
}
#endif
#endif /* COMMAND_HANDLER_H */