diff --git a/CHANGELOG.md b/CHANGELOG.md index ed5be39..9c3a494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Changelog [Unreleased] ------------ +**BREAKING** Update to `usb-device` 0.3. By adopting this release, you're +required to use `usb-device` 0.3 and its compatible packages. + [0.2.2] 2023-09-15 ------------------ diff --git a/Cargo.toml b/Cargo.toml index 71be9de..cfa0b15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ exclude = [ bitflags = "1.2" cortex-m = "0.7" ral-registers = "0.1" -usb-device = "0.2" +usb-device = "0.3" [dependencies.log] optional = true diff --git a/src/bus.rs b/src/bus.rs index 871c0b3..192c363 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -65,7 +65,7 @@ pub use super::driver::Speed; /// use usb_device::prelude::*; /// let bus_allocator = usb_device::bus::UsbBusAllocator::new(bus_adapter); /// let mut device = UsbDeviceBuilder::new(&bus_allocator, UsbVidPid(0x5824, 0x27dd)) -/// .product("imxrt-usbd") +/// .strings(&[StringDescriptors::default().product("imxrt-usbd")]).unwrap() /// // Other builder methods... /// .build(); /// diff --git a/src/endpoint.rs b/src/endpoint.rs index 9231445..34824f9 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -105,10 +105,10 @@ impl Endpoint { let endptctrl = endpoint_control::register(usb, self.address.index()); match self.address.direction() { UsbDirection::In => { - ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, TXE: 0, TXT: EndpointType::Bulk as u32) + ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, TXE: 0, TXT: into_raw_endpoint_type(EndpointType::Bulk)) } UsbDirection::Out => { - ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, RXE: 0, RXT: EndpointType::Bulk as u32) + ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, RXE: 0, RXT: into_raw_endpoint_type(EndpointType::Bulk)) } } } @@ -248,10 +248,10 @@ impl Endpoint { let endptctrl = endpoint_control::register(usb, self.address.index()); match self.address.direction() { UsbDirection::In => { - ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, TXE: 1, TXR: 1, TXT: self.kind as u32) + ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, TXE: 1, TXR: 1, TXT: into_raw_endpoint_type(self.kind)) } UsbDirection::Out => { - ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, RXE: 1, RXR: 1, RXT: self.kind as u32) + ral::modify_reg!(endpoint_control, &endptctrl, ENDPTCTRL, RXE: 1, RXR: 1, RXT: into_raw_endpoint_type(self.kind)) } } } @@ -284,3 +284,13 @@ impl Endpoint { } } } + +/// Converts the endpoint type into its ENDPTCTRL endpoint type +/// enumerations. +/// +/// See the ENDPTCTRL register documentation in the reference manual. +fn into_raw_endpoint_type(ep_type: EndpointType) -> u32 { + // Bits 0..1 represent the transfer type for the endpoint, + // and it's compatible with ENDPTCTRL's enumerated values. + (ep_type.to_bm_attributes() & 0b11u8).into() +} diff --git a/src/gpt.rs b/src/gpt.rs index 31ecca5..d7070b9 100644 --- a/src/gpt.rs +++ b/src/gpt.rs @@ -43,7 +43,7 @@ //! let bus_allocator = usb_device::bus::UsbBusAllocator::new(bus_adapter); //! //! let mut device = UsbDeviceBuilder::new(&bus_allocator, UsbVidPid(0x5824, 0x27dd)) -//! .product("imxrt-usbd") +//! .strings(&[StringDescriptors::default().product("imxrt-usbd")]).unwrap() //! .build(); //! //! // You can still access the timer through the bus() method on