Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove interrupts_enabled from Timers and Gpio #183

Open
3 tasks
rrbutani opened this issue Jul 28, 2022 · 0 comments
Open
3 tasks

Remove interrupts_enabled from Timers and Gpio #183

rrbutani opened this issue Jul 28, 2022 · 0 comments
Assignees
Labels
➕ improvement Chores and fixes: the small things. P-low Low priority T-peripheral traits Topic: Peripheral Traits

Comments

@rrbutani
Copy link
Member

what

The Input and Output traits have this method because whether or not interrupts are enabled is truly orthogonal to the current state of the peripheral: it's possible for the peripheral to be ready (i.e. to have data (Input) or to be ready to accept data (Output)) regardless of whether interrupts are enabled or disabled (#182).

This is not the case for Gpio and Timers.

Gpio

#[inline]
fn interrupts_enabled(&self, pin: GpioPin) -> bool {
matches!(self.get_state(pin), GpioState::Interrupt)
}

For Gpio, it's only valid for the peripheral to produce interrupts when a pin is in Interrupt mode. This makes Gpio::interrupts_enabled entirely redundant: you'd never want anything but the default interrupts_enabled impl.

Timers

#[inline]
fn interrupts_enabled(&self, timer: TimerId) -> bool {
matches!(self.get_state(timer), TimerState::WithPeriod(_)) ||
(self.get_state(timer) == TimerState::Disabled && self.interrupt_occurred(timer))
}

For Timers there isn't an enable/disable for interrupts because there is no other mode of use for Timers other than interrupts.

When a timer has fired there is an interrupt pending. Clearing that interrupt flag means there is no longer an interrupt pending and there are no additional states.

steps

  • remove the interrupts_enabled functions from Timers and Gpio
  • adjust mem_mapped in baseline-sim to match
  • update the docs on the Timers and Gpio traits

where

branch: imp/remove-interrupts-enables-function

open questions

@rrbutani rrbutani added ➕ improvement Chores and fixes: the small things. P-low Low priority T-peripheral traits Topic: Peripheral Traits labels Jul 28, 2022
@rrbutani rrbutani self-assigned this Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
➕ improvement Chores and fixes: the small things. P-low Low priority T-peripheral traits Topic: Peripheral Traits
Projects
None yet
Development

No branches or pull requests

1 participant