Skip to content

Commit

Permalink
Set direction before changing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
golemparts committed Oct 12, 2023
1 parent 0ce2eba commit d0d352b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/gpio/gpiomem/rp1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,16 @@ impl GpioRegisters for GpioMem {
Mode::Alt8 => FSEL_ALT8,
};

// Set the actual direction here, since this isn't set in the FSEL register.
if mode == Mode::Input || mode == Mode::Output {
self.set_direction(pin, mode);
}

reg_value = (reg_value & !CTRL_OUTOVER_MASK) | (OUTOVER_PERI << CTRL_OUTOVER_LSB);
reg_value = (reg_value & !CTRL_OEOVER_MASK) | (OEOVER_PERI << CTRL_OEOVER_LSB);
reg_value = (reg_value & !CTRL_FUNCSEL_MASK) | ((fsel_mode as u32) << CTRL_FUNCSEL_LSB);

self.write(offset, reg_value);

// Set the actual direction here, since this isn't set in the FSEL register.
if mode == Mode::Input || mode == Mode::Output {
self.set_direction(pin, mode);
}
}

fn set_bias(&self, pin: u8, bias: Bias) {
Expand Down

0 comments on commit d0d352b

Please sign in to comment.