diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-07-03 17:11:47 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-07-03 17:11:47 +0200 |
commit | 865a74dd0f02b46c6cc37a5c33314baaf90fa6e2 (patch) | |
tree | 85ead7b9ae9dbbf476b587a31328530183550688 /usart.h | |
parent | 4cdc0c7e9827b06ccb6ee96784b71d54b27017b3 (diff) |
Moved peripheral classes to seperate files.
Diffstat (limited to 'usart.h')
-rw-r--r-- | usart.h | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -0,0 +1,24 @@ +#ifndef USART_H +#define USART_H + +template<> +void interrupt<Interrupt::USART1>() { + 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 |