Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Cargo.lock
third_party
/Cargo.toml
out/
Session.vim
10 changes: 5 additions & 5 deletions embassy-stm32/src/can/bxcan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use super::common::{BufferedCanReceiver, BufferedCanSender};
use super::frame::{Envelope, Frame};
use super::util;
use crate::can::enums::{BusError, TryReadError};
use crate::gpio::AFType;
use crate::gpio::{AfType, OutputType, Pull, Speed};
use crate::interrupt::typelevel::Interrupt;
use crate::rcc::{self, RccPeripheral};
use crate::{interrupt, peripherals, Peripheral};
Expand Down Expand Up @@ -188,8 +188,8 @@ impl<'d> Can<'d> {
let info = T::info();
let regs = &T::info().regs;

rx.set_as_af(rx.af_num(), AFType::Input);
tx.set_as_af(tx.af_num(), AFType::OutputPushPull);
rx.set_as_af(rx.af_num(), AfType::input(Pull::None));
tx.set_as_af(tx.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));

rcc::enable_and_reset::<T>();

Expand Down Expand Up @@ -223,8 +223,8 @@ impl<'d> Can<'d> {
info.sce_interrupt.enable();
}

rx.set_as_af(rx.af_num(), AFType::Input);
tx.set_as_af(tx.af_num(), AFType::OutputPushPull);
rx.set_as_af(rx.af_num(), AfType::input(Pull::None));
tx.set_as_af(tx.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));

Registers(T::regs()).leave_init_mode();

Expand Down
10 changes: 5 additions & 5 deletions embassy-stm32/src/can/fdcan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use embassy_sync::channel::{Channel, DynamicReceiver, DynamicSender};
use embassy_sync::waitqueue::AtomicWaker;

use crate::can::fd::peripheral::Registers;
use crate::gpio::AFType;
use crate::gpio::{AfType, OutputType, Pull, Speed};
use crate::interrupt::typelevel::Interrupt;
use crate::rcc::{self, RccPeripheral};
use crate::{interrupt, peripherals, Peripheral};
Expand Down Expand Up @@ -184,17 +184,17 @@ impl<'d> CanConfigurator<'d> {
) -> CanConfigurator<'d> {
into_ref!(_peri, rx, tx);

rx.set_as_af(rx.af_num(), AFType::Input);
tx.set_as_af(tx.af_num(), AFType::OutputPushPull);
rx.set_as_af(rx.af_num(), AfType::input(Pull::None));
tx.set_as_af(tx.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));

rcc::enable_and_reset::<T>();

let mut config = crate::can::fd::config::FdCanConfig::default();
config.timestamp_source = TimestampSource::Prescaler(TimestampPrescaler::_1);
T::registers().into_config_mode(config);

rx.set_as_af(rx.af_num(), AFType::Input);
tx.set_as_af(tx.af_num(), AFType::OutputPushPull);
rx.set_as_af(rx.af_num(), AfType::input(Pull::None));
tx.set_as_af(tx.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));

unsafe {
T::IT0Interrupt::unpend(); // Not unsafe
Expand Down
5 changes: 2 additions & 3 deletions embassy-stm32/src/dcmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use embassy_hal_internal::{into_ref, PeripheralRef};
use embassy_sync::waitqueue::AtomicWaker;

use crate::dma::Transfer;
use crate::gpio::{AFType, Speed};
use crate::gpio::{AfType, Pull};
use crate::interrupt::typelevel::Interrupt;
use crate::{interrupt, rcc, Peripheral};

Expand Down Expand Up @@ -109,8 +109,7 @@ macro_rules! config_pins {
into_ref!($($pin),*);
critical_section::with(|_| {
$(
$pin.set_as_af($pin.af_num(), AFType::Input);
$pin.set_speed(Speed::VeryHigh);
$pin.set_as_af($pin.af_num(), AfType::input(Pull::None));
)*
})
};
Expand Down
2 changes: 1 addition & 1 deletion embassy-stm32/src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod dmamux;
pub(crate) use dmamux::*;

mod util;
pub(crate) use util::*;
pub use util::ChannelAndRequest;

pub(crate) mod ringbuffer;
pub mod word;
Expand Down
12 changes: 9 additions & 3 deletions embassy-stm32/src/dma/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ use embassy_hal_internal::PeripheralRef;
use super::word::Word;
use super::{AnyChannel, Request, Transfer, TransferOptions};

/// Convenience wrapper, contains a channel and a request number.
/// Convenience wrapper, contains a DMA channel and a DMA request number.
///
/// Commonly used in peripheral drivers that own DMA channels.
pub(crate) struct ChannelAndRequest<'d> {
pub struct ChannelAndRequest<'d> {
/// DMA channel.
pub channel: PeripheralRef<'d, AnyChannel>,
/// DMA request.
pub request: Request,
}

