gpiote: take borrow instead of owned pin.

This makes it possible to read the pin while the channel is created.
This commit is contained in:
Dario Nieuwenhuis 2020-09-29 04:17:32 +02:00
parent 32a9b3f4ae
commit c81d626254
2 changed files with 8 additions and 8 deletions

View File

@ -51,11 +51,11 @@ impl Gpiote {
}
}
pub fn new_input_channel<T>(
&self,
pin: GpioPin<Input<T>>,
pub fn new_input_channel<'a, T>(
&'a self,
pin: &'a GpioPin<Input<T>>,
trigger_mode: EventPolarity,
) -> Result<Channel<'_>, NewChannelError> {
) -> Result<Channel<'a>, NewChannelError> {
interrupt::free(|_| {
unsafe { INSTANCE = self };

View File

@ -28,7 +28,7 @@ async fn run() {
let pin1 = port0.p0_11.into_pullup_input().degrade();
let button1 = async {
let ch = g
.new_input_channel(pin1, gpiote::EventPolarity::HiToLo)
.new_input_channel(&pin1, gpiote::EventPolarity::HiToLo)
.dewrap();
loop {
@ -40,7 +40,7 @@ async fn run() {
let pin2 = port0.p0_12.into_pullup_input().degrade();
let button2 = async {
let ch = g
.new_input_channel(pin2, gpiote::EventPolarity::LoToHi)
.new_input_channel(&pin2, gpiote::EventPolarity::LoToHi)
.dewrap();
loop {
@ -52,7 +52,7 @@ async fn run() {
let pin3 = port0.p0_24.into_pullup_input().degrade();
let button3 = async {
let ch = g
.new_input_channel(pin3, gpiote::EventPolarity::Toggle)
.new_input_channel(&pin3, gpiote::EventPolarity::Toggle)
.dewrap();
loop {
@ -64,7 +64,7 @@ async fn run() {
let pin4 = port0.p0_25.into_pullup_input().degrade();
let button4 = async {
let ch = g
.new_input_channel(pin4, gpiote::EventPolarity::Toggle)
.new_input_channel(&pin4, gpiote::EventPolarity::Toggle)
.dewrap();
loop {