Midnight Sun Firmware
|
Classes | |
struct | Payload |
Gpio Datagram payload storage. More... | |
Public Types | |
enum class | Port { GPIO_PORT_A = 0 , GPIO_PORT_B , NUM_GPIO_PORTS } |
Gpio Port definition. More... | |
enum class | State { GPIO_STATE_LOW = 0 , GPIO_STATE_HIGH } |
Gpio State definition. More... | |
enum class | Mode { GPIO_ANALOG = 0 , GPIO_INPUT_FLOATING , GPIO_INPUT_PULL_DOWN , GPIO_INPUT_PULL_UP , GPIO_OUTPUT_OPEN_DRAIN , GPIO_OUTPUT_PUSH_PULL , GPIO_ALFTN_OPEN_DRAIN , GPIO_ALTFN_PUSH_PULL , NUM_GPIO_MODES } |
Gpio Mode definition. More... | |
enum class | AltFunction { GPIO_ALT_NONE = 0x00U , GPIO_ALT0_SWDIO = 0x00U , GPIO_ALT0_SWCLK = 0x00U , GPIO_ALT1_TIM1 = 0x01U , GPIO_ALT1_TIM2 = 0x01U , GPIO_ALT4_I2C1 = 0x04U , GPIO_ALT4_I2C2 = 0x04U , GPIO_ALT4_I2C3 = 0x04U , GPIO_ALT5_SPI1 = 0x05U , GPIO_ALT5_SPI2 = 0x05U , GPIO_ALT6_SPI3 = 0x06U , GPIO_ALT7_USART1 = 0x07U , GPIO_ALT7_USART2 = 0x07U , GPIO_ALT7_USART3 = 0x07U , GPIO_ALT9_CAN1 = 0x09U , GPIO_ALT14_TIM15 = 0x0EU , GPIO_ALT14_TIM16 = 0x0EU } |
Gpio Alt function definition. | |
Public Member Functions | |
Gpio (Payload &data) | |
Constructs a Gpio object with provided payload data. More... | |
Gpio ()=default | |
Default constructor for Gpio object. | |
std::string | serialize (const CommandCode &commandCode) const |
Serializes Gpio data with command code for transmission. More... | |
void | deserialize (std::string &gpioDatagramPayload) |
Deserializes Gpio data from payload string. More... | |
void | setGpioPort (const Port &gpioPort) |
Sets the target Gpio port. More... | |
void | setGpioPin (const uint8_t &gpioPin) |
Sets the target Gpio pin. More... | |
void | setBuffer (const uint8_t *data, uint8_t length) |
Sets data in the Gpio buffer. More... | |
void | clearBuffer () |
Clear the Gpio data buffer. | |
Port | getGpioPort () const |
Gets the target Gpio port. More... | |
uint8_t | getGpioPin () const |
Gets the target Gpio pin. More... | |
uint8_t | getBufferLength () const |
Gets the Gpio buffer length. More... | |
const uint8_t * | getBuffer () const |
Gets the Gpio buffer. More... | |
Static Public Attributes | |
static const constexpr uint8_t | PINS_PER_PORT = 16U |
static constexpr size_t | GPIO_MAX_BUFFER_SIZE = PINS_PER_PORT * static_cast<uint8_t>(Port::NUM_GPIO_PORTS) |
Private Attributes | |
Payload | m_gpioDatagram |
|
strong |
Gpio Mode definition.
Enumerator | |
---|---|
GPIO_ANALOG | Gpio Mode Analog |
GPIO_INPUT_FLOATING | Gpio Mode Input Floating |
GPIO_INPUT_PULL_DOWN | Gpio Mode Input Pull Down |
GPIO_INPUT_PULL_UP | Gpio Mode Input Pull Up |
GPIO_OUTPUT_OPEN_DRAIN | Gpio Mode Output Open Drain |
GPIO_OUTPUT_PUSH_PULL | Gpio Mode Output Push Pull |
GPIO_ALFTN_OPEN_DRAIN | Gpio Mode Alt Open Drain |
GPIO_ALTFN_PUSH_PULL | Gpio Mode Alt Push Pull |
NUM_GPIO_MODES | Number of Gpio Modes |
|
strong |
|
strong |
Constructs a Gpio object with provided payload data.
data | Reference to payload data |
void deserialize | ( | std::string & | gpioDatagramPayload | ) |
const uint8_t * getBuffer | ( | ) | const |
Gets the Gpio buffer.
uint8_t getBufferLength | ( | ) | const |
Gets the Gpio buffer length.
uint8_t getGpioPin | ( | ) | const |
Gets the target Gpio pin.
Gpio::Port getGpioPort | ( | ) | const |
Gets the target Gpio port.
std::string serialize | ( | const CommandCode & | commandCode | ) | const |
void setBuffer | ( | const uint8_t * | data, |
uint8_t | length | ||
) |
Sets data in the Gpio buffer.
data | Pointer to data to copy into buffer |
length | Length of data to copy |
void setGpioPin | ( | const uint8_t & | gpioPin | ) |
Sets the target Gpio pin.
gpioPin | Pin to set as target |
void setGpioPort | ( | const Port & | gpioPort | ) |
Sets the target Gpio port.
gpioPort | Port to set as target |
|
staticconstexpr |
Maximum buffer size dependent on the Pins per port and Number of Gpio ports
|
private |
Private datagram payload
|
staticconstexpr |
Supported Pins per Port