stm32: Add standard crate-wide macros for pin/dma traits, switch all drivers to use them.
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use embassy_stm32::peripherals::ETH;
|
||||
use example_common::config;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
@ -27,7 +28,7 @@ use peripherals::RNG;
|
||||
|
||||
#[embassy::task]
|
||||
async fn main_task(
|
||||
device: &'static mut Ethernet<'static, LAN8742A, 4, 4>,
|
||||
device: &'static mut Ethernet<'static, ETH, LAN8742A, 4, 4>,
|
||||
config: &'static mut StaticConfigurator,
|
||||
spawner: Spawner,
|
||||
) {
|
||||
@ -82,8 +83,8 @@ fn _embassy_rand(buf: &mut [u8]) {
|
||||
static mut RNG_INST: Option<Rng<RNG>> = None;
|
||||
|
||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
||||
static STATE: Forever<State<'static, 4, 4>> = Forever::new();
|
||||
static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new();
|
||||
static STATE: Forever<State<'static, ETH, 4, 4>> = Forever::new();
|
||||
static ETH: Forever<Ethernet<'static, ETH, LAN8742A, 4, 4>> = Forever::new();
|
||||
static CONFIG: Forever<StaticConfigurator> = Forever::new();
|
||||
static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new();
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use embassy_stm32::peripherals::ETH;
|
||||
use example_common::config;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
@ -26,7 +27,7 @@ use peripherals::RNG;
|
||||
|
||||
#[embassy::task]
|
||||
async fn main_task(
|
||||
device: &'static mut Ethernet<'static, LAN8742A, 4, 4>,
|
||||
device: &'static mut Ethernet<'static, ETH, LAN8742A, 4, 4>,
|
||||
config: &'static mut StaticConfigurator,
|
||||
spawner: Spawner,
|
||||
) {
|
||||
@ -81,8 +82,8 @@ fn _embassy_rand(buf: &mut [u8]) {
|
||||
static mut RNG_INST: Option<Rng<RNG>> = None;
|
||||
|
||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
||||
static STATE: Forever<State<'static, 4, 4>> = Forever::new();
|
||||
static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new();
|
||||
static STATE: Forever<State<'static, ETH, 4, 4>> = Forever::new();
|
||||
static ETH: Forever<Ethernet<'static, ETH, LAN8742A, 4, 4>> = Forever::new();
|
||||
static CONFIG: Forever<StaticConfigurator> = Forever::new();
|
||||
static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new();
|
||||
|
||||
|
@ -10,9 +10,10 @@ use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy::util::Unborrow;
|
||||
use embassy_hal_common::unborrow;
|
||||
use embassy_stm32::pwm::{pins::*, Channel, OutputCompareMode};
|
||||
use embassy_stm32::gpio::low_level::AFType;
|
||||
use embassy_stm32::gpio::Speed;
|
||||
use embassy_stm32::pwm::*;
|
||||
use embassy_stm32::time::{Hertz, U32Ext};
|
||||
use embassy_stm32::timer::GeneralPurpose32bitInstance;
|
||||
use embassy_stm32::{Config, Peripherals};
|
||||
use example_common::*;
|
||||
|
||||
@ -50,12 +51,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
Timer::after(Duration::from_millis(300)).await;
|
||||
}
|
||||
}
|
||||
pub struct SimplePwm32<'d, T: GeneralPurpose32bitInstance> {
|
||||
pub struct SimplePwm32<'d, T: CaptureCompare32bitInstance> {
|
||||
phantom: PhantomData<&'d mut T>,
|
||||
inner: T,
|
||||
}
|
||||
|
||||
impl<'d, T: GeneralPurpose32bitInstance> SimplePwm32<'d, T> {
|
||||
impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
|
||||
pub fn new<F: Into<Hertz>>(
|
||||
tim: impl Unborrow<Target = T> + 'd,
|
||||
ch1: impl Unborrow<Target = impl Channel1Pin<T>> + 'd,
|
||||
@ -70,10 +71,14 @@ impl<'d, T: GeneralPurpose32bitInstance> SimplePwm32<'d, T> {
|
||||
<T as embassy_stm32::rcc::low_level::RccPeripheral>::reset();
|
||||
|
||||
unsafe {
|
||||
ch1.configure();
|
||||
ch2.configure();
|
||||
ch3.configure();
|
||||
ch4.configure();
|
||||
ch1.set_speed(Speed::VeryHigh);
|
||||
ch1.set_as_af(ch1.af_num(), AFType::OutputPushPull);
|
||||
ch2.set_speed(Speed::VeryHigh);
|
||||
ch2.set_as_af(ch1.af_num(), AFType::OutputPushPull);
|
||||
ch3.set_speed(Speed::VeryHigh);
|
||||
ch3.set_as_af(ch1.af_num(), AFType::OutputPushPull);
|
||||
ch4.set_speed(Speed::VeryHigh);
|
||||
ch4.set_as_af(ch1.af_num(), AFType::OutputPushPull);
|
||||
}
|
||||
|
||||
let mut this = Self {
|
||||
|
Reference in New Issue
Block a user