diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-08-22 08:48:10 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-08-22 09:58:58 -0400 |
commit | a44bc950a393644b1af6b2e83bdcfc265a852583 (patch) | |
tree | 4206108a19775824342634b5297bad2416c75bb6 /src/stm32/serial.c | |
parent | 2a2cf1f536f985330054cf47f47ec7d2455e35fa (diff) | |
download | kutter-a44bc950a393644b1af6b2e83bdcfc265a852583.tar.gz kutter-a44bc950a393644b1af6b2e83bdcfc265a852583.tar.xz kutter-a44bc950a393644b1af6b2e83bdcfc265a852583.zip |
stm32: Move irq handler code above irq setup
Only code movement.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/serial.c')
-rw-r--r-- | src/stm32/serial.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/stm32/serial.c b/src/stm32/serial.c index 0cac8a1b..925d4f8e 100644 --- a/src/stm32/serial.c +++ b/src/stm32/serial.c @@ -44,24 +44,6 @@ DECL_CONSTANT_STR("RESERVE_PINS_serial", "PB11,PB10"); #define CR1_FLAGS (USART_CR1_UE | USART_CR1_RE | USART_CR1_TE \ | USART_CR1_RXNEIE) -void -serial_init(void) -{ - enable_pclock((uint32_t)USARTx); - - uint32_t pclk = get_pclock_frequency((uint32_t)USARTx); - uint32_t div = DIV_ROUND_CLOSEST(pclk, CONFIG_SERIAL_BAUD); - USARTx->BRR = (((div / 16) << USART_BRR_DIV_Mantissa_Pos) - | ((div % 16) << USART_BRR_DIV_Fraction_Pos)); - USARTx->CR1 = CR1_FLAGS; - NVIC_SetPriority(USARTx_IRQn, 0); - NVIC_EnableIRQ(USARTx_IRQn); - - gpio_peripheral(GPIO_Rx, GPIO_FUNCTION(7), 1); - gpio_peripheral(GPIO_Tx, GPIO_FUNCTION(7), 0); -} -DECL_INIT(serial_init); - void __visible USARTx_IRQHandler(void) { @@ -83,3 +65,21 @@ serial_enable_tx_irq(void) { USARTx->CR1 = CR1_FLAGS | USART_CR1_TXEIE; } + +void +serial_init(void) +{ + enable_pclock((uint32_t)USARTx); + + uint32_t pclk = get_pclock_frequency((uint32_t)USARTx); + uint32_t div = DIV_ROUND_CLOSEST(pclk, CONFIG_SERIAL_BAUD); + USARTx->BRR = (((div / 16) << USART_BRR_DIV_Mantissa_Pos) + | ((div % 16) << USART_BRR_DIV_Fraction_Pos)); + USARTx->CR1 = CR1_FLAGS; + NVIC_SetPriority(USARTx_IRQn, 0); + NVIC_EnableIRQ(USARTx_IRQn); + + gpio_peripheral(GPIO_Rx, GPIO_FUNCTION(7), 1); + gpio_peripheral(GPIO_Tx, GPIO_FUNCTION(7), 0); +} +DECL_INIT(serial_init); |