Skip to content

Instantly share code, notes, and snippets.

@smooker
Created December 16, 2020 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smooker/b2ecc938b4c231f5eb0fff31e8c88648 to your computer and use it in GitHub Desktop.
Save smooker/b2ecc938b4c231f5eb0fff31e8c88648 to your computer and use it in GitHub Desktop.
smooker@shd2 ~/src/stm32/libopencm3 $ cat ../libopencm3_rx_idle.diff
diff --git a/include/libopencm3/stm32/common/usart_common_all.h b/include/libopencm3/stm32/common/usart_common_all.h
index a39d6833..a3626559 100644
--- a/include/libopencm3/stm32/common/usart_common_all.h
+++ b/include/libopencm3/stm32/common/usart_common_all.h
@@ -123,6 +123,7 @@ void usart_disable_tx_interrupt(uint32_t usart);
void usart_enable_error_interrupt(uint32_t usart);
void usart_disable_error_interrupt(uint32_t usart);
bool usart_get_flag(uint32_t usart, uint32_t flag);
+void usart_enable_rx_idle_interrupt(uint32_t usart);
END_DECLS
diff --git a/lib/stm32/common/usart_common_all.c b/lib/stm32/common/usart_common_all.c
index 2c7e9a6d..69261530 100644
--- a/lib/stm32/common/usart_common_all.c
+++ b/lib/stm32/common/usart_common_all.c
@@ -301,6 +301,19 @@ void usart_disable_tx_dma(uint32_t usart)
USART_CR3(usart) &= ~USART_CR3_DMAT;
}
+
+/*---------------------------------------------------------------------------*/
+/** @brief USART Receiver Idle Interrupt Enable.
+
+@param[in] usart unsigned 32 bit. USART block register address base @ref
+usart_reg_base
+*/
+
+void usart_enable_rx_idle_interrupt(uint32_t usart)
+{
+ USART_CR1(usart) |= USART_CR1_IDLEIE;
+}
+
/*---------------------------------------------------------------------------*/
/** @brief USART Receiver Interrupt Enable.
@@ -326,6 +339,7 @@ void usart_disable_rx_interrupt(uint32_t usart)
USART_CR1(usart) &= ~USART_CR1_RXNEIE;
}
+
/*---------------------------------------------------------------------------*/
/** @brief USART Transmitter Interrupt Enable.
@smooker
Copy link
Author

smooker commented Dec 16, 2020

smooker@sw1 ~/src/stm32/libopencm3 $ patch -p1 < /tmp/libopencm3_rx_idle.diff 
patching file include/libopencm3/stm32/common/usart_common_all.h
patching file lib/stm32/common/usart_common_all.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment