From 99c2defa76012e28d1249c206ebe11718aeba3b7 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 19 May 2022 06:07:14 +0200 Subject: [PATCH] squash! Impl ToggleableOutputPin for embassy-rp Output Use value_xor as suggested in pull request feedback. --- embassy-rp/src/gpio.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 596dd64c..aa3c3a64 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -135,10 +135,9 @@ impl<'d, T: Pin> Output<'d, T> { /// Toggle pin output #[inline] pub fn toggle(&mut self) { - if self.is_set_low() { - self.set_high() - } else { - self.set_low() + let val = 1 << self.pin.pin(); + unsafe { + self.pin.sio_out().value_xor().write_value(val); } } }