Midnight Sun Firmware
Loading...
Searching...
No Matches
Gpio
Collaboration diagram for Gpio:

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
 

Member Enumeration Documentation

◆ Mode

enum class Mode
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

◆ Port

enum class Port
strong

Gpio Port definition.

Enumerator
GPIO_PORT_A 

Gpio port A

GPIO_PORT_B 

Gpio port B

NUM_GPIO_PORTS 

Number of Gpio Ports

◆ State

enum class State
strong

Gpio State definition.

Enumerator
GPIO_STATE_LOW 

Gpio state low

GPIO_STATE_HIGH 

Gpio state high

Constructor & Destructor Documentation

◆ Gpio()

Gpio ( Payload data)
explicit

Constructs a Gpio object with provided payload data.

Parameters
dataReference to payload data

Member Function Documentation

◆ deserialize()

void deserialize ( std::string &  gpioDatagramPayload)

Deserializes Gpio data from payload string.

Parameters
gpioDatagramPayloadString containing serialized Gpio data

◆ getBuffer()

const uint8_t * getBuffer ( ) const

Gets the Gpio buffer.

Returns
Pointer to the buffer array

◆ getBufferLength()

uint8_t getBufferLength ( ) const

Gets the Gpio buffer length.

Returns
Buffer length

◆ getGpioPin()

uint8_t getGpioPin ( ) const

Gets the target Gpio pin.

Returns
Target pin

◆ getGpioPort()

Gpio::Port getGpioPort ( ) const

Gets the target Gpio port.

Returns
Target port

◆ serialize()

std::string serialize ( const CommandCode commandCode) const

Serializes Gpio data with command code for transmission.

Parameters
commandCodeCommand code to include in serialized data
Returns
Serialized string containing Gpio data

◆ setBuffer()

void setBuffer ( const uint8_t *  data,
uint8_t  length 
)

Sets data in the Gpio buffer.

Parameters
dataPointer to data to copy into buffer
lengthLength of data to copy

◆ setGpioPin()

void setGpioPin ( const uint8_t &  gpioPin)

Sets the target Gpio pin.

Parameters
gpioPinPin to set as target

◆ setGpioPort()

void setGpioPort ( const Port gpioPort)

Sets the target Gpio port.

Parameters
gpioPortPort to set as target

Member Data Documentation

◆ GPIO_MAX_BUFFER_SIZE

constexpr size_t GPIO_MAX_BUFFER_SIZE = PINS_PER_PORT * static_cast<uint8_t>(Port::NUM_GPIO_PORTS)
staticconstexpr

Maximum buffer size dependent on the Pins per port and Number of Gpio ports

◆ m_gpioDatagram

Payload m_gpioDatagram
private

Private datagram payload

◆ PINS_PER_PORT

const constexpr uint8_t PINS_PER_PORT = 16U
staticconstexpr

Supported Pins per Port


The documentation for this class was generated from the following files: