Skip to content

Commit

Permalink
psx/irq: Make NUM_IRQS public
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrtonm committed Feb 17, 2023
1 parent cacbdd8 commit 35f41da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions psx/src/hw/irq.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
//! Interrupt request and acknowledge
use crate::hw::{MemRegister, Register};
use crate::irq::{ALL_IRQS, IRQ};
use core::mem::variant_count;
use crate::irq::{ALL_IRQS, IRQ, NUM_IRQS};

/// Interrupt status register
pub type Status = MemRegister<u16, 0x1F80_1070>;
/// Interrupt mask register
pub type Mask = MemRegister<u16, 0x1F80_1074>;

const NUM_IRQS: usize = variant_count::<IRQ>();
const ALL_IRQS_BITS: u16 = (1 << NUM_IRQS) - 1;

impl Status {
Expand Down
6 changes: 6 additions & 0 deletions psx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ pub mod constants {

/// Interrupt request types
pub mod irq {
use core::mem::variant_count;

/// The number of different interrupt requests
pub const NUM_IRQS: usize = variant_count::<IRQ>();

/// An interrupt request
#[repr(u16)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum IRQ {
/// vertical blank interrupt request (NTSC = 60Hz, PAL = 50Hz)
Expand Down

0 comments on commit 35f41da

Please sign in to comment.