Digital Outputs
Each of DLN-series adapter pins can be configured as a general purpose digital output.
This can be done using DlnGpioPortSetCfg() function.
You must specify the corresponding handle and port values, as well as configure validFields, mask and config parameters.
In order to configure pin direction, a user must set the first bit in a validFields parameter to 1. This way the corresponding configuration field (isOutput) becomes valid.
The config parameter contains the DLN_GPIO_PORT_CONFIG structure, which is filled with new configuration values to be set. Its second field - isOutput - triggers the pin direction and must be set to 1 for output.
The mask parameter in this case is used to define the I/O lines, whose I/O configuration must be triggered. Set the bits, corresponding to the pins to be affected to 1.
If the pin is not configured as a GPIO - line, you must set the isEnabled parameter, as well as zeroth bit in the validFields parameter to 1.
The third field of the structure - outputValue - is used to set an output level of an I/O line and must be set to 0 or 1 for logic 0 and logic 1 respectively. In order to change a port's output value, a user must set the second bit in the validFields parameter to 1. This way we can simultaneously connect a pin to GPIO module, configure it as output and set its output value.
We can further change the output values of digital outputs using the DlnGpioPortSetOutVal() function.
Digital outputs can function in the Open Drain mode. A user can also enable embedded Pull-Up resistors for each of the digital outputs.
The current level on each I/O line can be determined using the DlnGpioPortGetVal() function. This function returns levels on I/O lines regardless of their configuration, whether they are configured as GPIO inputs or outputs or even not connected to GPIO module at all. Another function - DlnGpioPortGetOutVal() retrieves pin's output values. If the pin is configured as digital output, this value matches the one returned by the DlnGpioPortGetVal() function. If the pin is not configured as digital output, the value is taken from an internal latch buffer.
2006-2012