Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
259d1f6
Add interrupt/isochron scheduling registers
Aug 15, 2024
943b3fa
Add helper for framelistlen
Aug 16, 2024
c2daf12
Add doping register
Aug 18, 2024
37a6298
Describe Hcdma reg, add HcdmaB & split hctsiz->xfersiz for interrupt/…
Aug 19, 2024
ccbeba4
Fix hcmda reg definition
Aug 19, 2024
19c0968
Add more regs
Sep 6, 2024
4b37efe
Add descriptor DMA setting & fix perschedena
Sep 9, 2024
e81f89f
Add frame interval dynamic loading ctl
Sep 9, 2024
e0ba265
Add frame list addr register
Sep 16, 2024
879b3d6
Fix perschena mutability & fifo no-op
Sep 16, 2024
ea5fece
Restore product_id W without no-op
Sep 16, 2024
49f51c3
Improve docs & remove unnecessary unsafe
Sep 18, 2024
83f5bf5
Create initial USB Host driver
ijager Jul 24, 2024
35c79d8
Create usb_host HAL driver module
ijager Aug 9, 2024
dde6f2f
Make set_address async and wait for completion
ijager Aug 9, 2024
404972a
Implement basic request_out api
ijager Aug 13, 2024
1c94f88
Implement basic out_request for requesting descriptor
ijager Aug 13, 2024
da705c4
Use proper status flaxs for detecting finisheed transactions
ijager Aug 13, 2024
f7aec87
Implement multi packet receiving
ijager Aug 14, 2024
e7013ad
Implement Endpoint0 change max_oacket_size and realloc
ijager Aug 19, 2024
fac172c
Add USBHost Trait to embassy-usb-driver crate
ijager Aug 21, 2024
d1df38d
Implement Read for non-control endpoints
ijager Aug 28, 2024
b392e58
Remove debug prints
ijager Aug 29, 2024
c78cf78
Reuse channel write/read for control transfers
ijager Sep 3, 2024
be54d9c
Disable channels on error
ijager Sep 3, 2024
dbbc7a0
Make usb_host available for usb_v4 peripherals
ijager Sep 3, 2024
d2c6bda
Add USB Host implementation and example for stm32g0
ijager Sep 3, 2024
19231e5
Add docstrings
ijager Sep 4, 2024
bb0f315
Add comment about NUCLE0-G0B1RE together with X-NUCLEO-DRP1M1
ijager Sep 4, 2024
25204e2
Try fix conditional compilation for usb_host.rs
ijager Sep 5, 2024
7da9b46
Use bitflags as alternative for defmt::bitflags in case no defmt feature
ijager Sep 5, 2024
25e121b
Dereive required traits on RequestType for non-rtt
ijager Sep 5, 2024
f0f706a
PoC partial usb host implementation for rp2040
nikvoid Sep 22, 2024
749f3b9
usb-host refactor, currently errors with rx timeout
nikvoid Sep 27, 2024
b202126
remove various leftovers
nikvoid Sep 28, 2024
ed7da63
fix swapped addr and packet size args...
nikvoid Sep 28, 2024
bf26312
allow to acquire host control channel, remove `usbh` leftovers, fix c…
nikvoid Sep 28, 2024
732b04b
relax usb channel wrapper generics; move its methods into separate ex…
nikvoid Sep 28, 2024
8b4d0ac
include some endpoint description fields into channel
nikvoid Sep 28, 2024
af56212
fix stall on SET_CONFIGURATION
nikvoid Sep 28, 2024
9715fb8
improve channel error handling (mostly in rp2040)
nikvoid Sep 28, 2024
4fc58a5
disable channel interrupts on drop (rp2040)
nikvoid Sep 28, 2024
3361205
process device disconnects (poorly)
nikvoid Sep 28, 2024
227edd1
channel link checks; shared usb device registry
nikvoid Sep 28, 2024
fbfede6
clear available bit on channel drop
nikvoid Sep 28, 2024
1fb8c5a
control channel alloc shortcut
nikvoid Oct 2, 2024
51556d9
usb host example with keyboard
nikvoid Oct 4, 2024
d4a6495
fix early return that would cause deadlock
nikvoid Oct 4, 2024
9c5f59f
split usb-host to multiple modules
nikvoid Oct 4, 2024
283193d
Initial implementation of usb hub driver, currently with LS through F…
nikvoid Oct 6, 2024
f5a648c
send PREamble packet for interrupt endpoints (rp2040)
nikvoid Oct 7, 2024
befb6bb
Re-add handler api
Oct 7, 2024
8dae41a
Re-add handler api
Oct 7, 2024
ee7ea38
Convert most of the hub to the universal handler trait
Oct 9, 2024
12e0a0f
Finish hub & Channel PoC
Oct 12, 2024
47d2186
Finished trait, and optimistically half-way impl for synopsys
Nov 1, 2024
d68987b
Clean up and add a few docs
Nov 6, 2024
570778e
Refactor stm32 usb host hal for new traits and architecture
ijager Nov 7, 2024
f1d4d57
Implement detecting device connect and speed
ijager Nov 7, 2024
ec998b0
Implement new UsbChannel for stm32-usb HAL
ijager Nov 11, 2024
b27361a
Add request_out to USBOTG host impl & fix drop bug found by @ijager
Nov 7, 2024
6247c9d
Remove completed todos
Nov 7, 2024
7394237
Compatibility
Nov 7, 2024
657e362
Add retries for post-changeaddr
Nov 8, 2024
a0d55f2
Add NAK ignore (test)
Nov 8, 2024
256d974
Reduce logging intensity for interrupt requests
Nov 8, 2024
ab26084
Try fix request_in length
Nov 8, 2024
86acb93
Use critical section for alloc channels
ijager Nov 11, 2024
f8b9c99
Ignore errors on SET_IDLE and SET_PROTOCOL
ijager Nov 11, 2024
94fba80
Implement Drop for Channel
ijager Nov 11, 2024
bcf91dc
Make KeyStatusUpdate fields public
ijager Nov 12, 2024
48c957c
Re-add handler api
Oct 7, 2024
7194fa6
Try improve reliability
Nov 11, 2024
ed3f1d1
Interrupt-less
Nov 13, 2024
83a836a
Try add back interrupts, with fifo leak workaround
Nov 13, 2024
6a11c24
Fix request_in
Nov 13, 2024
159199a
Fix disconnect event
Nov 13, 2024
2c134d9
USBOTG host cleanup
Mar 22, 2025
2e0a143
ConfigurationDescriptor/EnumerationInfo refactor to enable larger con…
Mar 27, 2025
b9b6cb8
Add timeout to UsbHostDriver trait & refactor descriptor parsing/enum…
Apr 1, 2025
077cbf9
Remove old handlers folder
Apr 1, 2025
0811280
Add `iter_descriptors` as proposed by @AlexCharlton & deprecate parse…
Apr 5, 2025
590bd9a
Add PartialEq to EndpointDescriptor & make StringIndex pub
Apr 5, 2025
7a5368a
Fix `get_configuration` (credit to @AlexCharlton)
Apr 5, 2025
b882a78
Compile with log
AlexCharlton Apr 4, 2025
2d5ad1b
Use macro to prevent code repetition
dobrowolski-lukasz Apr 6, 2025
0067fbb
examples/rp: Allign internal crate versions
dobrowolski-lukasz Apr 4, 2025
a4173ff
Revert "Compile with log"
AlexCharlton Apr 4, 2025
8902dda
embassy_rp: Add missing use-s
dobrowolski-lukasz Apr 4, 2025
751a901
embassy_rp: rm unused use-s
dobrowolski-lukasz Apr 4, 2025
211156e
embassy_rp: rm duplcated code
dobrowolski-lukasz Apr 4, 2025
83a76f2
embassy-rp: Allign to changed traits
dobrowolski-lukasz Apr 7, 2025
96980de
embassy-rp: Remove duplicate code
dobrowolski-lukasz Apr 7, 2025
a9a8808
Allign to DeviceEvent::Connected being parametrized by Speed
dobrowolski-lukasz Apr 7, 2025
cc2484b
Remove unused use-s
dobrowolski-lukasz Apr 7, 2025
fbc344b
Use uppercase names for globals
dobrowolski-lukasz Apr 7, 2025
e76cd04
Use EndpointInfo instead of EndpointDescriptor
dobrowolski-lukasz Apr 7, 2025
662f2b3
Correct type name in doc
dobrowolski-lukasz Apr 7, 2025
9981ed1
Placeholder implementation of set_timeout to satisfy trait
dobrowolski-lukasz Apr 7, 2025
60d28b1
Fix examples/rp/.../usb_host_keyboard.rs
dobrowolski-lukasz Apr 7, 2025
d93ba4a
Remove drop_channel and move to unimplemented `Drop` for Channel
Apr 9, 2025
8dc1efd
Remove usize from OUT direction requests
Apr 9, 2025
fdd1277
Add missing Synopsys registers
Apr 9, 2025
de59a26
Fix compilation
dobrowolski-lukasz Apr 24, 2025
de72e92
Fix channel stall
dobrowolski-lukasz Apr 24, 2025
eee315e
Take desc_type from argument in request_descriptor_bytes
dobrowolski-lukasz Apr 24, 2025
4ee8513
Fix InterfaceIterator
dobrowolski-lukasz Apr 30, 2025
7932af9
Remove depricated usb descripor parsing functions
dobrowolski-lukasz May 3, 2025
6194a06
Add empty set_timeout implementation
dobrowolski-lukasz May 3, 2025
424d21c
Fix example compilation
dobrowolski-lukasz May 3, 2025
81e25fc
Remove useless comment
dobrowolski-lukasz May 3, 2025
768cf44
Remove unused gpio from example
dobrowolski-lukasz May 3, 2025
6641d58
Don't use embassy-usb-driver directly
dobrowolski-lukasz May 3, 2025
6f9f5e5
Don't use embassy-usb-driver directly
dobrowolski-lukasz May 3, 2025
c630948
Make example name the same as for rp
dobrowolski-lukasz May 3, 2025
28fc71a
Refactor
dobrowolski-lukasz May 3, 2025
8c1f254
Don't use embassy-usb-driver symbols directly
dobrowolski-lukasz May 3, 2025
c51c10b
Remove unused import
dobrowolski-lukasz May 3, 2025
08f4b8f
Add docstrings
dobrowolski-lukasz May 3, 2025
34f4a80
cargo fmt
dobrowolski-lukasz May 3, 2025
b7cbeac
Add some missing docstrings
dobrowolski-lukasz May 6, 2025
3c7cd5d
spellcheck
dobrowolski-lukasz Jun 4, 2025
88445f2
Shorten docstring
dobrowolski-lukasz Jun 4, 2025
42e25a1
Fix after rebase
dobrowolski-lukasz Jun 18, 2025
f3c7b7d
cargo fmt
dobrowolski-lukasz Jun 18, 2025
4c6dd13
Fix stm32 after rebase
dobrowolski-lukasz Jun 19, 2025
f2ed077
cargo fmt
dobrowolski-lukasz Jun 19, 2025
6ce2e35
Fix compiling with log feature
AlexCharlton Jul 16, 2025
4bcfa74
Fix ConfigurationDescriptor.iter_interface
AlexCharlton Jul 16, 2025
39a6c3a
Request exact descriptor length in get_active_configuration
AlexCharlton Jul 17, 2025
c87f684
Rm unused import
dobrowolski-lukasz Jun 19, 2025
50955f3
Fix spelling
dobrowolski-lukasz Jul 27, 2025
a76c6f2
Extend docstring
dobrowolski-lukasz Jul 27, 2025
23265ea
Add ensure_transaction_end option to request_out
dobrowolski-lukasz Sep 22, 2025
7cdcaa7
Align example to new I2c interface
dobrowolski-lukasz Sep 22, 2025
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
57 changes: 6 additions & 51 deletions embassy-rp/src/usb.rs → embassy-rp/src/usb/device.rs
Original file line number Diff line number Diff line change
@@ -1,44 +1,19 @@
//! USB driver.
use core::future::poll_fn;
use core::marker::PhantomData;
use core::slice;
use core::sync::atomic::{compiler_fence, Ordering};
use core::task::Poll;

