mct8316a eeprom programming

This commit is contained in:
2025-10-19 15:57:57 -07:00
parent d552fe3627
commit 086ac7f195
19 changed files with 1106 additions and 203 deletions

View File

@@ -1,20 +1,21 @@
use std::fmt::{Display, Formatter};
use std::time::Duration;
use embedded_hal::pwm::{ErrorKind, ErrorType, SetDutyCycle};
use log::trace;
use rpi_pal::pwm::Pwm;
use std::fmt::{Display, Formatter};
use std::time::Duration;
const PWM_PERIOD: Duration = Duration::from_micros(1000); // 1kHz
pub struct PwmWrapper {
pwm: Pwm
pwm: Pwm,
}
impl PwmWrapper {
pub fn new(pwm: Pwm) -> anyhow::Result<Self> {
pub fn new(mut pwm: Pwm) -> anyhow::Result<Self> {
trace!("PwmWrapper::new(pwm: {pwm:?})");
pwm.set_period(PWM_PERIOD)?;
pwm.enable()?;
pwm.set_reset_on_drop(true);
Ok(Self {
pwm
})