| aDig_Config | Index |
Definition:
Parameters:
| index | - | The index of the digital I/O pin to configure. |
| flags | - | The configuration bits for the digital I/O pin. |
Return Value:
Description:
This routine configures a digital I/O pin as an input or output. It also configures the timer modes and input polling for a pin configured as an input.
Five defined flag values may be used to configure digital I/O pins:
| ADIG_INPUT | 1 | Set to make pin an input. Clear to make pin an output. |
| ADIG_POLLENA | 2 | Set to enable transition polling for the pin. Clear to disable transition polling for the pin. |
| ADIG_POLLHI | 4 | Set to trigger reflex on low-to-high transition when polling enabled. Clear to trigger reflex on high-to-low transition when polling enabled. |
| ADIG_TMRHI | 8 | Set to measure high pulses or elapsed time till pin goes high. Clear to measure low pulses or elapsed time till pin goes low. |
| ADIG_TMRWID | 16 | Set to make pin a pulse width timer. Clear to make pin an edge (elapsed time) timer. |
The defined value ADIG_OUTPUT may be used to configure a pin as an output. The timer flags are only relevant for inputs 1-4 on the BrainStem GP 1.0 Module.
Example:
aDig_Config(3, ADIG_INPUT | ADIG_TMRWID | ADIG_TMRHI);
This would configure digital I/O pin 3 as an input. When used as a timer, the pin will measure the duration of high pulse widths. Polling is disabled for the pin.
aDig_Config(3, ADIG_INPUT);
This would configure digital I/O pin 3 as an input. When used as a timer, the pin will measure the time until a high to low transition occurs on the pin. Polling is disabled for the pin.
aDig_Config(4, ADIG_INPUT | ADIG_POLLENA | ADIG_POLLHI);
This would configure digital I/O pin 3 as an input. Polling is enabled and the module will issue a reflex when the pin transitions from low to high.
aDig_Config(2, ADIG_OUTPUT);
This would configure digital I/O pin 2 as an output.
Related: