CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
GPIO Struct Reference

The Arty A7 configuration has two LEDs (LD5 and LD6), four buttons, and four switches, exposed over GPIO. More...

#include <platform-gpio.hh>

Collaboration diagram for GPIO:

Classes

struct  InputBits
 Helper that defines a set of bits in a GPIO input word used for a specific purpose. More...

Public Member Functions

template<InputBits Bits>
uint32_t bits () volatile
 Helper to read all of the bits defined by an InputBits instance.
template<InputBits Bits>
uint32_t bit (uint32_t index) volatile
 Helper to read a single bit defined by an InputBits instance.
uint32_t buttons () volatile
 Read the value of all of the buttons.
uint32_t switches () volatile
 Read the value of all of the switches.
uint32_t button (uint32_t index) volatile
 Read the value of one of the buttons, indicated by index.
uint32_t switch_value (uint32_t index) volatile
 Read the value of one of the switches, indicated by index.
void enable_all () volatile
 Enable all of the LED GPIO pins.
void led_on (uint32_t index) volatile
 Turn on the LED specified by index.
void led_off (uint32_t index) volatile
 Turn off the LED specified by index.

Static Public Member Functions

static constexpr uint32_t led_bit (uint32_t index)
 Helper that maps from an LED index to a bit to set / clear to control that LED.

Public Attributes

uint32_t read
 Input register.
uint32_t write
 The output register.
uint32_t writeEnable
 Write enable.

Static Public Attributes

static constexpr uint32_t FirstLED = 14
 The index of the first GPIO pin connected to a LED.
static constexpr uint32_t LastLED = 15
 The index of the last GPIO pin connected to a LED.
static constexpr uint32_t LEDCount = LastLED - FirstLED + 1
 The number of GPIO pins used for LEDs.
static constexpr InputBits Buttons = {4, 4}
 The buttons zero to three are in the low four bits.
static constexpr InputBits Switches = {4, 0}
 Switches zero to three are in the next four bits.

Detailed Description

The Arty A7 configuration has two LEDs (LD5 and LD6), four buttons, and four switches, exposed over GPIO.

This provides a simple driver for them.

Definition at line 11 of file platform-gpio.hh.

Member Function Documentation

◆ bit()

template<InputBits Bits>
uint32_t GPIO::bit ( uint32_t index) volatile
inline

Helper to read a single bit defined by an InputBits instance.

Definition at line 95 of file platform-gpio.hh.

References read.

Referenced by button(), and switch_value().

◆ bits()

template<InputBits Bits>
uint32_t GPIO::bits ( ) volatile
inline

Helper to read all of the bits defined by an InputBits instance.

Definition at line 86 of file platform-gpio.hh.

References read.

Referenced by buttons(), and switches().

◆ button()

uint32_t GPIO::button ( uint32_t index) volatile
inline

Read the value of one of the buttons, indicated by index.

Definition at line 119 of file platform-gpio.hh.

References bit().

◆ buttons()

uint32_t GPIO::buttons ( ) volatile
inline

Read the value of all of the buttons.

Definition at line 103 of file platform-gpio.hh.

References bits().

◆ enable_all()

void GPIO::enable_all ( ) volatile
inline

Enable all of the LED GPIO pins.

This must be called before led_on or led_off.

Definition at line 153 of file platform-gpio.hh.

References led_bit(), LEDCount, and writeEnable.

◆ led_bit()

constexpr uint32_t GPIO::led_bit ( uint32_t index)
inlinestaticconstexpr

Helper that maps from an LED index to a bit to set / clear to control that LED.

Returns 0 for out-of-bounds LED values and so can be safely masked.

Definition at line 139 of file platform-gpio.hh.

References FirstLED, and LEDCount.

Referenced by enable_all(), led_off(), and led_on().

◆ led_off()

void GPIO::led_off ( uint32_t index) volatile
inline

Turn off the LED specified by index.

Definition at line 174 of file platform-gpio.hh.

References led_bit(), and write.

◆ led_on()

void GPIO::led_on ( uint32_t index) volatile
inline

Turn on the LED specified by index.

Definition at line 166 of file platform-gpio.hh.

References led_bit(), and write.

◆ switch_value()

uint32_t GPIO::switch_value ( uint32_t index) volatile
inline

Read the value of one of the switches, indicated by index.

This should be called switch, but that's a keyword in C/C++.

Definition at line 129 of file platform-gpio.hh.

References bit().

◆ switches()

uint32_t GPIO::switches ( ) volatile
inline

Read the value of all of the switches.

Definition at line 111 of file platform-gpio.hh.

References bits().

Member Data Documentation

◆ Buttons

InputBits GPIO::Buttons = {4, 4}
staticconstexpr

The buttons zero to three are in the low four bits.

Definition at line 75 of file platform-gpio.hh.

◆ FirstLED

uint32_t GPIO::FirstLED = 14
staticconstexpr

The index of the first GPIO pin connected to a LED.

Definition at line 29 of file platform-gpio.hh.

Referenced by led_bit().

◆ LastLED

uint32_t GPIO::LastLED = 15
staticconstexpr

The index of the last GPIO pin connected to a LED.

Definition at line 33 of file platform-gpio.hh.

◆ LEDCount

uint32_t GPIO::LEDCount = LastLED - FirstLED + 1
staticconstexpr

The number of GPIO pins used for LEDs.

Definition at line 37 of file platform-gpio.hh.

Referenced by enable_all(), and led_bit().

◆ read

uint32_t GPIO::read

Input register.

This is unused for the LEDs.

Definition at line 16 of file platform-gpio.hh.

Referenced by bit(), and bits().

◆ Switches

InputBits GPIO::Switches = {4, 0}
staticconstexpr

Switches zero to three are in the next four bits.

Definition at line 80 of file platform-gpio.hh.

◆ write

uint32_t GPIO::write

The output register.

This is a bitmap of GPIO lines to set.

Definition at line 20 of file platform-gpio.hh.

Referenced by led_off(), and led_on().

◆ writeEnable

uint32_t GPIO::writeEnable

Write enable.

This sets the pins that should be controlled by write.

Definition at line 24 of file platform-gpio.hh.

Referenced by enable_all().


The documentation for this struct was generated from the following file: