diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2021-09-15 17:05:36 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2021-09-15 17:05:36 +0200 |
commit | 9801227da93abb418d12804d2ceb56ce04d90c1d (patch) | |
tree | 7927fbc98a8ff870a34315d54cf8ad5a38fbb4b7 /usart | |
parent | cb486529482ef66902fd15bbd6e3a3b12ff4fa4b (diff) |
uart: Generate instances from platform spec.
Diffstat (limited to 'usart')
-rw-r--r-- | usart/usart.h | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/usart/usart.h b/usart/usart.h deleted file mode 100644 index 9f3d838..0000000 --- a/usart/usart.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef USART_H -#define USART_H - -#include <rcc/rcc.h> -#include <interrupt/interrupt.h> - -#if defined(STM32F1) || defined(STM32F4) -struct USART_reg_t { - volatile uint32_t SR; - volatile uint32_t DR; - volatile uint32_t BRR; - volatile uint32_t CR1; - volatile uint32_t CR2; - volatile uint32_t CR3; - volatile uint32_t GTPR; -}; -#elif defined(STM32F3) || defined(STM32L0) -struct USART_reg_t { - volatile uint32_t CR1; - volatile uint32_t CR2; - volatile uint32_t CR3; - volatile uint32_t BRR; - volatile uint32_t GTPR; - volatile uint32_t RTOR; - volatile uint32_t RQR; - volatile uint32_t ISR; - volatile uint32_t ICR; - volatile uint32_t RDR; - volatile uint32_t TDR; -}; -#endif - -class USART_t { - public: - USART_reg_t& reg; - const uint32_t clk; - - USART_t(uint32_t reg_addr, uint32_t bus_clk) : reg(*(USART_reg_t*)reg_addr), clk(bus_clk) {} - - inline void set_baudrate(uint32_t baudrate) { - reg.BRR = clk / baudrate; - } -}; - -#if defined(STM32F1) || defined(STM32F3) -static USART_t USART1(0x40013800, 72000000); -static USART_t USART2(0x40004400, 36000000); -static USART_t USART3(0x40004800, 36000000); -#elif defined(STM32F4) -static USART_t USART1(0x40011000, 84000000); -static USART_t USART2(0x40004400, 42000000); -static USART_t USART3(0x40004800, 42000000); -#elif defined(STM32L0) -static USART_t USART1(0x40013800, 32000000); -static USART_t USART2(0x40004400, 32000000); -#endif - -#endif |