CrossGuard
|
Implementation of the stub functions for the pigpio library. This stub is used for environments not running Linux on ARM hardware. Created by Saleem Hamo on 20/03/2024. More...
#include "pigpio_stub.h"
#include "utils/Logger.h"
#include <map>
#include <functional>
#include <vector>
#include <string>
Functions | |
int | gpioInitialise () |
Initialize the GPIO simulation. | |
void | gpioTerminate () |
Terminate the GPIO simulation. | |
void | gpioSetMode (unsigned pin, unsigned mode) |
Set the mode of a GPIO pin. | |
void | gpioWrite (unsigned pin, unsigned level) |
Write a level to a GPIO pin. | |
int | gpioRead (unsigned pin) |
Read the level of a GPIO pin. | |
void | gpioDelay (unsigned micros) |
Simulate a delay in microseconds. | |
unsigned | gpioTick () |
Get the current value of the simulated tick counter. | |
int | gpioSetAlertFuncEx (unsigned pin, void(*func)(int, int, unsigned, void *), void *user) |
Set a callback function for GPIO pin alert events. | |
void | simulateCallback (unsigned pin, int level, unsigned tick) |
Simulate a callback function call for a specific GPIO pin. | |
Implementation of the stub functions for the pigpio library. This stub is used for environments not running Linux on ARM hardware. Created by Saleem Hamo on 20/03/2024.
void gpioDelay | ( | unsigned | micros | ) |
Simulate a delay in microseconds.
Increments the simulatedTick counter by the delay amount.
micros | The number of microseconds to delay. |
int gpioInitialise | ( | ) |
Initialize the GPIO simulation.
Clears the pin states and resets the simulated tick counter.
int gpioRead | ( | unsigned | pin | ) |
Read the level of a GPIO pin.
Returns the stored state if available, otherwise defaults to LOW.
pin | The GPIO pin number to read. |
int gpioSetAlertFuncEx | ( | unsigned | pin, |
void(*)(int, int, unsigned, void *) | func, | ||
void * | user ) |
Set a callback function for GPIO pin alert events.
This function stores the callback function and user data for the specified GPIO pin.
pin | The GPIO pin number. |
func | The callback function to set. |
user | A user-defined pointer passed to the callback function. |
void gpioSetMode | ( | unsigned | pin, |
unsigned | mode ) |
Set the mode of a GPIO pin.
This function logs the mode setting but does not simulate it.
pin | The GPIO pin number. |
mode | The mode to set for the pin (input or output). |
void gpioTerminate | ( | ) |
Terminate the GPIO simulation.
Clears the pin states. Optional in this implementation.
unsigned gpioTick | ( | ) |
Get the current value of the simulated tick counter.
void gpioWrite | ( | unsigned | pin, |
unsigned | level ) |
Write a level to a GPIO pin.
Saves the level of the pin in a simulation map.
pin | The GPIO pin number. |
level | The level to write to the pin (high or low). |
void simulateCallback | ( | unsigned | pin, |
int | level, | ||
unsigned | tick ) |
Simulate a callback function call for a specific GPIO pin.
This function calls all the registered callback functions for the specified GPIO pin with the provided level and tick values.
pin | The GPIO pin number for which to simulate the callback. |
level | The level value to pass to the callback function. |
tick | The tick value to pass to the callback function. |