Peter's electronic projects
| command line |
description |
| controlio getport |
read the digital I/O port states |
| controlio setdir <n> |
set the digital I/O port
directions. Use bit 1 to set direction to input, bit 0 to set direction
to output <n> is a 16-bit decimal number between 0-65535 |
| controlio setport <n> |
set the digital I/O port output
states. Sets all output I/O pins. Use bit 1 to set output to HIGH, 0 to
set output to LOW <n> is a 16-bit decimal number between 0-65535 |
| controlio setbit <n> |
set the selected digital I/O
port output pins to HIGH. Use bit 1 to select I/O pins to set <n> is a 16-bit decimal number between 0-65535 |
| controlio clearbit <n> |
set the selected digital I/O
port output pins to LOW. Use bit 1 to select I/O pins to clear |
| controlio
getport output |
buffer[0] |
buffer[1] |
||||||||||||||
| I/O pin |
RC7 |
RC6 |
RC5 |
RC4 |
RC3 |
RC2 |
RC1 |
RC0 |
RB7 |
RB6 |
RB5 |
RB4 |
- |
- |
- |
- |
| controlio
setport <n> controlio setdir <n> controlio setbit <n> controlio clearbit <n> |
bit#7 |
bit#6 |
bit#5 |
bit#4 |
bit#3 |
bit#2 |
bit#1 |
bit#0 |
bit#15 |
bit#14 |
bit#13 |
bit#12 |
bit#11 |
bit#10 |
bit#9 |
bit#8 |
| command line example |
explanation |
| controlio setdir 65535 |
set all I/O pins as input |
| controlio getport |
Read the digital I/O port
states. The buffer is 16 bit long, and is
shown in hexadecimal. Output ports usually read back the state they are
set to. Input ports read their externally set state. Command output is: OK: buffer length = 2 |
| controlio setdir 0 |
set all I/O pins as output |
| controlio setport 0 |
set all output I/O pins LOW |
| controlio setport 12 |
set the RC2 and RC3 I/O pins
HIGH, other output pins LOW (works only on output pins) |
| controlio setbit 32768 |
set the RB7 output pin HIGH,
don't change other output pins (works only if RB7 is an output pin) |
| controlio clearbit 4097 |
set the RB4 and the RC0 output
pins LOW, don't change other output pins (works only if RB4 and RC0 are
output pins) |
| name |
setup bmRequestType |
setup bRequest |
setup wValue |
setup wLength |
response |
| GETPORT |
USB_TYPE_VENDOR,
USB_ENDPOINT_IN,
USB_RECIP_DEVICE |
0x53 |
unused |
8 |
2 bytes, I/O port states |
| SETPORT |
USB_TYPE_VENDOR,
USB_ENDPOINT_OUT, USB_RECIP_DEVICE |
0x54 |
I/O port states <n> |
0 |
0 bytes ACK |
| SETDIR |
USB_TYPE_VENDOR, USB_ENDPOINT_OUT, USB_RECIP_DEVICE | 0x55 |
I/O port directions <n> |
0 |
0 bytes ACK |
| SETBIT |
USB_TYPE_VENDOR, USB_ENDPOINT_OUT, USB_RECIP_DEVICE | 0x56 |
I/O port pin selection <n> |
0 |
0 bytes ACK |
| CLEARBIT |
USB_TYPE_VENDOR, USB_ENDPOINT_OUT, USB_RECIP_DEVICE | 0x57 |
I/O port pint selection <n> |
0 |
0 bytes ACK |
yum install gcc libusb-devel # for redhat/fedora- compile the code
apt-get install gcc libusb-dev # for debian/ubuntu
cd c; cc -o controlio controlio.c -lusb- check operation with the command
./controlio getport
svn co svn://svn.openwrt.org/openwrt/packages/libs/libusb- select the libusb library and the usbio package to be built
make menuconfig- build the libusb and usbio packages
make package/libusb/compile V=99
make package/usbio/compile V=99
if (usb_claim_interface(udev, 0) < 0)
{
printf("Unable to claim interface\n");
exit(-1);
}
- download and install libusb-win32 from sourceforgegcc -o controlio controlio.c /lib/libusb.a -I/include- connect the USB device to the computer
controlio getport
| directory |
description |
| c/ |
source code for the USB host,
please check section "controlling the I/O extender" |
| pic18f14k50/ |
source code and compiled HEX
file (firmware) for the Microchip pic18f14k50 microcontroller |