DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions
dhcom::GPIO Class Reference

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
 

Detailed Description

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.

Member Enumeration Documentation

Direction of a GPIO port (input or output)

Enumerator:
DIRECTION_INPUT 

the pin used as input

DIRECTION_OUTPUT 

the pin used as output

Enumerator:
EDGE_NONE 

the pin used as input

EDGE_RISING 

the pin used as output

EDGE_FALLING 

the pin used as output

EDGE_BOTH 

the pin used as output

DHCOM module GPIO ports enumeration.

Enumerator:
PORT_GPIO_A 
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 

Constructor & Destructor Documentation

dhcom::GPIO::GPIO ( const System sys,
PORT  port 
)
dhcom::GPIO::GPIO ( uint16_t  pinInternal)

Constructs the GPIO object and defines which pin (internal number) it will represent.

Parameters
pinInternal- the pin number, used by operating system driver.
dhcom::GPIO::~GPIO ( )

Destructs the GPIO object, closing it if necessary.

Member Function Documentation

STATUS dhcom::GPIO::close ( )

Closes the GPIO port.

Returns
- can be STATUS_SUCCESS or STATUS_DEVICE_CLOSE_FAILED.
STATUS dhcom::GPIO::edgeDetect ( EDGE  edge)
int dhcom::GPIO::fileDescriptor ( ) const
bool dhcom::GPIO::get ( STATUS status = NULL) const

Reads the pin state.

Returns
- true if the pin was in high state, false otherwise
bool dhcom::GPIO::isOpen ( ) const

Checks if the GPIO port is open.

Returns
true is the 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.

Returns
- can be STATUS_SUCCESS, STATUS_DEVICE_OPEN_FAILED, STATUS_DEVICE_DOESNT_EXIST or STATUS_HARDWARE_UNDEFINED.
int16_t dhcom::GPIO::pin ( ) const

Gets the internal pin number, represented by the port.

Returns
- the pin number, used by the OS driver.

Warning: The internally used pin numbers depend on the target hardware.

STATUS dhcom::GPIO::set ( bool  value)

Sets the output pin state.

Parameters
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.

Parameters
dir- the direction to set.

The documentation for this class was generated from the following file: