@@ -104,21 +104,21 @@ pub struct Disabled<Opamp> {
104
104
pub struct Follower < Opamp , Input , Output > {
105
105
opamp : PhantomData < Opamp > ,
106
106
input : Input ,
107
- output : Option < Output > ,
107
+ output : Output ,
108
108
}
109
109
/// State type for opamp running in open-loop mode.
110
110
pub struct OpenLoop < Opamp , NonInverting , Inverting , Output > {
111
111
opamp : PhantomData < Opamp > ,
112
112
non_inverting : NonInverting ,
113
113
inverting : Inverting ,
114
- output : Option < Output > ,
114
+ output : Output ,
115
115
}
116
116
/// State type for opamp running in programmable-gain mode.
117
117
pub struct Pga < Opamp , NonInverting , MODE , Output > {
118
118
opamp : PhantomData < Opamp > ,
119
119
non_inverting : PhantomData < NonInverting > ,
120
120
config : MODE ,
121
- output : Option < Output > ,
121
+ output : Output ,
122
122
}
123
123
/// State type for an opamp that has been locked.
124
124
pub struct Locked < Opamp , Output > {
@@ -277,24 +277,19 @@ macro_rules! opamps {
277
277
/// Disables the opamp and returns the resources it held.
278
278
pub fn disable( self ) -> ( Disabled <$opamp>, Input , $output) {
279
279
unsafe { $opamp:: _reset( ) } ;
280
- // Safe to unwrap `self.output` because `self.output` is only None
281
- // when the Output type is InternalOutput
282
- ( Disabled { opamp: PhantomData } , self . input, self . output. unwrap( ) )
280
+ ( Disabled { opamp: PhantomData } , self . input, self . output)
283
281
}
284
282
285
283
/// Disables the external output.
286
284
/// This will connect the opamp output to the internal ADC.
287
285
/// If the output was enabled, the output pin is returned.
288
- pub fn disable_output( mut self ) -> ( Follower <$opamp, Input , InternalOutput >, $output) {
286
+ pub fn disable_output( self ) -> ( Follower <$opamp, Input , InternalOutput >, $output) {
289
287
unsafe { $opamp:: _disable_output( ) ; }
290
-
291
- // Safe to unwrap `self.output` because `self.output` is only None
292
- // when the Output type is InternalOutput
293
288
( Follower :: <$opamp, Input , InternalOutput > {
294
289
opamp: PhantomData ,
295
290
input: self . input,
296
- output: None ,
297
- } , self . output. take ( ) . unwrap ( ) )
291
+ output: InternalOutput ,
292
+ } , self . output)
298
293
}
299
294
300
295
/// Set the lock bit in the registers. After the lock bit is
@@ -320,7 +315,7 @@ macro_rules! opamps {
320
315
Follower :: <$opamp, Input , $output> {
321
316
opamp: PhantomData ,
322
317
input: self . input,
323
- output: Some ( output ) ,
318
+ output,
324
319
}
325
320
}
326
321
@@ -337,25 +332,20 @@ macro_rules! opamps {
337
332
/// Disables the opamp and returns the resources it held.
338
333
pub fn disable( self ) -> ( Disabled <$opamp>, NonInverting , Inverting , $output) {
339
334
unsafe { $opamp:: _reset( ) } ;
340
- // Safe to unwrap `self.output` because `self.output` is only None
341
- // when the Output type is InternalOutput
342
- ( Disabled { opamp: PhantomData } , self . non_inverting, self . inverting, self . output. unwrap( ) )
335
+ ( Disabled { opamp: PhantomData } , self . non_inverting, self . inverting, self . output)
343
336
}
344
337
345
338
/// Disables the external output.
346
339
/// This will connect the opamp output to the internal ADC.
347
340
/// If the output was enabled, the output pin is returned.
348
- pub fn disable_output( mut self ) -> ( OpenLoop <$opamp, NonInverting , Inverting , InternalOutput >, $output) {
341
+ pub fn disable_output( self ) -> ( OpenLoop <$opamp, NonInverting , Inverting , InternalOutput >, $output) {
349
342
unsafe { $opamp:: _disable_output( ) ; }
350
-
351
- // Safe to unwrap `self.output` because `self.output` is only None
352
- // when the Output type is InternalOutput
353
343
( OpenLoop :: <$opamp, NonInverting , Inverting , InternalOutput > {
354
344
opamp: PhantomData ,
355
345
inverting: self . inverting,
356
346
non_inverting: self . non_inverting,
357
- output: None ,
358
- } , self . output. take ( ) . unwrap ( ) )
347
+ output: InternalOutput ,
348
+ } , self . output)
359
349
}
360
350
361
351
/// Set the lock bit in the registers. After the lock bit is
@@ -382,7 +372,7 @@ macro_rules! opamps {
382
372
opamp: PhantomData ,
383
373
inverting: self . inverting,
384
374
non_inverting: self . non_inverting,
385
- output: Some ( output ) ,
375
+ output,
386
376
}
387
377
}
388
378
@@ -399,24 +389,19 @@ macro_rules! opamps {
399
389
/// Disables the opamp and returns the resources it held.
400
390
pub fn disable( self ) -> ( Disabled <$opamp>, MODE , $output) {
401
391
unsafe { $opamp:: _reset( ) } ;
402
- // Safe to unwrap `self.output` because `self.output` is only None
403
- // when the Output type is InternalOutput
404
- ( Disabled { opamp: PhantomData } , self . config, self . output. unwrap( ) )
392
+ ( Disabled { opamp: PhantomData } , self . config, self . output)
405
393
}
406
394
407
395
/// Disables the external output.
408
396
/// This will connect the opamp output to the internal ADC.
409
- pub fn disable_output( mut self ) -> ( Pga <$opamp, NonInverting , MODE , InternalOutput >, $output) {
397
+ pub fn disable_output( self ) -> ( Pga <$opamp, NonInverting , MODE , InternalOutput >, $output) {
410
398
unsafe { $opamp:: _disable_output( ) ; }
411
-
412
- // Safe to unwrap `self.output` because `self.output` is only None
413
- // when the Output type is InternalOutput
414
399
( Pga :: <$opamp, NonInverting , MODE , InternalOutput > {
415
400
opamp: PhantomData ,
416
401
non_inverting: self . non_inverting,
417
402
config: self . config,
418
- output: None ,
419
- } , self . output. take ( ) . unwrap ( ) )
403
+ output: InternalOutput ,
404
+ } , self . output)
420
405
}
421
406
422
407
/// Set the lock bit in the registers. After the lock bit is
@@ -443,7 +428,7 @@ macro_rules! opamps {
443
428
opamp: PhantomData ,
444
429
non_inverting: self . non_inverting,
445
430
config: self . config,
446
- output: Some ( output ) ,
431
+ output,
447
432
}
448
433
}
449
434
@@ -532,7 +517,7 @@ macro_rules! opamps {
532
517
. enabled( )
533
518
) ;
534
519
}
535
- Follower { opamp: PhantomData , input, output: Some ( output ) }
520
+ Follower { opamp: PhantomData , input, output}
536
521
}
537
522
}
538
523
@@ -562,7 +547,7 @@ macro_rules! opamps {
562
547
. enabled( )
563
548
) ;
564
549
}
565
- Follower { opamp: PhantomData , input, output: None }
550
+ Follower { opamp: PhantomData , input, output: InternalOutput }
566
551
}
567
552
}
568
553
@@ -630,7 +615,7 @@ macro_rules! opamps {
630
615
. enabled( )
631
616
) ;
632
617
}
633
- OpenLoop { opamp: PhantomData , non_inverting, inverting, output: Some ( output ) }
618
+ OpenLoop { opamp: PhantomData , non_inverting, inverting, output}
634
619
}
635
620
}
636
621
impl <IntoNonInverting , IntoInverting > IntoOpenLoop
@@ -662,7 +647,7 @@ macro_rules! opamps {
662
647
. enabled( )
663
648
) ;
664
649
}
665
- OpenLoop { opamp: PhantomData , non_inverting, inverting, output: None }
650
+ OpenLoop { opamp: PhantomData , non_inverting, inverting, output: InternalOutput }
666
651
}
667
652
}
668
653
) *
@@ -729,7 +714,7 @@ macro_rules! opamps {
729
714
. enabled( )
730
715
) ;
731
716
}
732
- Pga { opamp: PhantomData , non_inverting: PhantomData , config, output: Some ( output ) }
717
+ Pga { opamp: PhantomData , non_inverting: PhantomData , config, output}
733
718
}
734
719
}
735
720
impl IntoPga <$opamp, $mode, InternalOutput , $non_inverting, InternalOutput > for Disabled <$opamp>
@@ -758,7 +743,7 @@ macro_rules! opamps {
758
743
. enabled( )
759
744
) ;
760
745
}
761
- Pga { opamp: PhantomData , non_inverting: PhantomData , config, output: None }
746
+ Pga { opamp: PhantomData , non_inverting: PhantomData , config, output: InternalOutput }
762
747
}
763
748
}
764
749
}
0 commit comments