rename to UsbBus
This commit is contained in:
parent
2a6d92d641
commit
79502330de
@ -4,15 +4,15 @@ pub use embassy_hal_common::usb::*;
|
|||||||
use nrf_usbd::{UsbPeripheral, Usbd};
|
use nrf_usbd::{UsbPeripheral, Usbd};
|
||||||
use usb_device::bus::UsbBusAllocator;
|
use usb_device::bus::UsbBusAllocator;
|
||||||
|
|
||||||
pub struct UsbThing;
|
pub struct UsbBus;
|
||||||
unsafe impl UsbPeripheral for UsbThing {
|
unsafe impl UsbPeripheral for UsbBus {
|
||||||
// todo hardcoding
|
// todo hardcoding
|
||||||
const REGISTERS: *const () = crate::pac::USBD::ptr() as *const ();
|
const REGISTERS: *const () = crate::pac::USBD::ptr() as *const ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UsbThing {
|
impl UsbBus {
|
||||||
// todo should it consume a USBD peripheral?
|
// todo should it consume a USBD peripheral?
|
||||||
pub fn new() -> UsbBusAllocator<Usbd<UsbThing>> {
|
pub fn new() -> UsbBusAllocator<Usbd<UsbBus>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*crate::pac::USBD::ptr()).intenset.write(|w| {
|
(*crate::pac::USBD::ptr()).intenset.write(|w| {
|
||||||
w.sof().set_bit();
|
w.sof().set_bit();
|
||||||
@ -23,7 +23,7 @@ impl UsbThing {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
Usbd::new(UsbThing)
|
Usbd::new(UsbBus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use panic_probe as _; // print out panic messages
|
|||||||
use embassy::executor::Spawner;
|
use embassy::executor::Spawner;
|
||||||
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
||||||
use embassy::time::{Duration, Timer};
|
use embassy::time::{Duration, Timer};
|
||||||
use embassy_nrf::usb::{State, Usb, UsbSerial, UsbThing};
|
use embassy_nrf::usb::{State, Usb, UsbBus, UsbSerial};
|
||||||
use embassy_nrf::{interrupt, Peripherals};
|
use embassy_nrf::{interrupt, Peripherals};
|
||||||
use usb_device::device::{UsbDeviceBuilder, UsbVidPid};
|
use usb_device::device::{UsbDeviceBuilder, UsbVidPid};
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ async fn main(_spawner: Spawner, _p: Peripherals) {
|
|||||||
let mut tx_buffer = [0u8; 1024];
|
let mut tx_buffer = [0u8; 1024];
|
||||||
let mut rx_buffer = [0u8; 640];
|
let mut rx_buffer = [0u8; 640];
|
||||||
|
|
||||||
let usb_bus = UsbThing::new();
|
let usb_bus = UsbBus::new();
|
||||||
|
|
||||||
let serial = UsbSerial::new(&usb_bus, &mut rx_buffer, &mut tx_buffer);
|
let serial = UsbSerial::new(&usb_bus, &mut rx_buffer, &mut tx_buffer);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user