Lines 1-5
Link Here
|
1 |
--- picport.cc.orig Thu Apr 29 06:08:10 2004 |
1 |
--- picport.cc.orig Thu Apr 29 00:08:10 2004 |
2 |
+++ picport.cc Wed May 25 11:09:06 2005 |
2 |
+++ picport.cc Fri Jul 8 21:46:07 2005 |
3 |
@@ -40,7 +40,7 @@ |
3 |
@@ -40,7 +40,7 @@ |
4 |
#include <unistd.h> |
4 |
#include <unistd.h> |
5 |
#include <termios.h> |
5 |
#include <termios.h> |
Lines 9-11
Link Here
|
9 |
#include <sched.h> |
9 |
#include <sched.h> |
10 |
|
10 |
|
11 |
#include "picport.h" |
11 |
#include "picport.h" |
|
|
12 |
@@ -54,6 +54,11 @@ |
13 |
unsigned int picport::tsc_1000ns = 0; |
14 |
int picport::use_nanosleep = -1; |
15 |
|
16 |
+// Extra delays for long cables, in us |
17 |
+int picport::t_on = 0; |
18 |
+int picport::t_off = 0; |
19 |
+int picport::t_edge = 0; |
20 |
+ |
21 |
void |
22 |
picport::set_clock_data (int rts, int dtr) |
23 |
{ |
24 |
@@ -102,7 +107,7 @@ |
25 |
// Before first call to set_clock_data, read the modem status. |
26 |
ioctl (fd, TIOCMGET, &modembits); |
27 |
set_clock_data (0, 0); |
28 |
- usleep (50); |
29 |
+ usleep (50+t_edge); |
30 |
// Check the CTS. If it is up, even when we just lowered DTR, |
31 |
// we probably are not talking to a JDM type programmer. |
32 |
int i; |
33 |
@@ -200,13 +205,13 @@ |
34 |
cerr << "Unable to start break on tty " << tty << ":" << strerror (e) << endl; |
35 |
exit (EX_IOERR); |
36 |
} |
37 |
- usleep (10); |
38 |
+ usleep (10+t_off); |
39 |
} |
40 |
|
41 |
picport::~picport () |
42 |
{ |
43 |
ioctl (fd, TIOCCBRK, 0); |
44 |
- usleep (1); |
45 |
+ usleep (1+t_off); |
46 |
tcsetattr (fd, TCSANOW, &saved); |
47 |
close (fd); |
48 |
delete [] portname; |
49 |
@@ -216,15 +221,15 @@ |
50 |
{ |
51 |
set_clock_data (0, 0); |
52 |
ioctl (fd, TIOCCBRK, 0); |
53 |
- usleep (50); |
54 |
+ usleep (50+t_off); |
55 |
ioctl (fd, TIOCSBRK, 0); |
56 |
- usleep (10); |
57 |
+ usleep (10+t_on); |
58 |
addr = 0; |
59 |
} |
60 |
|
61 |
void picport::delay (long ns) |
62 |
{ |
63 |
- if (1 == use_nanosleep) { |
64 |
+ if (1 == use_nanosleep && !t_edge) { |
65 |
timespec ts = {ns / 1000000000, ns % 1000000000}, ts2; |
66 |
while (nanosleep (&ts, &ts2) && EINTR == errno) |
67 |
ts = ts2; |
68 |
@@ -232,7 +237,7 @@ |
69 |
} |
70 |
|
71 |
#ifdef RDTSC_WORKS |
72 |
- if (tsc_1000ns > 1) { |
73 |
+ if (tsc_1000ns > 1 && !t_edge) { |
74 |
unsigned long a1, d1, a2, d2; |
75 |
asm volatile("rdtsc":"=a" (a1), "=d" (d1)); |
76 |
d2 = d1; |
77 |
@@ -259,10 +264,10 @@ |
78 |
volatile int i; |
79 |
gettimeofday (&tv1, 0); |
80 |
tv2.tv_sec = tv1.tv_sec; |
81 |
- tv2.tv_usec = 0xffffffff & (tv1.tv_usec + 1 + (ns + 999)/1000); |
82 |
+ tv2.tv_usec = 0xffffffff & (tv1.tv_usec + 1 + (ns + 999)/1000+t_edge); |
83 |
if (tv2.tv_usec < tv1.tv_usec) |
84 |
tv2.tv_sec++; |
85 |
- for (i = 0; i < 10000; i++) { |
86 |
+ for (i = 0; i < 10000 || t_edge; i++) { |
87 |
gettimeofday (&tv1, 0); |
88 |
if (tv1.tv_sec > tv2.tv_sec |
89 |
|| tv1.tv_sec == tv2.tv_sec && tv1.tv_usec >= tv2.tv_usec) |