rktk_drivers_rp/keyscan/
flex_pin.rs1use embassy_rp::{
2 gpio::{Flex, Pin},
3 Peripheral,
4};
5use rktk_drivers_common::keyscan::flex_pin::{FlexPin, Pull};
6
7pub struct RpFlexPin<'a>(Flex<'a>);
9
10impl<'a> RpFlexPin<'a> {
11 pub fn new(pin: impl Peripheral<P = impl Pin> + 'a) -> Self {
12 Self(Flex::new(pin))
13 }
14}
15
16impl FlexPin for RpFlexPin<'_> {
17 fn set_as_input(&mut self) {
18 self.0.set_as_input();
19 }
20
21 fn set_as_output(&mut self) {
22 self.0.set_as_output();
23 }
24
25 fn set_low(&mut self) {
26 self.0.set_low();
27 }
28
29 fn set_high(&mut self) {
30 self.0.set_high();
31 }
32
33 fn is_high(&self) -> bool {
34 self.0.is_high()
35 }
36
37 fn is_low(&self) -> bool {
38 self.0.is_low()
39 }
40
41 async fn wait_for_high(&mut self) {
42 self.0.wait_for_high().await;
43 }
44
45 async fn wait_for_low(&mut self) {
46 self.0.wait_for_low().await;
47 }
48
49 fn set_pull(&mut self, pull: Pull) {
50 self.0.set_pull(match pull {
51 Pull::Up => embassy_rp::gpio::Pull::Up,
52 Pull::Down => embassy_rp::gpio::Pull::Down,
53 });
54 }
55}