mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
stm32/usb: merge usb and usb_otg into single module.
This commit is contained in:
parent
594d330a49
commit
530ff9d4d3
@ -826,20 +826,20 @@ fn main() {
|
||||
(("dcmi", "PIXCLK"), quote!(crate::dcmi::PixClkPin)),
|
||||
(("usb", "DP"), quote!(crate::usb::DpPin)),
|
||||
(("usb", "DM"), quote!(crate::usb::DmPin)),
|
||||
(("otg", "DP"), quote!(crate::usb_otg::DpPin)),
|
||||
(("otg", "DM"), quote!(crate::usb_otg::DmPin)),
|
||||
(("otg", "ULPI_CK"), quote!(crate::usb_otg::UlpiClkPin)),
|
||||
(("otg", "ULPI_DIR"), quote!(crate::usb_otg::UlpiDirPin)),
|
||||
(("otg", "ULPI_NXT"), quote!(crate::usb_otg::UlpiNxtPin)),
|
||||
(("otg", "ULPI_STP"), quote!(crate::usb_otg::UlpiStpPin)),
|
||||
(("otg", "ULPI_D0"), quote!(crate::usb_otg::UlpiD0Pin)),
|
||||
(("otg", "ULPI_D1"), quote!(crate::usb_otg::UlpiD1Pin)),
|
||||
(("otg", "ULPI_D2"), quote!(crate::usb_otg::UlpiD2Pin)),
|
||||
(("otg", "ULPI_D3"), quote!(crate::usb_otg::UlpiD3Pin)),
|
||||
(("otg", "ULPI_D4"), quote!(crate::usb_otg::UlpiD4Pin)),
|
||||
(("otg", "ULPI_D5"), quote!(crate::usb_otg::UlpiD5Pin)),
|
||||
(("otg", "ULPI_D6"), quote!(crate::usb_otg::UlpiD6Pin)),
|
||||
(("otg", "ULPI_D7"), quote!(crate::usb_otg::UlpiD7Pin)),
|
||||
(("otg", "DP"), quote!(crate::usb::DpPin)),
|
||||
(("otg", "DM"), quote!(crate::usb::DmPin)),
|
||||
(("otg", "ULPI_CK"), quote!(crate::usb::UlpiClkPin)),
|
||||
(("otg", "ULPI_DIR"), quote!(crate::usb::UlpiDirPin)),
|
||||
(("otg", "ULPI_NXT"), quote!(crate::usb::UlpiNxtPin)),
|
||||
(("otg", "ULPI_STP"), quote!(crate::usb::UlpiStpPin)),
|
||||
(("otg", "ULPI_D0"), quote!(crate::usb::UlpiD0Pin)),
|
||||
(("otg", "ULPI_D1"), quote!(crate::usb::UlpiD1Pin)),
|
||||
(("otg", "ULPI_D2"), quote!(crate::usb::UlpiD2Pin)),
|
||||
(("otg", "ULPI_D3"), quote!(crate::usb::UlpiD3Pin)),
|
||||
(("otg", "ULPI_D4"), quote!(crate::usb::UlpiD4Pin)),
|
||||
(("otg", "ULPI_D5"), quote!(crate::usb::UlpiD5Pin)),
|
||||
(("otg", "ULPI_D6"), quote!(crate::usb::UlpiD6Pin)),
|
||||
(("otg", "ULPI_D7"), quote!(crate::usb::UlpiD7Pin)),
|
||||
(("can", "TX"), quote!(crate::can::TxPin)),
|
||||
(("can", "RX"), quote!(crate::can::RxPin)),
|
||||
(("eth", "REF_CLK"), quote!(crate::eth::RefClkPin)),
|
||||
|
@ -79,10 +79,8 @@ pub mod ucpd;
|
||||
pub mod uid;
|
||||
#[cfg(usart)]
|
||||
pub mod usart;
|
||||
#[cfg(usb)]
|
||||
#[cfg(any(usb, otg))]
|
||||
pub mod usb;
|
||||
#[cfg(otg)]
|
||||
pub mod usb_otg;
|
||||
#[cfg(iwdg)]
|
||||
pub mod wdg;
|
||||
|
||||
@ -107,10 +105,10 @@ pub use crate::_generated::interrupt;
|
||||
/// Example of how to bind one interrupt:
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// use embassy_stm32::{bind_interrupts, usb_otg, peripherals};
|
||||
/// use embassy_stm32::{bind_interrupts, usb, peripherals};
|
||||
///
|
||||
/// bind_interrupts!(struct Irqs {
|
||||
/// OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
/// OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
/// });
|
||||
/// ```
|
||||
///
|
||||
|
@ -1,37 +1,6 @@
|
||||
//! Universal Serial Bus (USB)
|
||||
|
||||
use crate::interrupt;
|
||||
use crate::rcc::RccPeripheral;
|
||||
|
||||
mod usb;
|
||||
pub use usb::*;
|
||||
|
||||
pub(crate) mod sealed {
|
||||
pub trait Instance {
|
||||
fn regs() -> crate::pac::usb::Usb;
|
||||
}
|
||||
}
|
||||
|
||||
/// USB instance trait.
|
||||
pub trait Instance: sealed::Instance + RccPeripheral + 'static {
|
||||
/// Interrupt for this USB instance.
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
// Internal PHY pins
|
||||
pin_trait!(DpPin, Instance);
|
||||
pin_trait!(DmPin, Instance);
|
||||
|
||||
foreach_interrupt!(
|
||||
($inst:ident, usb, $block:ident, LP, $irq:ident) => {
|
||||
impl sealed::Instance for crate::peripherals::$inst {
|
||||
fn regs() -> crate::pac::usb::Usb {
|
||||
crate::pac::$inst
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
);
|
||||
#[cfg_attr(usb, path = "usb.rs")]
|
||||
#[cfg_attr(otg, path = "otg.rs")]
|
||||
mod _version;
|
||||
pub use _version::*;
|
||||
|
@ -11,7 +11,6 @@ use embassy_usb_driver::{
|
||||
};
|
||||
use futures::future::poll_fn;
|
||||
|
||||
use super::*;
|
||||
use crate::gpio::sealed::AFType;
|
||||
use crate::interrupt;
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
@ -1469,3 +1468,159 @@ fn calculate_trdt(speed: vals::Dspd, ahb_freq: Hertz) -> u8 {
|
||||
fn quirk_setup_late_cnak(r: crate::pac::otg::Otg) -> bool {
|
||||
r.cid().read().0 & 0xf000 == 0x1000
|
||||
}
|
||||
|
||||
// Using Instance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps
|
||||
const MAX_EP_COUNT: usize = 9;
|
||||
|
||||
pub(crate) mod sealed {
|
||||
pub trait Instance {
|
||||
const HIGH_SPEED: bool;
|
||||
const FIFO_DEPTH_WORDS: u16;
|
||||
const ENDPOINT_COUNT: usize;
|
||||
|
||||
fn regs() -> crate::pac::otg::Otg;
|
||||
fn state() -> &'static super::State<{ super::MAX_EP_COUNT }>;
|
||||
}
|
||||
}
|
||||
|
||||
/// USB instance trait.
|
||||
pub trait Instance: sealed::Instance + RccPeripheral + 'static {
|
||||
/// Interrupt for this USB instance.
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
// Internal PHY pins
|
||||
pin_trait!(DpPin, Instance);
|
||||
pin_trait!(DmPin, Instance);
|
||||
|
||||
// External PHY pins
|
||||
pin_trait!(UlpiClkPin, Instance);
|
||||
pin_trait!(UlpiDirPin, Instance);
|
||||
pin_trait!(UlpiNxtPin, Instance);
|
||||
pin_trait!(UlpiStpPin, Instance);
|
||||
pin_trait!(UlpiD0Pin, Instance);
|
||||
pin_trait!(UlpiD1Pin, Instance);
|
||||
pin_trait!(UlpiD2Pin, Instance);
|
||||
pin_trait!(UlpiD3Pin, Instance);
|
||||
pin_trait!(UlpiD4Pin, Instance);
|
||||
pin_trait!(UlpiD5Pin, Instance);
|
||||
pin_trait!(UlpiD6Pin, Instance);
|
||||
pin_trait!(UlpiD7Pin, Instance);
|
||||
|
||||
foreach_interrupt!(
|
||||
(USB_OTG_FS, otg, $block:ident, GLOBAL, $irq:ident) => {
|
||||
impl sealed::Instance for crate::peripherals::USB_OTG_FS {
|
||||
const HIGH_SPEED: bool = false;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(stm32f1)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 128;
|
||||
const ENDPOINT_COUNT: usize = 8;
|
||||
} else if #[cfg(any(
|
||||
stm32f2,
|
||||
stm32f401,
|
||||
stm32f405,
|
||||
stm32f407,
|
||||
stm32f411,
|
||||
stm32f415,
|
||||
stm32f417,
|
||||
stm32f427,
|
||||
stm32f429,
|
||||
stm32f437,
|
||||
stm32f439,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 320;
|
||||
const ENDPOINT_COUNT: usize = 4;
|
||||
} else if #[cfg(any(
|
||||
stm32f412,
|
||||
stm32f413,
|
||||
stm32f423,
|
||||
stm32f446,
|
||||
stm32f469,
|
||||
stm32f479,
|
||||
stm32f7,
|
||||
stm32l4,
|
||||
stm32u5,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 320;
|
||||
const ENDPOINT_COUNT: usize = 6;
|
||||
} else if #[cfg(stm32g0x1)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 512;
|
||||
const ENDPOINT_COUNT: usize = 8;
|
||||
} else if #[cfg(stm32h7)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 9;
|
||||
} else if #[cfg(stm32u5)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 320;
|
||||
const ENDPOINT_COUNT: usize = 6;
|
||||
} else {
|
||||
compile_error!("USB_OTG_FS peripheral is not supported by this chip.");
|
||||
}
|
||||
}
|
||||
|
||||
fn regs() -> crate::pac::otg::Otg {
|
||||
crate::pac::USB_OTG_FS
|
||||
}
|
||||
|
||||
fn state() -> &'static State<MAX_EP_COUNT> {
|
||||
static STATE: State<MAX_EP_COUNT> = State::new();
|
||||
&STATE
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::USB_OTG_FS {
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
|
||||
(USB_OTG_HS, otg, $block:ident, GLOBAL, $irq:ident) => {
|
||||
impl sealed::Instance for crate::peripherals::USB_OTG_HS {
|
||||
const HIGH_SPEED: bool = true;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
stm32f2,
|
||||
stm32f405,
|
||||
stm32f407,
|
||||
stm32f415,
|
||||
stm32f417,
|
||||
stm32f427,
|
||||
stm32f429,
|
||||
stm32f437,
|
||||
stm32f439,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 6;
|
||||
} else if #[cfg(any(
|
||||
stm32f446,
|
||||
stm32f469,
|
||||
stm32f479,
|
||||
stm32f7,
|
||||
stm32h7,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 9;
|
||||
} else if #[cfg(stm32u5)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 9;
|
||||
} else {
|
||||
compile_error!("USB_OTG_HS peripheral is not supported by this chip.");
|
||||
}
|
||||
}
|
||||
|
||||
fn regs() -> crate::pac::otg::Otg {
|
||||
// OTG HS registers are a superset of FS registers
|
||||
unsafe { crate::pac::otg::Otg::from_ptr(crate::pac::USB_OTG_HS.as_ptr()) }
|
||||
}
|
||||
|
||||
fn state() -> &'static State<MAX_EP_COUNT> {
|
||||
static STATE: State<MAX_EP_COUNT> = State::new();
|
||||
&STATE
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::USB_OTG_HS {
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
);
|
@ -12,7 +12,6 @@ use embassy_usb_driver::{
|
||||
Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported,
|
||||
};
|
||||
|
||||
use super::{DmPin, DpPin, Instance};
|
||||
use crate::interrupt::typelevel::Interrupt;
|
||||
use crate::pac::usb::regs;
|
||||
use crate::pac::usb::vals::{EpType, Stat};
|
||||
@ -1057,3 +1056,33 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod sealed {
|
||||
pub trait Instance {
|
||||
fn regs() -> crate::pac::usb::Usb;
|
||||
}
|
||||
}
|
||||
|
||||
/// USB instance trait.
|
||||
pub trait Instance: sealed::Instance + RccPeripheral + 'static {
|
||||
/// Interrupt for this USB instance.
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
// Internal PHY pins
|
||||
pin_trait!(DpPin, Instance);
|
||||
pin_trait!(DmPin, Instance);
|
||||
|
||||
foreach_interrupt!(
|
||||
($inst:ident, usb, $block:ident, LP, $irq:ident) => {
|
||||
impl sealed::Instance for crate::peripherals::$inst {
|
||||
fn regs() -> crate::pac::usb::Usb {
|
||||
crate::pac::$inst
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::$inst {
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
);
|
||||
|
@ -1,163 +0,0 @@
|
||||
//! USB On The Go (OTG)
|
||||
|
||||
use crate::rcc::RccPeripheral;
|
||||
use crate::{interrupt, peripherals};
|
||||
|
||||
mod usb;
|
||||
pub use usb::*;
|
||||
|
||||
// Using Instance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps
|
||||
const MAX_EP_COUNT: usize = 9;
|
||||
|
||||
pub(crate) mod sealed {
|
||||
pub trait Instance {
|
||||
const HIGH_SPEED: bool;
|
||||
const FIFO_DEPTH_WORDS: u16;
|
||||
const ENDPOINT_COUNT: usize;
|
||||
|
||||
fn regs() -> crate::pac::otg::Otg;
|
||||
fn state() -> &'static super::State<{ super::MAX_EP_COUNT }>;
|
||||
}
|
||||
}
|
||||
|
||||
/// USB OTG instance.
|
||||
pub trait Instance: sealed::Instance + RccPeripheral {
|
||||
/// Interrupt for this USB OTG instance.
|
||||
type Interrupt: interrupt::typelevel::Interrupt;
|
||||
}
|
||||
|
||||
// Internal PHY pins
|
||||
pin_trait!(DpPin, Instance);
|
||||
pin_trait!(DmPin, Instance);
|
||||
|
||||
// External PHY pins
|
||||
pin_trait!(UlpiClkPin, Instance);
|
||||
pin_trait!(UlpiDirPin, Instance);
|
||||
pin_trait!(UlpiNxtPin, Instance);
|
||||
pin_trait!(UlpiStpPin, Instance);
|
||||
pin_trait!(UlpiD0Pin, Instance);
|
||||
pin_trait!(UlpiD1Pin, Instance);
|
||||
pin_trait!(UlpiD2Pin, Instance);
|
||||
pin_trait!(UlpiD3Pin, Instance);
|
||||
pin_trait!(UlpiD4Pin, Instance);
|
||||
pin_trait!(UlpiD5Pin, Instance);
|
||||
pin_trait!(UlpiD6Pin, Instance);
|
||||
pin_trait!(UlpiD7Pin, Instance);
|
||||
|
||||
foreach_interrupt!(
|
||||
(USB_OTG_FS, otg, $block:ident, GLOBAL, $irq:ident) => {
|
||||
impl sealed::Instance for peripherals::USB_OTG_FS {
|
||||
const HIGH_SPEED: bool = false;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(stm32f1)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 128;
|
||||
const ENDPOINT_COUNT: usize = 8;
|
||||
} else if #[cfg(any(
|
||||
stm32f2,
|
||||
stm32f401,
|
||||
stm32f405,
|
||||
stm32f407,
|
||||
stm32f411,
|
||||
stm32f415,
|
||||
stm32f417,
|
||||
stm32f427,
|
||||
stm32f429,
|
||||
stm32f437,
|
||||
stm32f439,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 320;
|
||||
const ENDPOINT_COUNT: usize = 4;
|
||||
} else if #[cfg(any(
|
||||
stm32f412,
|
||||
stm32f413,
|
||||
stm32f423,
|
||||
stm32f446,
|
||||
stm32f469,
|
||||
stm32f479,
|
||||
stm32f7,
|
||||
stm32l4,
|
||||
stm32u5,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 320;
|
||||
const ENDPOINT_COUNT: usize = 6;
|
||||
} else if #[cfg(stm32g0x1)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 512;
|
||||
const ENDPOINT_COUNT: usize = 8;
|
||||
} else if #[cfg(stm32h7)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 9;
|
||||
} else if #[cfg(stm32u5)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 320;
|
||||
const ENDPOINT_COUNT: usize = 6;
|
||||
} else {
|
||||
compile_error!("USB_OTG_FS peripheral is not supported by this chip.");
|
||||
}
|
||||
}
|
||||
|
||||
fn regs() -> crate::pac::otg::Otg {
|
||||
crate::pac::USB_OTG_FS
|
||||
}
|
||||
|
||||
fn state() -> &'static State<MAX_EP_COUNT> {
|
||||
static STATE: State<MAX_EP_COUNT> = State::new();
|
||||
&STATE
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for peripherals::USB_OTG_FS {
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
|
||||
(USB_OTG_HS, otg, $block:ident, GLOBAL, $irq:ident) => {
|
||||
impl sealed::Instance for peripherals::USB_OTG_HS {
|
||||
const HIGH_SPEED: bool = true;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
stm32f2,
|
||||
stm32f405,
|
||||
stm32f407,
|
||||
stm32f415,
|
||||
stm32f417,
|
||||
stm32f427,
|
||||
stm32f429,
|
||||
stm32f437,
|
||||
stm32f439,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 6;
|
||||
} else if #[cfg(any(
|
||||
stm32f446,
|
||||
stm32f469,
|
||||
stm32f479,
|
||||
stm32f7,
|
||||
stm32h7,
|
||||
))] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 9;
|
||||
} else if #[cfg(stm32u5)] {
|
||||
const FIFO_DEPTH_WORDS: u16 = 1024;
|
||||
const ENDPOINT_COUNT: usize = 9;
|
||||
} else {
|
||||
compile_error!("USB_OTG_HS peripheral is not supported by this chip.");
|
||||
}
|
||||
}
|
||||
|
||||
fn regs() -> crate::pac::otg::Otg {
|
||||
// OTG HS registers are a superset of FS registers
|
||||
unsafe { crate::pac::otg::Otg::from_ptr(crate::pac::USB_OTG_HS.as_ptr()) }
|
||||
}
|
||||
|
||||
fn state() -> &'static State<MAX_EP_COUNT> {
|
||||
static STATE: State<MAX_EP_COUNT> = State::new();
|
||||
&STATE
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for peripherals::USB_OTG_HS {
|
||||
type Interrupt = crate::interrupt::typelevel::$irq;
|
||||
}
|
||||
};
|
||||
);
|
@ -7,8 +7,8 @@ use embassy_net::tcp::TcpSocket;
|
||||
use embassy_net::{Stack, StackResources};
|
||||
use embassy_stm32::rng::{self, Rng};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::usb_otg::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState};
|
||||
use embassy_usb::class::cdc_ncm::{CdcNcmClass, State};
|
||||
use embassy_usb::{Builder, UsbDevice};
|
||||
@ -36,7 +36,7 @@ async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! {
|
||||
}
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
HASH_RNG => rng::InterruptHandler<peripherals::RNG>;
|
||||
});
|
||||
|
||||
@ -69,7 +69,7 @@ async fn main(spawner: Spawner) {
|
||||
// Create the driver, from the HAL.
|
||||
static OUTPUT_BUFFER: StaticCell<[u8; 256]> = StaticCell::new();
|
||||
let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config);
|
||||
|
||||
|
@ -8,8 +8,8 @@ use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::usb_otg::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::class::hid::{HidReaderWriter, ReportId, RequestHandler, State};
|
||||
use embassy_usb::control::OutResponse;
|
||||
use embassy_usb::{Builder, Handler};
|
||||
@ -18,7 +18,7 @@ use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::usb_otg::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_time::Timer;
|
||||
use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State};
|
||||
use embassy_usb::control::OutResponse;
|
||||
@ -15,7 +15,7 @@ use usbd_hid::descriptor::{MouseReport, SerializedDescriptor};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
@ -52,8 +52,8 @@
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::usb_otg::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::Driver;
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::control::{InResponse, OutResponse, Recipient, Request, RequestType};
|
||||
use embassy_usb::msos::{self, windows_version};
|
||||
use embassy_usb::types::InterfaceNumber;
|
||||
@ -66,7 +66,7 @@ use {defmt_rtt as _, panic_probe as _};
|
||||
const DEVICE_INTERFACE_GUIDS: &[&str] = &["{DAC2087C-63FA-458D-A55D-827C0762DEC7}"];
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -97,7 +97,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
use defmt::{panic, *};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::usb_otg::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::Builder;
|
||||
@ -13,7 +13,7 @@ use futures::future::join;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
use defmt::{panic, *};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::usb_otg::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::Builder;
|
||||
@ -13,7 +13,7 @@ use futures::future::join;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
use defmt::{panic, *};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::usb_otg::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::Builder;
|
||||
@ -12,7 +12,7 @@ use futures::future::join;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
@ -5,8 +5,8 @@ use defmt::{panic, *};
|
||||
use defmt_rtt as _; // global logger
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::rcc::*;
|
||||
use embassy_stm32::usb_otg::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::Builder;
|
||||
@ -14,7 +14,7 @@ use futures::future::join;
|
||||
use panic_probe as _;
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -38,7 +38,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = true;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
use defmt::{panic, *};
|
||||
use defmt_rtt as _; // global logger
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::usb_otg::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config};
|
||||
use embassy_stm32::usb::{Driver, Instance};
|
||||
use embassy_stm32::{bind_interrupts, peripherals, usb, Config};
|
||||
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::Builder;
|
||||
@ -13,7 +13,7 @@ use futures::future::join;
|
||||
use panic_probe as _;
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
@ -41,7 +41,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Create the driver, from the HAL.
|
||||
let mut ep_out_buffer = [0u8; 256];
|
||||
let mut config = embassy_stm32::usb_otg::Config::default();
|
||||
let mut config = embassy_stm32::usb::Config::default();
|
||||
config.vbus_detection = false;
|
||||
let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user