Skip to content

Commit f00caf6

Browse files
committed
Fix examples.
1 parent 48d4f93 commit f00caf6

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

examples/rtic_frame_serial_dma.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ use heapless::{
2424
use panic_halt as _;
2525
use rtic::app;
2626
use stm32l4xx_hal as hal;
27-
use stm32l4xx_hal::dma::{RxDma, TxDma};
28-
use stm32l4xx_hal::serial::{Rx, Tx};
27+
use stm32l4xx_hal::{
28+
dma::{RxDma, TxDma},
29+
gpio::{self, Alternate, PushPull},
30+
serial::{Rx, Tx},
31+
};
32+
33+
type TxPin = gpio::PA2<Alternate<PushPull, 7>>;
34+
type RxPin = gpio::PA3<Alternate<PushPull, 7>>;
2935

3036
// The pool gives out `Box<DMAFrame>`s that can hold 8 bytes
3137
pool!(
@@ -36,8 +42,10 @@ pool!(
3642
#[app(device = stm32l4xx_hal::stm32, peripherals = true)]
3743
const APP: () = {
3844
struct Resources {
39-
frame_reader: FrameReader<Box<SerialDMAPool>, RxDma<Rx<USART2>, dma::dma1::C6>, 8>,
40-
frame_sender: FrameSender<Box<SerialDMAPool>, TxDma<Tx<USART2>, dma::dma1::C7>, 8>,
45+
frame_reader:
46+
FrameReader<Box<SerialDMAPool>, RxDma<Rx<USART2, (TxPin, RxPin)>, dma::dma1::C6>, 8>,
47+
frame_sender:
48+
FrameSender<Box<SerialDMAPool>, TxDma<Tx<USART2, (TxPin, RxPin)>, dma::dma1::C7>, 8>,
4149
}
4250

4351
#[init]

examples/serial_echo_rtic.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ use heapless::{consts::U8, spsc};
77
use nb::block;
88
use rtt_target::{rprint, rprintln};
99
use stm32l4xx_hal::{
10+
gpio::{self, Alternate, PushPull},
1011
pac::{self, USART2},
1112
prelude::*,
1213
serial::{self, Config, Serial},
1314
};
1415

16+
type TxPin = gpio::PA2<Alternate<PushPull, 7>>;
17+
type RxPin = gpio::PA3<Alternate<PushPull, 7>>;
18+
1519
#[rtic::app(device = stm32l4xx_hal::pac)]
1620
const APP: () = {
1721
struct Resources {
18-
rx: serial::Rx<USART2>,
19-
tx: serial::Tx<USART2>,
22+
rx: serial::Rx<USART2, (TxPin, RxPin)>,
23+
tx: serial::Tx<USART2, (TxPin, RxPin)>,
2024

2125
rx_prod: spsc::Producer<'static, u8, U8>,
2226
rx_cons: spsc::Consumer<'static, u8, U8>,

0 commit comments

Comments
 (0)