ut-utp / core

Mozilla Public License 2.0
1 stars 0 forks source link

Remove `interrupts_enabled` from `Timers` and `Gpio` #183

Open rrbutani opened 2 years ago

rrbutani commented 2 years ago

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

https://github.com/ut-utp/core/blob/5e0f0eb43de2fe9e94f124cff6bc7db0821c7737/traits/src/peripherals/gpio.rs#L269-L272

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

https://github.com/ut-utp/core/blob/5e0f0eb43de2fe9e94f124cff6bc7db0821c7737/traits/src/peripherals/timers.rs#L260-L264

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

where

branch: imp/remove-interrupts-enables-function

open questions