diff options
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 27 | ||||
| -rw-r--r-- | embassy-nrf/src/usb.rs | 6 |
2 files changed, 30 insertions, 3 deletions
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 7d39e33f8..af1aa8812 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -119,6 +119,25 @@ impl sealed::Input for VddhDiv5Input { | |||
| 119 | #[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] | 119 | #[cfg(any(feature = "_nrf5340-app", feature = "nrf52833", feature = "nrf52840"))] |
| 120 | impl Input for VddhDiv5Input {} | 120 | impl Input for VddhDiv5Input {} |
| 121 | 121 | ||
| 122 | pub struct AnyInput { | ||
| 123 | channel: InputChannel, | ||
| 124 | } | ||
| 125 | |||
| 126 | unsafe impl Unborrow for AnyInput { | ||
| 127 | type Target = AnyInput; | ||
| 128 | unsafe fn unborrow(self) -> Self::Target { | ||
| 129 | self | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | impl sealed::Input for AnyInput { | ||
| 134 | fn channel(&self) -> InputChannel { | ||
| 135 | self.channel | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | impl Input for AnyInput {} | ||
| 140 | |||
| 122 | impl<'d> ChannelConfig<'d> { | 141 | impl<'d> ChannelConfig<'d> { |
| 123 | /// Default configuration for single ended channel sampling. | 142 | /// Default configuration for single ended channel sampling. |
| 124 | pub fn single_ended(input: impl Unborrow<Target = impl Input> + 'd) -> Self { | 143 | pub fn single_ended(input: impl Unborrow<Target = impl Input> + 'd) -> Self { |
| @@ -670,7 +689,13 @@ pub(crate) mod sealed { | |||
| 670 | } | 689 | } |
| 671 | 690 | ||
| 672 | /// An input that can be used as either or negative end of a ADC differential in the SAADC periperhal. | 691 | /// An input that can be used as either or negative end of a ADC differential in the SAADC periperhal. |
| 673 | pub trait Input: sealed::Input + Unborrow<Target = Self> {} | 692 | pub trait Input: sealed::Input + Unborrow<Target = Self> + Sized { |
| 693 | fn degrade_saadc(self) -> AnyInput { | ||
| 694 | AnyInput { | ||
| 695 | channel: self.channel(), | ||
| 696 | } | ||
| 697 | } | ||
| 698 | } | ||
| 674 | 699 | ||
| 675 | macro_rules! impl_saadc_input { | 700 | macro_rules! impl_saadc_input { |
| 676 | ($pin:ident, $ch:ident) => { | 701 | ($pin:ident, $ch:ident) => { |
diff --git a/embassy-nrf/src/usb.rs b/embassy-nrf/src/usb.rs index 9b6e6e83d..a039427f1 100644 --- a/embassy-nrf/src/usb.rs +++ b/embassy-nrf/src/usb.rs | |||
| @@ -47,7 +47,9 @@ pub struct Driver<'d, T: Instance, P: UsbSupply> { | |||
| 47 | /// Uses the POWER peripheral to detect when power is available | 47 | /// Uses the POWER peripheral to detect when power is available |
| 48 | /// for USB. Unsuitable for usage with the nRF softdevice. | 48 | /// for USB. Unsuitable for usage with the nRF softdevice. |
| 49 | #[cfg(not(feature = "_nrf5340-app"))] | 49 | #[cfg(not(feature = "_nrf5340-app"))] |
| 50 | pub struct PowerUsb {} | 50 | pub struct PowerUsb { |
| 51 | _private: (), | ||
| 52 | } | ||
| 51 | 53 | ||
| 52 | /// Can be used to signal that power is available. Particularly suited for | 54 | /// Can be used to signal that power is available. Particularly suited for |
| 53 | /// use with the nRF softdevice. | 55 | /// use with the nRF softdevice. |
| @@ -70,7 +72,7 @@ impl PowerUsb { | |||
| 70 | regs.intenset | 72 | regs.intenset |
| 71 | .write(|w| w.usbdetected().set().usbremoved().set().usbpwrrdy().set()); | 73 | .write(|w| w.usbdetected().set().usbremoved().set().usbpwrrdy().set()); |
| 72 | 74 | ||
| 73 | Self {} | 75 | Self { _private: () } |
| 74 | } | 76 | } |
| 75 | 77 | ||
| 76 | #[cfg(not(feature = "_nrf5340-app"))] | 78 | #[cfg(not(feature = "_nrf5340-app"))] |
