diff options
| author | Anton Pöhl <[email protected]> | 2025-03-13 11:05:10 +0100 |
|---|---|---|
| committer | Anton Pöhl <[email protected]> | 2025-04-11 20:58:03 +0200 |
| commit | a544726be4ef66574419e95ee508f2062e9a3da2 (patch) | |
| tree | 92d414617f0ec358fc3e839c3bd722116cac3194 /examples/stm32g0/src | |
| parent | e3cec4a246a0e3cbaae60c91f946f608f6637f63 (diff) | |
Stm32 usart: remove HalfDuplexConfig
The pin parameters of usart::Config are used instead.
Diffstat (limited to 'examples/stm32g0/src')
| -rw-r--r-- | examples/stm32g0/src/bin/onewire_ds18b20.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/stm32g0/src/bin/onewire_ds18b20.rs b/examples/stm32g0/src/bin/onewire_ds18b20.rs index f85cc4ff8..75519bbf2 100644 --- a/examples/stm32g0/src/bin/onewire_ds18b20.rs +++ b/examples/stm32g0/src/bin/onewire_ds18b20.rs | |||
| @@ -8,7 +8,7 @@ use defmt::*; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::mode::Async; | 9 | use embassy_stm32::mode::Async; |
| 10 | use embassy_stm32::usart::{ | 10 | use embassy_stm32::usart::{ |
| 11 | BufferedUartRx, BufferedUartTx, Config, ConfigError, HalfDuplexConfig, RingBufferedUartRx, UartTx, | 11 | BufferedUartRx, BufferedUartTx, Config, ConfigError, OutputConfig, RingBufferedUartRx, UartTx, |
| 12 | }; | 12 | }; |
| 13 | use embassy_stm32::{bind_interrupts, peripherals, usart}; | 13 | use embassy_stm32::{bind_interrupts, peripherals, usart}; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| @@ -21,16 +21,18 @@ fn create_onewire(p: embassy_stm32::Peripherals) -> OneWire<UartTx<'static, Asyn | |||
| 21 | USART1 => usart::InterruptHandler<peripherals::USART1>; | 21 | USART1 => usart::InterruptHandler<peripherals::USART1>; |
| 22 | }); | 22 | }); |
| 23 | 23 | ||
| 24 | let mut config = Config::default(); | ||
| 25 | config.tx_config = OutputConfig::OpenDrainExternal; | ||
| 26 | |||
| 24 | let usart = Uart::new_half_duplex( | 27 | let usart = Uart::new_half_duplex( |
| 25 | p.USART1, | 28 | p.USART1, |
| 26 | p.PA9, | 29 | p.PA9, |
| 27 | Irqs, | 30 | Irqs, |
| 28 | p.DMA1_CH1, | 31 | p.DMA1_CH1, |
| 29 | p.DMA1_CH2, | 32 | p.DMA1_CH2, |
| 30 | Config::default(), | 33 | config, |
| 31 | // Enable readback so we can read sensor pulling data low while transmission is in progress | 34 | // Enable readback so we can read sensor pulling data low while transmission is in progress |
| 32 | usart::HalfDuplexReadback::Readback, | 35 | usart::HalfDuplexReadback::Readback, |
| 33 | HalfDuplexConfig::OpenDrainExternal, | ||
| 34 | ) | 36 | ) |
| 35 | .unwrap(); | 37 | .unwrap(); |
| 36 | 38 | ||
| @@ -50,6 +52,8 @@ fn create_onewire(p: embassy_stm32::Peripherals) -> OneWire<BufferedUartTx<'stat | |||
| 50 | }); | 52 | }); |
| 51 | 53 | ||
| 52 | const BUFFER_SIZE: usize = 16; | 54 | const BUFFER_SIZE: usize = 16; |
| 55 | let mut config = Confi::default(); | ||
| 56 | config.tx_config = OutputConfig::OpenDrainExternal; | ||
| 53 | let tx_buf: &mut [u8; BUFFER_SIZE] = singleton!(TX_BUF: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE]).unwrap(); | 57 | let tx_buf: &mut [u8; BUFFER_SIZE] = singleton!(TX_BUF: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE]).unwrap(); |
| 54 | let rx_buf: &mut [u8; BUFFER_SIZE] = singleton!(RX_BUF: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE]).unwrap(); | 58 | let rx_buf: &mut [u8; BUFFER_SIZE] = singleton!(RX_BUF: [u8; BUFFER_SIZE] = [0; BUFFER_SIZE]).unwrap(); |
| 55 | let usart = BufferedUart::new_half_duplex( | 59 | let usart = BufferedUart::new_half_duplex( |
| @@ -58,10 +62,9 @@ fn create_onewire(p: embassy_stm32::Peripherals) -> OneWire<BufferedUartTx<'stat | |||
| 58 | Irqs, | 62 | Irqs, |
| 59 | tx_buf, | 63 | tx_buf, |
| 60 | rx_buf, | 64 | rx_buf, |
| 61 | Config::default(), | 65 | config, |
| 62 | // Enable readback so we can read sensor pulling data low while transmission is in progress | 66 | // Enable readback so we can read sensor pulling data low while transmission is in progress |
| 63 | usart::HalfDuplexReadback::Readback, | 67 | usart::HalfDuplexReadback::Readback, |
| 64 | HalfDuplexConfig::OpenDrainExternal, | ||
| 65 | ) | 68 | ) |
| 66 | .unwrap(); | 69 | .unwrap(); |
| 67 | let (tx, rx) = usart.split(); | 70 | let (tx, rx) = usart.split(); |
