diff options
| author | Guillaume MICHEL <[email protected]> | 2022-10-26 18:58:22 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-10-26 19:06:18 +0200 |
| commit | 9cac649fcf5a633a89aa1b6e550d641270d14956 (patch) | |
| tree | 91b07477910a4908867e6125a76dea9a587a2360 /tests | |
| parent | ff76fde299d20c9a3f51a3b89ed69761a2531784 (diff) | |
stm32: Add support for read_until_idle on UART
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/stm32/src/bin/usart.rs | 17 | ||||
| -rw-r--r-- | tests/stm32/src/bin/usart_dma.rs | 48 |
2 files changed, 49 insertions, 16 deletions
diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 7673bfe6d..af55867f2 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs | |||
| @@ -7,6 +7,7 @@ mod example_common; | |||
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::interrupt; | ||
| 10 | use embassy_stm32::usart::{Config, Uart}; | 11 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use example_common::*; | 12 | use example_common::*; |
| 12 | 13 | ||
| @@ -18,22 +19,22 @@ async fn main(_spawner: Spawner) { | |||
| 18 | // Arduino pins D0 and D1 | 19 | // Arduino pins D0 and D1 |
| 19 | // They're connected together with a 1K resistor. | 20 | // They're connected together with a 1K resistor. |
| 20 | #[cfg(feature = "stm32f103c8")] | 21 | #[cfg(feature = "stm32f103c8")] |
| 21 | let (tx, rx, usart) = (p.PA9, p.PA10, p.USART1); | 22 | let (tx, rx, usart, irq) = (p.PA9, p.PA10, p.USART1, interrupt::take!(USART1)); |
| 22 | #[cfg(feature = "stm32g491re")] | 23 | #[cfg(feature = "stm32g491re")] |
| 23 | let (tx, rx, usart) = (p.PC4, p.PC5, p.USART1); | 24 | let (tx, rx, usart, irq) = (p.PC4, p.PC5, p.USART1, interrupt::take!(USART1)); |
| 24 | #[cfg(feature = "stm32g071rb")] | 25 | #[cfg(feature = "stm32g071rb")] |
| 25 | let (tx, rx, usart) = (p.PC4, p.PC5, p.USART1); | 26 | let (tx, rx, usart, irq) = (p.PC4, p.PC5, p.USART1, interrupt::take!(USART1)); |
| 26 | #[cfg(feature = "stm32f429zi")] | 27 | #[cfg(feature = "stm32f429zi")] |
| 27 | let (tx, rx, usart) = (p.PG14, p.PG9, p.USART6); | 28 | let (tx, rx, usart, irq) = (p.PG14, p.PG9, p.USART6, interrupt::take!(USART6)); |
| 28 | #[cfg(feature = "stm32wb55rg")] | 29 | #[cfg(feature = "stm32wb55rg")] |
| 29 | let (tx, rx, usart) = (p.PA2, p.PA3, p.LPUART1); | 30 | let (tx, rx, usart, irq) = (p.PA2, p.PA3, p.LPUART1, interrupt::take!(LPUART1)); |
| 30 | #[cfg(feature = "stm32h755zi")] | 31 | #[cfg(feature = "stm32h755zi")] |
| 31 | let (tx, rx, usart) = (p.PB6, p.PB7, p.USART1); | 32 | let (tx, rx, usart, irq) = (p.PB6, p.PB7, p.USART1, interrupt::take!(USART1)); |
| 32 | #[cfg(feature = "stm32u585ai")] | 33 | #[cfg(feature = "stm32u585ai")] |
| 33 | let (tx, rx, usart) = (p.PD8, p.PD9, p.USART3); | 34 | let (tx, rx, usart, irq) = (p.PD8, p.PD9, p.USART3, interrupt::take!(USART3)); |
| 34 | 35 | ||
| 35 | let config = Config::default(); | 36 | let config = Config::default(); |
| 36 | let mut usart = Uart::new(usart, rx, tx, NoDma, NoDma, config); | 37 | let mut usart = Uart::new(usart, rx, tx, irq, NoDma, NoDma, config); |
| 37 | 38 | ||
| 38 | // We can't send too many bytes, they have to fit in the FIFO. | 39 | // We can't send too many bytes, they have to fit in the FIFO. |
| 39 | // This is because we aren't sending+receiving at the same time. | 40 | // This is because we aren't sending+receiving at the same time. |
diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index e0389446f..d12605a9a 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | mod example_common; | 6 | mod example_common; |
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::interrupt; | ||
| 9 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 10 | use example_common::*; | 11 | use example_common::*; |
| 11 | 12 | ||
| @@ -17,22 +18,53 @@ async fn main(_spawner: Spawner) { | |||
| 17 | // Arduino pins D0 and D1 | 18 | // Arduino pins D0 and D1 |
| 18 | // They're connected together with a 1K resistor. | 19 | // They're connected together with a 1K resistor. |
| 19 | #[cfg(feature = "stm32f103c8")] | 20 | #[cfg(feature = "stm32f103c8")] |
| 20 | let (tx, rx, usart, tx_dma, rx_dma) = (p.PA9, p.PA10, p.USART1, p.DMA1_CH4, p.DMA1_CH5); | 21 | let (tx, rx, usart, irq, tx_dma, rx_dma) = ( |
| 22 | p.PA9, | ||
| 23 | p.PA10, | ||
| 24 | p.USART1, | ||
| 25 | interrupt::take!(USART1), | ||
| 26 | p.DMA1_CH4, | ||
| 27 | p.DMA1_CH5, | ||
| 28 | ); | ||
| 21 | #[cfg(feature = "stm32g491re")] | 29 | #[cfg(feature = "stm32g491re")] |
| 22 | let (tx, rx, usart, tx_dma, rx_dma) = (p.PC4, p.PC5, p.USART1, p.DMA1_CH1, p.DMA1_CH2); | 30 | let (tx, rx, usart, irq, tx_dma, rx_dma) = |
| 31 | (p.PC4, p.PC5, p.USART1, interrupt::take!(USART1), p.DMA1_CH1, p.DMA1_CH2); | ||
| 23 | #[cfg(feature = "stm32g071rb")] | 32 | #[cfg(feature = "stm32g071rb")] |
| 24 | let (tx, rx, usart, tx_dma, rx_dma) = (p.PC4, p.PC5, p.USART1, p.DMA1_CH1, p.DMA1_CH2); | 33 | let (tx, rx, usart, irq, tx_dma, rx_dma) = |
| 34 | (p.PC4, p.PC5, p.USART1, interrupt::take!(USART1), p.DMA1_CH1, p.DMA1_CH2); | ||
| 25 | #[cfg(feature = "stm32f429zi")] | 35 | #[cfg(feature = "stm32f429zi")] |
| 26 | let (tx, rx, usart, tx_dma, rx_dma) = (p.PG14, p.PG9, p.USART6, p.DMA2_CH6, p.DMA2_CH1); | 36 | let (tx, rx, usart, irq, tx_dma, rx_dma) = ( |
| 37 | p.PG14, | ||
| 38 | p.PG9, | ||
| 39 | p.USART6, | ||
| 40 | interrupt::take!(USART6), | ||
| 41 | p.DMA2_CH6, | ||
| 42 | p.DMA2_CH1, | ||
| 43 | ); | ||
| 27 | #[cfg(feature = "stm32wb55rg")] | 44 | #[cfg(feature = "stm32wb55rg")] |
| 28 | let (tx, rx, usart, tx_dma, rx_dma) = (p.PA2, p.PA3, p.LPUART1, p.DMA1_CH1, p.DMA1_CH2); | 45 | let (tx, rx, usart, irq, tx_dma, rx_dma) = ( |
| 46 | p.PA2, | ||
| 47 | p.PA3, | ||
| 48 | p.LPUART1, | ||
| 49 | interrupt::take!(LPUART1), | ||
| 50 | p.DMA1_CH1, | ||
| 51 | p.DMA1_CH2, | ||
| 52 | ); | ||
| 29 | #[cfg(feature = "stm32h755zi")] | 53 | #[cfg(feature = "stm32h755zi")] |
| 30 | let (tx, rx, usart, tx_dma, rx_dma) = (p.PB6, p.PB7, p.USART1, p.DMA1_CH0, p.DMA1_CH1); | 54 | let (tx, rx, usart, irq, tx_dma, rx_dma) = |
| 55 | (p.PB6, p.PB7, p.USART1, interrupt::take!(USART1), p.DMA1_CH0, p.DMA1_CH1); | ||
| 31 | #[cfg(feature = "stm32u585ai")] | 56 | #[cfg(feature = "stm32u585ai")] |
| 32 | let (tx, rx, usart, tx_dma, rx_dma) = (p.PD8, p.PD9, p.USART3, p.GPDMA1_CH0, p.GPDMA1_CH1); | 57 | let (tx, rx, usart, irq, tx_dma, rx_dma) = ( |
| 58 | p.PD8, | ||
| 59 | p.PD9, | ||
| 60 | p.USART3, | ||
| 61 | interrupt::take!(USART3), | ||
| 62 | p.GPDMA1_CH0, | ||
| 63 | p.GPDMA1_CH1, | ||
| 64 | ); | ||
| 33 | 65 | ||
| 34 | let config = Config::default(); | 66 | let config = Config::default(); |
| 35 | let mut usart = Uart::new(usart, rx, tx, tx_dma, rx_dma, config); | 67 | let mut usart = Uart::new(usart, rx, tx, irq, tx_dma, rx_dma, config); |
| 36 | 68 | ||
| 37 | // We can't send too many bytes, they have to fit in the FIFO. | 69 | // We can't send too many bytes, they have to fit in the FIFO. |
| 38 | // This is because we aren't sending+receiving at the same time. | 70 | // This is because we aren't sending+receiving at the same time. |
