mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 14:53:03 +00:00
gpiote: better naming
This commit is contained in:
parent
b40e09d502
commit
def225b982
@ -20,7 +20,7 @@ pub struct Gpiote {
|
|||||||
|
|
||||||
static mut INSTANCE: *const Gpiote = ptr::null_mut();
|
static mut INSTANCE: *const Gpiote = ptr::null_mut();
|
||||||
|
|
||||||
pub enum EventPolarity {
|
pub enum InputChannelPolarity {
|
||||||
None,
|
None,
|
||||||
HiToLo,
|
HiToLo,
|
||||||
LoToHi,
|
LoToHi,
|
||||||
@ -28,7 +28,7 @@ pub enum EventPolarity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Polarity of the `task out` operation.
|
/// Polarity of the `task out` operation.
|
||||||
pub enum TaskOutPolarity {
|
pub enum OutputChannelPolarity {
|
||||||
Set,
|
Set,
|
||||||
Clear,
|
Clear,
|
||||||
Toggle,
|
Toggle,
|
||||||
@ -87,7 +87,7 @@ impl Gpiote {
|
|||||||
pub fn new_input_channel<'a, T>(
|
pub fn new_input_channel<'a, T>(
|
||||||
&'a self,
|
&'a self,
|
||||||
pin: Pin<Input<T>>,
|
pin: Pin<Input<T>>,
|
||||||
trigger_mode: EventPolarity,
|
polarity: InputChannelPolarity,
|
||||||
) -> Result<InputChannel<'a, T>, NewChannelError> {
|
) -> Result<InputChannel<'a, T>, NewChannelError> {
|
||||||
interrupt::free(|_| {
|
interrupt::free(|_| {
|
||||||
unsafe { INSTANCE = self };
|
unsafe { INSTANCE = self };
|
||||||
@ -95,11 +95,11 @@ impl Gpiote {
|
|||||||
trace!("allocated in ch {:u8}", index as u8);
|
trace!("allocated in ch {:u8}", index as u8);
|
||||||
|
|
||||||
self.inner.config[index as usize].write(|w| {
|
self.inner.config[index as usize].write(|w| {
|
||||||
match trigger_mode {
|
match polarity {
|
||||||
EventPolarity::HiToLo => w.mode().event().polarity().hi_to_lo(),
|
InputChannelPolarity::HiToLo => w.mode().event().polarity().hi_to_lo(),
|
||||||
EventPolarity::LoToHi => w.mode().event().polarity().lo_to_hi(),
|
InputChannelPolarity::LoToHi => w.mode().event().polarity().lo_to_hi(),
|
||||||
EventPolarity::None => w.mode().event().polarity().none(),
|
InputChannelPolarity::None => w.mode().event().polarity().none(),
|
||||||
EventPolarity::Toggle => w.mode().event().polarity().toggle(),
|
InputChannelPolarity::Toggle => w.mode().event().polarity().toggle(),
|
||||||
};
|
};
|
||||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||||
w.port().bit(match pin.port() {
|
w.port().bit(match pin.port() {
|
||||||
@ -124,7 +124,7 @@ impl Gpiote {
|
|||||||
&'a self,
|
&'a self,
|
||||||
pin: Pin<Output<T>>,
|
pin: Pin<Output<T>>,
|
||||||
level: Level,
|
level: Level,
|
||||||
task_out_polarity: TaskOutPolarity,
|
polarity: OutputChannelPolarity,
|
||||||
) -> Result<OutputChannel<'a>, NewChannelError> {
|
) -> Result<OutputChannel<'a>, NewChannelError> {
|
||||||
interrupt::free(|_| {
|
interrupt::free(|_| {
|
||||||
unsafe { INSTANCE = self };
|
unsafe { INSTANCE = self };
|
||||||
@ -137,10 +137,10 @@ impl Gpiote {
|
|||||||
Level::High => w.outinit().high(),
|
Level::High => w.outinit().high(),
|
||||||
Level::Low => w.outinit().low(),
|
Level::Low => w.outinit().low(),
|
||||||
};
|
};
|
||||||
match task_out_polarity {
|
match polarity {
|
||||||
TaskOutPolarity::Set => w.polarity().lo_to_hi(),
|
OutputChannelPolarity::Set => w.polarity().lo_to_hi(),
|
||||||
TaskOutPolarity::Clear => w.polarity().hi_to_lo(),
|
OutputChannelPolarity::Clear => w.polarity().hi_to_lo(),
|
||||||
TaskOutPolarity::Toggle => w.polarity().toggle(),
|
OutputChannelPolarity::Toggle => w.polarity().toggle(),
|
||||||
};
|
};
|
||||||
#[cfg(any(feature = "52833", feature = "52840"))]
|
#[cfg(any(feature = "52833", feature = "52840"))]
|
||||||
w.port().bit(match pin.port() {
|
w.port().bit(match pin.port() {
|
||||||
|
@ -24,7 +24,7 @@ async fn run() {
|
|||||||
|
|
||||||
let pin1 = port0.p0_11.into_pullup_input().degrade();
|
let pin1 = port0.p0_11.into_pullup_input().degrade();
|
||||||
let button1 = async {
|
let button1 = async {
|
||||||
let ch = unwrap!(g.new_input_channel(pin1, gpiote::EventPolarity::HiToLo));
|
let ch = unwrap!(g.new_input_channel(pin1, gpiote::InputChannelPolarity::HiToLo));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
ch.wait().await;
|
ch.wait().await;
|
||||||
@ -34,7 +34,7 @@ async fn run() {
|
|||||||
|
|
||||||
let pin2 = port0.p0_12.into_pullup_input().degrade();
|
let pin2 = port0.p0_12.into_pullup_input().degrade();
|
||||||
let button2 = async {
|
let button2 = async {
|
||||||
let ch = unwrap!(g.new_input_channel(pin2, gpiote::EventPolarity::LoToHi));
|
let ch = unwrap!(g.new_input_channel(pin2, gpiote::InputChannelPolarity::LoToHi));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
ch.wait().await;
|
ch.wait().await;
|
||||||
@ -44,7 +44,7 @@ async fn run() {
|
|||||||
|
|
||||||
let pin3 = port0.p0_24.into_pullup_input().degrade();
|
let pin3 = port0.p0_24.into_pullup_input().degrade();
|
||||||
let button3 = async {
|
let button3 = async {
|
||||||
let ch = unwrap!(g.new_input_channel(pin3, gpiote::EventPolarity::Toggle));
|
let ch = unwrap!(g.new_input_channel(pin3, gpiote::InputChannelPolarity::Toggle));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
ch.wait().await;
|
ch.wait().await;
|
||||||
@ -54,7 +54,7 @@ async fn run() {
|
|||||||
|
|
||||||
let pin4 = port0.p0_25.into_pullup_input().degrade();
|
let pin4 = port0.p0_25.into_pullup_input().degrade();
|
||||||
let button4 = async {
|
let button4 = async {
|
||||||
let ch = unwrap!(g.new_input_channel(pin4, gpiote::EventPolarity::Toggle));
|
let ch = unwrap!(g.new_input_channel(pin4, gpiote::InputChannelPolarity::Toggle));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
ch.wait().await;
|
ch.wait().await;
|
||||||
|
Loading…
Reference in New Issue
Block a user