64 lines
1.3 KiB
Rust
64 lines
1.3 KiB
Rust
//! # Interrupt
|
|
//!
|
|
//! This module contains an interrupt Handler.
|
|
//! The methodes one_trick and idle aren't implemented for now
|
|
|
|
/// # Interrupt
|
|
///
|
|
/// Interrupt Handler
|
|
#[derive(PartialEq)]
|
|
pub struct Interrupt {
|
|
/// Current Status
|
|
level: InterruptStatus
|
|
}
|
|
|
|
impl Interrupt {
|
|
|
|
/// Interrupt constructor
|
|
///
|
|
/// ### Return
|
|
/// Interrupt with status Off
|
|
pub fn new() -> Self {
|
|
Self {
|
|
level: InterruptStatus::InterruptOff
|
|
}
|
|
}
|
|
|
|
/// Interrupt setter
|
|
/// Change the value of the Interrupt
|
|
///
|
|
/// ### Parameters
|
|
/// - **self** the interupt handler
|
|
/// - **new_status** the new status value
|
|
///
|
|
/// ### return
|
|
/// The previus status
|
|
pub fn set_status(&mut self, new_status: InterruptStatus) -> InterruptStatus {
|
|
let old = self.level;
|
|
self.level = new_status;
|
|
if new_status == InterruptStatus::InterruptOn && old == InterruptStatus::InterruptOff {
|
|
self.one_tick(1);
|
|
}
|
|
old
|
|
}
|
|
|
|
fn one_tick(&self, nb_cycle: i32) {
|
|
todo!();
|
|
}
|
|
|
|
/// Interupt getter
|
|
pub fn get_status(&self) -> InterruptStatus {
|
|
self.level
|
|
}
|
|
|
|
pub fn idle(&self) {
|
|
// todo!();
|
|
}
|
|
|
|
}
|
|
|
|
#[derive(PartialEq, Clone, Copy, Debug)]
|
|
pub enum InterruptStatus {
|
|
InterruptOff,
|
|
InterruptOn
|
|
} |