diff --git a/embassy-nrf/src/usb.rs b/embassy-nrf/src/usb.rs index d0944b7f..b110258c 100644 --- a/embassy-nrf/src/usb.rs +++ b/embassy-nrf/src/usb.rs @@ -20,15 +20,15 @@ unsafe impl<'d, T: Instance> UsbPeripheral for UsbBus<'d, T> { impl<'d, T: Instance> UsbBus<'d, T> { pub fn new(_usb: impl Unborrow + 'd) -> UsbBusAllocator>> { - unsafe { - (*pac::USBD::ptr()).intenset.write(|w| { - w.sof().set_bit(); - w.usbevent().set_bit(); - w.ep0datadone().set_bit(); - w.ep0setup().set_bit(); - w.usbreset().set_bit() - }) - }; + let r = T::regs(); + + r.intenset.write(|w| { + w.sof().set_bit(); + w.usbevent().set_bit(); + w.ep0datadone().set_bit(); + w.ep0setup().set_bit(); + w.usbreset().set_bit() + }); Usbd::new(UsbBus { phantom: PhantomData,