|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
Singleton access to platform-specific devices and initialization. More...
#include <platform.hpp>


Public Member Functions | |
| bool | Initialize () |
| Initialize platform-specific hardware. | |
| bool | EnsureArchInitialized () |
| Ensure the platform architecture is initialized. | |
| OnBoardLED * | GetOnBoardLed () |
| Access the on-board LED. | |
| OnChipTemperatureSensor * | GetOnChipTemperatureSensor () |
| Access the on-chip temperature sensor. | |
| PicoWBoard * | GetPicoWBoard () |
| Access the PicoWBoard singleton. | |
| Led & | GetLed (PicoWBoard::LedId id) |
| Get a board LED by logical ID. | |
| Button & | GetButton (PicoWBoard::ButtonId id) |
| Get a board button by logical ID. | |
| std::unique_ptr< PwmOut > | CreateLedPwm (PicoWBoard::LedId id, uint8_t dim) |
| Create a PWM output for a board LED pin. | |
| void | EnableButtonIrq (PicoWBoard::ButtonId id, GpioInputEvent events, std::function< void(uint32_t)> handler) |
| Enable IRQs for a board button. | |
| void | DisableButtonIrq (PicoWBoard::ButtonId id) |
| Disable IRQs for a board button. | |
| bool | IsButtonPressed (PicoWBoard::ButtonId id) |
| Read the current state of a board button (true if pressed). | |
| void | ToggleLed (PicoWBoard::LedId id) |
| Toggle a board LED. | |
| void | LedOn (PicoWBoard::LedId id) |
| Turn a board LED on. | |
| void | LedOff (PicoWBoard::LedId id) |
| Turn a board LED off. | |
| bool | IsInitialized () const |
| Return true if platform initialization has completed. | |
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 |
Static Public Member Functions | |
| static Platform * | GetInstance () |
| Get the singleton instance. | |
Timing helpers | |
These static wrappers provide access to common Pico SDK timing utilities for main-loop control and low-power waiting. Callers may use these without a Platform instance. | |
| static void | SleepMs (uint32_t ms) |
| Sleep for a number of milliseconds. | |
| static void | SleepUs (uint64_t us) |
| Sleep for a number of microseconds. | |
| static void | SleepUntil (std::chrono::steady_clock::time_point target) |
| Sleep until a steady-clock time point. | |
| static void | TightLoopContents () |
| Body for tight polling loops (no-op hook). | |
Additional Inherited Members | |
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 | |
Singleton access to platform-specific devices and initialization.
Purpose:
OnBoardLED, OnChipTemperatureSensor, PicoWBoard, Led, Button).Dependencies:
OnBoardLED: accessed via GetOnBoardLed(); must be explicitly initialized by the user.OnChipTemperatureSensor: accessed via GetOnChipTemperatureSensor(); must be explicitly initialized by the user.PicoWBoard: accessed via GetPicoWBoard() and the convenience LED/button helpers; provides higher-level board IO access.Pico platform initialization:
Initialize() calls EnsureArchInitialized(), which initializes the Pico SDK architecture layer (including CYW43 on Pico W).Proper usage:
Platform::Initialize() once early.PicoWBoard directly.Typical usage:
On-board LED (explicit init required):
Temperature sensor (explicit init required):
PicoWBoard LEDs and buttons:
Timing helpers:
| std::unique_ptr< PwmOut > c7222::Platform::CreateLedPwm | ( | PicoWBoard::LedId | id, |
| uint8_t | dim | ||
| ) |
Create a PWM output for a board LED pin.
| id | Board LED identifier. |
| dim | Brightness 0-255 (0 = off, 255 = fully on). |
Notes:
Led and PwmOut at the same time. If you previously used Led, stop using it and allow PWM to take over. 
|
inline |
Disable IRQs for a board button.

|
inline |
Enable IRQs for a board button.


| bool c7222::Platform::EnsureArchInitialized | ( | ) |
Ensure the platform architecture is initialized.
|
inline |
Get a board button by logical ID.

|
static |
Get the singleton instance.

|
inline |
Get a board LED by logical ID.


|
inline |
Access the on-board LED.
Note: Call Initialize() first. The LED's own Initialize() must be called explicitly by the user; Platform does not auto-initialize it.
Example:
Access the on-board LED singleton.

|
inline |
Access the on-chip temperature sensor.
Note: Call Initialize() first. The sensor's own Initialize() must be called explicitly by the user; Platform does not auto-initialize it.
Example:
Access the on-chip temperature sensor singleton.

|
inline |
Access the PicoWBoard singleton.


| bool c7222::Platform::Initialize | ( | ) |
Initialize platform-specific hardware.
This performs architecture-level initialization (e.g., CYW43 on Pico W). It does not automatically initialize the on-board LED or temperature sensor; those must be initialized explicitly by the user.

|
inline |
Read the current state of a board button (true if pressed).


|
inline |
Return true if platform initialization has completed.
|
inline |
Turn a board LED off.

|
inline |
Turn a board LED on.

|
static |
Sleep for a number of milliseconds.
| ms | Milliseconds to sleep. |
|
static |
Sleep until a steady-clock time point.
| target | Target time point. |
|
static |
Sleep for a number of microseconds.
| us | Microseconds to sleep. |
|
static |
Body for tight polling loops (no-op hook).
|
inline |
Toggle a board LED.
