|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
Output-only GPIO wrapper intended for LEDs. More...
#include <led.hpp>


Public Member Functions | |
| Led (uint32_t pin, bool initial_on=false, GpioDriveStrength drive=GpioDriveStrength::mA4, bool active_low=false) | |
| Construct an LED output pin. | |
| void | Configure (const Config &config)=delete |
| Disallow generic reconfiguration. | |
| void | Reconfigure (bool initial_on=false, GpioDriveStrength drive=GpioDriveStrength::mA4, bool active_low=false) |
| Reconfigure LED output settings. | |
| void | Set (bool on) |
| Set the LED state. | |
| void | On () |
| Turn the LED on. | |
| void | Off () |
| Turn the LED off. | |
| void | Toggle () |
| Toggle the LED state. | |
Public Member Functions inherited from c7222::GpioOut | |
| GpioOut (uint32_t pin) | |
| Create a GPIO output with default configuration. | |
| virtual | ~GpioOut () |
| Destructor. | |
| GpioOut (uint32_t pin, const Config &config) | |
| Create a GPIO output with the given configuration. | |
| void | Configure (const Config &config) |
| Apply a new configuration. | |
| void | Write (bool value) |
| Write an output value. | |
| void | Toggle () |
| Toggle the pin output. | |
| uint32_t | GetPin () const |
| Return the GPIO number. | |
| Config | GetConfig () const |
| Return the cached configuration. | |
Public Member Functions inherited from c7222::NonCopyable | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| NonCopyable (NonCopyable &&)=default | |
| NonCopyable & | operator= (NonCopyable &&)=default |
Public Member Functions inherited from c7222::NonMovable | |
| NonMovable (const NonMovable &)=default | |
| NonMovable & | operator= (const NonMovable &)=default |
| NonMovable (NonMovable &&)=delete | |
| NonMovable & | operator= (NonMovable &&)=delete |
Additional Inherited Members | |
Protected Member Functions inherited from c7222::GpioOut | |
| void | ApplyConfig () |
| Apply internal configuration to the hardware. | |
Protected Member Functions inherited from c7222::NonCopyableNonMovable | |
| NonCopyableNonMovable ()=default | |
| ~NonCopyableNonMovable ()=default | |
Protected Member Functions inherited from c7222::NonCopyable | |
| NonCopyable ()=default | |
| ~NonCopyable ()=default | |
Protected Member Functions inherited from c7222::NonMovable | |
| NonMovable ()=default | |
| ~NonMovable ()=default | |
Protected Attributes inherited from c7222::GpioOut | |
| uint32_t | pin_ |
| GPIO pin number managed by this instance. | |
| Config | config_ |
| Cached configuration used to (re)apply platform settings. | |
Output-only GPIO wrapper intended for LEDs.
Design intent:
GpioOut and deletes Configure() to prevent accidental reconfiguration into input mode.On(), Off(), Set(), and Toggle() instead of raw GPIO writes.Default configuration:
Active-low support:
active_low flag controls the logical-to-physical mapping so callers can use On()/Off() without worrying about wiring.Reconfiguration note:
Reconfigure() after releasing PWM ownership to restore LED-safe GPIO settings.
|
explicit |
Construct an LED output pin.
| pin | GPIO number. |
| initial_on | Initial LED state (default: false/off). |
| drive | Pad drive strength (default: 4 mA). |
| active_low | If true, LED is active-low (GPIO low = on). |
|
delete |
Disallow generic reconfiguration.
This prevents accidentally switching the LED pin into input mode.
| void c7222::Led::Off | ( | ) |
Turn the LED off.

| void c7222::Led::On | ( | ) |
Turn the LED on.

| void c7222::Led::Reconfigure | ( | bool | initial_on = false, |
| GpioDriveStrength | drive = GpioDriveStrength::mA4, |
||
| bool | active_low = false |
||
| ) |
Reconfigure LED output settings.
This is intended for cases where the pin was temporarily used for PWM and then returned to GPIO control. It only exposes LED-safe settings.
| initial_on | Initial LED state (default: false/off). |
| drive | Pad drive strength (default: 4 mA). |
| active_low | If true, LED is active-low (GPIO low = on). |
| void c7222::Led::Set | ( | bool | on | ) |
Set the LED state.
| on | true = on, false = off. |

| void c7222::Led::Toggle | ( | ) |
Toggle the LED state.
Note: For active-low LEDs, toggling the GPIO level still toggles the LED.
