Skip to content

Commit

Permalink
fix: gpio mutability of Pin
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Dec 23, 2023
1 parent c4ddb2d commit 18c38bf
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions esp-hal-common/src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,10 @@ impl<MODE, const GPIONUM: u8> embedded_hal_1::digital::InputPin for GpioPin<Inpu
where
Self: GpioProperties,
{
fn is_high(&self) -> Result<bool, Self::Error> {
fn is_high(&mut self) -> Result<bool, Self::Error> {
Ok(<Self as GpioProperties>::Bank::read_input() & (1 << (GPIONUM % 32)) != 0)
}
fn is_low(&self) -> Result<bool, Self::Error> {
fn is_low(&mut self) -> Result<bool, Self::Error> {
Ok(!self.is_high()?)
}
}
Expand All @@ -583,10 +583,10 @@ where
Self: GpioProperties,
<Self as GpioProperties>::PinType: IsOutputPin,
{
fn is_high(&self) -> Result<bool, Self::Error> {
fn is_high(&mut self) -> Result<bool, Self::Error> {
Ok(<Self as GpioProperties>::Bank::read_input() & (1 << (GPIONUM % 32)) != 0)
}
fn is_low(&self) -> Result<bool, Self::Error> {
fn is_low(&mut self) -> Result<bool, Self::Error> {
Ok(!self.is_high()?)
}
}
Expand Down Expand Up @@ -918,10 +918,10 @@ where
Self: GpioProperties,
<Self as GpioProperties>::PinType: IsOutputPin,
{
fn is_set_high(&self) -> Result<bool, Self::Error> {
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
Ok(<Self as GpioProperties>::Bank::read_output() & (1 << (GPIONUM % 32)) != 0)
}
fn is_set_low(&self) -> Result<bool, Self::Error> {
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
Ok(!self.is_set_high()?)
}
}
Expand Down Expand Up @@ -1376,12 +1376,12 @@ impl<MODE> embedded_hal_1::digital::ErrorType for AnyPin<Input<MODE>> {

#[cfg(feature = "eh1")]
impl<MODE> embedded_hal_1::digital::InputPin for AnyPin<Input<MODE>> {
fn is_high(&self) -> Result<bool, Self::Error> {
fn is_high(&mut self) -> Result<bool, Self::Error> {
let inner = &self.inner;
handle_gpio_input!(inner, target, { target.is_high() })
}

fn is_low(&self) -> Result<bool, Self::Error> {
fn is_low(&mut self) -> Result<bool, Self::Error> {
let inner = &self.inner;
handle_gpio_input!(inner, target, { target.is_low() })
}
Expand Down Expand Up @@ -1442,12 +1442,12 @@ impl<MODE> embedded_hal_1::digital::OutputPin for AnyPin<Output<MODE>> {

#[cfg(feature = "eh1")]
impl<MODE> embedded_hal_1::digital::StatefulOutputPin for AnyPin<Output<MODE>> {
fn is_set_high(&self) -> Result<bool, Self::Error> {
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
let inner = &self.inner;
handle_gpio_output!(inner, target, { target.is_set_high() })
}

fn is_set_low(&self) -> Result<bool, Self::Error> {
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
let inner = &self.inner;
handle_gpio_output!(inner, target, { target.is_set_low() })
}
Expand Down

0 comments on commit 18c38bf

Please sign in to comment.