THE DESIGN CYCLE
// function
typedef struct _gpio_ioctl_cb_t {
unsigned char ioctl_code;
unsigned char value;
} gpio_ioctl_cb_t;
//THIS CODE FOUND IN application_thread
unsigned char leds;
gpio_ioctl_cb_t gpio_iocb;
hGpio = vos_dev_open(VOS_DEV_GPIO);
gpio_iocb.ioctl_code = VOS_IOCTL_GPIO_
SET_MASK;
gpio_iocb.value = 0xff;
// set all as output
vos_dev_ioctl(hGpio, &gpio_iocb);
THUMB DRIVE HEAVEN
Communicating with a thumb drive is just as easy
as controlling the bank of LEDs. The FTDI Vinculum-II
site contains detailed code examples of how to put a
thumb drive online, as well as the Vinculum-II toolchain
and a treasure trove of application notes. You’ve all
been asking me to deliver low cost projects with a
punch. I think I have succeeded. For about 100 bucks
you can go to thumb drive heaven and add the
Vinculum-II embedded dual USB host controller to your
Design Cycle. NV
I pulled the SET_MASK and GPIO
control block definitions from the
GPIO.h file and added them in the
code mix for clarity. Once the
gpio_iocb control block is instantiated,
it gets used as a tool to set the I/O
data direction. Just before the I/O pin
data direction is set, the GPIO device
is opened and its handle is returned
to hGpio. The Vinculum-II Evaluation
Board LEDs are all connected as
common anode with respect to the
power source. Thus, the Vinculum-II
drives the cathodes from its I/O pins.
These lines of code will illuminate all
of the LEDs we’ve defined:
Over 1.7 Million
Parts Online
leds = 0;
vos_dev_write(hGpio,&leds,1,NULL);
These lines of code will extinguish
all of the defined LEDs:
leds = 0xFF;
vos_dev_write(hGpio,&leds,1,NULL);
I agine the Possibilities.
Want to turn off LED0 only?
Here’s how we do it:
leds = LED0;
vos_dev_write(hGpio,&leds,1,NULL);
The vos_dev_write API call uses
the GPIO handle (hGpio) to identify
the GPIO pins that are driving the
LEDs and writes the value of leds to
the I/O port. Pretty clever, huh?
Scan with your smart
phone or mobile
device’s camera/
QR-Code reader.
mouser.com
Fred Eady can be reached at
fred@edtp.com.
FTDI
Vinculum-II Embedded Dual USB
Host Controller
Vinculum-II IDE
Vinculum-II Toolchain
www.ftdichip.com
SOURCES
WARNING: Designing with Hot, New Products
May Cause A Time-to-Market Advantage.
mouser.com (800) 346-6873
Mouser and Mouser Electronics are registered trademarks of Mouser Electronics, Inc. Other products, logos, and company names mentioned herein, may be trademarks of their respective o wners.
October 2010 21