DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
|
Class provides initialization and R/W access to the discrete I/O pins of a DHCOM module. More...
#include <GPIO.h>
Public Types | |
enum | PORT { PORT_GPIO_A = 0, PORT_GPIO_B, PORT_GPIO_C, PORT_GPIO_D, PORT_GPIO_E, PORT_GPIO_F, PORT_GPIO_G, PORT_GPIO_H, PORT_GPIO_I, PORT_GPIO_J, PORT_GPIO_K, PORT_GPIO_L, PORT_GPIO_M, PORT_GPIO_N, PORT_GPIO_O, PORT_GPIO_P, PORT_GPIO_Q, PORT_GPIO_R, PORT_GPIO_S, PORT_GPIO_T, PORT_GPIO_U, PORT_GPIO_V, PORT_GPIO_W } |
DHCOM module GPIO ports enumeration. More... | |
enum | DIRECTION { DIRECTION_INPUT, DIRECTION_OUTPUT } |
Direction of a GPIO port (input or output) More... | |
enum | EDGE { EDGE_NONE = 0, EDGE_RISING = 1, EDGE_FALLING = 2, EDGE_BOTH = 3 } |
Public Member Functions | |
GPIO (const System &sys, PORT port) | |
GPIO (uint16_t pinInternal) | |
Constructs the GPIO object and defines which pin (internal number) it will represent. | |
~GPIO () | |
Destructs the GPIO object, closing it if necessary. | |
STATUS | open () |
Opens the GPIO pin for I/O operations. | |
STATUS | close () |
Closes the GPIO port. | |
bool | isOpen () const |
Checks if the GPIO port is open. | |
STATUS | setDirection (DIRECTION dir) |
Sets the direction of the I/O port. | |
STATUS | set (bool value) |
Sets the output pin state. | |
bool | get (STATUS *status=NULL) const |
Reads the pin state. | |
int16_t | pin () const |
Gets the internal pin number, represented by the port. | |
STATUS | edgeDetect (EDGE edge) |
int | fileDescriptor () const |
Class provides initialization and R/W access to the discrete I/O pins of a DHCOM module.
For different module types different number of pins is accessible. See the online wiki at http://xlon.de/wiki/index.php?title=DHCOM.
Direction of a GPIO port (input or output)
enum dhcom::GPIO::EDGE |
enum dhcom::GPIO::PORT |
DHCOM module GPIO ports enumeration.
dhcom::GPIO::GPIO | ( | uint16_t | pinInternal | ) |
Constructs the GPIO object and defines which pin (internal number) it will represent.
pinInternal | - the pin number, used by operating system driver. |
dhcom::GPIO::~GPIO | ( | ) |
Destructs the GPIO object, closing it if necessary.
STATUS dhcom::GPIO::close | ( | ) |
Closes the GPIO port.
int dhcom::GPIO::fileDescriptor | ( | ) | const |
bool dhcom::GPIO::get | ( | STATUS * | status = NULL | ) | const |
Reads the pin state.
bool dhcom::GPIO::isOpen | ( | ) | const |
Checks if the GPIO port is open.
STATUS dhcom::GPIO::open | ( | ) |
Opens the GPIO pin for I/O operations.
Before any set/get operations or setting the direction the port must be open.
int16_t dhcom::GPIO::pin | ( | ) | const |
Gets the internal pin number, represented by the port.
Warning: The internally used pin numbers depend on the target hardware.
STATUS dhcom::GPIO::set | ( | bool | value | ) |
Sets the output pin state.
value | - the value to set, true means high level, and false - low level. |
STATUS dhcom::GPIO::setDirection | ( | GPIO::DIRECTION | dir | ) |
Sets the direction of the I/O port.
dir | - the direction to set. |