1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
use crate::bitfield;
#[cfg(feature = "nightly")]
bitfield! {
/// A sample bitfield showcasing the library's features (open the source code to view).
#[derive(Clone, Copy, PartialEq, Eq)]
pub const struct Example(pub u16): Debug {
// A single field spanning the entire bitfield, using an unbounded range
pub raw: u16 @ ..,
// Single-bit flags
pub vblank: bool [read_only] @ 0,
pub hblank: bool [write_only] @ 1,
pub vcount_match: bool @ 2,
// Multi-bit field, specified using an inclusive range
pub irq_mask: u8 @ 3..=5,
// Bit 6 is ignored
// Single-bit field, specified using an exclusive range
pub vcount_compare_high: u8 @ 7..8,
// 8-bit field specified using its start bit and length
pub vcount_compare_low: u8 @ 8; 8,
}
}
#[cfg(not(feature = "nightly"))]
bitfield! {
/// A sample bitfield showcasing the library's features (open the source code to view).
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct Example(pub u16): Debug {
// A single field spanning the entire bitfield, using an unbounded range
pub raw: u16 @ ..,
// Single-bit flags
pub vblank: bool [read_only] @ 0,
pub hblank: bool [write_only] @ 1,
pub vcount_match: bool @ 2,
// Multi-bit field, specified using an inclusive range
pub irq_mask: u8 @ 3..=5,
// Bit 6 is ignored
// Single-bit field, specified using an exclusive range
pub vcount_compare_high: u8 @ 7..8,
// 8-bit field specified using its start bit and length
pub vcount_compare_low: u8 @ 8; 8,
}
}