summaryrefslogtreecommitdiff
path: root/hal/usart.h
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 17:21:31 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 19:23:33 +0100
commit025a38a1f743fd9e89cbd477abe3f79a8d098097 (patch)
treea1f20c1b6a7f6c418bee641da923ab3d0d7208fe /hal/usart.h
parent9e5875f2908c1ce506e7c5712ccabc379f911360 (diff)
Moved os and hal related files into subdirectories.
Diffstat (limited to 'hal/usart.h')
-rw-r--r--hal/usart.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/hal/usart.h b/hal/usart.h
new file mode 100644
index 0000000..8fde39a
--- /dev/null
+++ b/hal/usart.h
@@ -0,0 +1,26 @@
+#ifndef USART_H
+#define USART_H
+
+template<>
+void interrupt<Interrupt::USART1>() {
+ USART1.DR;
+ //GPIOB.ODR ^= 1 << 1;
+}
+
+void usart_enable() {
+ RCC.enable(RCC.USART1);
+ USART1.BRR = 625; // 115200 baud
+ USART1.CR1 = 0x202c;
+
+ Interrupt::enable(Interrupt::USART1);
+}
+
+void usart_send(uint8_t data) {
+ while(!(USART1.SR & 0x80)) {
+ Thread::yield();
+ } // Wait for TXE.
+
+ USART1.DR = data;
+}
+
+#endif