Started InterruptConfig type

This commit is contained in:
Zac Wilson 2025-12-22 17:18:17 +00:00
parent 597d2584b1
commit 0e697b48f1

View file

@ -51,3 +51,34 @@ impl MatrixConfig {
} }
} }
#[derive(Clone, Copy)]
pub struct InterruptConfig(u8);
impl InterruptConfig {
/// A new interrupt with the following configuration:
/// - GPI events are tracked when keypad is locked
/// - Overflow data is lost
/// - Processor interrupt remains asserted (or low) if host tries to clear
/// interrupt while there is still a pending key press, key release or
/// GPI interrupt
/// - ~INT is not asserted if the FIFO overflows
/// - ~INT is not asserted after a correct unlock key sequence
/// - ~INT is not asserted for a change on a GPI
/// - ~INT is not asserted when a key event occurs
pub const fn new() -> Self {
Self(0)
}
pub const fn without_gpi_event_tracking_when_locked(self) -> Self {
InterruptConfig(self.0 | 0b0100_0000)
}
pub const fn with_overflow_data_shifting(self) -> Self {
InterruptConfig(self.0 | 0b0010_0000)
}
pub const fn with_temporary_interrupt_deassertion(self) -> Self {
InterruptConfig(self.0 | 0b0001_0000)
}
}