> #include <stdio.h>
> #include <stdint.h>
> #include <string.h>
> #include <stdlib.h>
> #include <ctype.h>
> #include <ftdi.h>
>
> #define FTDI_VID 0x0403
> #define FTDI_PID 0x6010
>
> #define BITMODE_BITBANG_NORMAL 1
> #define BITMODE_BITBANG_SPI 2
>
> static struct ftdi_context ftdic_context;
>
> int main(void) {
> int ret;
> unsigned int i;
> unsigned char c = 0;
>
> ftdi_usb_open(&ftdic_context, FTDI_VID, FTDI_PID);
> ftdi_set_interface(&ftdic_context, INTERFACE_B);
> ftdi_set_bitmode(&ftdic_context, 0xc0, BITMODE_BITBANG_NORMAL);
>
> // Trying to blink some lights.
> printf("\nNow let's try to blinkenlights...\n");
> for (i = 0; i < 20; i++) {
> c ^= 0xc0;
> ftdi_write_data(&ftdic_context, &c, 1);
> sleep(1);
> }
>
> return EXIT_SUCCESS;
> }
This blinks both simultaneously. Blinking either separately is easy enough...
but I'm having trouble figuring out how to get this working with my SPI code on
interface A. I can't ftdi_usb_open() two ftdi_context objects... though having
one for each seems to be the right direction to go.
After I run my spi_init() function, I need to copy the context object, but it's
not obvious what of its guts need to be copied. Do I just copy the whole thing
and run set_interface on it?
Thanks,
John O.
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|