This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Serial port contention
Has anyone come across this issue? Is there a good preventive measure
I can use to make sure there is no contention?
This is what I do when I need to debug my system while my only serial
port is being used.
Stolen from a ppc board, all credits go to the originator(s).
David
---
commit 5b20c814009df6a19e63adc9058be47763e5496e
Author: David Ho <davidho@nanometrics.ca>
Date: Mon Aug 14 07:52:59 2006 -0400
Write diagnostics to RAM.
diff --git a/packages/hal/arm/at91/var/current/src/hal_diag.c
b/packages/hal/arm/at91/var/current/src/hal_diag.c
index 73c4830..34a8c3f 100644
--- a/packages/hal/arm/at91/var/current/src/hal_diag.c
+++ b/packages/hal/arm/at91/var/current/src/hal_diag.c
@@ -65,6 +65,49 @@ #include <cyg/hal/hal_diag.h>
#include <cyg/hal/var_io.h> // USART registers
+#define CYGDBG_DIAG_BUF
+
+#ifdef CYGDBG_DIAG_BUF
+// Keep diag messages in a buffer for later [re]display
+
+int enable_diag_uart = 0;
+int enable_diag_buf = 1;
+//static char diag_buf[40960*4];
+static char diag_buf[4096*4];
+static int diag_buf_ptr = 0;
+
+/**
+ * Turn this into a circular buffer - DKWH
+ */
+static void
+diag_putc(char c)
+{
+ if (enable_diag_buf) {
+ diag_buf[diag_buf_ptr++] = c;
+ if (diag_buf_ptr == sizeof(diag_buf)) {
+ diag_buf_ptr--;
+ }
+ }
+}
+
+/**
+ * Restore buffer after buffer dump - DKWH
+ */
+void
+dump_diag_buf(int start, int len)
+{
+ int i;
+ enable_diag_uart = 1;
+ enable_diag_buf = 0;
+ if (len == 0) len = diag_buf_ptr;
+ diag_printf("\nDiag buf\n");
+ for (i = start; i < len; i++) {
+ hal_diag_write_char(diag_buf[i]);
+ }
+ enable_diag_buf = 1;
+}
+#endif // CYGDBG_DIAG_BUF
+
//-----------------------------------------------------------------------------
typedef struct {
cyg_uint8* base;
@@ -104,6 +147,12 @@ cyg_hal_plf_serial_putc(void *__ch_data,
{
cyg_uint8* base = ((channel_data_t*)__ch_data)->base;
cyg_uint32 status, ch;
+
+#ifdef CYGDBG_DIAG_BUF
+ diag_putc(c);
+ if (!enable_diag_uart) return;
+#endif // CYGDBG_DIAG_BUF
+
CYGARC_HAL_SAVE_GP();
do {
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss