Merge #115
115: Feature/optional pounder r=jordens a=ryan-summers This PR updates the initialization function to measure the PGOOD output on pounder to detect whether or not pounder is installed. This also re-enables the high-speed external oscillator for Stabilizer. **Note**: No timing was conducted on firmware and power-supply management for monitoring PGOOD. It is currently assumed that PGOOD is steady-state before the firmware measures it. Co-authored-by: Ryan Summers <ryan.summers@vertigo-designs.com>
This commit is contained in:
commit
fa7037ac0b
112
src/main.rs
112
src/main.rs
|
@ -33,7 +33,7 @@ use rtic::cyccnt::{Instant, U32Ext};
|
|||
use stm32h7xx_hal as hal;
|
||||
use stm32h7xx_hal::prelude::*;
|
||||
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
||||
|
||||
use smoltcp as net;
|
||||
use stm32h7_ethernet as ethernet;
|
||||
|
@ -171,6 +171,18 @@ const APP: () = {
|
|||
eeprom_i2c: hal::i2c::I2c<hal::stm32::I2C2>,
|
||||
|
||||
timer: hal::timer::Timer<hal::stm32::TIM2>,
|
||||
|
||||
// Note: It appears that rustfmt generates a format that GDB cannot recognize, which
|
||||
// results in GDB breakpoints being set improperly. To debug, redefine the following
|
||||
// definition to:
|
||||
//
|
||||
// ```rust
|
||||
// net_interface: net::iface::EthernetInterface<
|
||||
// 'static,
|
||||
// 'static,
|
||||
// 'static,
|
||||
// ethernet::EthernetDMA<'static>>,
|
||||
// ```
|
||||
net_interface: net::iface::EthernetInterface<
|
||||
'static,
|
||||
'static,
|
||||
|
@ -180,7 +192,7 @@ const APP: () = {
|
|||
eth_mac: ethernet::EthernetMAC,
|
||||
mac_addr: net::wire::EthernetAddress,
|
||||
|
||||
pounder: pounder::PounderDevices<asm_delay::AsmDelay>,
|
||||
pounder: Option<pounder::PounderDevices<asm_delay::AsmDelay>>,
|
||||
|
||||
#[init([[0.; 5]; 2])]
|
||||
iir_state: [iir::IIRState; 2],
|
||||
|
@ -198,8 +210,7 @@ const APP: () = {
|
|||
|
||||
let rcc = dp.RCC.constrain();
|
||||
let mut clocks = rcc
|
||||
//TODO: Re-enable HSE for Stabilizer platform.
|
||||
// .use_hse(8.mhz())
|
||||
.use_hse(8.mhz())
|
||||
.sysclk(400.mhz())
|
||||
.hclk(200.mhz())
|
||||
.per_ck(100.mhz())
|
||||
|
@ -376,7 +387,10 @@ const APP: () = {
|
|||
fp_led_2.set_low().unwrap();
|
||||
fp_led_3.set_low().unwrap();
|
||||
|
||||
let pounder_devices = {
|
||||
// Measure the Pounder PGOOD output to detect if pounder is present on Stabilizer.
|
||||
let pounder_pgood = gpiob.pb13.into_pull_down_input();
|
||||
delay.delay_ms(2u8);
|
||||
let pounder_devices = if pounder_pgood.is_high().unwrap() {
|
||||
let ad9959 = {
|
||||
let qspi_interface = {
|
||||
// Instantiate the QUADSPI pins and peripheral interface.
|
||||
|
@ -489,16 +503,20 @@ const APP: () = {
|
|||
let adc1_in_p = gpiof.pf11.into_analog();
|
||||
let adc2_in_p = gpiof.pf14.into_analog();
|
||||
|
||||
pounder::PounderDevices::new(
|
||||
io_expander,
|
||||
ad9959,
|
||||
spi,
|
||||
adc1,
|
||||
adc2,
|
||||
adc1_in_p,
|
||||
adc2_in_p,
|
||||
Some(
|
||||
pounder::PounderDevices::new(
|
||||
io_expander,
|
||||
ad9959,
|
||||
spi,
|
||||
adc1,
|
||||
adc2,
|
||||
adc1_in_p,
|
||||
adc2_in_p,
|
||||
)
|
||||
.unwrap(),
|
||||
)
|
||||
.unwrap()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut eeprom_i2c = {
|
||||
|
@ -746,23 +764,38 @@ const APP: () = {
|
|||
"stabilizer/afe1/gain": (|| c.resources.afe1.get_gain()),
|
||||
"stabilizer/afe2/gain": (|| c.resources.afe2.get_gain()),
|
||||
"pounder/in0": (|| {
|
||||
c.resources.pounder.get_input_channel_state(
|
||||
pounder::Channel::In0)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.get_input_channel_state(pounder::Channel::In0),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/in1": (|| {
|
||||
c.resources.pounder.get_input_channel_state(
|
||||
pounder::Channel::In1)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.get_input_channel_state(pounder::Channel::In1),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/out0": (|| {
|
||||
c.resources.pounder.get_output_channel_state(
|
||||
pounder::Channel::Out0)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.get_output_channel_state(pounder::Channel::Out0),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/out1": (|| {
|
||||
c.resources.pounder.get_output_channel_state(
|
||||
pounder::Channel::Out1)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.get_output_channel_state(pounder::Channel::Out1),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/dds/clock": (|| {
|
||||
c.resources.pounder.get_dds_clock_config()
|
||||
match c.resources.pounder {
|
||||
Some(pounder) => pounder.get_dds_clock_config(),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
})
|
||||
],
|
||||
|
||||
|
@ -790,23 +823,38 @@ const APP: () = {
|
|||
})
|
||||
}),
|
||||
"pounder/in0": pounder::ChannelState, (|state| {
|
||||
c.resources.pounder.set_channel_state(pounder::Channel::In0,
|
||||
state)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.set_channel_state(pounder::Channel::In0, state),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/in1": pounder::ChannelState, (|state| {
|
||||
c.resources.pounder.set_channel_state(pounder::Channel::In1,
|
||||
state)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.set_channel_state(pounder::Channel::In1, state),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/out0": pounder::ChannelState, (|state| {
|
||||
c.resources.pounder.set_channel_state(pounder::Channel::Out0,
|
||||
state)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.set_channel_state(pounder::Channel::Out0, state),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/out1": pounder::ChannelState, (|state| {
|
||||
c.resources.pounder.set_channel_state(pounder::Channel::Out1,
|
||||
state)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) =>
|
||||
pounder.set_channel_state(pounder::Channel::Out1, state),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"pounder/dds/clock": pounder::DdsClockConfig, (|config| {
|
||||
c.resources.pounder.configure_dds_clock(config)
|
||||
match c.resources.pounder {
|
||||
Some(pounder) => pounder.configure_dds_clock(config),
|
||||
_ => Err(pounder::Error::Access),
|
||||
}
|
||||
}),
|
||||
"stabilizer/afe1/gain": afe::Gain, (|gain| {
|
||||
Ok::<(), ()>(c.resources.afe1.set_gain(gain))
|
||||
|
|
|
@ -29,6 +29,7 @@ pub enum Error {
|
|||
InvalidAddress,
|
||||
InvalidChannel,
|
||||
Adc,
|
||||
Access,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
Loading…
Reference in New Issue