libftdi Archives

Subject: How to use libftdi ftdi_set_bitmode function bitmask ?

From: Nicolas <nmassart+intra2net@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 20 Mar 2009 01:06:07 +0100
Hi,

Im really new to this sort of usb device developpement and C code (started yesterday), so my question is probably very low level. Sorry.

I built a small usb prototype based on MM232R module that lights a LED when PWREN# (12) pin goes low. It well works when the EEPROM is configured to have this pin switched on PWREN# event.

After that I configured the EEPROM to accept bitbang on this pin (the 3rd of the 4 bits capables to be used as general purpose I/O) in order to light my LED using a small C program based on libftdi.

So, I tried to use the ftdi_set_bitmode function, but I can't figure how to set the bitmask.
I would like to change level of the 3rd bit, but I'm messed up with bitmasks...
Sometimes it works, I tried all the bitmasks values from 0x00 to 0xFF and notices that some works. My LED lights sometimes.
Also I don't really know if I should use the bit as input or output.

To illustrate my problem, I can't understand why the bitmask value 0xA6 lights my LED :
    ftdi_set_bitmode(&ftdic, 0xA6, BITMODE_CBUS); // 0xA6 is 10100110 bits
and why 0x9A shut it down.
    ftdi_set_bitmode(&ftdic, 0x9A, BITMODE_CBUS); // 0x9A is 10011010 bits

What bitmasks should I use to change 3rd pin from low to high and high to low ? input or output ?

I now it's probably more a question of bitmask understanding than a libftdi problem, but any help or documentation URLs would be appreciated to understand this part and begin to learn using this library.

Thanks,
Nicolas.



libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx


Current Thread