1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
//! Operational Amplifier (OPAMP)
#![macro_use]
use embassy_hal_internal::PeripheralType;
use crate::Peri;
#[cfg(opamp_v5)]
use crate::block_for_us;
use crate::pac::opamp::vals::*;
#[cfg(not(any(stm32g4, stm32f3)))]
use crate::rcc::RccInfo;
/// Gain
#[allow(missing_docs)]
#[derive(Clone, Copy)]
pub enum OpAmpGain {
Mul2,
Mul4,
Mul8,
Mul16,
#[cfg(opamp_v5)]
Mul32,
#[cfg(opamp_v5)]
Mul64,
}
#[cfg(opamp_v5)]
enum OpAmpDifferentialPair {
P,
N,
}
/// Speed
#[allow(missing_docs)]
#[derive(Clone, Copy, PartialEq)]
pub enum OpAmpSpeed {
Normal,
HighSpeed,
}
/// OpAmp external outputs, wired to a GPIO pad.
///
/// This struct can also be used as an ADC input.
pub struct OpAmpOutput<'d, T: Instance> {
_inner: &'d OpAmp<'d, T>,
}
/// OpAmp internal outputs, wired directly to ADC inputs.
///
/// This struct can be used as an ADC input.
#[cfg(opamp_v5)]
pub struct OpAmpInternalOutput<'d, T: Instance> {
_inner: &'d OpAmp<'d, T>,
}
/// OpAmp driver.
pub struct OpAmp<'d, T: Instance> {
_inner: Peri<'d, T>,
}
impl<'d, T: Instance> OpAmp<'d, T> {
/// Create a new driver instance.
///
/// Does not enable the opamp, but does set the speed mode on some families.
pub fn new(opamp: Peri<'d, T>, #[cfg(opamp_v5)] speed: OpAmpSpeed) -> Self {
#[cfg(not(any(stm32g4, stm32f3)))]
T::info().rcc.enable_and_reset();
#[cfg(opamp_v5)]
T::regs().csr().modify(|w| {
w.set_opahsm(speed == OpAmpSpeed::HighSpeed);
});
Self { _inner: opamp }
}
/// Configure the OpAmp as a buffer for the provided input pin,
/// outputting to the provided output pin, and enable the opamp.
///
/// The input pin is configured for analogue mode but not consumed,
/// so it may subsequently be used for ADC or comparator inputs.
///
/// The output pin is held within the returned [`OpAmpOutput`] struct,
/// preventing it being used elsewhere. The `OpAmpOutput` can then be
/// directly used as an ADC input. The opamp will be disabled when the
/// [`OpAmpOutput`] is dropped.
pub fn buffer_ext(
&mut self,
in_pin: Peri<'_, impl NonInvertingPin<T> + crate::gpio::Pin>,
out_pin: Peri<'_, impl OutputPin<T> + crate::gpio::Pin>,
) -> OpAmpOutput<'_, T> {
in_pin.set_as_analog();
out_pin.set_as_analog();
#[cfg(opamp_v5)]
let vm_sel = VmSel::OUTPUT;
#[cfg(not(opamp_v5))]
let vm_sel = VmSel::from_bits(0b11);
T::regs().csr().modify(|w| {
w.set_vp_sel(VpSel::from_bits(in_pin.channel()));
w.set_vm_sel(vm_sel);
#[cfg(opamp_v5)]
w.set_opaintoen(false);
w.set_opampen(true);
});
OpAmpOutput { _inner: self }
}
/// Configure the OpAmp as a PGA for the provided input pin,
/// outputting to the provided output pin, and enable the opamp.
///
/// The input pin is configured for analogue mode but not consumed,
/// so it may subsequently be used for ADC or comparator inputs.
///
/// The output pin is held within the returned [`OpAmpOutput`] struct,
/// preventing it being used elsewhere. The `OpAmpOutput` can then be
/// directly used as an ADC input. The opamp will be disabled when the
/// [`OpAmpOutput`] is dropped.
pub fn pga_ext(
&mut self,
in_pin: Peri<'_, impl NonInvertingPin<T> + crate::gpio::Pin>,
out_pin: Peri<'_, impl OutputPin<T> + crate::gpio::Pin>,
gain: OpAmpGain,
) -> OpAmpOutput<'_, T> {
in_pin.set_as_analog();
out_pin.set_as_analog();
#[cfg(opamp_v5)]
let vm_sel = VmSel::PGA;
#[cfg(not(opamp_v5))]
let vm_sel = VmSel::from_bits(0b10);
#[cfg(opamp_v5)]
let pga_gain = match gain {
OpAmpGain::Mul2 => PgaGain::GAIN2,
OpAmpGain::Mul4 => PgaGain::GAIN4,
OpAmpGain::Mul8 => PgaGain::GAIN8,
OpAmpGain::Mul16 => PgaGain::GAIN16,
OpAmpGain::Mul32 => PgaGain::GAIN32,
OpAmpGain::Mul64 => PgaGain::GAIN64,
};
#[cfg(not(opamp_v5))]
let pga_gain = PgaGain::from_bits(match gain {
OpAmpGain::Mul2 => 0b00,
OpAmpGain::Mul4 => 0b01,
OpAmpGain::Mul8 => 0b10,
OpAmpGain::Mul16 => 0b11,
});
T::regs().csr().modify(|w| {
w.set_vp_sel(VpSel::from_bits(in_pin.channel()));
w.set_vm_sel(vm_sel);
w.set_pga_gain(pga_gain);
#[cfg(opamp_v5)]
w.set_opaintoen(false);
w.set_opampen(true);
});
OpAmpOutput { _inner: self }
}
/// Configure the OpAmp as a buffer for the DAC it is connected to,
/// outputting to the provided output pin, and enable the opamp.
///
/// The output pin is held within the returned [`OpAmpOutput`] struct,
/// preventing it being used elsewhere. The `OpAmpOutput` can then be
/// directly used as an ADC input. The opamp will be disabled when the
/// [`OpAmpOutput`] is dropped.
#[cfg(opamp_v5)]
pub fn buffer_dac(&mut self, out_pin: Peri<'_, impl OutputPin<T> + crate::gpio::Pin>) -> OpAmpOutput<'_, T> {
out_pin.set_as_analog();
T::regs().csr().modify(|w| {
use crate::pac::opamp::vals::*;
w.set_vm_sel(VmSel::OUTPUT);
w.set_vp_sel(VpSel::DAC3_CH1);
w.set_opaintoen(false);
w.set_opampen(true);
});
OpAmpOutput { _inner: self }
}
/// Configure the OpAmp as a buffer for the provided input pin,
/// with the output only used internally, and enable the opamp.
///
/// The input pin is configured for analogue mode but not consumed,
/// so it may be subsequently used for ADC or comparator inputs.
///
/// The returned `OpAmpInternalOutput` struct may be used as an ADC input.
/// The opamp output will be disabled when it is dropped.
#[cfg(opamp_v5)]
pub fn buffer_int(
&mut self,
pin: Peri<'_, impl NonInvertingPin<T> + crate::gpio::Pin>,
) -> OpAmpInternalOutput<'_, T> {
pin.set_as_analog();
T::regs().csr().modify(|w| {
w.set_vp_sel(VpSel::from_bits(pin.channel()));
w.set_vm_sel(VmSel::OUTPUT);
#[cfg(opamp_v5)]
w.set_opaintoen(true);
w.set_opampen(true);
});
OpAmpInternalOutput { _inner: self }
}
/// Configure the OpAmp as a PGA for the provided input pin,
/// with the output only used internally, and enable the opamp.
///
/// The input pin is configured for analogue mode but not consumed,
/// so it may be subsequently used for ADC or comparator inputs.
///
/// The returned `OpAmpInternalOutput` struct may be used as an ADC input.
/// The opamp output will be disabled when it is dropped.
#[cfg(opamp_v5)]
pub fn pga_int(
&mut self,
pin: Peri<'_, impl NonInvertingPin<T> + crate::gpio::Pin>,
gain: OpAmpGain,
) -> OpAmpInternalOutput<'_, T> {
pin.set_as_analog();
let pga_gain = match gain {
OpAmpGain::Mul2 => PgaGain::GAIN2,
OpAmpGain::Mul4 => PgaGain::GAIN4,
OpAmpGain::Mul8 => PgaGain::GAIN8,
OpAmpGain::Mul16 => PgaGain::GAIN16,
OpAmpGain::Mul32 => PgaGain::GAIN32,
OpAmpGain::Mul64 => PgaGain::GAIN64,
};
T::regs().csr().modify(|w| {
w.set_vp_sel(VpSel::from_bits(pin.channel()));
w.set_vm_sel(VmSel::PGA);
w.set_pga_gain(pga_gain);
w.set_opaintoen(true);
w.set_opampen(true);
});
OpAmpInternalOutput { _inner: self }
}
/// Configure the OpAmp as a standalone DAC with the inverting input
/// connected to the provided pin, and the output is connected
/// internally to an ADC channel.
///
/// The input pin is configured for analogue mode but not consumed,
/// so it may be subsequently used for ADC or comparator inputs.
///
/// The returned `OpAmpInternalOutput` struct may be used as an ADC
/// input. The opamp output will be disabled when it is dropped.
#[cfg(opamp_v5)]
pub fn standalone_dac_int(
&mut self,
m_pin: Peri<'_, impl InvertingPin<T> + crate::gpio::Pin>,
) -> OpAmpInternalOutput<'_, T> {
m_pin.set_as_analog();
T::regs().csr().modify(|w| {
use crate::pac::opamp::vals::*;
w.set_vp_sel(VpSel::DAC3_CH1); // Actually DAC3_CHx
w.set_vm_sel(VmSel::from_bits(m_pin.channel()));
w.set_opaintoen(true);
w.set_opampen(true);
});
OpAmpInternalOutput { _inner: self }
}
/// Configure the OpAmp as a standalone DAC with the inverting input
/// connected to the provided pin, and the output connected to the
/// provided pin.
///
/// The input pin is configured for analogue mode but not consumed,
/// so it may be subsequently used for ADC or comparator inputs.
///
/// The output pin is held within the returned [`OpAmpOutput`] struct,
/// preventing it being used elsewhere. The opamp will be disabled when
/// the [`OpAmpOutput`] is dropped.
#[cfg(opamp_v5)]
pub fn standalone_dac_ext(
&mut self,
m_pin: Peri<'_, impl InvertingPin<T> + crate::gpio::Pin>,
out_pin: Peri<'_, impl OutputPin<T> + crate::gpio::Pin>,
) -> OpAmpOutput<'_, T> {
m_pin.set_as_analog();
out_pin.set_as_analog();
T::regs().csr().modify(|w| {
use crate::pac::opamp::vals::*;
w.set_vp_sel(VpSel::DAC3_CH1); // Actually DAC3_CHx
w.set_vm_sel(VmSel::from_bits(m_pin.channel()));
w.set_opaintoen(false);
w.set_opampen(true);
});
OpAmpOutput { _inner: self }
}
/// Configure the OpAmp in standalone mode with the non-inverting input
/// connected to the provided `p_pin`, the inverting input connected to
/// the `m_pin`, and output to the provided `out_pin`.
///
/// The input pins are configured for analogue mode but not consumed,
/// allowing their subsequent use for ADC or comparator inputs.
///
/// The output pin is held within the returned [`OpAmpOutput`] struct,
/// preventing it being used elsewhere. The opamp will be disabled when
/// the [`OpAmpOutput`] is dropped.
#[cfg(opamp_v5)]
pub fn standalone_ext(
&mut self,
p_pin: Peri<'d, impl NonInvertingPin<T> + crate::gpio::Pin>,
m_pin: Peri<'d, impl InvertingPin<T> + crate::gpio::Pin>,
out_pin: Peri<'d, impl OutputPin<T> + crate::gpio::Pin>,
) -> OpAmpOutput<'_, T> {
p_pin.set_as_analog();
m_pin.set_as_analog();
out_pin.set_as_analog();
T::regs().csr().modify(|w| {
use crate::pac::opamp::vals::*;
w.set_vp_sel(VpSel::from_bits(p_pin.channel()));
w.set_vm_sel(VmSel::from_bits(m_pin.channel()));
w.set_opaintoen(false);
w.set_opampen(true);
});
OpAmpOutput { _inner: self }
}
/// Configure the OpAmp in standalone mode with the non-inverting input
/// connected to the provided `p_pin`, the inverting input connected to
/// the `m_pin`, and output is connected to the DAC.
///
/// The input pins are configured for analogue mode but not consumed,
/// allowing their subsequent use for ADC or comparator inputs.
///
/// The returned `OpAmpOutput` struct may be used as an ADC
/// input. The opamp output will be disabled when it is dropped.
#[cfg(opamp_v5)]
pub fn standalone_int(
&mut self,
p_pin: Peri<'d, impl NonInvertingPin<T> + crate::gpio::Pin>,
m_pin: Peri<'d, impl InvertingPin<T> + crate::gpio::Pin>,
) -> OpAmpOutput<'_, T> {
p_pin.set_as_analog();
m_pin.set_as_analog();
T::regs().csr().modify(|w| {
use crate::pac::opamp::vals::*;
w.set_vp_sel(VpSel::from_bits(p_pin.channel()));
w.set_vm_sel(VmSel::from_bits(m_pin.channel()));
w.set_opaintoen(true);
w.set_opampen(true);
});
OpAmpOutput { _inner: self }
}
/// Calibrates the operational amplifier.
///
/// This function enables the opamp and sets the user trim mode for calibration.
/// Depending on the speed mode of the opamp, it calibrates the differential pair inputs.
/// For normal speed, both the P and N differential pairs are calibrated,
/// while for high-speed mode, only the P differential pair is calibrated.
///
/// Calibrating a differential pair requires waiting 12ms in the worst case (binary method).
#[cfg(opamp_v5)]
pub fn calibrate(&mut self) {
T::regs().csr().modify(|w| {
w.set_opampen(true);
w.set_calon(true);
w.set_usertrim(true);
});
if T::regs().csr().read().opahsm() {
self.calibrate_differential_pair(OpAmpDifferentialPair::P);
} else {
self.calibrate_differential_pair(OpAmpDifferentialPair::P);
self.calibrate_differential_pair(OpAmpDifferentialPair::N);
}
T::regs().csr().modify(|w| {
w.set_calon(false);
w.set_opampen(false);
});
}
/// Calibrate differential pair.
///
/// The calibration is done by trying different offset values and
/// measuring the outcal bit.
///
/// The calibration range is from 0 to 31.
///
/// The result is stored in the OPAMP_CSR register.
#[cfg(opamp_v5)]
fn calibrate_differential_pair(&mut self, pair: OpAmpDifferentialPair) {
let mut low = 0;
let mut high = 31;
let calsel = match pair {
OpAmpDifferentialPair::P => Calsel::PERCENT10,
OpAmpDifferentialPair::N => Calsel::PERCENT90,
};
T::regs().csr().modify(|w| {
w.set_calsel(calsel);
});
while low <= high {
let mid = (low + high) / 2;
T::regs().csr().modify(|w| match pair {
OpAmpDifferentialPair::P => {
#[cfg(feature = "defmt")]
defmt::debug!("opamp p calibration. offset: {}", mid);
w.set_trimoffsetp(mid);
}
OpAmpDifferentialPair::N => {
#[cfg(feature = "defmt")]
defmt::debug!("opamp n calibration. offset: {}", mid);
w.set_trimoffsetn(mid);
}
});
// The closer the trimming value is to the optimum trimming value, the longer it takes to stabilize
// (with a maximum stabilization time remaining below 2 ms in any case) -- RM0440 25.3.7
block_for_us(2_000);
if !T::regs().csr().read().calout() {
if mid == 0 {
break;
}
high = mid - 1;
} else {
if mid == 31 {
break;
}
low = mid + 1;
}
}
}
}
#[cfg(not(any(stm32g4, stm32f3)))]
impl<'d, T: Instance> Drop for OpAmp<'d, T> {
fn drop(&mut self) {
T::info().rcc.disable();
}
}
impl<'d, T: Instance> Drop for OpAmpOutput<'d, T> {
fn drop(&mut self) {
T::regs().csr().modify(|w| {
w.set_opampen(false);
});
}
}
#[cfg(opamp_v5)]
impl<'d, T: Instance> Drop for OpAmpInternalOutput<'d, T> {
fn drop(&mut self) {
T::regs().csr().modify(|w| {
w.set_opampen(false);
});
}
}
#[cfg(not(any(stm32g4, stm32f3)))]
pub(crate) struct Info {
rcc: RccInfo,
}
pub(crate) trait SealedInstance {
#[cfg(not(any(stm32g4, stm32f3)))]
fn info() -> &'static Info;
fn regs() -> crate::pac::opamp::Opamp;
}
pub(crate) trait SealedNonInvertingPin<T: Instance> {
fn channel(&self) -> u8;
}
pub(crate) trait SealedInvertingPin<T: Instance> {
#[allow(unused)]
fn channel(&self) -> u8;
}
pub(crate) trait SealedOutputPin<T: Instance> {}
/// Opamp instance trait.
#[allow(private_bounds)]
pub trait Instance: SealedInstance + PeripheralType + 'static {}
/// Non-inverting pin trait.
#[allow(private_bounds)]
pub trait NonInvertingPin<T: Instance>: SealedNonInvertingPin<T> {}
/// Inverting pin trait.
#[allow(private_bounds)]
pub trait InvertingPin<T: Instance>: SealedInvertingPin<T> {}
/// Output pin trait.
#[allow(private_bounds)]
pub trait OutputPin<T: Instance>: SealedOutputPin<T> {}
macro_rules! impl_opamp_external_output {
($inst:ident, $adc:ident, $ch:expr) => {
foreach_adc!(
($adc, $common_inst:ident, $adc_clock:ident) => {
impl<'d> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
for OpAmpOutput<'d, crate::peripherals::$inst>
{
fn channel(&self) -> u8 {
$ch
}
}
impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc>
for OpAmpOutput<'d, crate::peripherals::$inst>
{
}
};
);
};
}
foreach_peripheral!(
(opamp, OPAMP1) => {
impl_opamp_external_output!(OPAMP1, ADC1, 3);
};
(opamp, OPAMP2) => {
impl_opamp_external_output!(OPAMP2, ADC2, 3);
};
(opamp, OPAMP3) => {
impl_opamp_external_output!(OPAMP3, ADC1, 12);
impl_opamp_external_output!(OPAMP3, ADC3, 1);
};
// OPAMP4 only in STM32G4 Cat 3 devices
(opamp, OPAMP4) => {
impl_opamp_external_output!(OPAMP4, ADC1, 11);
impl_opamp_external_output!(OPAMP4, ADC4, 3);
};
// OPAMP5 only in STM32G4 Cat 3 devices
(opamp, OPAMP5) => {
impl_opamp_external_output!(OPAMP5, ADC5, 1);
};
// OPAMP6 only in STM32G4 Cat 3/4 devices
(opamp, OPAMP6) => {
impl_opamp_external_output!(OPAMP6, ADC1, 14);
impl_opamp_external_output!(OPAMP6, ADC2, 14);
};
);
#[cfg(opamp_v5)]
macro_rules! impl_opamp_internal_output {
($inst:ident, $adc:ident, $ch:expr) => {
foreach_adc!(
($adc, $common_inst:ident, $adc_clock:ident) => {
impl<'d> crate::adc::SealedAdcChannel<crate::peripherals::$adc>
for OpAmpInternalOutput<'d, crate::peripherals::$inst>
{
fn channel(&self) -> u8 {
$ch
}
}
impl<'d> crate::adc::AdcChannel<crate::peripherals::$adc>
for OpAmpInternalOutput<'d, crate::peripherals::$inst>
{
}
};
);
};
}
#[cfg(opamp_v5)]
foreach_peripheral!(
(opamp, OPAMP1) => {
impl_opamp_internal_output!(OPAMP1, ADC1, 13);
};
(opamp, OPAMP2) => {
impl_opamp_internal_output!(OPAMP2, ADC2, 16);
};
(opamp, OPAMP3) => {
impl_opamp_internal_output!(OPAMP3, ADC2, 18);
// Only in Cat 3/4 devices
impl_opamp_internal_output!(OPAMP3, ADC3, 13);
};
// OPAMP4 only in Cat 3 devices
(opamp, OPAMP4) => {
impl_opamp_internal_output!(OPAMP4, ADC5, 5);
};
// OPAMP5 only in Cat 3 devices
(opamp, OPAMP5) => {
impl_opamp_internal_output!(OPAMP5, ADC5, 3);
};
// OPAMP6 only in Cat 3/4 devices
(opamp, OPAMP6) => {
// Only in Cat 3 devices
impl_opamp_internal_output!(OPAMP6, ADC4, 17);
// Only in Cat 4 devices
impl_opamp_internal_output!(OPAMP6, ADC3, 17);
};
);
foreach_peripheral! {
(opamp, $inst:ident) => {
impl SealedInstance for crate::peripherals::$inst {
// G4 and F3 use SYSCFGEN, which is always enabled
#[cfg(not(any(stm32g4, stm32f3)))]
fn info() -> &'static Info {
use crate::rcc::SealedRccPeripheral;
static INFO: Info = Info {
rcc: crate::peripherals::$inst::RCC_INFO,
};
&INFO
}
fn regs() -> crate::pac::opamp::Opamp {
crate::pac::$inst
}
}
impl Instance for crate::peripherals::$inst {
}
};
}
#[allow(unused_macros)]
macro_rules! impl_opamp_vp_pin {
($inst:ident, $pin:ident, $ch:expr) => {
impl crate::opamp::NonInvertingPin<peripherals::$inst> for crate::peripherals::$pin {}
impl crate::opamp::SealedNonInvertingPin<peripherals::$inst> for crate::peripherals::$pin {
fn channel(&self) -> u8 {
$ch
}
}
};
}
#[allow(unused_macros)]
macro_rules! impl_opamp_vn_pin {
($inst:ident, $pin:ident, $ch:expr) => {
impl crate::opamp::InvertingPin<peripherals::$inst> for crate::peripherals::$pin {}
impl crate::opamp::SealedInvertingPin<peripherals::$inst> for crate::peripherals::$pin {
fn channel(&self) -> u8 {
$ch
}
}
};
}
#[allow(unused_macros)]
macro_rules! impl_opamp_vout_pin {
($inst:ident, $pin:ident) => {
impl crate::opamp::OutputPin<peripherals::$inst> for crate::peripherals::$pin {}
impl crate::opamp::SealedOutputPin<peripherals::$inst> for crate::peripherals::$pin {}
};
}
|