diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-03-19 20:44:33 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-03-19 22:07:16 +0100 |
| commit | 530ff9d4d33abff34edb718d650c71a41dd68f8c (patch) | |
| tree | 4b2508fe52e8f279a544e93550c6316e01b6f4c7 | |
| parent | 594d330a494a246bd2611e8793f34d08fde80b5c (diff) | |
stm32/usb: merge usb and usb_otg into single module.
| -rw-r--r-- | embassy-stm32/build.rs | 28 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32/src/usb/mod.rs | 39 | ||||
| -rw-r--r-- | embassy-stm32/src/usb/otg.rs (renamed from embassy-stm32/src/usb_otg/usb.rs) | 157 | ||||
| -rw-r--r-- | embassy-stm32/src/usb/usb.rs | 31 | ||||
| -rw-r--r-- | embassy-stm32/src/usb_otg/mod.rs | 163 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_ethernet.rs | 8 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_hid_keyboard.rs | 8 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_hid_mouse.rs | 8 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_raw.rs | 8 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/usb_serial.rs | 8 | ||||
| -rw-r--r-- | examples/stm32f7/src/bin/usb_serial.rs | 8 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usb_serial.rs | 8 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/usb_serial.rs | 8 | ||||
| -rw-r--r-- | examples/stm32u5/src/bin/usb_serial.rs | 8 |
15 files changed, 243 insertions, 255 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index fe5236ed6..ee224da67 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -826,20 +826,20 @@ fn main() { | |||
| 826 | (("dcmi", "PIXCLK"), quote!(crate::dcmi::PixClkPin)), | 826 | (("dcmi", "PIXCLK"), quote!(crate::dcmi::PixClkPin)), |
| 827 | (("usb", "DP"), quote!(crate::usb::DpPin)), | 827 | (("usb", "DP"), quote!(crate::usb::DpPin)), |
| 828 | (("usb", "DM"), quote!(crate::usb::DmPin)), | 828 | (("usb", "DM"), quote!(crate::usb::DmPin)), |
| 829 | (("otg", "DP"), quote!(crate::usb_otg::DpPin)), | 829 | (("otg", "DP"), quote!(crate::usb::DpPin)), |
| 830 | (("otg", "DM"), quote!(crate::usb_otg::DmPin)), | 830 | (("otg", "DM"), quote!(crate::usb::DmPin)), |
| 831 | (("otg", "ULPI_CK"), quote!(crate::usb_otg::UlpiClkPin)), | 831 | (("otg", "ULPI_CK"), quote!(crate::usb::UlpiClkPin)), |
| 832 | (("otg", "ULPI_DIR"), quote!(crate::usb_otg::UlpiDirPin)), | 832 | (("otg", "ULPI_DIR"), quote!(crate::usb::UlpiDirPin)), |
| 833 | (("otg", "ULPI_NXT"), quote!(crate::usb_otg::UlpiNxtPin)), | 833 | (("otg", "ULPI_NXT"), quote!(crate::usb::UlpiNxtPin)), |
| 834 | (("otg", "ULPI_STP"), quote!(crate::usb_otg::UlpiStpPin)), | 834 | (("otg", "ULPI_STP"), quote!(crate::usb::UlpiStpPin)), |
| 835 | (("otg", "ULPI_D0"), quote!(crate::usb_otg::UlpiD0Pin)), | 835 | (("otg", "ULPI_D0"), quote!(crate::usb::UlpiD0Pin)), |
| 836 | (("otg", "ULPI_D1"), quote!(crate::usb_otg::UlpiD1Pin)), | 836 | (("otg", "ULPI_D1"), quote!(crate::usb::UlpiD1Pin)), |
| 837 | (("otg", "ULPI_D2"), quote!(crate::usb_otg::UlpiD2Pin)), | 837 | (("otg", "ULPI_D2"), quote!(crate::usb::UlpiD2Pin)), |
| 838 | (("otg", "ULPI_D3"), quote!(crate::usb_otg::UlpiD3Pin)), | 838 | (("otg", "ULPI_D3"), quote!(crate::usb::UlpiD3Pin)), |
| 839 | (("otg", "ULPI_D4"), quote!(crate::usb_otg::UlpiD4Pin)), | 839 | (("otg", "ULPI_D4"), quote!(crate::usb::UlpiD4Pin)), |
| 840 | (("otg", "ULPI_D5"), quote!(crate::usb_otg::UlpiD5Pin)), | 840 | (("otg", "ULPI_D5"), quote!(crate::usb::UlpiD5Pin)), |
| 841 | (("otg", "ULPI_D6"), quote!(crate::usb_otg::UlpiD6Pin)), | 841 | (("otg", "ULPI_D6"), quote!(crate::usb::UlpiD6Pin)), |
| 842 | (("otg", "ULPI_D7"), quote!(crate::usb_otg::UlpiD7Pin)), | 842 | (("otg", "ULPI_D7"), quote!(crate::usb::UlpiD7Pin)), |
| 843 | (("can", "TX"), quote!(crate::can::TxPin)), | 843 | (("can", "TX"), quote!(crate::can::TxPin)), |
| 844 | (("can", "RX"), quote!(crate::can::RxPin)), | 844 | (("can", "RX"), quote!(crate::can::RxPin)), |
| 845 | (("eth", "REF_CLK"), quote!(crate::eth::RefClkPin)), | 845 | (("eth", "REF_CLK"), quote!(crate::eth::RefClkPin)), |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index b38b5c29d..9e26a3513 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -79,10 +79,8 @@ pub mod ucpd; | |||
| 79 | pub mod uid; | 79 | pub mod uid; |
| 80 | #[cfg(usart)] | 80 | #[cfg(usart)] |
| 81 | pub mod usart; | 81 | pub mod usart; |
| 82 | #[cfg(usb)] | 82 | #[cfg(any(usb, otg))] |
| 83 | pub mod usb; | 83 | pub mod usb; |
| 84 | #[cfg(otg)] | ||
| 85 | pub mod usb_otg; | ||
| 86 | #[cfg(iwdg)] | 84 | #[cfg(iwdg)] |
| 87 | pub mod wdg; | 85 | pub mod wdg; |
| 88 | 86 | ||
| @@ -107,10 +105,10 @@ pub use crate::_generated::interrupt; | |||
| 107 | /// Example of how to bind one interrupt: | 105 | /// Example of how to bind one interrupt: |
| 108 | /// | 106 | /// |
| 109 | /// ```rust,ignore | 107 | /// ```rust,ignore |
| 110 | /// use embassy_stm32::{bind_interrupts, usb_otg, peripherals}; | 108 | /// use embassy_stm32::{bind_interrupts, usb, peripherals}; |
| 111 | /// | 109 | /// |
| 112 | /// bind_interrupts!(struct Irqs { | 110 | /// bind_interrupts!(struct Irqs { |
| 113 | /// OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 111 | /// OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 114 | /// }); | 112 | /// }); |
| 115 | /// ``` | 113 | /// ``` |
| 116 | /// | 114 | /// |
diff --git a/embassy-stm32/src/usb/mod.rs b/embassy-stm32/src/usb/mod.rs index 4debd4e54..974880900 100644 --- a/embassy-stm32/src/usb/mod.rs +++ b/embassy-stm32/src/usb/mod.rs | |||
| @@ -1,37 +1,6 @@ | |||
| 1 | //! Universal Serial Bus (USB) | 1 | //! Universal Serial Bus (USB) |
| 2 | 2 | ||
| 3 | use crate::interrupt; | 3 | #[cfg_attr(usb, path = "usb.rs")] |
| 4 | use crate::rcc::RccPeripheral; | 4 | #[cfg_attr(otg, path = "otg.rs")] |
| 5 | 5 | mod _version; | |
| 6 | mod usb; | 6 | pub use _version::*; |
| 7 | pub use usb::*; | ||
| 8 | |||
| 9 | pub(crate) mod sealed { | ||
| 10 | pub trait Instance { | ||
| 11 | fn regs() -> crate::pac::usb::Usb; | ||
| 12 | } | ||
| 13 | } | ||
| 14 | |||
| 15 | /// USB instance trait. | ||
| 16 | pub trait Instance: sealed::Instance + RccPeripheral + 'static { | ||
| 17 | /// Interrupt for this USB instance. | ||
| 18 | type Interrupt: interrupt::typelevel::Interrupt; | ||
| 19 | } | ||
| 20 | |||
| 21 | // Internal PHY pins | ||
| 22 | pin_trait!(DpPin, Instance); | ||
| 23 | pin_trait!(DmPin, Instance); | ||
| 24 | |||
| 25 | foreach_interrupt!( | ||
| 26 | ($inst:ident, usb, $block:ident, LP, $irq:ident) => { | ||
| 27 | impl sealed::Instance for crate::peripherals::$inst { | ||
| 28 | fn regs() -> crate::pac::usb::Usb { | ||
| 29 | crate::pac::$inst | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | impl Instance for crate::peripherals::$inst { | ||
| 34 | type Interrupt = crate::interrupt::typelevel::$irq; | ||
| 35 | } | ||
| 36 | }; | ||
| 37 | ); | ||
diff --git a/embassy-stm32/src/usb_otg/usb.rs b/embassy-stm32/src/usb/otg.rs index 373697ec8..d15d929f6 100644 --- a/embassy-stm32/src/usb_otg/usb.rs +++ b/embassy-stm32/src/usb/otg.rs | |||
| @@ -11,7 +11,6 @@ use embassy_usb_driver::{ | |||
| 11 | }; | 11 | }; |
| 12 | use futures::future::poll_fn; | 12 | use futures::future::poll_fn; |
| 13 | 13 | ||
| 14 | use super::*; | ||
| 15 | use crate::gpio::sealed::AFType; | 14 | use crate::gpio::sealed::AFType; |
| 16 | use crate::interrupt; | 15 | use crate::interrupt; |
| 17 | use crate::interrupt::typelevel::Interrupt; | 16 | use crate::interrupt::typelevel::Interrupt; |
| @@ -1469,3 +1468,159 @@ fn calculate_trdt(speed: vals::Dspd, ahb_freq: Hertz) -> u8 { | |||
| 1469 | fn quirk_setup_late_cnak(r: crate::pac::otg::Otg) -> bool { | 1468 | fn quirk_setup_late_cnak(r: crate::pac::otg::Otg) -> bool { |
| 1470 | r.cid().read().0 & 0xf000 == 0x1000 | 1469 | r.cid().read().0 & 0xf000 == 0x1000 |
| 1471 | } | 1470 | } |
| 1471 | |||
| 1472 | // Using Instance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps | ||
| 1473 | const MAX_EP_COUNT: usize = 9; | ||
| 1474 | |||
| 1475 | pub(crate) mod sealed { | ||
| 1476 | pub trait Instance { | ||
| 1477 | const HIGH_SPEED: bool; | ||
| 1478 | const FIFO_DEPTH_WORDS: u16; | ||
| 1479 | const ENDPOINT_COUNT: usize; | ||
| 1480 | |||
| 1481 | fn regs() -> crate::pac::otg::Otg; | ||
| 1482 | fn state() -> &'static super::State<{ super::MAX_EP_COUNT }>; | ||
| 1483 | } | ||
| 1484 | } | ||
| 1485 | |||
| 1486 | /// USB instance trait. | ||
| 1487 | pub trait Instance: sealed::Instance + RccPeripheral + 'static { | ||
| 1488 | /// Interrupt for this USB instance. | ||
| 1489 | type Interrupt: interrupt::typelevel::Interrupt; | ||
| 1490 | } | ||
| 1491 | |||
| 1492 | // Internal PHY pins | ||
| 1493 | pin_trait!(DpPin, Instance); | ||
| 1494 | pin_trait!(DmPin, Instance); | ||
| 1495 | |||
| 1496 | // External PHY pins | ||
| 1497 | pin_trait!(UlpiClkPin, Instance); | ||
| 1498 | pin_trait!(UlpiDirPin, Instance); | ||
| 1499 | pin_trait!(UlpiNxtPin, Instance); | ||
| 1500 | pin_trait!(UlpiStpPin, Instance); | ||
| 1501 | pin_trait!(UlpiD0Pin, Instance); | ||
| 1502 | pin_trait!(UlpiD1Pin, Instance); | ||
| 1503 | pin_trait!(UlpiD2Pin, Instance); | ||
| 1504 | pin_trait!(UlpiD3Pin, Instance); | ||
| 1505 | pin_trait!(UlpiD4Pin, Instance); | ||
| 1506 | pin_trait!(UlpiD5Pin, Instance); | ||
| 1507 | pin_trait!(UlpiD6Pin, Instance); | ||
| 1508 | pin_trait!(UlpiD7Pin, Instance); | ||
| 1509 | |||
| 1510 | foreach_interrupt!( | ||
| 1511 | (USB_OTG_FS, otg, $block:ident, GLOBAL, $irq:ident) => { | ||
| 1512 | impl sealed::Instance for crate::peripherals::USB_OTG_FS { | ||
| 1513 | const HIGH_SPEED: bool = false; | ||
| 1514 | |||
| 1515 | cfg_if::cfg_if! { | ||
| 1516 | if #[cfg(stm32f1)] { | ||
| 1517 | const FIFO_DEPTH_WORDS: u16 = 128; | ||
| 1518 | const ENDPOINT_COUNT: usize = 8; | ||
| 1519 | } else if #[cfg(any( | ||
| 1520 | stm32f2, | ||
| 1521 | stm32f401, | ||
| 1522 | stm32f405, | ||
| 1523 | stm32f407, | ||
| 1524 | stm32f411, | ||
| 1525 | stm32f415, | ||
| 1526 | stm32f417, | ||
| 1527 | stm32f427, | ||
| 1528 | stm32f429, | ||
| 1529 | stm32f437, | ||
| 1530 | stm32f439, | ||
| 1531 | ))] { | ||
| 1532 | const FIFO_DEPTH_WORDS: u16 = 320; | ||
| 1533 | const ENDPOINT_COUNT: usize = 4; | ||
| 1534 | } else if #[cfg(any( | ||
| 1535 | stm32f412, | ||
| 1536 | stm32f413, | ||
| 1537 | stm32f423, | ||
| 1538 | stm32f446, | ||
| 1539 | stm32f469, | ||
| 1540 | stm32f479, | ||
| 1541 | stm32f7, | ||
| 1542 | stm32l4, | ||
| 1543 | stm32u5, | ||
| 1544 | ))] { | ||
| 1545 | const FIFO_DEPTH_WORDS: u16 = 320; | ||
| 1546 | const ENDPOINT_COUNT: usize = 6; | ||
| 1547 | } else if #[cfg(stm32g0x1)] { | ||
| 1548 | const FIFO_DEPTH_WORDS: u16 = 512; | ||
| 1549 | const ENDPOINT_COUNT: usize = 8; | ||
| 1550 | } else if #[cfg(stm32h7)] { | ||
| 1551 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 1552 | const ENDPOINT_COUNT: usize = 9; | ||
| 1553 | } else if #[cfg(stm32u5)] { | ||
| 1554 | const FIFO_DEPTH_WORDS: u16 = 320; | ||
| 1555 | const ENDPOINT_COUNT: usize = 6; | ||
| 1556 | } else { | ||
| 1557 | compile_error!("USB_OTG_FS peripheral is not supported by this chip."); | ||
| 1558 | } | ||
| 1559 | } | ||
| 1560 | |||
| 1561 | fn regs() -> crate::pac::otg::Otg { | ||
| 1562 | crate::pac::USB_OTG_FS | ||
| 1563 | } | ||
| 1564 | |||
| 1565 | fn state() -> &'static State<MAX_EP_COUNT> { | ||
| 1566 | static STATE: State<MAX_EP_COUNT> = State::new(); | ||
| 1567 | &STATE | ||
| 1568 | } | ||
| 1569 | } | ||
| 1570 | |||
| 1571 | impl Instance for crate::peripherals::USB_OTG_FS { | ||
| 1572 | type Interrupt = crate::interrupt::typelevel::$irq; | ||
| 1573 | } | ||
| 1574 | }; | ||
| 1575 | |||
| 1576 | (USB_OTG_HS, otg, $block:ident, GLOBAL, $irq:ident) => { | ||
| 1577 | impl sealed::Instance for crate::peripherals::USB_OTG_HS { | ||
| 1578 | const HIGH_SPEED: bool = true; | ||
| 1579 | |||
| 1580 | cfg_if::cfg_if! { | ||
| 1581 | if #[cfg(any( | ||
| 1582 | stm32f2, | ||
| 1583 | stm32f405, | ||
| 1584 | stm32f407, | ||
| 1585 | stm32f415, | ||
| 1586 | stm32f417, | ||
| 1587 | stm32f427, | ||
| 1588 | stm32f429, | ||
| 1589 | stm32f437, | ||
| 1590 | stm32f439, | ||
| 1591 | ))] { | ||
| 1592 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 1593 | const ENDPOINT_COUNT: usize = 6; | ||
| 1594 | } else if #[cfg(any( | ||
| 1595 | stm32f446, | ||
| 1596 | stm32f469, | ||
| 1597 | stm32f479, | ||
| 1598 | stm32f7, | ||
| 1599 | stm32h7, | ||
| 1600 | ))] { | ||
| 1601 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 1602 | const ENDPOINT_COUNT: usize = 9; | ||
| 1603 | } else if #[cfg(stm32u5)] { | ||
| 1604 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 1605 | const ENDPOINT_COUNT: usize = 9; | ||
| 1606 | } else { | ||
| 1607 | compile_error!("USB_OTG_HS peripheral is not supported by this chip."); | ||
| 1608 | } | ||
| 1609 | } | ||
| 1610 | |||
| 1611 | fn regs() -> crate::pac::otg::Otg { | ||
| 1612 | // OTG HS registers are a superset of FS registers | ||
| 1613 | unsafe { crate::pac::otg::Otg::from_ptr(crate::pac::USB_OTG_HS.as_ptr()) } | ||
| 1614 | } | ||
| 1615 | |||
| 1616 | fn state() -> &'static State<MAX_EP_COUNT> { | ||
| 1617 | static STATE: State<MAX_EP_COUNT> = State::new(); | ||
| 1618 | &STATE | ||
| 1619 | } | ||
| 1620 | } | ||
| 1621 | |||
| 1622 | impl Instance for crate::peripherals::USB_OTG_HS { | ||
| 1623 | type Interrupt = crate::interrupt::typelevel::$irq; | ||
| 1624 | } | ||
| 1625 | }; | ||
| 1626 | ); | ||
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index be321a19b..b3b3470e4 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -12,7 +12,6 @@ use embassy_usb_driver::{ | |||
| 12 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, | 12 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | use super::{DmPin, DpPin, Instance}; | ||
| 16 | use crate::interrupt::typelevel::Interrupt; | 15 | use crate::interrupt::typelevel::Interrupt; |
| 17 | use crate::pac::usb::regs; | 16 | use crate::pac::usb::regs; |
| 18 | use crate::pac::usb::vals::{EpType, Stat}; | 17 | use crate::pac::usb::vals::{EpType, Stat}; |
| @@ -1057,3 +1056,33 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | |||
| 1057 | }); | 1056 | }); |
| 1058 | } | 1057 | } |
| 1059 | } | 1058 | } |
| 1059 | |||
| 1060 | pub(crate) mod sealed { | ||
| 1061 | pub trait Instance { | ||
| 1062 | fn regs() -> crate::pac::usb::Usb; | ||
| 1063 | } | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | /// USB instance trait. | ||
| 1067 | pub trait Instance: sealed::Instance + RccPeripheral + 'static { | ||
| 1068 | /// Interrupt for this USB instance. | ||
| 1069 | type Interrupt: interrupt::typelevel::Interrupt; | ||
| 1070 | } | ||
| 1071 | |||
| 1072 | // Internal PHY pins | ||
| 1073 | pin_trait!(DpPin, Instance); | ||
| 1074 | pin_trait!(DmPin, Instance); | ||
| 1075 | |||
| 1076 | foreach_interrupt!( | ||
| 1077 | ($inst:ident, usb, $block:ident, LP, $irq:ident) => { | ||
| 1078 | impl sealed::Instance for crate::peripherals::$inst { | ||
| 1079 | fn regs() -> crate::pac::usb::Usb { | ||
| 1080 | crate::pac::$inst | ||
| 1081 | } | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | impl Instance for crate::peripherals::$inst { | ||
| 1085 | type Interrupt = crate::interrupt::typelevel::$irq; | ||
| 1086 | } | ||
| 1087 | }; | ||
| 1088 | ); | ||
diff --git a/embassy-stm32/src/usb_otg/mod.rs b/embassy-stm32/src/usb_otg/mod.rs deleted file mode 100644 index 0649e684b..000000000 --- a/embassy-stm32/src/usb_otg/mod.rs +++ /dev/null | |||
| @@ -1,163 +0,0 @@ | |||
| 1 | //! USB On The Go (OTG) | ||
| 2 | |||
| 3 | use crate::rcc::RccPeripheral; | ||
| 4 | use crate::{interrupt, peripherals}; | ||
| 5 | |||
| 6 | mod usb; | ||
| 7 | pub use usb::*; | ||
| 8 | |||
| 9 | // Using Instance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps | ||
| 10 | const MAX_EP_COUNT: usize = 9; | ||
| 11 | |||
| 12 | pub(crate) mod sealed { | ||
| 13 | pub trait Instance { | ||
| 14 | const HIGH_SPEED: bool; | ||
| 15 | const FIFO_DEPTH_WORDS: u16; | ||
| 16 | const ENDPOINT_COUNT: usize; | ||
| 17 | |||
| 18 | fn regs() -> crate::pac::otg::Otg; | ||
| 19 | fn state() -> &'static super::State<{ super::MAX_EP_COUNT }>; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | |||
| 23 | /// USB OTG instance. | ||
| 24 | pub trait Instance: sealed::Instance + RccPeripheral { | ||
| 25 | /// Interrupt for this USB OTG instance. | ||
| 26 | type Interrupt: interrupt::typelevel::Interrupt; | ||
| 27 | } | ||
| 28 | |||
| 29 | // Internal PHY pins | ||
| 30 | pin_trait!(DpPin, Instance); | ||
| 31 | pin_trait!(DmPin, Instance); | ||
| 32 | |||
| 33 | // External PHY pins | ||
| 34 | pin_trait!(UlpiClkPin, Instance); | ||
| 35 | pin_trait!(UlpiDirPin, Instance); | ||
| 36 | pin_trait!(UlpiNxtPin, Instance); | ||
| 37 | pin_trait!(UlpiStpPin, Instance); | ||
| 38 | pin_trait!(UlpiD0Pin, Instance); | ||
| 39 | pin_trait!(UlpiD1Pin, Instance); | ||
| 40 | pin_trait!(UlpiD2Pin, Instance); | ||
| 41 | pin_trait!(UlpiD3Pin, Instance); | ||
| 42 | pin_trait!(UlpiD4Pin, Instance); | ||
| 43 | pin_trait!(UlpiD5Pin, Instance); | ||
| 44 | pin_trait!(UlpiD6Pin, Instance); | ||
| 45 | pin_trait!(UlpiD7Pin, Instance); | ||
| 46 | |||
| 47 | foreach_interrupt!( | ||
| 48 | (USB_OTG_FS, otg, $block:ident, GLOBAL, $irq:ident) => { | ||
| 49 | impl sealed::Instance for peripherals::USB_OTG_FS { | ||
| 50 | const HIGH_SPEED: bool = false; | ||
| 51 | |||
| 52 | cfg_if::cfg_if! { | ||
| 53 | if #[cfg(stm32f1)] { | ||
| 54 | const FIFO_DEPTH_WORDS: u16 = 128; | ||
| 55 | const ENDPOINT_COUNT: usize = 8; | ||
| 56 | } else if #[cfg(any( | ||
| 57 | stm32f2, | ||
| 58 | stm32f401, | ||
| 59 | stm32f405, | ||
| 60 | stm32f407, | ||
| 61 | stm32f411, | ||
| 62 | stm32f415, | ||
| 63 | stm32f417, | ||
| 64 | stm32f427, | ||
| 65 | stm32f429, | ||
| 66 | stm32f437, | ||
| 67 | stm32f439, | ||
| 68 | ))] { | ||
| 69 | const FIFO_DEPTH_WORDS: u16 = 320; | ||
| 70 | const ENDPOINT_COUNT: usize = 4; | ||
| 71 | } else if #[cfg(any( | ||
| 72 | stm32f412, | ||
| 73 | stm32f413, | ||
| 74 | stm32f423, | ||
| 75 | stm32f446, | ||
| 76 | stm32f469, | ||
| 77 | stm32f479, | ||
| 78 | stm32f7, | ||
| 79 | stm32l4, | ||
| 80 | stm32u5, | ||
| 81 | ))] { | ||
| 82 | const FIFO_DEPTH_WORDS: u16 = 320; | ||
| 83 | const ENDPOINT_COUNT: usize = 6; | ||
| 84 | } else if #[cfg(stm32g0x1)] { | ||
| 85 | const FIFO_DEPTH_WORDS: u16 = 512; | ||
| 86 | const ENDPOINT_COUNT: usize = 8; | ||
| 87 | } else if #[cfg(stm32h7)] { | ||
| 88 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 89 | const ENDPOINT_COUNT: usize = 9; | ||
| 90 | } else if #[cfg(stm32u5)] { | ||
| 91 | const FIFO_DEPTH_WORDS: u16 = 320; | ||
| 92 | const ENDPOINT_COUNT: usize = 6; | ||
| 93 | } else { | ||
| 94 | compile_error!("USB_OTG_FS peripheral is not supported by this chip."); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | fn regs() -> crate::pac::otg::Otg { | ||
| 99 | crate::pac::USB_OTG_FS | ||
| 100 | } | ||
| 101 | |||
| 102 | fn state() -> &'static State<MAX_EP_COUNT> { | ||
| 103 | static STATE: State<MAX_EP_COUNT> = State::new(); | ||
| 104 | &STATE | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | impl Instance for peripherals::USB_OTG_FS { | ||
| 109 | type Interrupt = crate::interrupt::typelevel::$irq; | ||
| 110 | } | ||
| 111 | }; | ||
| 112 | |||
| 113 | (USB_OTG_HS, otg, $block:ident, GLOBAL, $irq:ident) => { | ||
| 114 | impl sealed::Instance for peripherals::USB_OTG_HS { | ||
| 115 | const HIGH_SPEED: bool = true; | ||
| 116 | |||
| 117 | cfg_if::cfg_if! { | ||
| 118 | if #[cfg(any( | ||
| 119 | stm32f2, | ||
| 120 | stm32f405, | ||
| 121 | stm32f407, | ||
| 122 | stm32f415, | ||
| 123 | stm32f417, | ||
| 124 | stm32f427, | ||
| 125 | stm32f429, | ||
| 126 | stm32f437, | ||
| 127 | stm32f439, | ||
| 128 | ))] { | ||
| 129 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 130 | const ENDPOINT_COUNT: usize = 6; | ||
| 131 | } else if #[cfg(any( | ||
| 132 | stm32f446, | ||
| 133 | stm32f469, | ||
| 134 | stm32f479, | ||
| 135 | stm32f7, | ||
| 136 | stm32h7, | ||
| 137 | ))] { | ||
| 138 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 139 | const ENDPOINT_COUNT: usize = 9; | ||
| 140 | } else if #[cfg(stm32u5)] { | ||
| 141 | const FIFO_DEPTH_WORDS: u16 = 1024; | ||
| 142 | const ENDPOINT_COUNT: usize = 9; | ||
| 143 | } else { | ||
| 144 | compile_error!("USB_OTG_HS peripheral is not supported by this chip."); | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | fn regs() -> crate::pac::otg::Otg { | ||
| 149 | // OTG HS registers are a superset of FS registers | ||
| 150 | unsafe { crate::pac::otg::Otg::from_ptr(crate::pac::USB_OTG_HS.as_ptr()) } | ||
| 151 | } | ||
| 152 | |||
| 153 | fn state() -> &'static State<MAX_EP_COUNT> { | ||
| 154 | static STATE: State<MAX_EP_COUNT> = State::new(); | ||
| 155 | &STATE | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | impl Instance for peripherals::USB_OTG_HS { | ||
| 160 | type Interrupt = crate::interrupt::typelevel::$irq; | ||
| 161 | } | ||
| 162 | }; | ||
| 163 | ); | ||
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs index a196259a8..60e580609 100644 --- a/examples/stm32f4/src/bin/usb_ethernet.rs +++ b/examples/stm32f4/src/bin/usb_ethernet.rs | |||
| @@ -7,8 +7,8 @@ use embassy_net::tcp::TcpSocket; | |||
| 7 | use embassy_net::{Stack, StackResources}; | 7 | use embassy_net::{Stack, StackResources}; |
| 8 | use embassy_stm32::rng::{self, Rng}; | 8 | use embassy_stm32::rng::{self, Rng}; |
| 9 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::usb_otg::Driver; | 10 | use embassy_stm32::usb::Driver; |
| 11 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 11 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; | 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; |
| 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 14 | use embassy_usb::{Builder, UsbDevice}; | 14 | use embassy_usb::{Builder, UsbDevice}; |
| @@ -36,7 +36,7 @@ async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! { | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | bind_interrupts!(struct Irqs { | 38 | bind_interrupts!(struct Irqs { |
| 39 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 39 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 40 | HASH_RNG => rng::InterruptHandler<peripherals::RNG>; | 40 | HASH_RNG => rng::InterruptHandler<peripherals::RNG>; |
| 41 | }); | 41 | }); |
| 42 | 42 | ||
| @@ -69,7 +69,7 @@ async fn main(spawner: Spawner) { | |||
| 69 | // Create the driver, from the HAL. | 69 | // Create the driver, from the HAL. |
| 70 | static OUTPUT_BUFFER: StaticCell<[u8; 256]> = StaticCell::new(); | 70 | static OUTPUT_BUFFER: StaticCell<[u8; 256]> = StaticCell::new(); |
| 71 | let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..]; | 71 | let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..]; |
| 72 | let mut config = embassy_stm32::usb_otg::Config::default(); | 72 | let mut config = embassy_stm32::usb::Config::default(); |
| 73 | config.vbus_detection = true; | 73 | config.vbus_detection = true; |
| 74 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config); | 74 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config); |
| 75 | 75 | ||
diff --git a/examples/stm32f4/src/bin/usb_hid_keyboard.rs b/examples/stm32f4/src/bin/usb_hid_keyboard.rs index 19b5971fb..ae4ce6b6a 100644 --- a/examples/stm32f4/src/bin/usb_hid_keyboard.rs +++ b/examples/stm32f4/src/bin/usb_hid_keyboard.rs | |||
| @@ -8,8 +8,8 @@ use embassy_executor::Spawner; | |||
| 8 | use embassy_stm32::exti::ExtiInput; | 8 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::Pull; | 9 | use embassy_stm32::gpio::Pull; |
| 10 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::usb_otg::Driver; | 11 | use embassy_stm32::usb::Driver; |
| 12 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 12 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 13 | use embassy_usb::class::hid::{HidReaderWriter, ReportId, RequestHandler, State}; | 13 | use embassy_usb::class::hid::{HidReaderWriter, ReportId, RequestHandler, State}; |
| 14 | use embassy_usb::control::OutResponse; | 14 | use embassy_usb::control::OutResponse; |
| 15 | use embassy_usb::{Builder, Handler}; | 15 | use embassy_usb::{Builder, Handler}; |
| @@ -18,7 +18,7 @@ use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor}; | |||
| 18 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
| 21 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 21 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 22 | }); | 22 | }); |
| 23 | 23 | ||
| 24 | #[embassy_executor::main] | 24 | #[embassy_executor::main] |
| @@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) { | |||
| 47 | 47 | ||
| 48 | // Create the driver, from the HAL. | 48 | // Create the driver, from the HAL. |
| 49 | let mut ep_out_buffer = [0u8; 256]; | 49 | let mut ep_out_buffer = [0u8; 256]; |
| 50 | let mut config = embassy_stm32::usb_otg::Config::default(); | 50 | let mut config = embassy_stm32::usb::Config::default(); |
| 51 | config.vbus_detection = true; | 51 | config.vbus_detection = true; |
| 52 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 52 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 53 | 53 | ||
diff --git a/examples/stm32f4/src/bin/usb_hid_mouse.rs b/examples/stm32f4/src/bin/usb_hid_mouse.rs index c98792880..5c64f4969 100644 --- a/examples/stm32f4/src/bin/usb_hid_mouse.rs +++ b/examples/stm32f4/src/bin/usb_hid_mouse.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::time::Hertz; | 6 | use embassy_stm32::time::Hertz; |
| 7 | use embassy_stm32::usb_otg::Driver; | 7 | use embassy_stm32::usb::Driver; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 10 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| 11 | use embassy_usb::control::OutResponse; | 11 | use embassy_usb::control::OutResponse; |
| @@ -15,7 +15,7 @@ use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; | |||
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | bind_interrupts!(struct Irqs { | 17 | bind_interrupts!(struct Irqs { |
| 18 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 18 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 19 | }); | 19 | }); |
| 20 | 20 | ||
| 21 | #[embassy_executor::main] | 21 | #[embassy_executor::main] |
| @@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) { | |||
| 44 | 44 | ||
| 45 | // Create the driver, from the HAL. | 45 | // Create the driver, from the HAL. |
| 46 | let mut ep_out_buffer = [0u8; 256]; | 46 | let mut ep_out_buffer = [0u8; 256]; |
| 47 | let mut config = embassy_stm32::usb_otg::Config::default(); | 47 | let mut config = embassy_stm32::usb::Config::default(); |
| 48 | config.vbus_detection = true; | 48 | config.vbus_detection = true; |
| 49 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 49 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 50 | 50 | ||
diff --git a/examples/stm32f4/src/bin/usb_raw.rs b/examples/stm32f4/src/bin/usb_raw.rs index afff55187..c13fe051f 100644 --- a/examples/stm32f4/src/bin/usb_raw.rs +++ b/examples/stm32f4/src/bin/usb_raw.rs | |||
| @@ -52,8 +52,8 @@ | |||
| 52 | use defmt::*; | 52 | use defmt::*; |
| 53 | use embassy_executor::Spawner; | 53 | use embassy_executor::Spawner; |
| 54 | use embassy_stm32::time::Hertz; | 54 | use embassy_stm32::time::Hertz; |
| 55 | use embassy_stm32::usb_otg::Driver; | 55 | use embassy_stm32::usb::Driver; |
| 56 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 56 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 57 | use embassy_usb::control::{InResponse, OutResponse, Recipient, Request, RequestType}; | 57 | use embassy_usb::control::{InResponse, OutResponse, Recipient, Request, RequestType}; |
| 58 | use embassy_usb::msos::{self, windows_version}; | 58 | use embassy_usb::msos::{self, windows_version}; |
| 59 | use embassy_usb::types::InterfaceNumber; | 59 | use embassy_usb::types::InterfaceNumber; |
| @@ -66,7 +66,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 66 | const DEVICE_INTERFACE_GUIDS: &[&str] = &["{DAC2087C-63FA-458D-A55D-827C0762DEC7}"]; | 66 | const DEVICE_INTERFACE_GUIDS: &[&str] = &["{DAC2087C-63FA-458D-A55D-827C0762DEC7}"]; |
| 67 | 67 | ||
| 68 | bind_interrupts!(struct Irqs { | 68 | bind_interrupts!(struct Irqs { |
| 69 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 69 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 70 | }); | 70 | }); |
| 71 | 71 | ||
| 72 | #[embassy_executor::main] | 72 | #[embassy_executor::main] |
| @@ -97,7 +97,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | 97 | ||
| 98 | // Create the driver, from the HAL. | 98 | // Create the driver, from the HAL. |
| 99 | let mut ep_out_buffer = [0u8; 256]; | 99 | let mut ep_out_buffer = [0u8; 256]; |
| 100 | let mut config = embassy_stm32::usb_otg::Config::default(); | 100 | let mut config = embassy_stm32::usb::Config::default(); |
| 101 | config.vbus_detection = true; | 101 | config.vbus_detection = true; |
| 102 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 102 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 103 | 103 | ||
diff --git a/examples/stm32f4/src/bin/usb_serial.rs b/examples/stm32f4/src/bin/usb_serial.rs index 58d994a61..21e255612 100644 --- a/examples/stm32f4/src/bin/usb_serial.rs +++ b/examples/stm32f4/src/bin/usb_serial.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::{panic, *}; | 4 | use defmt::{panic, *}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::time::Hertz; | 6 | use embassy_stm32::time::Hertz; |
| 7 | use embassy_stm32::usb_otg::{Driver, Instance}; | 7 | use embassy_stm32::usb::{Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 10 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | 11 | use embassy_usb::Builder; |
| @@ -13,7 +13,7 @@ use futures::future::join; | |||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| 16 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 16 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 17 | }); | 17 | }); |
| 18 | 18 | ||
| 19 | #[embassy_executor::main] | 19 | #[embassy_executor::main] |
| @@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) { | |||
| 44 | 44 | ||
| 45 | // Create the driver, from the HAL. | 45 | // Create the driver, from the HAL. |
| 46 | let mut ep_out_buffer = [0u8; 256]; | 46 | let mut ep_out_buffer = [0u8; 256]; |
| 47 | let mut config = embassy_stm32::usb_otg::Config::default(); | 47 | let mut config = embassy_stm32::usb::Config::default(); |
| 48 | config.vbus_detection = true; | 48 | config.vbus_detection = true; |
| 49 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 49 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 50 | 50 | ||
diff --git a/examples/stm32f7/src/bin/usb_serial.rs b/examples/stm32f7/src/bin/usb_serial.rs index 97daf6bd1..bdd7b76ff 100644 --- a/examples/stm32f7/src/bin/usb_serial.rs +++ b/examples/stm32f7/src/bin/usb_serial.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::{panic, *}; | 4 | use defmt::{panic, *}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::time::Hertz; | 6 | use embassy_stm32::time::Hertz; |
| 7 | use embassy_stm32::usb_otg::{Driver, Instance}; | 7 | use embassy_stm32::usb::{Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 10 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | 11 | use embassy_usb::Builder; |
| @@ -13,7 +13,7 @@ use futures::future::join; | |||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| 16 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 16 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 17 | }); | 17 | }); |
| 18 | 18 | ||
| 19 | #[embassy_executor::main] | 19 | #[embassy_executor::main] |
| @@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) { | |||
| 44 | 44 | ||
| 45 | // Create the driver, from the HAL. | 45 | // Create the driver, from the HAL. |
| 46 | let mut ep_out_buffer = [0u8; 256]; | 46 | let mut ep_out_buffer = [0u8; 256]; |
| 47 | let mut config = embassy_stm32::usb_otg::Config::default(); | 47 | let mut config = embassy_stm32::usb::Config::default(); |
| 48 | config.vbus_detection = true; | 48 | config.vbus_detection = true; |
| 49 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 49 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 50 | 50 | ||
diff --git a/examples/stm32h7/src/bin/usb_serial.rs b/examples/stm32h7/src/bin/usb_serial.rs index d81efb541..3d42a24f3 100644 --- a/examples/stm32h7/src/bin/usb_serial.rs +++ b/examples/stm32h7/src/bin/usb_serial.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{panic, *}; | 4 | use defmt::{panic, *}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::usb_otg::{Driver, Instance}; | 6 | use embassy_stm32::usb::{Driver, Instance}; |
| 7 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 7 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 8 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 8 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 9 | use embassy_usb::driver::EndpointError; | 9 | use embassy_usb::driver::EndpointError; |
| 10 | use embassy_usb::Builder; | 10 | use embassy_usb::Builder; |
| @@ -12,7 +12,7 @@ use futures::future::join; | |||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
| 15 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 15 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 16 | }); | 16 | }); |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) { | |||
| 45 | 45 | ||
| 46 | // Create the driver, from the HAL. | 46 | // Create the driver, from the HAL. |
| 47 | let mut ep_out_buffer = [0u8; 256]; | 47 | let mut ep_out_buffer = [0u8; 256]; |
| 48 | let mut config = embassy_stm32::usb_otg::Config::default(); | 48 | let mut config = embassy_stm32::usb::Config::default(); |
| 49 | config.vbus_detection = true; | 49 | config.vbus_detection = true; |
| 50 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 50 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 51 | 51 | ||
diff --git a/examples/stm32l4/src/bin/usb_serial.rs b/examples/stm32l4/src/bin/usb_serial.rs index 9247e56a1..c7f4add7f 100644 --- a/examples/stm32l4/src/bin/usb_serial.rs +++ b/examples/stm32l4/src/bin/usb_serial.rs | |||
| @@ -5,8 +5,8 @@ use defmt::{panic, *}; | |||
| 5 | use defmt_rtt as _; // global logger | 5 | use defmt_rtt as _; // global logger |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::*; | 7 | use embassy_stm32::rcc::*; |
| 8 | use embassy_stm32::usb_otg::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | 12 | use embassy_usb::Builder; |
| @@ -14,7 +14,7 @@ use futures::future::join; | |||
| 14 | use panic_probe as _; | 14 | use panic_probe as _; |
| 15 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | 16 | bind_interrupts!(struct Irqs { |
| 17 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 17 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 18 | }); | 18 | }); |
| 19 | 19 | ||
| 20 | #[embassy_executor::main] | 20 | #[embassy_executor::main] |
| @@ -38,7 +38,7 @@ async fn main(_spawner: Spawner) { | |||
| 38 | 38 | ||
| 39 | // Create the driver, from the HAL. | 39 | // Create the driver, from the HAL. |
| 40 | let mut ep_out_buffer = [0u8; 256]; | 40 | let mut ep_out_buffer = [0u8; 256]; |
| 41 | let mut config = embassy_stm32::usb_otg::Config::default(); | 41 | let mut config = embassy_stm32::usb::Config::default(); |
| 42 | config.vbus_detection = true; | 42 | config.vbus_detection = true; |
| 43 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 43 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 44 | 44 | ||
diff --git a/examples/stm32u5/src/bin/usb_serial.rs b/examples/stm32u5/src/bin/usb_serial.rs index 61851e5a2..98ae46b1c 100644 --- a/examples/stm32u5/src/bin/usb_serial.rs +++ b/examples/stm32u5/src/bin/usb_serial.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::{panic, *}; | 4 | use defmt::{panic, *}; |
| 5 | use defmt_rtt as _; // global logger | 5 | use defmt_rtt as _; // global logger |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::usb_otg::{Driver, Instance}; | 7 | use embassy_stm32::usb::{Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; |
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 10 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | 11 | use embassy_usb::Builder; |
| @@ -13,7 +13,7 @@ use futures::future::join; | |||
| 13 | use panic_probe as _; | 13 | use panic_probe as _; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
| 16 | OTG_FS => usb_otg::InterruptHandler<peripherals::USB_OTG_FS>; | 16 | OTG_FS => usb::InterruptHandler<peripherals::USB_OTG_FS>; |
| 17 | }); | 17 | }); |
| 18 | 18 | ||
| 19 | #[embassy_executor::main] | 19 | #[embassy_executor::main] |
| @@ -41,7 +41,7 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | // Create the driver, from the HAL. | 42 | // Create the driver, from the HAL. |
| 43 | let mut ep_out_buffer = [0u8; 256]; | 43 | let mut ep_out_buffer = [0u8; 256]; |
| 44 | let mut config = embassy_stm32::usb_otg::Config::default(); | 44 | let mut config = embassy_stm32::usb::Config::default(); |
| 45 | config.vbus_detection = false; | 45 | config.vbus_detection = false; |
| 46 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); | 46 | let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); |
| 47 | 47 | ||
