diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-07-02 13:26:22 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-07-02 13:26:22 +0200 |
commit | 9b22cfb2aad32aeb5c0e878e7b72b1590296cf7d (patch) | |
tree | 0648e545409e1ef6a092b0d0a5d166176b10b6dd | |
parent | 5033da7f5a7932b69c3e8746145f2304e63e4dc3 (diff) |
Test USART1 interrupt.
-rw-r--r-- | main.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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))) { |