Skip to main content

sbi_spec/binary/
trigger_mask.rs

1use super::sbi_ret::SbiRegister;
2
3/// Debug trigger mask structure for the `DBTR` extension ยง19.
4#[repr(C)]
5#[derive(Debug, Copy, Clone, Eq, PartialEq)]
6pub struct TriggerMask<T = usize> {
7    trig_idx_base: T,
8    trig_idx_mask: T,
9}
10
11impl<T: SbiRegister> TriggerMask<T> {
12    /// Construct a [TriggerMask] from mask value and base counter index.
13    ///
14    /// The `trig_idx_base` specifies the starting trigger index, while the `trig_idx_mask` is a
15    /// bitmask indicating which triggers, relative to the base, are to be operated.
16    #[inline]
17    pub const fn from_mask_base(trig_idx_mask: T, trig_idx_base: T) -> Self {
18        Self {
19            trig_idx_mask,
20            trig_idx_base,
21        }
22    }
23
24    /// Returns `mask` and `base` parameters from the [TriggerMask].
25    #[inline]
26    pub const fn into_inner(self) -> (T, T) {
27        (self.trig_idx_mask, self.trig_idx_base)
28    }
29}