Here's what I have so far, and it's correct near as I can tell (runs without 
segfault, error, or exiting... and I know what most of it is at this point):

int ft2232_bb_init(void) {
        int f;
        struct ftdi_context *ftdic = &ftdic_context;
        unsigned char buf[512];
        enum ftdi_interface ft2232_interface = INTERFACE_B;
                                
        if (ftdi_init(ftdic) < 0) {
                printf("ftdi_init failed\n");
                return EXIT_FAILURE; // TODO
        }

        f = ftdi_usb_open(ftdic, FTDI_VID, FTDI_PID);
        
        if (f < 0 && f != -5) {
                printf("Unable to open FTDI device: %d (%s)\n", f, 
ftdi_get_error_string(ftdic));
                exit(-1); // TODO
        }
                
        if (ftdi_set_interface(ftdic, ft2232_interface) < 0) {
                printf("Unable to select interface: %s\n", ftdic->error_str);
        }

        if (ftdi_usb_reset(ftdic) < 0) {
                printf("Unable to reset FTDI device\n");
        }
        if (ftdi_set_latency_timer(ftdic, 2) < 0) {
                printf("Unable to set latency timer\n");
        }                                                                       
 

        if (ftdi_write_data_set_chunksize(ftdic, 512)) {
                printf("Unable to set chunk size\n");
        }

        if (ftdi_set_bitmode(ftdic, 0xc0, BITMODE_BITBANG_NORMAL) < 0) {  // 
BITMODE_BITBANG_NORMAL = 1
                printf("Unable to set bitmode to bitbangin'\n");
        }

        return 0;
}


As long as you've not also run ftdi_usb_open(), this works fine. I'm having 
trouble figuring out what to do next though. Do I just send a 0x80 (set data 
bits lowbyte) ?

I'd like to blink some leds on BDBUS6 and 7, and I'd like to read two 
interrupts on BDBUS0 and 1. But it's not clicking for me what it is that I need 
to do.

John O.

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]   

Reply via email to