|
From: Alain P. <apa...@us...> - 2002-04-22 14:22:55
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btinit.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added option -D that allow to use RTS to reset a module if you don't use fl=
ow control.
The diff of the modified file(s):
--- btinit.c 16 Oct 2001 15:02:20 -0000 1.17
+++ btinit.c 22 Apr 2002 14:22:53 -0000 1.18
@@ -140,11 +140,34 @@
static void sighandler(int sig);
=20
=20
+void unreset_force_rts()
+{
+ int iosettings;
+
+ /* Normally, the RTS should be LOW after having opened the serial port */
+ /* Wait 200 ms to be sure to have a valid reset */
+
+ usleep(200000);
+ if (ioctl (phys_fd, TIOCMGET, &iosettings) !=3D 0) {
+ fprintf(stderr, "btinit : Error for ioctl TIOCMGET\n");
+ }
+ iosettings &=3D ~TIOCM_RTS;
+ if (ioctl (phys_fd, TIOCMSET, &iosettings) !=3D 0) {
+ fprintf(stderr, "btinit : Error for ioctl TIOCMSET\n");
+ }
+ D(syslogprintf("btinit : RTS set to HIGH\n"));
+ sleep(2); /* Wait that module boot. 1 second is too short */
+
+}
+
+
+
int
main(int argc, char **argv)
{=20=20
int opt;
int bt_disc =3D N_BT;
+ volatile int rts_hard_reset =3D 0;
=20
syslog(LOG_INFO, "Bluetooth daemon starting");
=20
@@ -155,7 +178,7 @@
}
=20
/* now parse options */
- while ((opt =3D getopt_long(argc, argv, "fi:nRs:u:",
+ while ((opt =3D getopt_long(argc, argv, "fi:nRs:u:D",
long_options, &option_index)) !=3D -1)
{
switch(opt)
@@ -196,11 +219,24 @@
physdev =3D optarg;
break;
=20
+ case 'D':
+ /* If called with -f option, set RTS to 1 after the port has been op=
ened */
+ /* It's usefull if you command a reset by the RTS pin */
+ D(syslog(LOG_INFO, "Use RTS for hard reset", optarg));
+ rts_hard_reset =3D 1;
default:
break;
}
}
=20
+ /* Verify that options if we have -D option, we have -f too */
+ if (rts_hard_reset & !(flow_control =3D=3D USE_NO_FLOW))
+ {
+ fprintf(stderr, "You can't use -D option without -f option.\n");
+ fprintf(stderr, "bti won't care about -D option\n");
+ rts_hard_reset =3D 0;
+ }
+=09
/* Set restart point */
if (sigsetjmp(jmpbuffer, 1) !=3D 0)
{
@@ -228,6 +264,10 @@
=20=20=20
bt_cfd =3D bt_openctrl();
=20
+ /* Use RTS to reset/unreset the card (only if option selected) */
+ if (rts_hard_reset)
+ unreset_force_rts();
+=20=20
tcflush(phys_fd, TCIOFLUSH);
=20
/* Hardreset of BT hardware */
|