FluxSand 1.0
FluxSand - Interactive Digital Hourglass
|
#include <bsp_gpio.hpp>
Public Types | |
using | Callback = std::function< void()> |
Public Member Functions | |
Gpio (const std::string &chip_name, unsigned int line_num, bool is_output, int default_value=1) | |
~Gpio () | |
void | Write (int value) |
int | Read () const |
void | EnableInterruptRisingEdgeWithCallback (Callback cb) |
Private Member Functions | |
void | InterruptWaitLoop () |
Private Attributes | |
gpiod_chip * | chip_ |
gpiod_line * | line_ {} |
unsigned int | line_num_ |
bool | is_output_ |
std::atomic< bool > | running_ {false} |
std::thread | interrupt_thread_ |
Callback | callback_ |
Gpio class
Handles GPIO initialization, configuration (input/output), read/write operations, and interrupt callback support.
Definition at line 19 of file bsp_gpio.hpp.
using Gpio::Callback = std::function<void()> |
Definition at line 21 of file bsp_gpio.hpp.
|
inline |
Constructor
chip_name | GPIO chip name, e.g., "gpiochip0" |
line_num | GPIO line number |
is_output | true for output mode, false for input mode |
default_value | Initial value for output mode (default: 1) |
Definition at line 31 of file bsp_gpio.hpp.
|
inline |
Destructor
Releases allocated resources and stops interrupt thread.
Definition at line 61 of file bsp_gpio.hpp.
|
inline |
Enable rising edge interrupt and register callback.
This starts a background thread to monitor GPIO events.
cb | Callback function to be invoked on rising edge. |
Definition at line 109 of file bsp_gpio.hpp.
|
inlineprivate |
Background thread loop that waits for GPIO rising edge events.
Definition at line 134 of file bsp_gpio.hpp.
|
inline |
Read the current GPIO value.
Definition at line 94 of file bsp_gpio.hpp.
|
inline |
Write a value to the GPIO line (only valid in output mode).
value | Value to write (0 or 1) |
Definition at line 82 of file bsp_gpio.hpp.
|
private |
Definition at line 154 of file bsp_gpio.hpp.
|
private |
Definition at line 147 of file bsp_gpio.hpp.
|
private |
Definition at line 153 of file bsp_gpio.hpp.
|
private |
Definition at line 150 of file bsp_gpio.hpp.
|
private |
Definition at line 148 of file bsp_gpio.hpp.
|
private |
Definition at line 149 of file bsp_gpio.hpp.
|
private |
Definition at line 152 of file bsp_gpio.hpp.