stm32: Remove OptionalPin
The idea behind OptionalPin has a few problems: - you need to impl the signal traits for NoPin which is a bit weird https://github.com/embassy-rs/embassy/blob/master/embassy-stm32/src/dcmi.rs#L413-L416 - you can pass any combination of set/unset pins, which needs checking at runtime https://github.com/embassy-rs/embassy/blob/master/embassy-stm32/src/dcmi.rs#L130 The replacement is to do multiple `new` constructors for each combination of pins you want to take.
This commit is contained in:
@ -6,7 +6,6 @@
|
||||
mod example_common;
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy_stm32::gpio::NoPin;
|
||||
use embassy_stm32::pwm::{simple_pwm::SimplePwm, Channel};
|
||||
use embassy_stm32::time::U32Ext;
|
||||
use embassy_stm32::Peripherals;
|
||||
@ -16,7 +15,7 @@ use example_common::*;
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
let mut pwm = SimplePwm::new(p.TIM2, p.PA5, NoPin, NoPin, NoPin, 10000.hz());
|
||||
let mut pwm = SimplePwm::new_1ch(p.TIM2, p.PA5, 10000.hz());
|
||||
let max = pwm.get_max_duty();
|
||||
pwm.enable(Channel::Ch1);
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy_stm32::dcmi::*;
|
||||
use embassy_stm32::gpio::{Level, NoPin, Output, Speed};
|
||||
use embassy_stm32::dcmi::{self, *};
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::i2c::I2c;
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::rcc::{Mco, Mco1Source, McoClock};
|
||||
@ -78,31 +78,10 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
);
|
||||
|
||||
let dcmi_irq = interrupt::take!(DCMI);
|
||||
let mut dcmi = Dcmi::new(
|
||||
p.DCMI,
|
||||
p.DMA1_CH0,
|
||||
VSyncDataInvalidLevel::High,
|
||||
HSyncDataInvalidLevel::Low,
|
||||
PixelClockPolarity::RisingEdge,
|
||||
false,
|
||||
dcmi_irq,
|
||||
p.PC6,
|
||||
p.PC7,
|
||||
p.PE0,
|
||||
p.PE1,
|
||||
p.PE4,
|
||||
p.PD3,
|
||||
p.PE5,
|
||||
p.PE6,
|
||||
NoPin,
|
||||
NoPin,
|
||||
NoPin,
|
||||
NoPin,
|
||||
NoPin,
|
||||
NoPin,
|
||||
p.PB7,
|
||||
p.PA4,
|
||||
p.PA6,
|
||||
let config = dcmi::Config::default();
|
||||
let mut dcmi = Dcmi::new_8bit(
|
||||
p.DCMI, p.DMA1_CH0, dcmi_irq, p.PC6, p.PC7, p.PE0, p.PE1, p.PE4, p.PD3, p.PE5, p.PE6,
|
||||
p.PB7, p.PA4, p.PA6, config,
|
||||
);
|
||||
|
||||
defmt::info!("attempting capture");
|
||||
|
@ -5,7 +5,6 @@
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
|
||||
use embassy_stm32::gpio::NoPin;
|
||||
use example_common::*;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
@ -17,7 +16,7 @@ fn main() -> ! {
|
||||
|
||||
let p = embassy_stm32::init(config());
|
||||
|
||||
let mut dac = Dac::new(p.DAC1, p.PA4, NoPin);
|
||||
let mut dac = Dac::new_1ch(p.DAC1, p.PA4);
|
||||
|
||||
loop {
|
||||
for v in 0..=255 {
|
||||
|
@ -10,7 +10,6 @@ use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy::util::Unborrow;
|
||||
use embassy_hal_common::unborrow;
|
||||
use embassy_stm32::gpio::NoPin;
|
||||
use embassy_stm32::pwm::{pins::*, Channel, OutputCompareMode};
|
||||
use embassy_stm32::time::{Hertz, U32Ext};
|
||||
use embassy_stm32::timer::GeneralPurpose32bitInstance;
|
||||
@ -33,7 +32,7 @@ pub fn config() -> Config {
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
let mut pwm = SimplePwm32::new(p.TIM5, p.PA0, NoPin, NoPin, NoPin, 10000.hz());
|
||||
let mut pwm = SimplePwm32::new(p.TIM5, p.PA0, p.PA1, p.PA2, p.PA3, 10000.hz());
|
||||
let max = pwm.get_max_duty();
|
||||
pwm.enable(Channel::Ch1);
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
mod example_common;
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy_stm32::gpio::NoPin;
|
||||
use embassy_stm32::pwm::{simple_pwm::SimplePwm, Channel};
|
||||
use embassy_stm32::time::U32Ext;
|
||||
use embassy_stm32::{Config, Peripherals};
|
||||
@ -28,7 +27,7 @@ pub fn config() -> Config {
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
let mut pwm = SimplePwm::new(p.TIM3, p.PA6, NoPin, NoPin, NoPin, 10000.hz());
|
||||
let mut pwm = SimplePwm::new_1ch(p.TIM3, p.PA6, 10000.hz());
|
||||
let max = pwm.get_max_duty();
|
||||
pwm.enable(Channel::Ch1);
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
mod example_common;
|
||||
|
||||
use embassy_stm32::dac::{Channel, Dac, Value};
|
||||
use embassy_stm32::gpio::NoPin;
|
||||
use embassy_stm32::pac;
|
||||
use example_common::*;
|
||||
|
||||
@ -22,7 +21,7 @@ fn main() -> ! {
|
||||
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
let mut dac = Dac::new(p.DAC1, p.PA4, NoPin);
|
||||
let mut dac = Dac::new_1ch(p.DAC1, p.PA4);
|
||||
|
||||
loop {
|
||||
for v in 0..=255 {
|
||||
|
Reference in New Issue
Block a user