feat: allow schmitt, slew, and drive strength be set from Flex, Input, Output
Allows the schmitt, slew and drive strength to be set from Flex. Input and Output[OpenDrain] also expose the appropriate setters.
This commit is contained in:
parent
a1036e111e
commit
f98c8886b2
2 changed files with 41 additions and 0 deletions
|
@ -97,6 +97,12 @@ impl<'d, T: Pin> Input<'d, T> {
|
||||||
Self { pin }
|
Self { pin }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the pin's Schmitt trigger.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_schmitt(&mut self, enable: bool) {
|
||||||
|
self.pin.set_schmitt(enable)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_high(&self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
self.pin.is_high()
|
self.pin.is_high()
|
||||||
|
@ -326,6 +332,18 @@ impl<'d, T: Pin> Output<'d, T> {
|
||||||
Self { pin }
|
Self { pin }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the pin's drive strength.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_drive_strength(&mut self, strength: Drive) {
|
||||||
|
self.pin.set_drive_strength(strength)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the pin's slew rate.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_slew_rate(&mut self, slew_rate: SlewRate) {
|
||||||
|
self.pin.set_slew_rate(slew_rate)
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the output as high.
|
/// Set the output as high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_high(&mut self) {
|
pub fn set_high(&mut self) {
|
||||||
|
@ -386,6 +404,18 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
||||||
Self { pin }
|
Self { pin }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the pin's drive strength.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_drive_strength(&mut self, strength: Drive) {
|
||||||
|
self.pin.set_drive_strength(strength)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the pin's slew rate.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_slew_rate(&mut self, slew_rate: SlewRate) {
|
||||||
|
self.pin.set_slew_rate(slew_rate)
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the output as high.
|
/// Set the output as high.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_high(&mut self) {
|
pub fn set_high(&mut self) {
|
||||||
|
@ -541,6 +571,14 @@ impl<'d, T: Pin> Flex<'d, T> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the pin's Schmitt trigger.
|
||||||
|
#[inline]
|
||||||
|
pub fn set_schmitt(&mut self, enable: bool) {
|
||||||
|
self.pin.pad_ctrl().modify(|w| {
|
||||||
|
w.set_schmitt(enable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Put the pin into input mode.
|
/// Put the pin into input mode.
|
||||||
///
|
///
|
||||||
/// The pull setting is left unchanged.
|
/// The pull setting is left unchanged.
|
||||||
|
|
|
@ -78,6 +78,9 @@ async fn main(_spawner: Spawner) {
|
||||||
// Set up the signal pin that will be used to trigger the keyboard.
|
// Set up the signal pin that will be used to trigger the keyboard.
|
||||||
let mut signal_pin = Input::new(p.PIN_16, Pull::None);
|
let mut signal_pin = Input::new(p.PIN_16, Pull::None);
|
||||||
|
|
||||||
|
// Enable the schmitt trigger to slightly debounce.
|
||||||
|
signal_pin.set_schmitt(true);
|
||||||
|
|
||||||
let (reader, mut writer) = hid.split();
|
let (reader, mut writer) = hid.split();
|
||||||
|
|
||||||
// Do stuff with the class!
|
// Do stuff with the class!
|
||||||
|
|
Loading…
Reference in a new issue