Compare commits

..

No commits in common. "5244077144d16cf925c2954e7e72a9b2b7593fb2" and "9a912392bed5ff6367c420e9cc2f5f9ea3a16a01" have entirely different histories.

5 changed files with 12 additions and 76 deletions

9
Cargo.lock generated
View File

@ -241,9 +241,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.20"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "175c513d55719db99da20232b06cda8bab6b83ec2d04e3283edf0213c37c1a29"
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
dependencies = [
"unicode-xid",
]
@ -314,7 +314,6 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "stm32-eth"
version = "0.2.0"
source = "git+https://github.com/stm32-rs/stm32-eth.git#4d6b29bf1ecdd1f68e5bc304a3d4f170049896c8"
dependencies = [
"aligned",
"cortex-m",
@ -354,9 +353,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.40"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"
checksum = "891d8d6567fe7c7f8835a3a98af4208f3846fba258c1bc3c31d6e506239f11f9"
dependencies = [
"proc-macro2",
"quote",

View File

@ -1 +1 @@
"02cxj3iwj6b26r81fmxcmrbj2chd8xp7f9n5qq7l833lxh5rim4p"
"1y1ry0b5wv4jcnh5sijrpd71nqgwgvd5vq4crmb4rmxk21g2vbca"

View File

@ -1,44 +0,0 @@
use stm32f4xx_hal::{
gpio::{
gpiod::{PD9, PD10, PD11},
Output, PushPull,
},
hal::digital::v2::OutputPin,
};
pub struct Leds {
/// Red LED L1
pub r1: Led<PD9<Output<PushPull>>>,
/// Green LED L3
pub g3: Led<PD10<Output<PushPull>>>,
/// Green LED L4
pub g4: Led<PD11<Output<PushPull>>>,
}
impl Leds {
pub fn new<M1, M2, M3>(r1: PD9<M1>, g3: PD10<M2>, g4: PD11<M3>) -> Self {
Leds {
r1: Led::new(r1.into_push_pull_output()),
g3: Led::new(g3.into_push_pull_output()),
g4: Led::new(g4.into_push_pull_output()),
}
}
}
pub struct Led<P> {
pin: P,
}
impl<P: OutputPin> Led<P> {
pub fn new(pin: P) -> Self {
Led { pin }
}
pub fn on(&mut self) {
let _ = self.pin.set_high();
}
pub fn off(&mut self) {
let _ = self.pin.set_low();
}
}

View File

@ -30,7 +30,6 @@ use smoltcp::{
mod init_log;
use init_log::init_log;
mod leds;
mod pins;
use pins::Pins;
mod ad7172;
@ -90,17 +89,12 @@ fn main() -> ! {
timer::setup(cp.SYST, clocks);
let (pins, mut leds, eth_pins) = Pins::setup(
let (pins, eth_pins) = Pins::setup(
clocks, dp.TIM1, dp.TIM3,
dp.GPIOA, dp.GPIOB, dp.GPIOC, dp.GPIOD, dp.GPIOE, dp.GPIOF, dp.GPIOG,
dp.GPIOA, dp.GPIOB, dp.GPIOC, dp.GPIOE, dp.GPIOF, dp.GPIOG,
dp.SPI2, dp.SPI4, dp.SPI5,
dp.ADC1,
);
leds.r1.on();
leds.g3.off();
leds.g4.off();
let mut channels = Channels::new(pins);
channels.calibrate_dac_value(0);
channels.calibrate_dac_value(1);
@ -116,8 +110,6 @@ fn main() -> ! {
net::run(clocks, dp.ETHERNET_MAC, dp.ETHERNET_DMA, eth_pins, hwaddr, |iface| {
Server::<Session>::run(iface, |server| {
leds.r1.off();
loop {
let instant = Instant::from_millis(i64::from(timer::now()));
let updated_channel = channels.poll_adc(instant);
@ -267,13 +259,11 @@ fn main() -> ! {
}
Command::PwmPid { channel } => {
channels.channel_state(channel).pid_engaged = true;
leds.g3.on();
let _ = writeln!(socket, "channel {}: PID enabled to control PWM", channel
);
}
Command::Pwm { channel, pin: PwmPin::ISet, duty } => {
channels.channel_state(channel).pid_engaged = false;
leds.g3.off();
let voltage = Volts(duty);
channels.set_dac(channel, voltage);
let _ = writeln!(
@ -386,7 +376,6 @@ fn main() -> ! {
// Update watchdog
wd.feed();
leds.g4.off();
cortex_m::interrupt::free(|cs| {
if !net::is_pending(cs) {
// Wait for interrupts
@ -394,7 +383,6 @@ fn main() -> ! {
wfi();
}
});
leds.g4.on();
}
});
});

View File

@ -6,7 +6,6 @@ use stm32f4xx_hal::{
gpioa::*,
gpiob::*,
gpioc::*,
gpiod::*,
gpioe::*,
gpiof::*,
gpiog::*,
@ -17,14 +16,11 @@ use stm32f4xx_hal::{
rcc::Clocks,
pwm::{self, PwmChannels},
spi::{Spi, NoMiso},
stm32::{ADC1, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, SPI2, SPI4, SPI5, TIM1, TIM3},
stm32::{ADC1, GPIOA, GPIOB, GPIOC, GPIOE, GPIOF, GPIOG, SPI2, SPI4, SPI5, TIM1, TIM3},
time::U32Ext,
};
use stm32_eth::EthPins;
use crate::{
channel::{Channel0, Channel1},
leds::Leds,
};
use crate::channel::{Channel0, Channel1};
pub type EthernetPins = EthPins<
@ -100,14 +96,13 @@ impl Pins {
pub fn setup(
clocks: Clocks,
tim1: TIM1, tim3: TIM3,
gpioa: GPIOA, gpiob: GPIOB, gpioc: GPIOC, gpiod: GPIOD, gpioe: GPIOE, gpiof: GPIOF, gpiog: GPIOG,
gpioa: GPIOA, gpiob: GPIOB, gpioc: GPIOC, gpioe: GPIOE, gpiof: GPIOF, gpiog: GPIOG,
spi2: SPI2, spi4: SPI4, spi5: SPI5,
adc1: ADC1,
) -> (Self, Leds, EthernetPins) {
) -> (Self, EthernetPins) {
let gpioa = gpioa.split();
let gpiob = gpiob.split();
let gpioc = gpioc.split();
let gpiod = gpiod.split();
let gpioe = gpioe.split();
let gpiof = gpiof.split();
let gpiog = gpiog.split();
@ -172,8 +167,6 @@ impl Pins {
channel1,
};
let leds = Leds::new(gpiod.pd9, gpiod.pd10.into_push_pull_output(), gpiod.pd11.into_push_pull_output());
let eth_pins = EthPins {
ref_clk: gpioa.pa1,
md_io: gpioa.pa2,
@ -186,7 +179,7 @@ impl Pins {
rx_d1: gpioc.pc5,
};
(pins, leds, eth_pins)
(pins, eth_pins)
}
/// Configure the GPIO pins for SPI operation, and initialize SPI