Skip to content

Commit

Permalink
Fix examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed May 15, 2022
1 parent 48d4f93 commit f00caf6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 12 additions & 4 deletions examples/rtic_frame_serial_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ use heapless::{
use panic_halt as _;
use rtic::app;
use stm32l4xx_hal as hal;
use stm32l4xx_hal::dma::{RxDma, TxDma};
use stm32l4xx_hal::serial::{Rx, Tx};
use stm32l4xx_hal::{
dma::{RxDma, TxDma},
gpio::{self, Alternate, PushPull},
serial::{Rx, Tx},
};

type TxPin = gpio::PA2<Alternate<PushPull, 7>>;
type RxPin = gpio::PA3<Alternate<PushPull, 7>>;

// The pool gives out `Box<DMAFrame>`s that can hold 8 bytes
pool!(
Expand All @@ -36,8 +42,10 @@ pool!(
#[app(device = stm32l4xx_hal::stm32, peripherals = true)]
const APP: () = {
struct Resources {
frame_reader: FrameReader<Box<SerialDMAPool>, RxDma<Rx<USART2>, dma::dma1::C6>, 8>,
frame_sender: FrameSender<Box<SerialDMAPool>, TxDma<Tx<USART2>, dma::dma1::C7>, 8>,
frame_reader:
FrameReader<Box<SerialDMAPool>, RxDma<Rx<USART2, (TxPin, RxPin)>, dma::dma1::C6>, 8>,
frame_sender:
FrameSender<Box<SerialDMAPool>, TxDma<Tx<USART2, (TxPin, RxPin)>, dma::dma1::C7>, 8>,
}

#[init]
Expand Down
8 changes: 6 additions & 2 deletions examples/serial_echo_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ use heapless::{consts::U8, spsc};
use nb::block;
use rtt_target::{rprint, rprintln};
use stm32l4xx_hal::{
gpio::{self, Alternate, PushPull},
pac::{self, USART2},
prelude::*,
serial::{self, Config, Serial},
};

type TxPin = gpio::PA2<Alternate<PushPull, 7>>;
type RxPin = gpio::PA3<Alternate<PushPull, 7>>;

#[rtic::app(device = stm32l4xx_hal::pac)]
const APP: () = {
struct Resources {
rx: serial::Rx<USART2>,
tx: serial::Tx<USART2>,
rx: serial::Rx<USART2, (TxPin, RxPin)>,
tx: serial::Tx<USART2, (TxPin, RxPin)>,

rx_prod: spsc::Producer<'static, u8, U8>,
rx_cons: spsc::Consumer<'static, u8, U8>,
Expand Down

0 comments on commit f00caf6

Please sign in to comment.