summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--digital/ucoolib/ucoolib/hal/uart/Config6
-rw-r--r--digital/ucoolib/ucoolib/hal/uart/Module1
-rw-r--r--digital/ucoolib/ucoolib/hal/uart/test/Makefile9
-rw-r--r--digital/ucoolib/ucoolib/hal/uart/test/test_uart.cc31
-rw-r--r--digital/ucoolib/ucoolib/hal/uart/uart.hh33
-rw-r--r--digital/ucoolib/ucoolib/hal/uart/uart.stm32.cc55
-rw-r--r--digital/ucoolib/ucoolib/hal/uart/uart.stm32.hh51
7 files changed, 186 insertions, 0 deletions
diff --git a/digital/ucoolib/ucoolib/hal/uart/Config b/digital/ucoolib/ucoolib/hal/uart/Config
new file mode 100644
index 00000000..0a67d635
--- /dev/null
+++ b/digital/ucoolib/ucoolib/hal/uart/Config
@@ -0,0 +1,6 @@
+[hal/uart]
+# Size of reception buffer.
+rx_buffer = 32
+# Size of transmission buffer.
+tx_buffer = 32
+
diff --git a/digital/ucoolib/ucoolib/hal/uart/Module b/digital/ucoolib/ucoolib/hal/uart/Module
new file mode 100644
index 00000000..a9d185e5
--- /dev/null
+++ b/digital/ucoolib/ucoolib/hal/uart/Module
@@ -0,0 +1 @@
+hal_uart_SOURCES = uart.stm32.cc
diff --git a/digital/ucoolib/ucoolib/hal/uart/test/Makefile b/digital/ucoolib/ucoolib/hal/uart/test/Makefile
new file mode 100644
index 00000000..e9a31fac
--- /dev/null
+++ b/digital/ucoolib/ucoolib/hal/uart/test/Makefile
@@ -0,0 +1,9 @@
+BASE = ../../../..
+
+TARGETS = stm32f4
+PROGS = test_uart
+test_uart_SOURCES = test_uart.cc
+
+MODULES = hal/uart intf
+
+include $(BASE)/build/top.mk
diff --git a/digital/ucoolib/ucoolib/hal/uart/test/test_uart.cc b/digital/ucoolib/ucoolib/hal/uart/test/test_uart.cc
new file mode 100644
index 00000000..ec6f2cb6
--- /dev/null
+++ b/digital/ucoolib/ucoolib/hal/uart/test/test_uart.cc
@@ -0,0 +1,31 @@
+// ucoolib - Microcontroller object oriented library. {{{
+//
+// Copyright (C) 2012 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "ucoolib/hal/uart/uart.hh"
+
+int
+main ()
+{
+ ucoo::Uart u (0, 38400, ucoo::Uart::EVEN, 1);
+ return 0;
+}
diff --git a/digital/ucoolib/ucoolib/hal/uart/uart.hh b/digital/ucoolib/ucoolib/hal/uart/uart.hh
new file mode 100644
index 00000000..86238a50
--- /dev/null
+++ b/digital/ucoolib/ucoolib/hal/uart/uart.hh
@@ -0,0 +1,33 @@
+#ifndef ucoolib_hal_uart_uart_hh
+#define ucoolib_hal_uart_uart_hh
+// ucoolib - Microcontroller object oriented library. {{{
+//
+// Copyright (C) 2012 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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.
+//
+// }}}
+
+#ifdef TARGET_SUB_stm32
+# include "uart.stm32.hh"
+#else
+# error "not implemented for this target"
+#endif
+
+#endif // ucoolib_hal_uart_uart_hh
diff --git a/digital/ucoolib/ucoolib/hal/uart/uart.stm32.cc b/digital/ucoolib/ucoolib/hal/uart/uart.stm32.cc
new file mode 100644
index 00000000..39ee1f8d
--- /dev/null
+++ b/digital/ucoolib/ucoolib/hal/uart/uart.stm32.cc
@@ -0,0 +1,55 @@
+// ucoolib - Microcontroller object oriented library. {{{
+//
+// Copyright (C) 2012 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "uart.stm32.hh"
+
+#include "config/hal/uart.hh"
+
+namespace ucoo {
+
+Uart::Uart (int n, int speed, Parity parity, int stop_bits)
+{
+}
+
+Uart::~Uart ()
+{
+}
+
+void
+Uart::setup (int speed, Parity parity, int stop_bits)
+{
+}
+
+int
+Uart::read (char *buf, int count)
+{
+ return -1;
+}
+
+int
+Uart::write (const char *buf, int count)
+{
+ return -1;
+}
+
+} // namespace ucoo
diff --git a/digital/ucoolib/ucoolib/hal/uart/uart.stm32.hh b/digital/ucoolib/ucoolib/hal/uart/uart.stm32.hh
new file mode 100644
index 00000000..86dfb8ac
--- /dev/null
+++ b/digital/ucoolib/ucoolib/hal/uart/uart.stm32.hh
@@ -0,0 +1,51 @@
+#ifndef ucoolib_hal_uart_uart_stm32_hh
+#define ucoolib_hal_uart_uart_stm32_hh
+// ucoolib - Microcontroller object oriented library. {{{
+//
+// Copyright (C) 2012 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "ucoolib/intf/stream.hh"
+
+namespace ucoo {
+
+/// Universal asynchronous receiver transmitter (UART).
+class Uart : public Stream
+{
+ public:
+ /// Parity setting.
+ enum Parity { ODD, EVEN, NONE };
+ public:
+ /// Initialise the Nth UART with given parameters.
+ Uart (int n, int speed, Parity parity, int stop_bits);
+ /// Shutdown UART.
+ ~Uart ();
+ /// Change UART settings.
+ void setup (int speed, Parity parity, int stop_bits);
+ /// See Stream::read.
+ int read (char *buf, int count);
+ /// See Stream::write.
+ int write (const char *buf, int count);
+};
+
+} // namespace ucoo
+
+#endif // ucoolib_hal_uart_uart_stm32_hh