aboutsummaryrefslogtreecommitdiff
path: root/03-refactor/src/main.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2018-01-24 00:12:03 -0700
committerJosh Rahm <joshuarahm@gmail.com>2018-01-24 00:12:03 -0700
commit80360c4b8361320b726897c86ee13f9b4caf004a (patch)
tree9a590055e440025d7d36701a540d9e7e39c082d4 /03-refactor/src/main.c
parent2545ae2d57e5b70975e3fd3b3e570da13dbf62f0 (diff)
downloadstm32l4-80360c4b8361320b726897c86ee13f9b4caf004a.tar.gz
stm32l4-80360c4b8361320b726897c86ee13f9b4caf004a.tar.bz2
stm32l4-80360c4b8361320b726897c86ee13f9b4caf004a.zip
More fields in USART and RCC set to use bitfields.
Diffstat (limited to '03-refactor/src/main.c')
-rw-r--r--03-refactor/src/main.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/03-refactor/src/main.c b/03-refactor/src/main.c
index 5af52ed..0545087 100644
--- a/03-refactor/src/main.c
+++ b/03-refactor/src/main.c
@@ -30,9 +30,9 @@ int enable_usart2(uint32_t baud_rate)
// disable USART first to allow setting of other control bits
// This also disables parity checking and enables 16 times oversampling
- USART2.c_r1 = 0;
- USART2.c_r2 = 0;
- USART2.c_r3 = 0;
+ USART2.c1.r = 0;
+ USART2.c2.r = 0;
+ USART2.c3.r = 0;
usart_set_divisor(&USART2, 16000000 / baud_rate);
usart_set_enabled(&USART2, USART_ENABLE_TX | USART_ENABLE_RX);
@@ -60,13 +60,13 @@ int enable_usart1(uint32_t baud_rate)
RCC.apb2rst_r &= ~BIT(14); /* De-assert reset of USART1 */
uint32_t baud_rate_div = 80000000 / baud_rate;
- USART1.c_r1 = 0;
- USART1.c_r2 = 0;
- USART1.c_r3 = 0;
- USART1.br_r = baud_rate_div;
+ USART1.c1.r = 0;
+ USART1.c2.r = 0;
+ USART1.c3.r = 0;
+ USART1.br.v = baud_rate_div;
- USART1.c_r1 |= BIT(3) | BIT(2);
- USART1.c_r1 |= BIT(0);
+ USART1.c1.r |= BIT(3) | BIT(2);
+ USART1.c1.r |= BIT(0);
/* Enable the transmitter and the receiver. */
usart_set_enabled(&USART1, USART_ENABLE_TX);