summaryrefslogtreecommitdiff
path: root/ucoo/dev/lcd/test
diff options
context:
space:
mode:
authorNicolas Schodet2015-05-04 16:57:10 +0200
committerNicolas Schodet2019-10-07 00:44:50 +0200
commit7bd977afc2d1f833ca6adb10b742527df43d3370 (patch)
treefd44090542c766214a163c9505c1310aaa6025cd /ucoo/dev/lcd/test
parente43de81bf8c58029521fd8eaeaa9c2b7cd638244 (diff)
ucoo/{intf,dev/lcd}: add text LCD support
Diffstat (limited to 'ucoo/dev/lcd/test')
-rw-r--r--ucoo/dev/lcd/test/Makefile9
-rw-r--r--ucoo/dev/lcd/test/test_lcd.cc58
2 files changed, 67 insertions, 0 deletions
diff --git a/ucoo/dev/lcd/test/Makefile b/ucoo/dev/lcd/test/Makefile
new file mode 100644
index 0000000..f8bef65
--- /dev/null
+++ b/ucoo/dev/lcd/test/Makefile
@@ -0,0 +1,9 @@
+BASE = ../../../..
+
+TARGETS = stm32f1
+PROGS = test_lcd
+test_lcd_SOURCES = test_lcd.cc
+
+MODULES = intf utils hal/gpio hal/spi dev/lcd
+
+include $(BASE)/build/top.mk
diff --git a/ucoo/dev/lcd/test/test_lcd.cc b/ucoo/dev/lcd/test/test_lcd.cc
new file mode 100644
index 0000000..c654287
--- /dev/null
+++ b/ucoo/dev/lcd/test/test_lcd.cc
@@ -0,0 +1,58 @@
+// ucoolib - Microcontroller object oriented library. {{{
+//
+// Copyright (C) 2015 Nicolas Schodet
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+// }}}
+#include "ucoo/hal/spi/spi_soft.hh"
+#include "ucoo/hal/gpio/gpio.hh"
+#include "ucoo/utils/delay.hh"
+
+#include "ucoo/dev/lcd/lcd_spi.hh"
+
+#include "ucoo/arch/arch.hh"
+
+#include <libopencm3/stm32/rcc.h>
+
+int
+main (int argc, const char **argv)
+{
+ ucoo::arch_init (argc, argv);
+ rcc_periph_clock_enable (RCC_GPIOB);
+ ucoo::Gpio rw (GPIOB, 10);
+ ucoo::Gpio rs (GPIOB, 11);
+ ucoo::Gpio cs (GPIOB, 12);
+ ucoo::Gpio sck (GPIOB, 13);
+ ucoo::Gpio miso (GPIOB, 14);
+ ucoo::Gpio mosi (GPIOB, 15);
+ ucoo::SpiSoftMaster spi (sck, mosi, miso);
+ rw.reset ();
+ rw.output ();
+ ucoo::LcdSpi lcd (spi, cs, rs);
+ ucoo::delay (1);
+ lcd.enable ();
+ int i = 0;
+ while (1)
+ {
+ lcd.printf ("Hello world!\n%02d:%02d\n", i / 60, i % 60);
+ i++;
+ ucoo::delay (1);
+ }
+}