use atomic_polyfill::{compiler_fence, Ordering};
use embassy_hal_internal::PeripheralType;
use embassy_sync::waitqueue::AtomicWaker;
use embassy_usb_driver as driver;
use embassy_usb_driver::{
Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported,
};

use super::{Dir, In, Instance, Out};
use crate::interrupt::typelevel::{Binding, Interrupt};
use crate::{interrupt, pac, peripherals, Peri, RegExt};

trait SealedInstance {
fn regs() -> crate::pac::usb::Usb;
fn dpram() -> crate::pac::usb_dpram::UsbDpram;
}

/// USB peripheral instance.
#[allow(private_bounds)]
pub trait Instance: SealedInstance + PeripheralType + 'static {
/// Interrupt for this peripheral.
type Interrupt: interrupt::typelevel::Interrupt;
}

impl crate::usb::SealedInstance for peripherals::USB {
fn regs() -> pac::usb::Usb {
pac::USB
}
fn dpram() -> crate::pac::usb_dpram::UsbDpram {
pac::USB_DPRAM
}
}

impl crate::usb::Instance for peripherals::USB {
type Interrupt = crate::interrupt::typelevel::USBCTRL_IRQ;
}
use crate::{interrupt, pac, Peri, RegExt};

const EP_COUNT: usize = 16;
const EP_MEMORY_SIZE: usize = 4096;
Expand Down Expand Up @@ -99,14 +74,14 @@ impl EndpointData {
}

