Compare commits
No commits in common. "8e0229d2651633fc6cd449b55a559742c56add18" and "5c054cc90194b7647f78168b51bc452eed42f33e" have entirely different histories.
8e0229d265
...
5c054cc901
|
@ -29,7 +29,7 @@ pub struct FrequencySettings {
|
||||||
pub n31: u32,
|
pub n31: u32,
|
||||||
pub n32: u32,
|
pub n32: u32,
|
||||||
pub bwsel: u8,
|
pub bwsel: u8,
|
||||||
pub crystal_as_ckin2: bool
|
pub crystal_ref: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Input {
|
pub enum Input {
|
||||||
|
@ -84,7 +84,7 @@ fn map_frequency_settings(settings: &FrequencySettings) -> Result<FrequencySetti
|
||||||
n31: settings.n31 - 1,
|
n31: settings.n31 - 1,
|
||||||
n32: settings.n32 - 1,
|
n32: settings.n32 - 1,
|
||||||
bwsel: settings.bwsel,
|
bwsel: settings.bwsel,
|
||||||
crystal_as_ckin2: settings.crystal_as_ckin2
|
crystal_ref: settings.crystal_ref
|
||||||
};
|
};
|
||||||
Ok(r)
|
Ok(r)
|
||||||
}
|
}
|
||||||
|
@ -219,15 +219,18 @@ pub fn bypass(i2c: &mut I2c, input: Input, timer: &mut GlobalTimer) -> Result<()
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup(i2c: &mut I2c, settings: &FrequencySettings, input: Input, timer: &mut GlobalTimer) -> Result<()> {
|
pub fn setup(i2c: &mut I2c, settings: &FrequencySettings, ext_input: Input, timer: &mut GlobalTimer) -> Result<()> {
|
||||||
let s = map_frequency_settings(settings)?;
|
let s = map_frequency_settings(settings)?;
|
||||||
|
|
||||||
|
// FREE_RUN=1 routes XA/XB to CKIN2.
|
||||||
|
let input = if settings.crystal_ref { Input::Ckin2 } else { ext_input };
|
||||||
let cksel_reg = match input {
|
let cksel_reg = match input {
|
||||||
Input::Ckin1 => 0b00,
|
Input::Ckin1 => 0b00,
|
||||||
Input::Ckin2 => 0b01,
|
Input::Ckin2 => 0b01,
|
||||||
};
|
};
|
||||||
|
|
||||||
init(i2c, timer)?;
|
init(i2c, timer)?;
|
||||||
if settings.crystal_as_ckin2 {
|
if settings.crystal_ref {
|
||||||
rmw(i2c, 0, |v| v | 0x40)?; // FREE_RUN=1
|
rmw(i2c, 0, |v| v | 0x40)?; // FREE_RUN=1
|
||||||
}
|
}
|
||||||
rmw(i2c, 2, |v| (v & 0x0f) | (s.bwsel << 4))?;
|
rmw(i2c, 2, |v| (v & 0x0f) | (s.bwsel << 4))?;
|
||||||
|
|
|
@ -121,121 +121,100 @@ const SI5324_EXT_INPUT: si5324::Input = si5324::Input::Ckin1;
|
||||||
|
|
||||||
#[cfg(has_si5324)]
|
#[cfg(has_si5324)]
|
||||||
fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) {
|
fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) {
|
||||||
let (si5324_settings, si5324_ref_input) = match clk {
|
let si5324_settings = match clk {
|
||||||
RtioClock::Ext0_Synth0_10to125 => { // 125 MHz output from 10 MHz CLKINx reference, 504 Hz BW
|
RtioClock::Ext0_Synth0_10to125 => { // 125 MHz output from 10 MHz CLKINx reference, 504 Hz BW
|
||||||
info!("using 10MHz reference to make 125MHz RTIO clock with PLL");
|
info!("using 10MHz reference to make 125MHz RTIO clock with PLL");
|
||||||
(
|
si5324::FrequencySettings {
|
||||||
si5324::FrequencySettings {
|
n1_hs : 10,
|
||||||
n1_hs : 10,
|
nc1_ls : 4,
|
||||||
nc1_ls : 4,
|
n2_hs : 10,
|
||||||
n2_hs : 10,
|
n2_ls : 300,
|
||||||
n2_ls : 300,
|
n31 : 6,
|
||||||
n31 : 6,
|
n32 : 6,
|
||||||
n32 : 6,
|
bwsel : 4,
|
||||||
bwsel : 4,
|
crystal_ref: false
|
||||||
crystal_as_ckin2: false
|
}
|
||||||
},
|
|
||||||
SI5324_EXT_INPUT
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
RtioClock::Ext0_Synth0_100to125 => { // 125MHz output, from 100MHz CLKINx reference, 586 Hz loop bandwidth
|
RtioClock::Ext0_Synth0_100to125 => { // 125MHz output, from 100MHz CLKINx reference, 586 Hz loop bandwidth
|
||||||
info!("using 100MHz reference to make 125MHz RTIO clock with PLL");
|
info!("using 100MHz reference to make 125MHz RTIO clock with PLL");
|
||||||
(
|
si5324::FrequencySettings {
|
||||||
si5324::FrequencySettings {
|
n1_hs : 10,
|
||||||
n1_hs : 10,
|
nc1_ls : 4,
|
||||||
nc1_ls : 4,
|
n2_hs : 10,
|
||||||
n2_hs : 10,
|
n2_ls : 260,
|
||||||
n2_ls : 260,
|
n31 : 52,
|
||||||
n31 : 52,
|
n32 : 52,
|
||||||
n32 : 52,
|
bwsel : 4,
|
||||||
bwsel : 4,
|
crystal_ref: false
|
||||||
crystal_as_ckin2: false
|
}
|
||||||
},
|
|
||||||
SI5324_EXT_INPUT
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
RtioClock::Ext0_Synth0_125to125 => { // 125MHz output, from 125MHz CLKINx reference, 606 Hz loop bandwidth
|
RtioClock::Ext0_Synth0_125to125 => { // 125MHz output, from 125MHz CLKINx reference, 606 Hz loop bandwidth
|
||||||
info!("using 125MHz reference to make 125MHz RTIO clock with PLL");
|
info!("using 125MHz reference to make 125MHz RTIO clock with PLL");
|
||||||
(
|
si5324::FrequencySettings {
|
||||||
si5324::FrequencySettings {
|
n1_hs : 5,
|
||||||
n1_hs : 5,
|
nc1_ls : 8,
|
||||||
nc1_ls : 8,
|
n2_hs : 7,
|
||||||
n2_hs : 7,
|
n2_ls : 360,
|
||||||
n2_ls : 360,
|
n31 : 63,
|
||||||
n31 : 63,
|
n32 : 63,
|
||||||
n32 : 63,
|
bwsel : 4,
|
||||||
bwsel : 4,
|
crystal_ref: false
|
||||||
crystal_as_ckin2: false
|
}
|
||||||
},
|
|
||||||
SI5324_EXT_INPUT
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
RtioClock::Int_150 => { // 150MHz output, from crystal
|
RtioClock::Int_150 => { // 150MHz output, from crystal
|
||||||
info!("using internal 150MHz RTIO clock");
|
info!("using internal 150MHz RTIO clock");
|
||||||
(
|
si5324::FrequencySettings {
|
||||||
si5324::FrequencySettings {
|
n1_hs : 9,
|
||||||
n1_hs : 9,
|
nc1_ls : 4,
|
||||||
nc1_ls : 4,
|
n2_hs : 10,
|
||||||
n2_hs : 10,
|
n2_ls : 33732,
|
||||||
n2_ls : 33732,
|
n31 : 7139,
|
||||||
n31 : 7139,
|
n32 : 7139,
|
||||||
n32 : 7139,
|
bwsel : 3,
|
||||||
bwsel : 3,
|
crystal_ref: true
|
||||||
crystal_as_ckin2: true
|
}
|
||||||
},
|
|
||||||
si5324::Input::Ckin2
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
RtioClock::Int_100 => { // 100MHz output, from crystal
|
RtioClock::Int_100 => { // 100MHz output, from crystal
|
||||||
info!("using internal 100MHz RTIO clock");
|
info!("using internal 100MHz RTIO clock");
|
||||||
(
|
si5324::FrequencySettings {
|
||||||
si5324::FrequencySettings {
|
n1_hs : 9,
|
||||||
n1_hs : 9,
|
nc1_ls : 6,
|
||||||
nc1_ls : 6,
|
n2_hs : 10,
|
||||||
n2_hs : 10,
|
n2_ls : 33732,
|
||||||
n2_ls : 33732,
|
n31 : 7139,
|
||||||
n31 : 7139,
|
n32 : 7139,
|
||||||
n32 : 7139,
|
bwsel : 3,
|
||||||
bwsel : 3,
|
crystal_ref: true
|
||||||
crystal_as_ckin2: true
|
}
|
||||||
},
|
|
||||||
si5324::Input::Ckin2
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
RtioClock::Int_125 => { // 125MHz output, from crystal, 7 Hz
|
RtioClock::Int_125 => { // 125MHz output, from crystal, 7 Hz
|
||||||
info!("using internal 125MHz RTIO clock");
|
info!("using internal 125MHz RTIO clock");
|
||||||
(
|
si5324::FrequencySettings {
|
||||||
si5324::FrequencySettings {
|
n1_hs : 10,
|
||||||
n1_hs : 10,
|
nc1_ls : 4,
|
||||||
nc1_ls : 4,
|
n2_hs : 10,
|
||||||
n2_hs : 10,
|
n2_ls : 19972,
|
||||||
n2_ls : 19972,
|
n31 : 4565,
|
||||||
n31 : 4565,
|
n32 : 4565,
|
||||||
n32 : 4565,
|
bwsel : 4,
|
||||||
bwsel : 4,
|
crystal_ref: true
|
||||||
crystal_as_ckin2: true
|
}
|
||||||
},
|
}
|
||||||
si5324::Input::Ckin2
|
_ => { // 125MHz output like above, default (if chosen option is not supported)
|
||||||
)
|
warn!("rtio_clock setting '{:?}' is not supported. Falling back to default internal 125MHz RTIO clock.", clk);
|
||||||
},
|
si5324::FrequencySettings {
|
||||||
_ => { // same setting as Int_125, but fallback to default
|
n1_hs : 10,
|
||||||
warn!("rtio_clock setting '{:?}' is unsupported. Falling back to default internal 125MHz RTIO clock.", clk);
|
nc1_ls : 4,
|
||||||
(
|
n2_hs : 10,
|
||||||
si5324::FrequencySettings {
|
n2_ls : 19972,
|
||||||
n1_hs : 10,
|
n31 : 4565,
|
||||||
nc1_ls : 4,
|
n32 : 4565,
|
||||||
n2_hs : 10,
|
bwsel : 4,
|
||||||
n2_ls : 19972,
|
crystal_ref: true
|
||||||
n31 : 4565,
|
}
|
||||||
n32 : 4565,
|
|
||||||
bwsel : 4,
|
|
||||||
crystal_as_ckin2: true
|
|
||||||
},
|
|
||||||
si5324::Input::Ckin2
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
si5324::setup(i2c, &si5324_settings, si5324_ref_input, timer).expect("cannot initialize Si5324");
|
si5324::setup(i2c, &si5324_settings, SI5324_EXT_INPUT, timer).expect("cannot initialize Si5324");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(timer: &mut GlobalTimer, cfg: &Config) {
|
pub fn init(timer: &mut GlobalTimer, cfg: &Config) {
|
||||||
|
|
|
@ -428,7 +428,7 @@ const SI5324_SETTINGS: si5324::FrequencySettings
|
||||||
n31 : 63,
|
n31 : 63,
|
||||||
n32 : 63,
|
n32 : 63,
|
||||||
bwsel : 4,
|
bwsel : 4,
|
||||||
crystal_as_ckin2: true
|
crystal_ref: true
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(has_si5324, rtio_frequency = "100.0"))]
|
#[cfg(all(has_si5324, rtio_frequency = "100.0"))]
|
||||||
|
@ -441,7 +441,7 @@ const SI5324_SETTINGS: si5324::FrequencySettings
|
||||||
n31 : 50,
|
n31 : 50,
|
||||||
n32 : 50,
|
n32 : 50,
|
||||||
bwsel : 4,
|
bwsel : 4,
|
||||||
crystal_as_ckin2: true
|
crystal_ref: true
|
||||||
};
|
};
|
||||||
|
|
||||||
static mut LOG_BUFFER: [u8; 1<<17] = [0; 1<<17];
|
static mut LOG_BUFFER: [u8; 1<<17] = [0; 1<<17];
|
||||||
|
|
Loading…
Reference in New Issue