orion-rf.piolibdepsesp32-s3-n16r8RF24utilitypigpiogpio.cpp
| 1 | /* |
| 2 | * GPIO Functions |
| 3 | */ |
| 4 | #include <pigpio.h> |
| 5 | #include "gpio.h" |
| 6 | |
| 7 | bool initialized = 0; |
| 8 | |
| 9 | GPIO::GPIO() |
| 10 | { |
| 11 | } |
| 12 | |
| 13 | GPIO::~GPIO() |
| 14 | { |
| 15 | gpioTerminate(); |
| 16 | } |
| 17 | |
| 18 | void GPIO::open(int port, int DDR) |
| 19 | { |
| 20 | if (!initialized) { |
| 21 | gpioInitialise(); |
| 22 | } |
| 23 | initialized = true; |
| 24 | gpioSetMode(port, PI_OUTPUT); |
| 25 | } |
| 26 | |
| 27 | void GPIO::close(int port) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | int GPIO::read(int port) |
| 32 | { |
| 33 | return gpioRead(port); |
| 34 | } |
| 35 | |
| 36 | void GPIO::write(int port, int value) |
| 37 | { |
| 38 | gpioWrite(port, value); |
| 39 | } |