int eth32_set_direction(eth32 handle, int port, int direction);
This function sets the direction register for a digital I/O port, which configures each pin (bit) of the port as an input or output. The direction of each bit of the port can be set individually, meaning that some bits of the port can be inputs at the same time that other bits on the same port are outputs. A 1-bit in the direction register causes the corresponding bit of the port to be put into output mode, while a 0-bit specifies input mode. For example, a value of 0xF0 would put bits 0-3 into input mode and bits 4-7 into output mode.
handle - The value returned by the eth32_open function.
port - The port number (0-5).
direction - The new direction register for the port.
This function returns zero on success and a negative error code on failure. Please see the Error Codes section for possible error codes.
Port 3 shares its pins with the analog channels. When the ADC is enabled, all pins of port 3 are forced into input mode. The direction register of port 3 cannot be modified while the ADC is enabled.
The valid range for the direction parameter is any 8-bit number (ranges from 0 to 255). However, note that because ports 4 and 5 are single-bit ports, only bit 0 will have any effect on those ports.
For your convenience, constants for the direction parameter are provided that configure the port bits to be all inputs or all outputs. These are, respectively, DIR_INPUT and DIR_OUTPUT.
eth32 handle; int result; // .... Your code that establishes a connection here // Configure all odd bits of port 0 as inputs and even bits as outputs // Direction parameter of 10101010 binary, which is 0xAA hex or 170 decimal result=eth32_set_direction(handle, 0, 0xAA); if(result) { // handle error }