summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-07-02 13:26:22 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-07-02 13:26:22 +0200
commit9b22cfb2aad32aeb5c0e878e7b72b1590296cf7d (patch)
tree0648e545409e1ef6a092b0d0a5d166176b10b6dd
parent5033da7f5a7932b69c3e8746145f2304e63e4dc3 (diff)
Test USART1 interrupt.
-rw-r--r--main.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index 468a0b9..75468ed 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,4 +1,5 @@
#include "stm32.h"
+#include "interrupt.h"
volatile unsigned int cnt;
@@ -60,6 +61,12 @@ void i2c_read_reg(uint8_t addr, uint8_t reg, uint8_t len, uint8_t* buf) {
}
}
+template<>
+void interrupt<Interrupt::USART1>() {
+ USART1.DR;
+ GPIOA.ODR ^= 1 << 5;
+}
+
void usart_send(uint8_t data) {
while(!(USART1.SR & 0x80)); // Wait for TXE.
@@ -135,14 +142,16 @@ int main() {
RCC.enable(RCC.USART1);
USART1.BRR = 7500; // 9600 baud
- USART1.CR1 = 0x2008;
+ USART1.CR1 = 0x202c;
+
+ Interrupt::enable(Interrupt::USART1);
while(1) {
cnt++;
if(cnt & (1 << 20)) {
- GPIOA.ODR = 1 << 5;
+ //GPIOA.ODR = 1 << 5;
} else {
- GPIOA.ODR = 0;
+ //GPIOA.ODR = 0;
}
if(!(cnt & ((1 << 20) - 1))) {