Hi all,
I would like to manual control DTR pin on FT232R (SSOP). Simplified
example is:
#include <stdio.h>
#include <ftdi.h>
struct ftdi_context *ftdi;
int ftdi_vid = 0xa600, ftdi_pid = 0xe112;
int i, ret, speed = 9600;
int main(int argc, char *argv[]){
ftdi = ftdi_new();
if (!ftdi){
printf("Can't init ftdi library");
return 1;
}
printf("ftdi_open %04x:%04x\n", ftdi_vid, ftdi_pid);
ret=ftdi_usb_open(ftdi, ftdi_vid, ftdi_pid);
if (ret){
printf("Can't open ftdi device %04x:%04x, error=%d %s",
ftdi_vid, ftdi_pid, ret, ftdi_get_error_string(ftdi));
if (ret==-8) printf("Maybe try to add user %s into proper group
or run program as root", getenv("USER"));
ftdi_free(ftdi);
return ret;
}
ret=ftdi_set_baudrate(ftdi, speed);
if (ret){
printf("Can't set baudrate %d, error=%d %s", speed, ret,
ftdi_get_error_string(ftdi));
ftdi_free(ftdi);
return ret;
}
while(1){
ret = ftdi_setdtr(ftdi, i);
printf("ftdi_dtr(%d) = %d\n", i, ret);
usleep(100000);
i = !i;
}
}
Output is:
ftdi_dtr(1) = 0
ftdi_dtr(0) = 0
ftdi_dtr(1) = 0
ftdi_dtr(0) = 0
........
But at pin 2 I can't see any change, it is in log.1. What is wrong?
Hardware is good, If I use bitmode 1, I can turn DTR by changing bit 4
(mask 0x10).
Thank you Lada
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|