summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))) {