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

A Simple Driver for the Sonata's GPIO. More...

#include <platform-gpio.hh>

Public Member Functions

void led_on (uint32_t index) volatile
 Switches off the LED at the given user LED index.
void led_off (uint32_t index) volatile
 Switches on the LED at the given user LED index.
void led_toggle (uint32_t index) volatile
 Toggles the LED at the given user LED index.
bool read_switch (uint32_t index) volatile
 Returns the value of the switch at the given user switch index.
SonataJoystick read_joystick () volatile
 Returns the state of the joystick.

Static Public Member Functions

static constexpr uint32_t led_bit (uint32_t index)
 The output bit mask for a given user LED index.
static constexpr uint32_t switch_bit (uint32_t index)
 The input bit mask for a given user switch index.

Public Attributes

uint32_t output
uint32_t input
uint32_t debouncedInput
uint32_t debouncedThreshold
uint32_t raspberryPiHeader
uint32_t raspberryPiMask
uint32_t arduinoShieldHeader
uint32_t arduinoShieldMask

Static Public Attributes

static constexpr uint32_t FirstLED = 4
 The bit index of the first GPIO pin connected to a user LED.
static constexpr uint32_t LastLED = 11
 The bit index of the last GPIO pin connected to a user LED.
static constexpr uint32_t LEDCount = LastLED - FirstLED + 1
 The number of user LEDs.
static constexpr uint32_t LEDMask = ((1 << LEDCount) - 1) << FirstLED
 The mask covering the GPIO pins used for user LEDs.
static constexpr uint32_t FirstSwitch = 5
 The bit index of the first GPIO pin connected to a user switch.
static constexpr uint32_t LastSwitch = 13
 The bit index of the last GPIO pin connected to a user switch.
static constexpr uint32_t SwitchCount = LastSwitch - FirstSwitch + 1
 The number of user switches.
static constexpr uint32_t SwitchMask
 The mask covering the GPIO pins used for user switches.

Detailed Description

A Simple Driver for the Sonata's GPIO.

Documentation source can be found at: https://github.com/lowRISC/sonata-system/blob/1a59633d2515d4fe186a07d53e49ff95c18d9bbf/doc/ip/gpio.md

Rendered documentation is served from: https://lowrisc.org/sonata-system/doc/ip/gpio.html

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

Member Function Documentation

◆ led_bit()

constexpr uint32_t SonataGPIO::led_bit ( uint32_t index)
inlinestaticconstexpr

The output bit mask for a given user LED index.

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

References FirstLED, and LEDMask.

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

◆ led_off()

void SonataGPIO::led_off ( uint32_t index) volatile
inline

Switches on the LED at the given user LED index.

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

References led_bit().

◆ led_on()

void SonataGPIO::led_on ( uint32_t index) volatile
inline

Switches off the LED at the given user LED index.

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

References led_bit().

◆ led_toggle()

void SonataGPIO::led_toggle ( uint32_t index) volatile
inline

Toggles the LED at the given user LED index.

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

References led_bit().

◆ read_joystick()

SonataJoystick SonataGPIO::read_joystick ( ) volatile
inline

Returns the state of the joystick.

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

◆ read_switch()

bool SonataGPIO::read_switch ( uint32_t index) volatile
inline

Returns the value of the switch at the given user switch index.

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

References switch_bit().

◆ switch_bit()

constexpr uint32_t SonataGPIO::switch_bit ( uint32_t index)
inlinestaticconstexpr

The input bit mask for a given user switch index.

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

References FirstSwitch, and SwitchMask.

Referenced by read_switch().

Member Data Documentation

◆ arduinoShieldHeader

uint32_t SonataGPIO::arduinoShieldHeader

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

◆ arduinoShieldMask

uint32_t SonataGPIO::arduinoShieldMask

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

◆ debouncedInput

uint32_t SonataGPIO::debouncedInput

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

◆ debouncedThreshold

uint32_t SonataGPIO::debouncedThreshold

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

◆ FirstLED

uint32_t SonataGPIO::FirstLED = 4
staticconstexpr

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

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

Referenced by led_bit().

◆ FirstSwitch

uint32_t SonataGPIO::FirstSwitch = 5
staticconstexpr

The bit index of the first GPIO pin connected to a user switch.

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

Referenced by switch_bit().

◆ input

uint32_t SonataGPIO::input

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

◆ LastLED

uint32_t SonataGPIO::LastLED = 11
staticconstexpr

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

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

◆ LastSwitch

uint32_t SonataGPIO::LastSwitch = 13
staticconstexpr

The bit index of the last GPIO pin connected to a user switch.

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

◆ LEDCount

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

The number of user LEDs.

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

◆ LEDMask

uint32_t SonataGPIO::LEDMask = ((1 << LEDCount) - 1) << FirstLED
staticconstexpr

The mask covering the GPIO pins used for user LEDs.

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

Referenced by led_bit().

◆ output

uint32_t SonataGPIO::output

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

◆ raspberryPiHeader

uint32_t SonataGPIO::raspberryPiHeader

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

◆ raspberryPiMask

uint32_t SonataGPIO::raspberryPiMask

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

◆ SwitchCount

uint32_t SonataGPIO::SwitchCount = LastSwitch - FirstSwitch + 1
staticconstexpr

The number of user switches.

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

◆ SwitchMask

uint32_t SonataGPIO::SwitchMask
staticconstexpr
Initial value:
= ((1 << SwitchCount) - 1)
static constexpr uint32_t SwitchCount
The number of user switches.
static constexpr uint32_t FirstSwitch
The bit index of the first GPIO pin connected to a user switch.

The mask covering the GPIO pins used for user switches.

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

Referenced by switch_bit().


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