summaryrefslogtreecommitdiff
path: root/lib/ccdbg-io.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-03-06 22:52:35 -0800
committerKeith Packard <keithp@keithp.com>2009-03-06 22:56:47 -0800
commitcc0495b7028f4b1189a00707d828a68534d1dea2 (patch)
treea7727c8af99af7781f801a00235a6b9fb8d107f1 /lib/ccdbg-io.c
parent41289e6d8f1767547a33fea349866e928e44910f (diff)
Wait for a while when switching the RESET_N line
The cc1111 manual suggests placing a 2.7kΩ resister and 1nF capacitor on the RESET_N line to filter out noise. This increases the time necessary to reset the chip to several microseconds which is longer than the interval between two USB packets. Flush the USB packet queue and sleep for a while after changing the value on the RESET_N line to make sure the chip sees the state change. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'lib/ccdbg-io.c')
-rw-r--r--lib/ccdbg-io.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/ccdbg-io.c b/lib/ccdbg-io.c
index e5e85e43..3606c57c 100644
--- a/lib/ccdbg-io.c
+++ b/lib/ccdbg-io.c
@@ -25,6 +25,7 @@
#endif
static uint32_t cc_clock_us = CC_CLOCK_US;
+static uint32_t cc_reset_us = CC_RESET_US;
void
ccdbg_set_clock(uint32_t us)
@@ -41,6 +42,17 @@ ccdbg_half_clock(struct ccdbg *dbg)
nanosleep(&req, &rem);
}
+void
+ccdbg_wait_reset(struct ccdbg *dbg)
+{
+ struct timespec req, rem;
+
+ ccdbg_sync_io(dbg);
+ req.tv_sec = (cc_reset_us) / 1000000;
+ req.tv_nsec = ((cc_reset_us) % 1000000) * 1000;
+ nanosleep(&req, &rem);
+}
+
struct ccdbg *
ccdbg_open(void)
{