clean up item visibility

* There isn't much API that would only be used accross modules within
  stabilizer/dsp but should not be pub beyond stabilizer/dsp.
* Therefore it's easier to let the definition determine visibility and
  the mod.rs/lib.rs determine location in the namesapce.
* Blanket use pub items in mod and lib.
This commit is contained in:
Robert Jördens 2021-05-17 13:01:45 +02:00
parent 261ed12798
commit e58e7f179e
7 changed files with 48 additions and 91 deletions

38
Cargo.lock generated
View File

@ -208,7 +208,7 @@ dependencies = [
"easybench",
"miniconf",
"ndarray",
"num",
"num-complex",
"rand",
"serde",
]
@ -458,19 +458,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2178127478ae4ee9be7180bc9c3bffb6354dd7238400db567102f98c413a9f35"
[[package]]
name = "num"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
dependencies = [
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.4.0"
@ -478,6 +465,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085"
dependencies = [
"num-traits",
"serde",
]
[[package]]
@ -490,28 +478,6 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"

View File

@ -2,19 +2,18 @@
#![no_std]
#![no_main]
use stabilizer::{hardware, net};
use miniconf::Miniconf;
use serde::Deserialize;
use dsp::iir;
use hardware::{
Adc0Input, Adc1Input, AdcCode, AfeGain, Dac0Output, Dac1Output, DacCode,
DigitalInput0, DigitalInput1, InputPin, SystemTimer, AFE0, AFE1,
use stabilizer::{
hardware::{
hal, setup, Adc0Input, Adc1Input, AdcCode, AfeGain, Dac0Output,
Dac1Output, DacCode, DigitalInput0, DigitalInput1, InputPin,
SystemTimer, AFE0, AFE1,
},
net::{Miniconf, NetworkUsers, Telemetry, TelemetryBuffer, UpdateState},
};
use net::{NetworkUsers, Telemetry, TelemetryBuffer, UpdateState};
const SCALE: f32 = i16::MAX as _;
// The number of cascaded IIR biquads per channel. Select 1 or 2!
@ -50,7 +49,7 @@ impl Default for Settings {
}
}
#[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, monotonic = stabilizer::hardware::SystemTimer)]
#[rtic::app(device = stabilizer::hardware::hal::stm32, peripherals = true, monotonic = stabilizer::hardware::SystemTimer)]
const APP: () = {
struct Resources {
afes: (AFE0, AFE1),
@ -69,7 +68,7 @@ const APP: () = {
#[init(spawn=[telemetry, settings_update])]
fn init(c: init::Context) -> init::LateResources {
// Configure the microcontroller
let (mut stabilizer, _pounder) = hardware::setup(c.core, c.device);
let (mut stabilizer, _pounder) = setup(c.core, c.device);
let network = NetworkUsers::new(
stabilizer.net.stack,
@ -98,7 +97,7 @@ const APP: () = {
dacs: stabilizer.dacs,
network,
digital_inputs: stabilizer.digital_inputs,
telemetry: net::TelemetryBuffer::default(),
telemetry: TelemetryBuffer::default(),
settings: Settings::default(),
}
}
@ -214,7 +213,7 @@ const APP: () = {
#[task(binds = ETH, priority = 1)]
fn eth(_: eth::Context) {
unsafe { stm32h7xx_hal::ethernet::interrupt_handler() }
unsafe { hal::ethernet::interrupt_handler() }
}
#[task(binds = SPI2, priority = 3)]

View File

@ -2,23 +2,18 @@
#![no_std]
#![no_main]
use embedded_hal::digital::v2::InputPin;
use serde::Deserialize;
use dsp::{Accu, Complex, ComplexExt, Lockin, RPLL};
use stabilizer::net;
use stabilizer::hardware::{
design_parameters, setup, Adc0Input, Adc1Input, AdcCode, AfeGain,
Dac0Output, Dac1Output, DacCode, DigitalInput0, DigitalInput1,
InputStamper, SystemTimer, AFE0, AFE1,
use stabilizer::{
hardware::{
design_parameters, hal, setup, Adc0Input, Adc1Input, AdcCode, AfeGain,
Dac0Output, Dac1Output, DacCode, DigitalInput0, DigitalInput1,
InputPin, InputStamper, SystemTimer, AFE0, AFE1,
},
net::{Miniconf, NetworkUsers, Telemetry, TelemetryBuffer, UpdateState},
};
use miniconf::Miniconf;
use net::{NetworkUsers, Telemetry, TelemetryBuffer, UpdateState};
// A constant sinusoid to send on the DAC output.
// Full-scale gives a +/- 10.24V amplitude waveform. Scale it down to give +/- 1V.
const ONE: i16 = ((1.0 / 10.24) * i16::MAX as f32) as _;
@ -78,7 +73,7 @@ impl Default for Settings {
}
}
#[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, monotonic = stabilizer::hardware::SystemTimer)]
#[rtic::app(device = stabilizer::hardware::hal::stm32, peripherals = true, monotonic = stabilizer::hardware::SystemTimer)]
const APP: () = {
struct Resources {
afes: (AFE0, AFE1),
@ -140,7 +135,7 @@ const APP: () = {
network,
digital_inputs: stabilizer.digital_inputs,
timestamper: stabilizer.timestamper,
telemetry: net::TelemetryBuffer::default(),
telemetry: TelemetryBuffer::default(),
settings,
@ -295,7 +290,7 @@ const APP: () = {
#[task(binds = ETH, priority = 1)]
fn eth(_: eth::Context) {
unsafe { stm32h7xx_hal::ethernet::interrupt_handler() }
unsafe { hal::ethernet::interrupt_handler() }
}
#[task(binds = SPI2, priority = 3)]

View File

@ -833,7 +833,7 @@ pub fn setup(
.set_speed(hal::gpio::Speed::VeryHigh);
// Configure the IO_Update signal for the DDS.
let mut hrtimer = pounder::hrtimer::HighResTimerE::new(
let mut hrtimer = pounder::HighResTimerE::new(
device.HRTIM_TIME,
device.HRTIM_MASTER,
device.HRTIM_COMMON,
@ -845,7 +845,7 @@ pub fn setup(
// is triggered after the QSPI write, which can take approximately 120nS, so
// there is additional margin.
hrtimer.configure_single_shot(
pounder::hrtimer::Channel::Two,
pounder::HRTimerChannel::Two,
design_parameters::POUNDER_IO_UPDATE_DURATION,
design_parameters::POUNDER_IO_UPDATE_DELAY,
);

View File

@ -1,5 +1,5 @@
///! Module for all hardware-specific setup of Stabilizer
use stm32h7xx_hal as hal;
pub use stm32h7xx_hal as hal;
// Re-export for the DigitalInputs below:
pub use embedded_hal::digital::v2::InputPin;
@ -16,13 +16,13 @@ pub mod pounder;
mod system_timer;
mod timers;
pub use adc::{Adc0Input, Adc1Input, AdcCode};
pub use afe::Gain as AfeGain;
pub use cycle_counter::CycleCounter;
pub use dac::{Dac0Output, Dac1Output, DacCode};
pub use digital_input_stamper::InputStamper;
pub use pounder::DdsOutput;
pub use system_timer::SystemTimer;
pub use adc::*;
pub use afe::{Gain as AfeGain, *};
pub use cycle_counter::*;
pub use dac::*;
pub use digital_input_stamper::*;
pub use pounder::*;
pub use system_timer::*;
// Type alias for the analog front-end (AFE) for ADC0.
pub type AFE0 = afe::ProgrammableGainAmplifier<

View File

@ -1,21 +1,19 @@
use super::hal;
use embedded_hal::{adc::OneShot, blocking::spi::Transfer};
use serde::{Deserialize, Serialize};
pub mod attenuators;
mod attenuators;
mod dds_output;
pub mod hrtimer;
mod hrtimer;
mod rf_power;
#[cfg(feature = "pounder_v1_1")]
pub mod timestamp;
pub use dds_output::DdsOutput;
use super::hal;
use attenuators::AttenuatorInterface;
use rf_power::PowerMeasurementInterface;
use embedded_hal::{adc::OneShot, blocking::spi::Transfer};
pub use attenuators::*;
pub use dds_output::*;
pub use hrtimer::{Channel as HRTimerChannel, *};
pub use rf_power::*;
const EXT_CLK_SEL_PIN: u8 = 8 + 7;
#[allow(dead_code)]

View File

@ -5,11 +5,10 @@
///! telemetry (via MQTT), configuration of run-time settings (via MQTT + Miniconf), and live data
///! streaming over raw UDP/TCP sockets. This module encompasses the main processing routines
///! related to Stabilizer networking operations.
use heapless::{consts, String};
use miniconf::Miniconf;
use serde::Serialize;
use core::fmt::Write;
use heapless::{consts, String};
pub use miniconf::Miniconf;
use serde::Serialize;
mod messages;
mod miniconf_client;
@ -20,10 +19,10 @@ mod telemetry;
use crate::hardware::{CycleCounter, EthernetPhy, NetworkStack};
use messages::{MqttMessage, SettingsResponse};
pub use miniconf_client::MiniconfClient;
pub use network_processor::NetworkProcessor;
pub use shared::NetworkManager;
pub use telemetry::{Telemetry, TelemetryBuffer, TelemetryClient};
pub use miniconf_client::*;
pub use network_processor::*;
pub use shared::*;
pub use telemetry::*;
pub type NetworkReference = shared::NetworkStackProxy<'static, NetworkStack>;