summaryrefslogtreecommitdiff
path: root/n
diff options
context:
space:
mode:
authorschodet2005-10-17 21:42:58 +0000
committerschodet2005-10-17 21:42:58 +0000
commit08792dc2e4726cdc546ac97d44d2175ffdac09be (patch)
tree6a6da39f0ca69a14e88310714e2dd67505f148bd /n
parentb6bea4ac2e2e8129240b07ff8bd4efdaebed563d (diff)
Ajout du code d'uart pour simulavrxx.
Diffstat (limited to 'n')
-rw-r--r--n/avr/modules/uart/avrconfig.h1
-rw-r--r--n/avr/modules/uart/test/avrconfig_polling.h1
-rw-r--r--n/avr/modules/uart/test/avrconfig_ring.h1
-rw-r--r--n/avr/modules/uart/test/avrconfig_twoports.h1
-rw-r--r--n/avr/modules/uart/uart.simu.c78
-rw-r--r--n/avr/modules/uart/uart0.c8
-rw-r--r--n/avr/modules/uart/uart1.c8
-rw-r--r--n/avr/modules/uart/uart_common.h4
8 files changed, 96 insertions, 6 deletions
diff --git a/n/avr/modules/uart/avrconfig.h b/n/avr/modules/uart/avrconfig.h
index c52072c..d645e69 100644
--- a/n/avr/modules/uart/avrconfig.h
+++ b/n/avr/modules/uart/avrconfig.h
@@ -66,5 +66,6 @@
#define AC_UART1_SEND_BUFFER_SIZE 32
#define AC_UART1_RECV_BUFFER_SIZE 32
#define AC_UART1_SEND_BUFFER_FULL WAIT
+#define AC_UART1_HOST_DRIVER PTS
#endif /* avrconfig_h */
diff --git a/n/avr/modules/uart/test/avrconfig_polling.h b/n/avr/modules/uart/test/avrconfig_polling.h
index 81e5f0e..99b4514 100644
--- a/n/avr/modules/uart/test/avrconfig_polling.h
+++ b/n/avr/modules/uart/test/avrconfig_polling.h
@@ -71,5 +71,6 @@
#define AC_UART1_SEND_BUFFER_SIZE 32
#define AC_UART1_RECV_BUFFER_SIZE 32
#define AC_UART1_SEND_BUFFER_FULL WAIT
+#define AC_UART1_HOST_DRIVER STDIO
#endif /* avrconfig_polling_h */
diff --git a/n/avr/modules/uart/test/avrconfig_ring.h b/n/avr/modules/uart/test/avrconfig_ring.h
index e712d05..f35f904 100644
--- a/n/avr/modules/uart/test/avrconfig_ring.h
+++ b/n/avr/modules/uart/test/avrconfig_ring.h
@@ -71,5 +71,6 @@
#define AC_UART1_SEND_BUFFER_SIZE 32
#define AC_UART1_RECV_BUFFER_SIZE 32
#define AC_UART1_SEND_BUFFER_FULL WAIT
+#define AC_UART1_HOST_DRIVER PTS
#endif /* avrconfig_ring_h */
diff --git a/n/avr/modules/uart/test/avrconfig_twoports.h b/n/avr/modules/uart/test/avrconfig_twoports.h
index 07993fc..d4c8fa6 100644
--- a/n/avr/modules/uart/test/avrconfig_twoports.h
+++ b/n/avr/modules/uart/test/avrconfig_twoports.h
@@ -71,5 +71,6 @@
#define AC_UART1_SEND_BUFFER_SIZE 32
#define AC_UART1_RECV_BUFFER_SIZE 16
#define AC_UART1_SEND_BUFFER_FULL DROP
+#define AC_UART1_HOST_DRIVER PTS
#endif /* avrconfig_twoports_h */
diff --git a/n/avr/modules/uart/uart.simu.c b/n/avr/modules/uart/uart.simu.c
new file mode 100644
index 0000000..e860579
--- /dev/null
+++ b/n/avr/modules/uart/uart.simu.c
@@ -0,0 +1,78 @@
+/* uart.simu.c - used for simulavrxx pseudo ports. */
+/* avr.uart - UART AVR module. {{{
+ *
+ * Copyright (C) 2005 Nicolas Schodet
+ *
+ * Robot APB Team/Efrei 2006.
+ * Web: http://assos.efrei.fr/robot/
+ * Email: robot AT efrei DOT fr
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+#include "common.h"
+#include "uart.h"
+
+#include "uart_common.h"
+
+#if AC_UART (PORT) != -1
+
+int uart (eof);
+
+/** Initialise uart. */
+void
+uart_init (void)
+{
+ uart (eof) = 0;
+}
+
+/** Use this as exit point. */
+void
+uart (exit) (void)
+{
+ uart (eof) = 1;
+}
+
+/** Read a char. */
+uint8_t
+uart_getc (void)
+{
+ uint8_t c;
+ if (uart (eof))
+ return 0xff;
+ c = *(uint8_t *) 0x20;
+ if (!c)
+ {
+ uart (exit) ();
+ c = 0xff;
+ }
+ return c;
+}
+
+/** Write a char. */
+void
+uart_putc (uint8_t c)
+{
+ *(uint8_t *) 0x22 = c;
+}
+
+/** Retrieve availlable chars. */
+uint8_t
+uart_poll (void)
+{
+ return !uart (eof);
+}
+
+#endif /* AC_UART (PORT) != -1 */
diff --git a/n/avr/modules/uart/uart0.c b/n/avr/modules/uart/uart0.c
index 66444eb..4a8fb35 100644
--- a/n/avr/modules/uart/uart0.c
+++ b/n/avr/modules/uart/uart0.c
@@ -25,8 +25,10 @@
#define UART_N 0
-#ifdef HOST
-#include "uart.host.c"
+#if defined (HOST)
+# include "uart.host.c"
+#elif defined (SIMU)
+# include "uart.simu.c"
#else
-#include "uart.avr.c"
+# include "uart.avr.c"
#endif
diff --git a/n/avr/modules/uart/uart1.c b/n/avr/modules/uart/uart1.c
index 8a15e2c..c391527 100644
--- a/n/avr/modules/uart/uart1.c
+++ b/n/avr/modules/uart/uart1.c
@@ -25,8 +25,10 @@
#define UART_N 1
-#ifdef HOST
-#include "uart.host.c"
+#if defined (HOST)
+# include "uart.host.c"
+#elif defined (SIMU)
+# include "uart.simu.c"
#else
-#include "uart.avr.c"
+# include "uart.avr.c"
#endif
diff --git a/n/avr/modules/uart/uart_common.h b/n/avr/modules/uart/uart_common.h
index a856aa9..8f5a3af 100644
--- a/n/avr/modules/uart/uart_common.h
+++ b/n/avr/modules/uart/uart_common.h
@@ -67,6 +67,8 @@
|| !defined (AC_UART0_STOP_BITS) \
|| !defined (AC_UART0_SEND_BUFFER_SIZE) \
|| !defined (AC_UART0_RECV_BUFFER_SIZE) \
+ || !defined (AC_UART0_SEND_BUFFER_FULL) \
+ || !defined (AC_UART0_HOST_DRIVER) \
|| !defined (AC_UART1_PORT) \
|| !defined (AC_UART1_BAUDRATE) \
|| !defined (AC_UART1_SEND_MODE) \
@@ -76,6 +78,8 @@
|| !defined (AC_UART1_STOP_BITS) \
|| !defined (AC_UART1_SEND_BUFFER_SIZE) \
|| !defined (AC_UART1_RECV_BUFFER_SIZE) \
+ || !defined (AC_UART1_SEND_BUFFER_FULL) \
+ || !defined (AC_UART1_HOST_DRIVER) \
|| AC_UART0_PORT == AC_UART1_PORT
# error "uart: error in configuration"
#endif