avr_tester/pins/
analog_pin.rs1use crate::*;
2
3pub struct AnalogPin<'a> {
5 avr: &'a mut AvrTester,
6 pin: u32,
7}
8
9impl<'a> AnalogPin<'a> {
10 pub(crate) fn new(avr: &'a mut AvrTester, pin: u32) -> Self {
11 Self { avr, pin }
12 }
13
14 pub fn set_mv(&mut self, voltage: u32) {
16 self.avr.sim().set_analog_pin(self.pin as _, voltage);
17 }
18}
19
20pub struct AnalogPinAsync {
24 pin: u32,
25}
26
27impl AnalogPinAsync {
28 pub(crate) fn new(pin: u32) -> Self {
29 Self { pin }
30 }
31
32 pub fn set_mv(&self, voltage: u32) {
34 ComponentRuntime::with(|rt| {
35 rt.sim().set_analog_pin(self.pin as _, voltage);
36 });
37 }
38}