On Tue, May 17, 2011 at 8:33 AM, Thomas Jarosch
<[email protected]> wrote:
> On 05/13/2011 05:41 PM, Mark Rages wrote:
>>> I thought about releasing libftdi 0.19 next week.
>>> Any outstanding issues/patches?
>>
>> ftdi_get_bitmode()
>
> "examples/bitbang_cbus.c" might help.
>
> Thomas

But I need to use the bitbang pins and the cbus pins at the same time.

The attached file shows what doesn't work:  I want to maintain the CTS
pin high, but when I set BITMODE_CBUS it drops the CTS pin.  When I
set BITMODE_BITBANG it drops the CTS pin again.

The attached file demonstrates the problem.  Run it and watch the CTS
pin toggle in the mainloop.

As a workaround I can set BITBANG_CBUS | BITMODE_BITBANG and it will
maintain CTS state and let me address the CBUS pins (the same mask
fortuitously works for both sets of pins), but then ftdi_read_pins()
reads the bitbang pins instead of the cbus pins.   The D2xx function
FD_GetBitMode() does what I need (in Windows; it is broken in Linux)
but I would prefer to use libftdi instead.

Is there a preferred way to address the CBUS pins and remember the
state of the bitbang pins?

Regards,
Mark
markrages@gmail
-- 
Mark Rages, Engineer
Midwest Telecine LLC
[email protected]


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]   
#include <stdio.h>
#include <ftdi.h>

struct ftdi_context ftdic;

int main(void) {

    int r,i;
    
    r=ftdi_init(&ftdic); if (r) exit(-r);
    r=ftdi_usb_open(&ftdic, 0x0403, 0x6001); if ((r) && (r != -5)) exit(-r);


    printf("ftdi open succeeded\n");

    // FTDI cable assignments:
#define BIT_TXD   (1<<0) //  1: TXD
#define BIT_RXD   (1<<1) //  2: RXD
#define BIT_RTS   (1<<2) //  4: RTS
#define BIT_CTS   (1<<3) //  8: CTS
#define BIT_DTR   (1<<4) // 16: DTR
#define BIT_DSR   (1<<5) // 32: DSR
#define BIT_DCD   (1<<6) // 64: DCD
#define BIT_RI    (1<<7) //128: RI

#define BIT_VOLTS_CS BIT_CTS
#define BIT_AMPS_CS BIT_DSR
#define BIT_PORTX_CS BIT_DCD

#define BIT_SPI_CK (1<<0)
#define BIT_SPI_MOSI (1<<1) 
#define BIT_SPI_MISO (1<<2) // input
#define BIT_ENABLE (1<<3)

    r=ftdi_set_bitmode(&ftdic, BIT_VOLTS_CS , BITMODE_BITBANG);  
    if (r) exit(-r);

    char c[]="\0";
    c[0] |= BIT_VOLTS_CS;

    r=ftdi_write_data(&ftdic,c,1);  if (r!=1) exit(-1);
    
    while (1) {
      r=ftdi_set_bitmode(&ftdic, (BIT_VOLTS_CS | BIT_AMPS_CS | BIT_PORTX_CS), BITMODE_BITBANG);  if (r) exit(-r);

      r=ftdi_set_bitmode(&ftdic, 0xff, BITMODE_CBUS ); if (r) exit(-r);
    }
}


Reply via email to