USB-ISS Multifunction USB Communications Module
I/O Mode - Technical Specification
The are three commands for I/O operations. These are:
| SETPINS | 0x63 | Used to set output pins high or low |
| GETPINS | 0x64 | Returns the state of all input and output pins |
| GETAD | 0x65 | Returns the analogue value on the pin. |
SETPINS
The SETPINS command only operates on pins that have been set as output pins.
Digital or analogue input pins, or pins that are used for I2C or serial are not
affected. The command is:
| SETPINS command (0x63) | Pin States |
Bits within the Pin States byte define which pins are high or low as follows:
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| x | x | x | x | I/O4 | I/O3 | I/O2 | I/O1 |
The response is single byte containing ACK (0xFF) if the command was successful or NACK (0x00) if it failed.
GETPINS
This is used to get the current state of all digital I/O pins.
Just send the single byte:
| GETPINS command (0x64) |
The response is a single byte indicating the Pin States as defined above.
GETAD
This is a two byte command.
| GETAD command (0x65) | Channel (1-4) |
The GETAD command will convert the requested channel (I/O pin number) and return the two byte result. The result is the high byte and low byte of a 16-bit number.
| Result High Byte | Result Low Byte |
The A/D conversion is a 10-bit conversion so the range is 0-1023
for a voltage swing of Vss to Vcc on the pin.
For example if you get a reading of 678, this is 0x02A6 in hex. So the high byte
would be 0x02 and the low byte would be 0xA6.
And if the result is 0x00, 0x3D, then this is 0x003D or 61 in decimal.
If you try to convert a channel which is not setup as an analogue pin or the channel is outside the range 1-4 then the result will be 0x0000.