diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /tests/stm32/src | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'tests/stm32/src')
| -rw-r--r-- | tests/stm32/src/bin/can.rs | 2 | ||||
| -rw-r--r-- | tests/stm32/src/bin/cordic.rs | 4 | ||||
| -rw-r--r-- | tests/stm32/src/bin/gpio.rs | 44 | ||||
| -rw-r--r-- | tests/stm32/src/bin/sdmmc.rs | 26 | ||||
| -rw-r--r-- | tests/stm32/src/bin/spi.rs | 16 | ||||
| -rw-r--r-- | tests/stm32/src/bin/spi_dma.rs | 34 | ||||
| -rw-r--r-- | tests/stm32/src/bin/ucpd.rs | 10 | ||||
| -rw-r--r-- | tests/stm32/src/bin/usart.rs | 6 |
8 files changed, 74 insertions, 68 deletions
diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs index 85a5f8d83..778d88a7b 100644 --- a/tests/stm32/src/bin/can.rs +++ b/tests/stm32/src/bin/can.rs | |||
| @@ -43,7 +43,7 @@ async fn main(_spawner: Spawner) { | |||
| 43 | // To synchronise to the bus the RX input needs to see a high level. | 43 | // To synchronise to the bus the RX input needs to see a high level. |
| 44 | // Use `mem::forget()` to release the borrow on the pin but keep the | 44 | // Use `mem::forget()` to release the borrow on the pin but keep the |
| 45 | // pull-up resistor enabled. | 45 | // pull-up resistor enabled. |
| 46 | let rx_pin = Input::new(&mut rx, Pull::Up); | 46 | let rx_pin = Input::new(rx.reborrow(), Pull::Up); |
| 47 | core::mem::forget(rx_pin); | 47 | core::mem::forget(rx_pin); |
| 48 | 48 | ||
| 49 | let mut can = embassy_stm32::can::Can::new(can, rx, tx, Irqs); | 49 | let mut can = embassy_stm32::can::Can::new(can, rx, tx, Irqs); |
diff --git a/tests/stm32/src/bin/cordic.rs b/tests/stm32/src/bin/cordic.rs index 879ad56b6..e86eea58b 100644 --- a/tests/stm32/src/bin/cordic.rs +++ b/tests/stm32/src/bin/cordic.rs | |||
| @@ -82,8 +82,8 @@ async fn main(_spawner: Spawner) { | |||
| 82 | let cnt1 = defmt::unwrap!( | 82 | let cnt1 = defmt::unwrap!( |
| 83 | cordic | 83 | cordic |
| 84 | .async_calc_32bit( | 84 | .async_calc_32bit( |
| 85 | &mut write_dma, | 85 | write_dma.reborrow(), |
| 86 | &mut read_dma, | 86 | read_dma.reborrow(), |
| 87 | &input_q1_31[2..], | 87 | &input_q1_31[2..], |
| 88 | &mut output_q1_31[cnt0..], | 88 | &mut output_q1_31[cnt0..], |
| 89 | true, | 89 | true, |
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 4a2584b4e..40b03201c 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs | |||
| @@ -20,10 +20,10 @@ async fn main(_spawner: Spawner) { | |||
| 20 | 20 | ||
| 21 | // Test initial output | 21 | // Test initial output |
| 22 | { | 22 | { |
| 23 | let b = Input::new(&mut b, Pull::None); | 23 | let b = Input::new(b.reborrow(), Pull::None); |
| 24 | 24 | ||
| 25 | { | 25 | { |
| 26 | let a = Output::new(&mut a, Level::Low, Speed::Low); | 26 | let a = Output::new(a.reborrow(), Level::Low, Speed::Low); |
| 27 | delay(); | 27 | delay(); |
| 28 | assert!(b.is_low()); | 28 | assert!(b.is_low()); |
| 29 | assert!(!b.is_high()); | 29 | assert!(!b.is_high()); |
| @@ -31,7 +31,7 @@ async fn main(_spawner: Spawner) { | |||
| 31 | assert!(!a.is_set_high()); | 31 | assert!(!a.is_set_high()); |
| 32 | } | 32 | } |
| 33 | { | 33 | { |
| 34 | let mut a = Output::new(&mut a, Level::High, Speed::Low); | 34 | let mut a = Output::new(a.reborrow(), Level::High, Speed::Low); |
| 35 | delay(); | 35 | delay(); |
| 36 | assert!(!b.is_low()); | 36 | assert!(!b.is_low()); |
| 37 | assert!(b.is_high()); | 37 | assert!(b.is_high()); |
| @@ -68,10 +68,10 @@ async fn main(_spawner: Spawner) { | |||
| 68 | 68 | ||
| 69 | // Test input no pull | 69 | // Test input no pull |
| 70 | { | 70 | { |
| 71 | let b = Input::new(&mut b, Pull::None); | 71 | let b = Input::new(b.reborrow(), Pull::None); |
| 72 | // no pull, the status is undefined | 72 | // no pull, the status is undefined |
| 73 | 73 | ||
| 74 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 74 | let mut a = Output::new(a.reborrow(), Level::Low, Speed::Low); |
| 75 | delay(); | 75 | delay(); |
| 76 | assert!(b.is_low()); | 76 | assert!(b.is_low()); |
| 77 | a.set_high(); | 77 | a.set_high(); |
| @@ -81,11 +81,11 @@ async fn main(_spawner: Spawner) { | |||
| 81 | 81 | ||
| 82 | // Test input pulldown | 82 | // Test input pulldown |
| 83 | { | 83 | { |
| 84 | let b = Input::new(&mut b, Pull::Down); | 84 | let b = Input::new(b.reborrow(), Pull::Down); |
| 85 | delay(); | 85 | delay(); |
| 86 | assert!(b.is_low()); | 86 | assert!(b.is_low()); |
| 87 | 87 | ||
| 88 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 88 | let mut a = Output::new(a.reborrow(), Level::Low, Speed::Low); |
| 89 | delay(); | 89 | delay(); |
| 90 | assert!(b.is_low()); | 90 | assert!(b.is_low()); |
| 91 | a.set_high(); | 91 | a.set_high(); |
| @@ -95,11 +95,11 @@ async fn main(_spawner: Spawner) { | |||
| 95 | 95 | ||
| 96 | // Test input pullup | 96 | // Test input pullup |
| 97 | { | 97 | { |
| 98 | let b = Input::new(&mut b, Pull::Up); | 98 | let b = Input::new(b.reborrow(), Pull::Up); |
| 99 | delay(); | 99 | delay(); |
| 100 | assert!(b.is_high()); | 100 | assert!(b.is_high()); |
| 101 | 101 | ||
| 102 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 102 | let mut a = Output::new(a.reborrow(), Level::Low, Speed::Low); |
| 103 | delay(); | 103 | delay(); |
| 104 | assert!(b.is_low()); | 104 | assert!(b.is_low()); |
| 105 | a.set_high(); | 105 | a.set_high(); |
| @@ -109,10 +109,10 @@ async fn main(_spawner: Spawner) { | |||
| 109 | 109 | ||
| 110 | // Test output open drain | 110 | // Test output open drain |
| 111 | { | 111 | { |
| 112 | let b = Input::new(&mut b, Pull::Down); | 112 | let b = Input::new(b.reborrow(), Pull::Down); |
| 113 | // no pull, the status is undefined | 113 | // no pull, the status is undefined |
| 114 | 114 | ||
| 115 | let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low); | 115 | let mut a = OutputOpenDrain::new(a.reborrow(), Level::Low, Speed::Low); |
| 116 | delay(); | 116 | delay(); |
| 117 | assert!(b.is_low()); | 117 | assert!(b.is_low()); |
| 118 | a.set_high(); // High-Z output | 118 | a.set_high(); // High-Z output |
| @@ -124,12 +124,12 @@ async fn main(_spawner: Spawner) { | |||
| 124 | // Test initial output | 124 | // Test initial output |
| 125 | { | 125 | { |
| 126 | //Flex pin configured as input | 126 | //Flex pin configured as input |
| 127 | let mut b = Flex::new(&mut b); | 127 | let mut b = Flex::new(b.reborrow()); |
| 128 | b.set_as_input(Pull::None); | 128 | b.set_as_input(Pull::None); |
| 129 | 129 | ||
| 130 | { | 130 | { |
| 131 | //Flex pin configured as output | 131 | //Flex pin configured as output |
| 132 | let mut a = Flex::new(&mut a); //Flex pin configured as output | 132 | let mut a = Flex::new(a.reborrow()); //Flex pin configured as output |
| 133 | a.set_low(); // Pin state must be set before configuring the pin, thus we avoid unknown state | 133 | a.set_low(); // Pin state must be set before configuring the pin, thus we avoid unknown state |
| 134 | a.set_as_output(Speed::Low); | 134 | a.set_as_output(Speed::Low); |
| 135 | delay(); | 135 | delay(); |
| @@ -137,7 +137,7 @@ async fn main(_spawner: Spawner) { | |||
| 137 | } | 137 | } |
| 138 | { | 138 | { |
| 139 | //Flex pin configured as output | 139 | //Flex pin configured as output |
| 140 | let mut a = Flex::new(&mut a); | 140 | let mut a = Flex::new(a.reborrow()); |
| 141 | a.set_high(); | 141 | a.set_high(); |
| 142 | a.set_as_output(Speed::Low); | 142 | a.set_as_output(Speed::Low); |
| 143 | 143 | ||
| @@ -148,10 +148,10 @@ async fn main(_spawner: Spawner) { | |||
| 148 | 148 | ||
| 149 | // Test input no pull | 149 | // Test input no pull |
| 150 | { | 150 | { |
| 151 | let mut b = Flex::new(&mut b); | 151 | let mut b = Flex::new(b.reborrow()); |
| 152 | b.set_as_input(Pull::None); // no pull, the status is undefined | 152 | b.set_as_input(Pull::None); // no pull, the status is undefined |
| 153 | 153 | ||
| 154 | let mut a = Flex::new(&mut a); | 154 | let mut a = Flex::new(a.reborrow()); |
| 155 | a.set_low(); | 155 | a.set_low(); |
| 156 | a.set_as_output(Speed::Low); | 156 | a.set_as_output(Speed::Low); |
| 157 | 157 | ||
| @@ -164,12 +164,12 @@ async fn main(_spawner: Spawner) { | |||
| 164 | 164 | ||
| 165 | // Test input pulldown | 165 | // Test input pulldown |
| 166 | { | 166 | { |
| 167 | let mut b = Flex::new(&mut b); | 167 | let mut b = Flex::new(b.reborrow()); |
| 168 | b.set_as_input(Pull::Down); | 168 | b.set_as_input(Pull::Down); |
| 169 | delay(); | 169 | delay(); |
| 170 | assert!(b.is_low()); | 170 | assert!(b.is_low()); |
| 171 | 171 | ||
| 172 | let mut a = Flex::new(&mut a); | 172 | let mut a = Flex::new(a.reborrow()); |
| 173 | a.set_low(); | 173 | a.set_low(); |
| 174 | a.set_as_output(Speed::Low); | 174 | a.set_as_output(Speed::Low); |
| 175 | delay(); | 175 | delay(); |
| @@ -181,12 +181,12 @@ async fn main(_spawner: Spawner) { | |||
| 181 | 181 | ||
| 182 | // Test input pullup | 182 | // Test input pullup |
| 183 | { | 183 | { |
| 184 | let mut b = Flex::new(&mut b); | 184 | let mut b = Flex::new(b.reborrow()); |
| 185 | b.set_as_input(Pull::Up); | 185 | b.set_as_input(Pull::Up); |
| 186 | delay(); | 186 | delay(); |
| 187 | assert!(b.is_high()); | 187 | assert!(b.is_high()); |
| 188 | 188 | ||
| 189 | let mut a = Flex::new(&mut a); | 189 | let mut a = Flex::new(a.reborrow()); |
| 190 | a.set_high(); | 190 | a.set_high(); |
| 191 | a.set_as_output(Speed::Low); | 191 | a.set_as_output(Speed::Low); |
| 192 | delay(); | 192 | delay(); |
| @@ -198,10 +198,10 @@ async fn main(_spawner: Spawner) { | |||
| 198 | 198 | ||
| 199 | // Test output open drain | 199 | // Test output open drain |
| 200 | { | 200 | { |
| 201 | let mut b = Flex::new(&mut b); | 201 | let mut b = Flex::new(b.reborrow()); |
| 202 | b.set_as_input(Pull::Down); | 202 | b.set_as_input(Pull::Down); |
| 203 | 203 | ||
| 204 | let mut a = Flex::new(&mut a); | 204 | let mut a = Flex::new(a.reborrow()); |
| 205 | a.set_low(); | 205 | a.set_low(); |
| 206 | a.set_as_input_output(Speed::Low); | 206 | a.set_as_input_output(Speed::Low); |
| 207 | delay(); | 207 | delay(); |
diff --git a/tests/stm32/src/bin/sdmmc.rs b/tests/stm32/src/bin/sdmmc.rs index a6bc117c0..07f17b569 100644 --- a/tests/stm32/src/bin/sdmmc.rs +++ b/tests/stm32/src/bin/sdmmc.rs | |||
| @@ -40,15 +40,15 @@ async fn main(_spawner: Spawner) { | |||
| 40 | // ======== Try 4bit. ============== | 40 | // ======== Try 4bit. ============== |
| 41 | info!("initializing in 4-bit mode..."); | 41 | info!("initializing in 4-bit mode..."); |
| 42 | let mut s = Sdmmc::new_4bit( | 42 | let mut s = Sdmmc::new_4bit( |
| 43 | &mut sdmmc, | 43 | sdmmc.reborrow(), |
| 44 | Irqs, | 44 | Irqs, |
| 45 | &mut dma, | 45 | dma.reborrow(), |
| 46 | &mut clk, | 46 | clk.reborrow(), |
| 47 | &mut cmd, | 47 | cmd.reborrow(), |
| 48 | &mut d0, | 48 | d0.reborrow(), |
| 49 | &mut d1, | 49 | d1.reborrow(), |
| 50 | &mut d2, | 50 | d2.reborrow(), |
| 51 | &mut d3, | 51 | d3.reborrow(), |
| 52 | Default::default(), | 52 | Default::default(), |
| 53 | ); | 53 | ); |
| 54 | 54 | ||
| @@ -89,12 +89,12 @@ async fn main(_spawner: Spawner) { | |||
| 89 | // ======== Try 1bit. ============== | 89 | // ======== Try 1bit. ============== |
| 90 | info!("initializing in 1-bit mode..."); | 90 | info!("initializing in 1-bit mode..."); |
| 91 | let mut s = Sdmmc::new_1bit( | 91 | let mut s = Sdmmc::new_1bit( |
| 92 | &mut sdmmc, | 92 | sdmmc.reborrow(), |
| 93 | Irqs, | 93 | Irqs, |
| 94 | &mut dma, | 94 | dma.reborrow(), |
| 95 | &mut clk, | 95 | clk.reborrow(), |
| 96 | &mut cmd, | 96 | cmd.reborrow(), |
| 97 | &mut d0, | 97 | d0.reborrow(), |
| 98 | Default::default(), | 98 | Default::default(), |
| 99 | ); | 99 | ); |
| 100 | 100 | ||
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index 9712a8c5a..e8310866a 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs | |||
| @@ -25,10 +25,10 @@ async fn main(_spawner: Spawner) { | |||
| 25 | spi_config.frequency = Hertz(1_000_000); | 25 | spi_config.frequency = Hertz(1_000_000); |
| 26 | 26 | ||
| 27 | let mut spi = Spi::new_blocking( | 27 | let mut spi = Spi::new_blocking( |
| 28 | &mut spi_peri, | 28 | spi_peri.reborrow(), |
| 29 | &mut sck, // Arduino D13 | 29 | sck.reborrow(), // Arduino D13 |
| 30 | &mut mosi, // Arduino D11 | 30 | mosi.reborrow(), // Arduino D11 |
| 31 | &mut miso, // Arduino D12 | 31 | miso.reborrow(), // Arduino D12 |
| 32 | spi_config, | 32 | spi_config, |
| 33 | ); | 33 | ); |
| 34 | 34 | ||
| @@ -43,20 +43,20 @@ async fn main(_spawner: Spawner) { | |||
| 43 | defmt::assert!(!embassy_stm32::pac::RCC.apb2enr().read().spi1en()); | 43 | defmt::assert!(!embassy_stm32::pac::RCC.apb2enr().read().spi1en()); |
| 44 | 44 | ||
| 45 | // test rx-only configuration | 45 | // test rx-only configuration |
| 46 | let mut spi = Spi::new_blocking_rxonly(&mut spi_peri, &mut sck, &mut miso, spi_config); | 46 | let mut spi = Spi::new_blocking_rxonly(spi_peri.reborrow(), sck.reborrow(), miso.reborrow(), spi_config); |
| 47 | let mut mosi_out = Output::new(&mut mosi, Level::Low, Speed::VeryHigh); | 47 | let mut mosi_out = Output::new(mosi.reborrow(), Level::Low, Speed::VeryHigh); |
| 48 | 48 | ||
| 49 | test_rx::<u8>(&mut spi, &mut mosi_out); | 49 | test_rx::<u8>(&mut spi, &mut mosi_out); |
| 50 | test_rx::<u16>(&mut spi, &mut mosi_out); | 50 | test_rx::<u16>(&mut spi, &mut mosi_out); |
| 51 | drop(spi); | 51 | drop(spi); |
| 52 | drop(mosi_out); | 52 | drop(mosi_out); |
| 53 | 53 | ||
| 54 | let mut spi = Spi::new_blocking_txonly(&mut spi_peri, &mut sck, &mut mosi, spi_config); | 54 | let mut spi = Spi::new_blocking_txonly(spi_peri.reborrow(), sck.reborrow(), mosi.reborrow(), spi_config); |
| 55 | test_tx::<u8>(&mut spi); | 55 | test_tx::<u8>(&mut spi); |
| 56 | test_tx::<u16>(&mut spi); | 56 | test_tx::<u16>(&mut spi); |
| 57 | drop(spi); | 57 | drop(spi); |
| 58 | 58 | ||
| 59 | let mut spi = Spi::new_blocking_txonly_nosck(&mut spi_peri, &mut mosi, spi_config); | 59 | let mut spi = Spi::new_blocking_txonly_nosck(spi_peri.reborrow(), mosi.reborrow(), spi_config); |
| 60 | test_tx::<u8>(&mut spi); | 60 | test_tx::<u8>(&mut spi); |
| 61 | test_tx::<u16>(&mut spi); | 61 | test_tx::<u16>(&mut spi); |
| 62 | drop(spi); | 62 | drop(spi); |
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 307409a16..b4fdb8faa 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs | |||
| @@ -27,12 +27,12 @@ async fn main(_spawner: Spawner) { | |||
| 27 | spi_config.frequency = Hertz(1_000_000); | 27 | spi_config.frequency = Hertz(1_000_000); |
| 28 | 28 | ||
| 29 | let mut spi = Spi::new( | 29 | let mut spi = Spi::new( |
| 30 | &mut spi_peri, | 30 | spi_peri.reborrow(), |
| 31 | &mut sck, // Arduino D13 | 31 | sck.reborrow(), // Arduino D13 |
| 32 | &mut mosi, // Arduino D11 | 32 | mosi.reborrow(), // Arduino D11 |
| 33 | &mut miso, // Arduino D12 | 33 | miso.reborrow(), // Arduino D12 |
| 34 | &mut tx_dma, | 34 | tx_dma.reborrow(), |
| 35 | &mut rx_dma, | 35 | rx_dma.reborrow(), |
| 36 | spi_config, | 36 | spi_config, |
| 37 | ); | 37 | ); |
| 38 | 38 | ||
| @@ -42,28 +42,34 @@ async fn main(_spawner: Spawner) { | |||
| 42 | 42 | ||
| 43 | // test rx-only configuration | 43 | // test rx-only configuration |
| 44 | let mut spi = Spi::new_rxonly( | 44 | let mut spi = Spi::new_rxonly( |
| 45 | &mut spi_peri, | 45 | spi_peri.reborrow(), |
| 46 | &mut sck, | 46 | sck.reborrow(), |
| 47 | &mut miso, | 47 | miso.reborrow(), |
| 48 | // SPIv1/f1 requires txdma even if rxonly. | 48 | // SPIv1/f1 requires txdma even if rxonly. |
| 49 | #[cfg(not(feature = "spi-v345"))] | 49 | #[cfg(not(feature = "spi-v345"))] |
| 50 | &mut tx_dma, | 50 | tx_dma.reborrow(), |
| 51 | &mut rx_dma, | 51 | rx_dma.reborrow(), |
| 52 | spi_config, | 52 | spi_config, |
| 53 | ); | 53 | ); |
| 54 | let mut mosi_out = Output::new(&mut mosi, Level::Low, Speed::VeryHigh); | 54 | let mut mosi_out = Output::new(mosi.reborrow(), Level::Low, Speed::VeryHigh); |
| 55 | 55 | ||
| 56 | test_rx::<u8>(&mut spi, &mut mosi_out).await; | 56 | test_rx::<u8>(&mut spi, &mut mosi_out).await; |
| 57 | test_rx::<u16>(&mut spi, &mut mosi_out).await; | 57 | test_rx::<u16>(&mut spi, &mut mosi_out).await; |
| 58 | drop(spi); | 58 | drop(spi); |
| 59 | drop(mosi_out); | 59 | drop(mosi_out); |
| 60 | 60 | ||
| 61 | let mut spi = Spi::new_txonly(&mut spi_peri, &mut sck, &mut mosi, &mut tx_dma, spi_config); | 61 | let mut spi = Spi::new_txonly( |
| 62 | spi_peri.reborrow(), | ||
| 63 | sck.reborrow(), | ||
| 64 | mosi.reborrow(), | ||
| 65 | tx_dma.reborrow(), | ||
| 66 | spi_config, | ||
| 67 | ); | ||
| 62 | test_tx::<u8>(&mut spi).await; | 68 | test_tx::<u8>(&mut spi).await; |
| 63 | test_tx::<u16>(&mut spi).await; | 69 | test_tx::<u16>(&mut spi).await; |
| 64 | drop(spi); | 70 | drop(spi); |
| 65 | 71 | ||
| 66 | let mut spi = Spi::new_txonly_nosck(&mut spi_peri, &mut mosi, &mut tx_dma, spi_config); | 72 | let mut spi = Spi::new_txonly_nosck(spi_peri.reborrow(), mosi.reborrow(), tx_dma.reborrow(), spi_config); |
| 67 | test_tx::<u8>(&mut spi).await; | 73 | test_tx::<u8>(&mut spi).await; |
| 68 | test_tx::<u16>(&mut spi).await; | 74 | test_tx::<u16>(&mut spi).await; |
| 69 | drop(spi); | 75 | drop(spi); |
diff --git a/tests/stm32/src/bin/ucpd.rs b/tests/stm32/src/bin/ucpd.rs index bd7b35d6b..97aefe1a0 100644 --- a/tests/stm32/src/bin/ucpd.rs +++ b/tests/stm32/src/bin/ucpd.rs | |||
| @@ -9,7 +9,7 @@ use defmt::{assert, assert_eq}; | |||
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_futures::join::join; | 10 | use embassy_futures::join::join; |
| 11 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, RxError, Ucpd}; | 11 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, RxError, Ucpd}; |
| 12 | use embassy_stm32::{bind_interrupts, peripherals}; | 12 | use embassy_stm32::{bind_interrupts, peripherals, Peri}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| @@ -28,8 +28,8 @@ async fn wait_for_vstate<T: ucpd::Instance>(cc_phy: &mut CcPhy<'_, T>, vstate: C | |||
| 28 | 28 | ||
| 29 | async fn source( | 29 | async fn source( |
| 30 | mut ucpd: Ucpd<'static, peripherals::UCPD1>, | 30 | mut ucpd: Ucpd<'static, peripherals::UCPD1>, |
| 31 | rx_dma: peripherals::DMA1_CH1, | 31 | rx_dma: Peri<'static, peripherals::DMA1_CH1>, |
| 32 | tx_dma: peripherals::DMA1_CH2, | 32 | tx_dma: Peri<'static, peripherals::DMA1_CH2>, |
| 33 | ) { | 33 | ) { |
| 34 | debug!("source: setting default current pull-up"); | 34 | debug!("source: setting default current pull-up"); |
| 35 | ucpd.cc_phy().set_pull(CcPull::SourceDefaultUsb); | 35 | ucpd.cc_phy().set_pull(CcPull::SourceDefaultUsb); |
| @@ -65,8 +65,8 @@ async fn source( | |||
| 65 | 65 | ||
| 66 | async fn sink( | 66 | async fn sink( |
| 67 | mut ucpd: Ucpd<'static, peripherals::UCPD2>, | 67 | mut ucpd: Ucpd<'static, peripherals::UCPD2>, |
| 68 | rx_dma: peripherals::DMA1_CH3, | 68 | rx_dma: Peri<'static, peripherals::DMA1_CH3>, |
| 69 | tx_dma: peripherals::DMA1_CH4, | 69 | tx_dma: Peri<'static, peripherals::DMA1_CH4>, |
| 70 | ) { | 70 | ) { |
| 71 | debug!("sink: setting pull down"); | 71 | debug!("sink: setting pull down"); |
| 72 | ucpd.cc_phy().set_pull(CcPull::Sink); | 72 | ucpd.cc_phy().set_pull(CcPull::Sink); |
diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 2f601ad0e..129c7b692 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | 22 | ||
| 23 | { | 23 | { |
| 24 | let config = Config::default(); | 24 | let config = Config::default(); |
| 25 | let mut usart = Uart::new_blocking(&mut usart, &mut rx, &mut tx, config).unwrap(); | 25 | let mut usart = Uart::new_blocking(usart.reborrow(), rx.reborrow(), tx.reborrow(), config).unwrap(); |
| 26 | 26 | ||
| 27 | // We can't send too many bytes, they have to fit in the FIFO. | 27 | // We can't send too many bytes, they have to fit in the FIFO. |
| 28 | // This is because we aren't sending+receiving at the same time. | 28 | // This is because we aren't sending+receiving at the same time. |
| @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) { | |||
| 45 | // Test error handling with with an overflow error | 45 | // Test error handling with with an overflow error |
| 46 | { | 46 | { |
| 47 | let config = Config::default(); | 47 | let config = Config::default(); |
| 48 | let mut usart = Uart::new_blocking(&mut usart, &mut rx, &mut tx, config).unwrap(); | 48 | let mut usart = Uart::new_blocking(usart.reborrow(), rx.reborrow(), tx.reborrow(), config).unwrap(); |
| 49 | 49 | ||
| 50 | // Send enough bytes to fill the RX FIFOs off all USART versions. | 50 | // Send enough bytes to fill the RX FIFOs off all USART versions. |
| 51 | let data = [0; 64]; | 51 | let data = [0; 64]; |
| @@ -75,7 +75,7 @@ async fn main(_spawner: Spawner) { | |||
| 75 | 75 | ||
| 76 | let mut config = Config::default(); | 76 | let mut config = Config::default(); |
| 77 | config.baudrate = baudrate; | 77 | config.baudrate = baudrate; |
| 78 | let mut usart = match Uart::new_blocking(&mut usart, &mut rx, &mut tx, config) { | 78 | let mut usart = match Uart::new_blocking(usart.reborrow(), rx.reborrow(), tx.reborrow(), config) { |
| 79 | Ok(x) => x, | 79 | Ok(x) => x, |
| 80 | Err(ConfigError::BaudrateTooHigh) => { | 80 | Err(ConfigError::BaudrateTooHigh) => { |
| 81 | info!("baudrate too high"); | 81 | info!("baudrate too high"); |
