diff options
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 26 | ||||
| -rw-r--r-- | examples/src/bin/gpiote.rs | 8 |
2 files changed, 17 insertions, 17 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index c18db2626..ffea98f2e 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -20,7 +20,7 @@ pub struct Gpiote { | |||
| 20 | 20 | ||
| 21 | static mut INSTANCE: *const Gpiote = ptr::null_mut(); | 21 | static mut INSTANCE: *const Gpiote = ptr::null_mut(); |
| 22 | 22 | ||
| 23 | pub enum EventPolarity { | 23 | pub enum InputChannelPolarity { |
| 24 | None, | 24 | None, |
| 25 | HiToLo, | 25 | HiToLo, |
| 26 | LoToHi, | 26 | LoToHi, |
| @@ -28,7 +28,7 @@ pub enum EventPolarity { | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /// Polarity of the `task out` operation. | 30 | /// Polarity of the `task out` operation. |
| 31 | pub enum TaskOutPolarity { | 31 | pub enum OutputChannelPolarity { |
| 32 | Set, | 32 | Set, |
| 33 | Clear, | 33 | Clear, |
| 34 | Toggle, | 34 | Toggle, |
| @@ -87,7 +87,7 @@ impl Gpiote { | |||
| 87 | pub fn new_input_channel<'a, T>( | 87 | pub fn new_input_channel<'a, T>( |
| 88 | &'a self, | 88 | &'a self, |
| 89 | pin: Pin<Input<T>>, | 89 | pin: Pin<Input<T>>, |
| 90 | trigger_mode: EventPolarity, | 90 | polarity: InputChannelPolarity, |
| 91 | ) -> Result<InputChannel<'a, T>, NewChannelError> { | 91 | ) -> Result<InputChannel<'a, T>, NewChannelError> { |
| 92 | interrupt::free(|_| { | 92 | interrupt::free(|_| { |
| 93 | unsafe { INSTANCE = self }; | 93 | unsafe { INSTANCE = self }; |
| @@ -95,11 +95,11 @@ impl Gpiote { | |||
| 95 | trace!("allocated in ch {:u8}", index as u8); | 95 | trace!("allocated in ch {:u8}", index as u8); |
| 96 | 96 | ||
| 97 | self.inner.config[index as usize].write(|w| { | 97 | self.inner.config[index as usize].write(|w| { |
| 98 | match trigger_mode { | 98 | match polarity { |
| 99 | EventPolarity::HiToLo => w.mode().event().polarity().hi_to_lo(), | 99 | InputChannelPolarity::HiToLo => w.mode().event().polarity().hi_to_lo(), |
| 100 | EventPolarity::LoToHi => w.mode().event().polarity().lo_to_hi(), | 100 | InputChannelPolarity::LoToHi => w.mode().event().polarity().lo_to_hi(), |
| 101 | EventPolarity::None => w.mode().event().polarity().none(), | 101 | InputChannelPolarity::None => w.mode().event().polarity().none(), |
| 102 | EventPolarity::Toggle => w.mode().event().polarity().toggle(), | 102 | InputChannelPolarity::Toggle => w.mode().event().polarity().toggle(), |
| 103 | }; | 103 | }; |
| 104 | #[cfg(any(feature = "52833", feature = "52840"))] | 104 | #[cfg(any(feature = "52833", feature = "52840"))] |
| 105 | w.port().bit(match pin.port() { | 105 | w.port().bit(match pin.port() { |
| @@ -124,7 +124,7 @@ impl Gpiote { | |||
| 124 | &'a self, | 124 | &'a self, |
| 125 | pin: Pin<Output<T>>, | 125 | pin: Pin<Output<T>>, |
| 126 | level: Level, | 126 | level: Level, |
| 127 | task_out_polarity: TaskOutPolarity, | 127 | polarity: OutputChannelPolarity, |
| 128 | ) -> Result<OutputChannel<'a>, NewChannelError> { | 128 | ) -> Result<OutputChannel<'a>, NewChannelError> { |
| 129 | interrupt::free(|_| { | 129 | interrupt::free(|_| { |
| 130 | unsafe { INSTANCE = self }; | 130 | unsafe { INSTANCE = self }; |
| @@ -137,10 +137,10 @@ impl Gpiote { | |||
| 137 | Level::High => w.outinit().high(), | 137 | Level::High => w.outinit().high(), |
| 138 | Level::Low => w.outinit().low(), | 138 | Level::Low => w.outinit().low(), |
| 139 | }; | 139 | }; |
| 140 | match task_out_polarity { | 140 | match polarity { |
| 141 | TaskOutPolarity::Set => w.polarity().lo_to_hi(), | 141 | OutputChannelPolarity::Set => w.polarity().lo_to_hi(), |
| 142 | TaskOutPolarity::Clear => w.polarity().hi_to_lo(), | 142 | OutputChannelPolarity::Clear => w.polarity().hi_to_lo(), |
| 143 | TaskOutPolarity::Toggle => w.polarity().toggle(), | 143 | OutputChannelPolarity::Toggle => w.polarity().toggle(), |
| 144 | }; | 144 | }; |
| 145 | #[cfg(any(feature = "52833", feature = "52840"))] | 145 | #[cfg(any(feature = "52833", feature = "52840"))] |
| 146 | w.port().bit(match pin.port() { | 146 | w.port().bit(match pin.port() { |
diff --git a/examples/src/bin/gpiote.rs b/examples/src/bin/gpiote.rs index d8394155d..edc3f5ef1 100644 --- a/examples/src/bin/gpiote.rs +++ b/examples/src/bin/gpiote.rs | |||
| @@ -24,7 +24,7 @@ async fn run() { | |||
| 24 | 24 | ||
| 25 | let pin1 = port0.p0_11.into_pullup_input().degrade(); | 25 | let pin1 = port0.p0_11.into_pullup_input().degrade(); |
| 26 | let button1 = async { | 26 | let button1 = async { |
| 27 | let ch = unwrap!(g.new_input_channel(pin1, gpiote::EventPolarity::HiToLo)); | 27 | let ch = unwrap!(g.new_input_channel(pin1, gpiote::InputChannelPolarity::HiToLo)); |
| 28 | 28 | ||
| 29 | loop { | 29 | loop { |
| 30 | ch.wait().await; | 30 | ch.wait().await; |
| @@ -34,7 +34,7 @@ async fn run() { | |||
| 34 | 34 | ||
| 35 | let pin2 = port0.p0_12.into_pullup_input().degrade(); | 35 | let pin2 = port0.p0_12.into_pullup_input().degrade(); |
| 36 | let button2 = async { | 36 | let button2 = async { |
| 37 | let ch = unwrap!(g.new_input_channel(pin2, gpiote::EventPolarity::LoToHi)); | 37 | let ch = unwrap!(g.new_input_channel(pin2, gpiote::InputChannelPolarity::LoToHi)); |
| 38 | 38 | ||
| 39 | loop { | 39 | loop { |
| 40 | ch.wait().await; | 40 | ch.wait().await; |
| @@ -44,7 +44,7 @@ async fn run() { | |||
| 44 | 44 | ||
| 45 | let pin3 = port0.p0_24.into_pullup_input().degrade(); | 45 | let pin3 = port0.p0_24.into_pullup_input().degrade(); |
| 46 | let button3 = async { | 46 | let button3 = async { |
| 47 | let ch = unwrap!(g.new_input_channel(pin3, gpiote::EventPolarity::Toggle)); | 47 | let ch = unwrap!(g.new_input_channel(pin3, gpiote::InputChannelPolarity::Toggle)); |
| 48 | 48 | ||
| 49 | loop { | 49 | loop { |
| 50 | ch.wait().await; | 50 | ch.wait().await; |
| @@ -54,7 +54,7 @@ async fn run() { | |||
| 54 | 54 | ||
| 55 | let pin4 = port0.p0_25.into_pullup_input().degrade(); | 55 | let pin4 = port0.p0_25.into_pullup_input().degrade(); |
| 56 | let button4 = async { | 56 | let button4 = async { |
| 57 | let ch = unwrap!(g.new_input_channel(pin4, gpiote::EventPolarity::Toggle)); | 57 | let ch = unwrap!(g.new_input_channel(pin4, gpiote::InputChannelPolarity::Toggle)); |
| 58 | 58 | ||
| 59 | loop { | 59 | loop { |
| 60 | ch.wait().await; | 60 | ch.wait().await; |
