@@ -174,6 +174,8 @@ macro_rules! opamps {
174174
175175 /// States for opampX.
176176 pub mod $opamp {
177+ use core:: { borrow:: Borrow , marker:: PhantomData } ;
178+
177179 #[ allow( unused_imports) ]
178180 use crate :: gpio:: gpioa:: * ;
179181
@@ -219,18 +221,18 @@ macro_rules! opamps {
219221
220222 /// State type for opamp running in programmable-gain mode.
221223 pub struct Pga <NonInverting , MODE > {
222- non_inverting: NonInverting ,
224+ non_inverting: PhantomData < NonInverting > ,
223225 config: MODE ,
224226 output: Option <$output>,
225227 }
226228
227229 /// Trait for opamps that can be run in programmable gain mode.
228- pub trait IntoPga <IntoNonInverting , MODE , IntoOutput , NonInverting >
230+ pub trait IntoPga <MODE , IntoOutput , NonInverting >
229231 where
230232 IntoOutput : Into <$output>,
231233 {
232234 /// Configures the opamp for programmable gain operation.
233- fn pga( self , non_inverting: IntoNonInverting , config: MODE , output: Option <IntoOutput >)
235+ fn pga< B : Borrow < NonInverting >> ( self , non_inverting: B , config: MODE , output: Option <IntoOutput >)
234236 -> Pga <NonInverting , MODE >;
235237 }
236238
@@ -295,9 +297,9 @@ macro_rules! opamps {
295297 impl <NonInverting , MODE > Pga <NonInverting , MODE > {
296298
297299 /// Disables the opamp and returns the resources it held.
298- pub fn disable( self ) -> ( Disabled , NonInverting , MODE , Option <$output>) {
300+ pub fn disable( self ) -> ( Disabled , MODE , Option <$output>) {
299301 unsafe { ( * crate :: stm32:: OPAMP :: ptr( ) ) . [ <$opamp _csr>] . reset( ) }
300- ( Disabled , self . non_inverting , self . config, self . output)
302+ ( Disabled , self . config, self . output)
301303 }
302304
303305 /// Enables the external output pin.
@@ -504,19 +506,16 @@ macro_rules! opamps {
504506 $mode: ty
505507 } => {
506508 paste:: paste!{
507- impl <IntoNonInverting , IntoOutput > IntoPga
508- <IntoNonInverting , $mode, IntoOutput , $non_inverting> for Disabled
509+ impl <IntoOutput > IntoPga <$mode, IntoOutput , $non_inverting> for Disabled
509510 where
510- IntoNonInverting : Into <$non_inverting>,
511511 IntoOutput : Into <$output>,
512512 {
513- fn pga(
513+ fn pga< B : Borrow <$non_inverting>> (
514514 self ,
515- non_inverting : IntoNonInverting ,
515+ _non_inverting : B ,
516516 config: $mode,
517517 output: Option <IntoOutput >,
518518 ) -> Pga <$non_inverting, $mode> {
519- let non_inverting = non_inverting. into( ) ;
520519 let output = output. map( |output| output. into( ) ) ;
521520 unsafe {
522521 use crate :: stm32:: opamp:: [ <$opamp _csr>] :: OPAINTOEN_A ;
@@ -539,7 +538,7 @@ macro_rules! opamps {
539538 . enabled( )
540539 ) ;
541540 }
542- Pga { non_inverting, config, output}
541+ Pga { non_inverting: PhantomData , config, output}
543542 }
544543 }
545544 }
0 commit comments