Skip to content

Commit

Permalink
update gpio
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Domnikov committed Nov 25, 2023
1 parent acc2c5b commit 03864bf
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ impl Gpio {
pub fn try_new() -> Result<Gpio, io::Error> {
Self::set_pin_mode_out(platform::PIN_PICO_RUN, true)?;
Self::set_pin_mode_out(platform::PIN_PICO_BOOT, true)?;
Self::set_pin_mode_out(platform::PIN_AUX_EN, false)?;
Self::set_pin_mode_out(platform::PIN_VDD_EN, false)?;
Self::set_pin_mode_out(platform::PIN_USB_EN, false)?;
Self::set_pin_mode_in(platform::PIN_AUX_OCP)?;
Self::set_pin_mode_in(platform::PIN_VDD_OCP)?;
Self::set_pin_mode_in(platform::PIN_USB_OCP)?;
Self::set_pin_mode_out(platform::PIN_VDD_EN, false)?;
if platform::AUX_SWITCH {
Self::set_pin_mode_out(platform::PIN_AUX_EN, false)?;
}
if platform::OCP_REPORTING {
Self::set_pin_mode_in(platform::PIN_AUX_OCP)?;
Self::set_pin_mode_in(platform::PIN_VDD_OCP)?;
Self::set_pin_mode_in(platform::PIN_USB_OCP)?;
}
Ok(Self {})
}

Expand All @@ -32,9 +36,12 @@ impl Gpio {

pub fn set_power_enabled(&mut self, line: PowerLine, enabled: bool) -> Result<(), io::Error> {
match line {
PowerLine::Aux => Self::set_pin_state(platform::PIN_AUX_EN, !enabled),
PowerLine::Vdd => Self::set_pin_state(platform::PIN_VDD_EN, !enabled),
PowerLine::Usb => Self::set_pin_state(platform::PIN_USB_EN, !enabled),
PowerLine::Aux if platform::AUX_SWITCH => {
Self::set_pin_state(platform::PIN_AUX_EN, !enabled)
}
_ => Ok(()),
}
}

Expand Down

0 comments on commit 03864bf

Please sign in to comment.