|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
Pico W board-level GPIO layout and helpers (C API). More...
#include <stdbool.h>#include <stdint.h>

Go to the source code of this file.
Enumerations | |
| enum | c7222_led_type { C7222_PICO_W_LED3_GREEN = 16 , C7222_PICO_W_LED3_RED = 17 , C7222_PICO_W_LED2_GREEN = 18 , C7222_PICO_W_LED2_RED = 19 , C7222_PICO_W_LED1_GREEN = 20 , C7222_PICO_W_LED1_RED = 21 } |
| Logical LED identifiers mapped to GPIO pins. More... | |
| enum | c7222_button_type { C7222_PICO_W_BUTTON_B1 = 2 , C7222_PICO_W_BUTTON_B2 = 3 , C7222_PICO_W_BUTTON_B3 = 4 , C7222_PICO_W_BUTTON_B4 = 5 } |
| Logical button identifiers mapped to GPIO pins. More... | |
| enum | c7222_gpio_event_type { C7222_GPIO_EVENT_LEVEL_LOW = 0x1u , C7222_GPIO_EVENT_LEVEL_HIGH = 0x2u , C7222_GPIO_EVENT_FALL = 0x4u , C7222_GPIO_EVENT_RISE = 0x8u } |
| GPIO IRQ event bits compatible with Pico SDK GPIO IRQ flags. More... | |
Functions | |
| void | c7222_pico_w_board_init_gpio (void) |
| Initialize all LED and button GPIOs for the board. | |
| void | c7222_pico_w_board_init_led (enum c7222_led_type led) |
| Initialize a single LED GPIO. | |
| void | c7222_pico_w_board_button_init (enum c7222_button_type button, void(*handler)(uint32_t, uint32_t), uint32_t events, bool enabled) |
| Initialize a button GPIO and optionally attach an IRQ handler. | |
| bool | c7222_pico_w_board_button_read (enum c7222_button_type button) |
| Read the current button GPIO level. | |
| bool | c7222_pico_w_board_led_read (enum c7222_led_type led) |
| Read the current LED state. | |
| void | c7222_pico_w_board_led_on (enum c7222_led_type led) |
| Turn an LED ON (active-low). | |
| void | c7222_pico_w_board_led_off (enum c7222_led_type led) |
| Turn an LED OFF (active-low). | |
| void | c7222_pico_w_board_led_toggle (enum c7222_led_type led) |
| Toggle an LED output. | |
| bool | c7222_pico_w_onboard_led_init (void) |
| Initialize the Pico W on-board LED. | |
| void | c7222_pico_w_onboard_led_set (bool on) |
| Set the on-board LED state. | |
| void | c7222_pico_w_onboard_led_on (void) |
| Turn the on-board LED ON. | |
| void | c7222_pico_w_onboard_led_off (void) |
| Turn the on-board LED OFF. | |
| void | c7222_pico_w_onboard_led_toggle (void) |
| Toggle the on-board LED. | |
| bool | c7222_pico_w_onboard_led_read (void) |
| Read the on-board LED state. | |
Pico W board-level GPIO layout and helpers (C API).
This header defines the GPIO layout for LEDs and buttons on the C7222 Pico W board and provides C-style helper functions for initializing and accessing those pins, plus a thin C wrapper for the Pico W on-board LED. The implementation is in libs/elec_c7222/devices/platform/rpi_pico/c7222_pico_w_board.c.
Note: This header is intended for C code. For C++ projects, prefer the c7222_pico_w_board.hpp API and its associated classes (PicoWBoard, Led, and Button).
c7222_pico_w_board_led_on/off/read). | enum c7222_button_type |
| enum c7222_led_type |
| void c7222_pico_w_board_button_init | ( | enum c7222_button_type | button, |
| void(*)(uint32_t, uint32_t) | handler, | ||
| uint32_t | events, | ||
| bool | enabled | ||
| ) |
Initialize a button GPIO and optionally attach an IRQ handler.
| button | Button identifier. |
| handler | IRQ callback (may be NULL). |
| events | Bitmask of c7222_gpio_event_type. |
| enabled | Enable or disable the IRQ for this button. |
Implementation assumptions:
gpio_set_irq_enabled_with_callback if a handler is provided.
| bool c7222_pico_w_board_button_read | ( | enum c7222_button_type | button | ) |
Read the current button GPIO level.

| void c7222_pico_w_board_init_gpio | ( | void | ) |
Initialize all LED and button GPIOs for the board.
Implementation assumptions:

| void c7222_pico_w_board_init_led | ( | enum c7222_led_type | led | ) |
Initialize a single LED GPIO.
| led | LED identifier to initialize. |
| void c7222_pico_w_board_led_off | ( | enum c7222_led_type | led | ) |
Turn an LED OFF (active-low).

| void c7222_pico_w_board_led_on | ( | enum c7222_led_type | led | ) |
Turn an LED ON (active-low).

| bool c7222_pico_w_board_led_read | ( | enum c7222_led_type | led | ) |
Read the current LED state.
| void c7222_pico_w_board_led_toggle | ( | enum c7222_led_type | led | ) |
Toggle an LED output.

| bool c7222_pico_w_onboard_led_init | ( | void | ) |
Initialize the Pico W on-board LED.
Uses either PICO_DEFAULT_LED_PIN or CYW43_WL_GPIO_LED_PIN depending on build configuration. Sets an internal initialization flag.
| void c7222_pico_w_onboard_led_off | ( | void | ) |
Turn the on-board LED OFF.
| void c7222_pico_w_onboard_led_on | ( | void | ) |
Turn the on-board LED ON.
| bool c7222_pico_w_onboard_led_read | ( | void | ) |
Read the on-board LED state.
| void c7222_pico_w_onboard_led_set | ( | bool | on | ) |
Set the on-board LED state.
| on | true for ON, false for OFF. |
| void c7222_pico_w_onboard_led_toggle | ( | void | ) |
Toggle the on-board LED.