use heterob::{bit_numbering::Lsb, P13};
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct BridgeControl {
pub parity_error_response_enable: bool,
pub serr_enable: bool,
pub isa_enable: bool,
pub vga_enable: bool,
pub vga_16_enable: bool,
pub master_abort_mode: bool,
pub secondary_bus_reset: bool,
pub fast_back_to_back_enable: bool,
pub primary_discard_timer: bool,
pub secondary_discard_timer: bool,
pub discard_timer_status: bool,
pub discard_timer_serr_enable: bool,
}
impl From<u16> for BridgeControl {
fn from(word: u16) -> Self {
let Lsb((
parity_error_response_enable,
serr_enable,
isa_enable,
vga_enable,
vga_16_enable,
master_abort_mode,
secondary_bus_reset,
fast_back_to_back_enable,
primary_discard_timer,
secondary_discard_timer,
discard_timer_status,
discard_timer_serr_enable,
(),
)) = P13::<_, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4>(word).into();
Self {
parity_error_response_enable,
serr_enable,
isa_enable,
vga_enable,
vga_16_enable,
master_abort_mode,
secondary_bus_reset,
fast_back_to_back_enable,
primary_discard_timer,
secondary_discard_timer,
discard_timer_status,
discard_timer_serr_enable,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn from_word() {
let result = 0xAAAA.into();
let sample = BridgeControl {
parity_error_response_enable: false,
serr_enable: true,
isa_enable: false,
vga_enable: true,
vga_16_enable: false,
master_abort_mode: true,
secondary_bus_reset: false,
fast_back_to_back_enable: true,
primary_discard_timer: false,
secondary_discard_timer: true,
discard_timer_status: false,
discard_timer_serr_enable: true,
};
assert_eq!(sample, result);
}
}