rename to UsbBus

This commit is contained in:
Jacob Rosenthal 2021-12-15 09:59:56 -07:00
parent 2a6d92d641
commit 79502330de
2 changed files with 7 additions and 7 deletions

View File

@ -4,15 +4,15 @@ pub use embassy_hal_common::usb::*;
use nrf_usbd::{UsbPeripheral, Usbd};
use usb_device::bus::UsbBusAllocator;
pub struct UsbThing;
unsafe impl UsbPeripheral for UsbThing {
pub struct UsbBus;
unsafe impl UsbPeripheral for UsbBus {
// todo hardcoding
const REGISTERS: *const () = crate::pac::USBD::ptr() as *const ();
}
impl UsbThing {
impl UsbBus {
// todo should it consume a USBD peripheral?
pub fn new() -> UsbBusAllocator<Usbd<UsbThing>> {
pub fn new() -> UsbBusAllocator<Usbd<UsbBus>> {
unsafe {
(*crate::pac::USBD::ptr()).intenset.write(|w| {
w.sof().set_bit();
@ -23,7 +23,7 @@ impl UsbThing {
})
};
Usbd::new(UsbThing)
Usbd::new(UsbBus)
}
}

View File

@ -16,7 +16,7 @@ use panic_probe as _; // print out panic messages
use embassy::executor::Spawner;
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
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 usb_device::device::{UsbDeviceBuilder, UsbVidPid};
@ -25,7 +25,7 @@ async fn main(_spawner: Spawner, _p: Peripherals) {
let mut tx_buffer = [0u8; 1024];
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);