From 865a74dd0f02b46c6cc37a5c33314baaf90fa6e2 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 3 Jul 2011 17:11:47 +0200 Subject: Moved peripheral classes to seperate files. --- usart.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 usart.h (limited to 'usart.h') diff --git a/usart.h b/usart.h new file mode 100644 index 0000000..6c145c6 --- /dev/null +++ b/usart.h @@ -0,0 +1,24 @@ +#ifndef USART_H +#define USART_H + +template<> +void interrupt() { + USART1.DR; + GPIOA.ODR ^= 1 << 5; +} + +void usart_enable() { + RCC.enable(RCC.USART1); + USART1.BRR = 7500; // 9600 baud + USART1.CR1 = 0x202c; + + Interrupt::enable(Interrupt::USART1); +} + +void usart_send(uint8_t data) { + while(!(USART1.SR & 0x80)); // Wait for TXE. + + USART1.DR = data; +} + +#endif -- cgit v1.2.3