use heterob::{bit_numbering::Lsb, P12};
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct CardbusBridgeControl {
pub parity_error_response_enable: bool,
pub serr_enable: bool,
pub isa_enable: bool,
pub vga_enable: bool,
pub master_abort_mode: bool,
pub cardbus_reset: bool,
pub ireq_int_enable: bool,
pub memory_0_prefetch_enable: bool,
pub memory_1_prefetch_enable: bool,
pub write_posting_enable: bool,
}
impl From<u16> for CardbusBridgeControl {
fn from(word: u16) -> Self {
let Lsb((
parity_error_response_enable,
serr_enable,
isa_enable,
vga_enable,
(),
master_abort_mode,
cardbus_reset,
ireq_int_enable,
memory_0_prefetch_enable,
memory_1_prefetch_enable,
write_posting_enable,
(),
)) = P12::<_, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5>(word).into();
Self {
parity_error_response_enable,
serr_enable,
isa_enable,
vga_enable,
master_abort_mode,
cardbus_reset,
ireq_int_enable,
memory_0_prefetch_enable,
memory_1_prefetch_enable,
write_posting_enable,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn from_word() {
let result = 0xAAAA.into();
let sample = CardbusBridgeControl {
parity_error_response_enable: false,
serr_enable: true,
isa_enable: false,
vga_enable: true,
master_abort_mode: true,
cardbus_reset: false,
ireq_int_enable: true,
memory_0_prefetch_enable: false,
memory_1_prefetch_enable: true,
write_posting_enable: false,
};
assert_eq!(sample, result);
}
}