diff options
| author | Ardelean Călin Petru <[email protected]> | 2022-11-22 16:56:04 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-22 16:56:04 +0200 |
| commit | a074cd0625d68e72694c6575063ae53a840d12dc (patch) | |
| tree | 82572a80786e62d6f8509dee171b7bb590b1bcea | |
| parent | ca4f615b25d2e135f3f8d6caf99fceaab1e01c24 (diff) | |
Update gpiote.rs
Adding these changes enables us to define a channel using a mutable reference to `GPIOTE_CH(n)`, similar to how we can do with other drivers.
So instead of using:
```rust
let freq_in = InputChannel::new(
p.GPIOTE_CH0,
Input::new(&mut p.P0_19, embassy_nrf::gpio::Pull::Up),
embassy_nrf::gpiote::InputChannelPolarity::HiToLo,
);
```
we can use:
```rust
let freq_in = InputChannel::new(
&mut p.GPIOTE_CH0,
Input::new(&mut p.P0_19, embassy_nrf::gpio::Pull::Up),
embassy_nrf::gpiote::InputChannelPolarity::HiToLo,
);
```
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 25ad90496..4f11f33ef 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -419,6 +419,12 @@ macro_rules! impl_channel { | |||
| 419 | $number as usize | 419 | $number as usize |
| 420 | } | 420 | } |
| 421 | } | 421 | } |
| 422 | impl sealed::Channel for &mut peripherals::$type {} | ||
| 423 | impl Channel for &mut peripherals::$type { | ||
| 424 | fn number(&self) -> usize { | ||
| 425 | $number as usize | ||
| 426 | } | ||
| 427 | } | ||
| 422 | }; | 428 | }; |
| 423 | } | 429 | } |
| 424 | 430 | ||
