tangled
alpha
login
or
join now
sachy.dev
/
strike-sensor
0
fork
atom
Repo for designs & driver for a TA7642 powered lightning detector
0
fork
atom
overview
issues
pulls
pipelines
use Duty Cycle API for PwmDriver
sachy.dev
1 month ago
7d7f5cc4
c39b6dde
1/1
test.yml
success
16s
+4
-4
1 changed file
expand all
collapse all
unified
split
embassy-strike-driver
src
drivers.rs
+4
-4
embassy-strike-driver/src/drivers.rs
···
6
6
dma,
7
7
interrupt::typelevel::{ADC_IRQ_FIFO, Binding},
8
8
peripherals::ADC,
9
9
-
pwm::{self, ChannelBPin, Pwm, Slice},
9
9
+
pwm::{self, ChannelBPin, Pwm, SetDutyCycle, Slice},
10
10
};
11
11
use embassy_sync::{blocking_mutex::raw::RawMutex, mutex::Mutex};
12
12
···
92
92
config.compare_b = 0;
93
93
let pwm = Pwm::new_output_b(slice, b, config.clone());
94
94
95
95
-
96
95
Self { pwm, config }
97
96
}
98
97
}
99
98
100
99
impl PwmSource for PwmDriver<'_> {
101
100
fn set_duty(&mut self, duty: u16) {
102
102
-
self.config.compare_b = duty.clamp(0, self.config.top);
103
103
-
self.pwm.set_config(&self.config);
101
101
+
let duty = duty.clamp(0, self.pwm.max_duty_cycle());
102
102
+
103
103
+
self.pwm.set_duty_cycle(duty).ok();
104
104
}
105
105
106
106
fn enable(&mut self) {