impl<'d> ChannelAndRequest<'d> {
/// See [`Transfer::new_read()`].
pub unsafe fn read<'a, W: Word>(
&'a mut self,
peri_addr: *mut W,
Expand All @@ -21,6 +24,7 @@ impl<'d> ChannelAndRequest<'d> {
Transfer::new_read(&mut self.channel, self.request, peri_addr, buf, options)
}

/// See [`Transfer::new_read_raw()`].
pub unsafe fn read_raw<'a, W: Word>(
&'a mut self,
peri_addr: *mut W,
Expand All @@ -30,6 +34,7 @@ impl<'d> ChannelAndRequest<'d> {
Transfer::new_read_raw(&mut self.channel, self.request, peri_addr, buf, options)
}

/// See [`Transfer::new_write()`].
pub unsafe fn write<'a, W: Word>(
&'a mut self,
buf: &'a [W],
Expand All @@ -39,6 +44,7 @@ impl<'d> ChannelAndRequest<'d> {
Transfer::new_write(&mut self.channel, self.request, buf, peri_addr, options)
}

/// See [`Transfer::new_write_raw()`].
pub unsafe fn write_raw<'a, W: Word>(
&'a mut self,
buf: *const [W],
Expand All @@ -48,7 +54,7 @@ impl<'d> ChannelAndRequest<'d> {
Transfer::new_write_raw(&mut self.channel, self.request, buf, peri_addr, options)
}

#[allow(dead_code)]
/// See [`Transfer::new_write_repeated()`].
pub unsafe fn write_repeated<'a, W: Word>(
&'a mut self,
repeated: &'a W,
Expand Down
5 changes: 2 additions & 3 deletions embassy-stm32/src/dsihost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::marker::PhantomData;
use embassy_hal_internal::{into_ref, PeripheralRef};

//use crate::gpio::{AnyPin, SealedPin};
use crate::gpio::{AFType, AnyPin, Pull, Speed};
use crate::gpio::{AfType, AnyPin, OutputType, Speed};
use crate::rcc::{self, RccPeripheral};
use crate::{peripherals, Peripheral};

Expand Down Expand Up @@ -80,8 +80,7 @@ impl<'d, T: Instance> DsiHost<'d, T> {
rcc::enable_and_reset::<T>();

// Set Tearing Enable pin according to CubeMx example
te.set_as_af_pull(te.af_num(), AFType::OutputPushPull, Pull::None);
te.set_speed(Speed::Low);
te.set_as_af(te.af_num(), AfType::output(OutputType::PushPull, Speed::Low));
/*
T::regs().wcr().modify(|w| {
w.set_dsien(true);
Expand Down
12 changes: 6 additions & 6 deletions embassy-stm32/src/eth/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use stm32_metapac::eth::vals::{Apcs, Cr, Dm, DmaomrSr, Fes, Ftf, Ifg, MbProgress
pub(crate) use self::rx_desc::{RDes, RDesRing};
pub(crate) use self::tx_desc::{TDes, TDesRing};
use super::*;
use crate::gpio::{AFType, AnyPin, SealedPin};
#[cfg(eth_v1a)]
use crate::gpio::Pull;
use crate::gpio::{AfType, AnyPin, OutputType, SealedPin, Speed};
use crate::interrupt::InterruptExt;
#[cfg(eth_v1a)]
use crate::pac::AFIO;
Expand Down Expand Up @@ -61,7 +63,7 @@ macro_rules! config_in_pins {
critical_section::with(|_| {
$(
// TODO properly create a set_as_input function
$pin.set_as_af($pin.af_num(), AFType::Input);
$pin.set_as_af($pin.af_num(), AfType::input(Pull::None));
)*
})
}
Expand All @@ -72,8 +74,7 @@ macro_rules! config_af_pins {
($($pin:ident),*) => {
critical_section::with(|_| {
$(
// We are lucky here, this configures to max speed (50MHz)
$pin.set_as_af($pin.af_num(), AFType::OutputPushPull);
$pin.set_as_af($pin.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));
)*
})
};
Expand All @@ -84,8 +85,7 @@ macro_rules! config_pins {
($($pin:ident),*) => {
critical_section::with(|_| {
$(
$pin.set_as_af($pin.af_num(), AFType::OutputPushPull);
$pin.set_speed(crate::gpio::Speed::VeryHigh);
$pin.set_as_af($pin.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));
)*
})
};
Expand Down
6 changes: 3 additions & 3 deletions embassy-stm32/src/eth/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use stm32_metapac::syscfg::vals::EthSelPhy;

pub(crate) use self::descriptors::{RDes, RDesRing, TDes, TDesRing};
use super::*;
use crate::gpio::{AFType, AnyPin, SealedPin as _, Speed};
use crate::gpio::{AfType, AnyPin, OutputType, SealedPin as _, Speed};
use crate::interrupt::InterruptExt;
use crate::pac::ETH;
use crate::rcc::SealedRccPeripheral;
Expand Down Expand Up @@ -56,8 +56,8 @@ macro_rules! config_pins {
($($pin:ident),*) => {
critical_section::with(|_| {
$(
$pin.set_as_af($pin.af_num(), AFType::OutputPushPull);
$pin.set_speed(Speed::VeryHigh);
// TODO: shouldn't some pins be configured as inputs?
$pin.set_as_af($pin.af_num(), AfType::output(OutputType::PushPull, Speed::VeryHigh));
)*
})
};
Expand Down
5 changes: 2 additions & 3 deletions embassy-stm32/src/fmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::marker::PhantomData;

use embassy_hal_internal::into_ref;

use crate::gpio::{AFType, Pull, Speed};
use crate::gpio::{AfType, OutputType, Pull, Speed};
use crate::{rcc, Peripheral};

/// FMC driver
Expand Down Expand Up @@ -76,8 +76,7 @@ macro_rules! config_pins {
($($pin:ident),*) => {
into_ref!($($pin),*);
$(
$pin.set_as_af_pull($pin.af_num(), AFType::OutputPushPull, Pull::Up);
$pin.set_speed(Speed::VeryHigh);
$pin.set_as_af($pin.af_num(), AfType::output_pull(OutputType::PushPull, Speed::VeryHigh, Pull::Up));
)*
};
}
Expand Down
Loading