Skip to content

Commit

Permalink
Simplifying code
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed Nov 20, 2023
1 parent 1bdf22a commit 2f41b1d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ features = ["stm32h743v", "rt", "ethernet", "xspi", "usb_hs"]

[patch.crates-io.usbd-serial]
git = "https://github.com/rust-embedded-community/usbd-serial"
branch = "rs/bugfix"

[patch.crates-io.synopsys-usb-otg]
git = "https://github.com/quartiq/synopsys-usb-otg"
Expand Down
8 changes: 4 additions & 4 deletions src/bin/dual-iir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use stabilizer::{
hal,
signal_generator::{self, SignalGenerator},
timers::SamplingTimer,
usb::UsbDevice,
UsbDevice,
DigitalInput0, DigitalInput1, SerialTerminal, SystemTimer, Systick,
AFE0, AFE1,
},
Expand Down Expand Up @@ -233,7 +233,7 @@ mod app {
let settings = Settings::default();

let shared = Shared {
usb: stabilizer.usb_device,
usb: stabilizer.usb,
network,
settings,
telemetry: TelemetryBuffer::default(),
Expand Down Expand Up @@ -406,7 +406,7 @@ mod app {
NetworkState::Updated => {}
NetworkState::NoChange => {
// We can't sleep if USB is not in suspend.
if c.shared.usb.lock(|usb| usb.usb_is_suspended()) {
if c.shared.usb.lock(|usb| usb.state() == usb_device::device::UsbDeviceState::Suspend) {
cortex_m::asm::wfi();
}
}
Expand Down Expand Up @@ -469,7 +469,7 @@ mod app {
fn usb(mut c: usb::Context) {
// Handle the USB serial terminal.
c.shared.usb.lock(|usb| {
usb.process(c.local.usb_terminal);
usb.poll(&mut [c.local.usb_terminal.interface_mut()]);
});

c.local.usb_terminal.process().unwrap();
Expand Down
8 changes: 4 additions & 4 deletions src/bin/lockin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use stabilizer::{
input_stamper::InputStamper,
signal_generator,
timers::SamplingTimer,
usb::UsbDevice,
UsbDevice,
DigitalInput0, DigitalInput1, SerialTerminal, SystemTimer, Systick,
AFE0, AFE1,
},
Expand Down Expand Up @@ -272,7 +272,7 @@ mod app {

let shared = Shared {
network,
usb: stabilizer.usb_device,
usb: stabilizer.usb,
telemetry: TelemetryBuffer::default(),
settings: Settings::default(),
};
Expand Down Expand Up @@ -468,7 +468,7 @@ mod app {
NetworkState::Updated => {}
NetworkState::NoChange => {
// We can't sleep if USB is not in suspend.
if c.shared.usb.lock(|usb| usb.usb_is_suspended()) {
if c.shared.usb.lock(|usb| usb.state() == usb_device::device::UsbDeviceState::Suspend) {
cortex_m::asm::wfi();
}
}
Expand Down Expand Up @@ -520,7 +520,7 @@ mod app {
fn usb(mut c: usb::Context) {
// Handle the USB serial terminal.
c.shared.usb.lock(|usb| {
usb.process(c.local.usb_terminal);
usb.poll(&mut [c.local.usb_terminal.interface_mut()]);
});

c.local.usb_terminal.process().unwrap();
Expand Down
4 changes: 3 additions & 1 deletion src/hardware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub mod setup;
pub mod shared_adc;
pub mod signal_generator;
pub mod timers;
pub mod usb;

mod eeprom;

Expand All @@ -34,6 +33,9 @@ pub type AFE1 = afe::ProgrammableGainAmplifier<

pub type UsbBus = stm32h7xx_hal::usb_hs::UsbBus<stm32h7xx_hal::usb_hs::USB2>;

// Type alias for the USB device.
pub type UsbDevice = usb_device::device::UsbDevice<'static, UsbBus>;

// Type alias for digital input 0 (DI0).
pub type DigitalInput0 = hal::gpio::gpiog::PG9<hal::gpio::Input>;

Expand Down
8 changes: 4 additions & 4 deletions src/hardware/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::{
adc, afe, cpu_temp_sensor::CpuTempSensor, dac, delay, design_parameters,
eeprom, input_stamper::InputStamper, pounder,
pounder::dds_output::DdsOutput, shared_adc::SharedAdc, timers,
usb::UsbDevice, DigitalInput0, DigitalInput1, EemDigitalInput0,
UsbDevice, DigitalInput0, DigitalInput1, EemDigitalInput0,
EemDigitalInput1, EemDigitalOutput0, EemDigitalOutput1, EthernetPhy,
NetworkStack, SerialTerminal, SystemTimer, Systick, UsbBus, AFE0, AFE1,
};
Expand Down Expand Up @@ -118,7 +118,7 @@ pub struct StabilizerDevices {
pub digital_inputs: (DigitalInput0, DigitalInput1),
pub eem_gpio: EemGpioDevices,
pub usb_serial: SerialTerminal,
pub usb_device: UsbDevice,
pub usb: UsbDevice,
}

/// The available Pounder-specific hardware interfaces.
Expand Down Expand Up @@ -1070,7 +1070,7 @@ pub fn setup(
.device_class(usbd_serial::USB_CLASS_CDC)
.build();

(UsbDevice::new(usb_device), serial)
(usb_device, serial)
};

let usb_serial = {
Expand Down Expand Up @@ -1109,7 +1109,7 @@ pub fn setup(
timestamp_timer,
digital_inputs,
eem_gpio,
usb_device,
usb: usb_device,
usb_serial,
};

Expand Down
22 changes: 0 additions & 22 deletions src/hardware/usb.rs

This file was deleted.

0 comments on commit 2f41b1d

Please sign in to comment.