/// RP2040 USB driver handle.
pub struct Driver<'d, T: Instance> {
pub struct Driver<'d, T: Instance + PeripheralType> {
phantom: PhantomData<&'d mut T>,
ep_in: [EndpointData; EP_COUNT],
ep_out: [EndpointData; EP_COUNT],
ep_mem_free: u16, // first free address in EP mem, in bytes.
}

impl<'d, T: Instance> Driver<'d, T> {
impl<'d, T: Instance + PeripheralType> Driver<'d, T> {
/// Create a new USB driver.
pub fn new(_usb: Peri<'d, T>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>>) -> Self {
T::Interrupt::unpend();
Expand Down Expand Up @@ -304,7 +279,7 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl
}
}

impl<'d, T: Instance> driver::Driver<'d> for Driver<'d, T> {
impl<'d, T: Instance + PeripheralType> driver::Driver<'d> for Driver<'d, T> {
type EndpointOut = Endpoint<'d, T, Out>;
type EndpointIn = Endpoint<'d, T, In>;
type ControlPipe = ControlPipe<'d, T>;
Expand Down Expand Up @@ -507,26 +482,6 @@ impl<'d, T: Instance> driver::Bus for Bus<'d, T> {
}
}

trait Dir {
fn dir() -> Direction;
}

/// Type for In direction.
pub enum In {}
impl Dir for In {
fn dir() -> Direction {
Direction::In
}
}

/// Type for Out direction.
pub enum Out {}
impl Dir for Out {
fn dir() -> Direction {
Direction::Out
}
}

/// Endpoint for RP USB driver.
pub struct Endpoint<'d, T: Instance, D> {
_phantom: PhantomData<(&'d mut T, D)>,
Expand Down
Loading
Loading