diff --git a/src/lib.rs b/src/lib.rs index 157d396..f515bcc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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) + } +} +