nrf/usb: prevent user code from constructing a PowerUsb directly.

PowerUsb must be constructed through `new()` so that it sets up the IRQ.
It must have at least one private field, otherwise user code can construct
it directly with `PowerUsb{}`.
This commit is contained in:
Dario Nieuwenhuis 2022-07-21 19:47:09 +02:00
parent 26fdfdb00a
commit c40d5f6e6f

View File

@ -47,7 +47,9 @@ pub struct Driver<'d, T: Instance, P: UsbSupply> {
/// Uses the POWER peripheral to detect when power is available /// Uses the POWER peripheral to detect when power is available
/// for USB. Unsuitable for usage with the nRF softdevice. /// for USB. Unsuitable for usage with the nRF softdevice.
#[cfg(not(feature = "_nrf5340-app"))] #[cfg(not(feature = "_nrf5340-app"))]
pub struct PowerUsb {} pub struct PowerUsb {
_private: (),
}
/// Can be used to signal that power is available. Particularly suited for /// Can be used to signal that power is available. Particularly suited for
/// use with the nRF softdevice. /// use with the nRF softdevice.
@ -70,7 +72,7 @@ impl PowerUsb {
regs.intenset regs.intenset
.write(|w| w.usbdetected().set().usbremoved().set().usbpwrrdy().set()); .write(|w| w.usbdetected().set().usbremoved().set().usbpwrrdy().set());
Self {} Self { _private: () }
} }
#[cfg(not(feature = "_nrf5340-app"))] #[cfg(not(feature = "_nrf5340-app"))]