oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
gpio.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
14#pragma once
15
16#include <ove/gpio.h>
17#include <ove/types.hpp>
18
19#ifdef CONFIG_OVE_GPIO
20
21namespace ove {
22
30namespace gpio {
31
39[[nodiscard]] inline int configure(unsigned int port, unsigned int pin,
40 ove_gpio_mode_t mode) {
41 return ove_gpio_configure(port, pin, mode);
42}
43
51[[nodiscard]] inline int set(unsigned int port, unsigned int pin,
52 int value) {
53 return ove_gpio_set(port, pin, value);
54}
55
62[[nodiscard]] inline int get(unsigned int port, unsigned int pin) {
63 return ove_gpio_get(port, pin);
64}
65
75[[nodiscard]] inline int irq_register(unsigned int port,
76 unsigned int pin,
77 ove_gpio_irq_mode_t mode,
78 ove_gpio_irq_cb callback,
79 void *user_data) {
80 return ove_gpio_irq_register(port, pin, mode, callback,
81 user_data);
82}
83
84// Undef RTOS macros that collide with our function names
85#ifdef irq_enable
86#undef irq_enable
87#endif
88#ifdef irq_disable
89#undef irq_disable
90#endif
91
98[[nodiscard]] inline int irq_enable(unsigned int port,
99 unsigned int pin) {
100 return ove_gpio_irq_enable(port, pin);
101}
102
109[[nodiscard]] inline int irq_disable(unsigned int port,
110 unsigned int pin) {
111 return ove_gpio_irq_disable(port, pin);
112}
113
114} /* namespace gpio */
115
116} // namespace ove
117
118#endif /* CONFIG_OVE_GPIO */
int irq_enable(unsigned int port, unsigned int pin)
Enables the interrupt for a GPIO pin (must be registered first).
Definition gpio.hpp:98
int get(unsigned int port, unsigned int pin)
Reads the current logic level of a GPIO pin.
Definition gpio.hpp:62
int configure(unsigned int port, unsigned int pin, ove_gpio_mode_t mode)
Configures a GPIO pin with the specified mode.
Definition gpio.hpp:39
int irq_register(unsigned int port, unsigned int pin, ove_gpio_irq_mode_t mode, ove_gpio_irq_cb callback, void *user_data)
Registers an interrupt callback for a GPIO pin.
Definition gpio.hpp:75
int irq_disable(unsigned int port, unsigned int pin)
Disables the interrupt for a GPIO pin.
Definition gpio.hpp:109
int set(unsigned int port, unsigned int pin, int value)
Drives a GPIO output pin to the specified logic level.
Definition gpio.hpp:51
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:19
Common type definitions and concepts for the C++ wrapper layer.