use bitfield::bitfield;
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum FpgaCtrlEn {
FpgaConfigurationPins = 0,
FpgaManager = 1,
}
impl From<u32> for FpgaCtrlEn {
fn from(b: u32) -> Self {
match b {
0 => FpgaCtrlEn::FpgaConfigurationPins,
1 => FpgaCtrlEn::FpgaManager,
_ => unreachable!(),
}
}
}
impl From<FpgaCtrlEn> for u32 {
fn from(f: FpgaCtrlEn) -> Self {
f as Self
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum FpgaCtrlNce {
Enabled = 0,
Disabled = 1,
}
impl From<u32> for FpgaCtrlNce {
fn from(b: u32) -> Self {
match b {
0 => FpgaCtrlNce::Enabled,
1 => FpgaCtrlNce::Disabled,
_ => unreachable!(),
}
}
}
impl From<FpgaCtrlNce> for u32 {
fn from(f: FpgaCtrlNce) -> Self {
f as Self
}
}
#[derive(Debug, Clone, Copy)]
pub enum FpgaCtrlCdRatio {
X1 = 0,
X2 = 1,
X4 = 2,
X8 = 3,
}
impl From<u32> for FpgaCtrlCdRatio {
fn from(value: u32) -> Self {
match value {
0 => FpgaCtrlCdRatio::X1,
1 => FpgaCtrlCdRatio::X2,
2 => FpgaCtrlCdRatio::X4,
3 => FpgaCtrlCdRatio::X8,
_ => unreachable!(),
}
}
}
impl From<FpgaCtrlCdRatio> for u32 {
fn from(f: FpgaCtrlCdRatio) -> Self {
f as Self
}
}
#[derive(Debug, Clone, Copy)]
pub enum FpgaCtrlCfgWidth {
Passive16Bit = 0,
Passive32Bit = 1,
}
impl From<u32> for FpgaCtrlCfgWidth {
fn from(value: u32) -> Self {
match value {
0 => FpgaCtrlCfgWidth::Passive16Bit,
1 => FpgaCtrlCfgWidth::Passive32Bit,
x => unreachable!("Invalid value for FpgaCtrlCfgWidth: {}", x),
}
}
}
impl From<FpgaCtrlCfgWidth> for u32 {
fn from(f: FpgaCtrlCfgWidth) -> Self {
f as Self
}
}
bitfield! {
pub struct FpgaConfigurationControl(u32);
impl Debug;
u32;
pub from into FpgaCtrlEn, en, set_en: 0, 0;
pub from into FpgaCtrlNce, nce, set_nce: 1, 1;
pub nconfigpull, set_nconfigpull: 2;
pub nstatuspull, set_nstatuspull: 3;
pub confdonepull, set_confdonepull: 4;
pub prreq, set_prreq: 5;
pub from into FpgaCtrlCdRatio, cdratio, set_cdratio: 7, 6;
pub axicfgen, set_axicfgen: 8;
pub from into FpgaCtrlCfgWidth, cfgwdth, set_cfgwdth: 9, 9;
}