From 9b22cfb2aad32aeb5c0e878e7b72b1590296cf7d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 2 Jul 2011 13:26:22 +0200 Subject: Test USART1 interrupt. --- main.cpp | 15 ++++++++++++--- 1 file 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() { + 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))) { -- cgit v1.2.3