forked from M-Labs/thermostat
delint
This commit is contained in:
parent
7361619a53
commit
a4dde1b8ca
|
@ -100,24 +100,6 @@ impl<SPI: Transfer<u8, Error = E>, NSS: OutputPin, E: fmt::Debug> Adc<SPI, NSS>
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn disable_channel(
|
||||
&mut self, index: u8
|
||||
) -> Result<(), SPI::Error> {
|
||||
self.update_reg(®s::Channel { index }, |data| {
|
||||
data.set_enabled(false);
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn disable_all_channels(&mut self) -> Result<(), SPI::Error> {
|
||||
for index in 0..4 {
|
||||
self.update_reg(®s::Channel { index }, |data| {
|
||||
data.set_enabled(false);
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_calibration(&mut self, index: u8) -> Result<ChannelCalibration, SPI::Error> {
|
||||
let offset = self.read_reg(®s::Offset { index })?.offset();
|
||||
let gain = self.read_reg(®s::Gain { index })?.gain();
|
||||
|
|
|
@ -19,8 +19,6 @@ pub const SPI_MODE: spi::Mode = spi::Mode {
|
|||
/// 2 MHz
|
||||
pub const SPI_CLOCK: MegaHertz = MegaHertz(2);
|
||||
|
||||
pub const MAX_VALUE: u32 = 0xFF_FFFF;
|
||||
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[repr(u8)]
|
||||
|
|
|
@ -45,8 +45,8 @@ impl Channels {
|
|||
.expect("adc_calibration1");
|
||||
adc.start_continuous_conversion().unwrap();
|
||||
|
||||
let mut channel0 = Channel::new(pins.channel0, adc_calibration0);
|
||||
let mut channel1 = Channel::new(pins.channel1, adc_calibration1);
|
||||
let channel0 = Channel::new(pins.channel0, adc_calibration0);
|
||||
let channel1 = Channel::new(pins.channel1, adc_calibration1);
|
||||
let pins_adc = pins.pins_adc;
|
||||
let pwm = pins.pwm;
|
||||
let mut channels = Channels { channel0, channel1, adc, pins_adc, pwm };
|
||||
|
@ -164,7 +164,6 @@ impl Channels {
|
|||
let mut prev = self.read_dac_feedback(channel);
|
||||
loop {
|
||||
let current = self.read_dac_feedback(channel);
|
||||
use num_traits::float::Float;
|
||||
if (current - prev).abs() < tolerance {
|
||||
return current;
|
||||
}
|
||||
|
|
|
@ -122,17 +122,6 @@ pub enum PwmPin {
|
|||
MaxV,
|
||||
}
|
||||
|
||||
impl PwmPin {
|
||||
pub fn name(&self) -> &'static str {
|
||||
match self {
|
||||
PwmPin::ISet => "i_set",
|
||||
PwmPin::MaxIPos => "max_i_pos",
|
||||
PwmPin::MaxINeg => "max_i_neg",
|
||||
PwmPin::MaxV => "max_v",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Command {
|
||||
Quit,
|
||||
|
@ -178,19 +167,6 @@ fn whitespace(input: &[u8]) -> IResult<&[u8], ()> {
|
|||
fold_many1(char(' '), (), |(), _| ())(input)
|
||||
}
|
||||
|
||||
fn unsigned(input: &[u8]) -> IResult<&[u8], Result<u32, Error>> {
|
||||
take_while1(is_digit)(input)
|
||||
.map(|(input, digits)| {
|
||||
let result =
|
||||
from_utf8(digits)
|
||||
.map_err(|e| e.into())
|
||||
.and_then(|digits| u32::from_str_radix(digits, 10)
|
||||
.map_err(|e| e.into())
|
||||
);
|
||||
(input, result)
|
||||
})
|
||||
}
|
||||
|
||||
fn float(input: &[u8]) -> IResult<&[u8], Result<f64, Error>> {
|
||||
let (input, sign) = opt(is_a("-"))(input)?;
|
||||
let negative = sign.is_some();
|
||||
|
|
|
@ -5,7 +5,7 @@ static USB_LOGGER: usb::Logger = usb::Logger;
|
|||
|
||||
#[cfg(not(feature = "semihosting"))]
|
||||
pub fn init_log() {
|
||||
log::set_logger(&USB_LOGGER);
|
||||
let _ = log::set_logger(&USB_LOGGER);
|
||||
}
|
||||
|
||||
#[cfg(feature = "semihosting")]
|
||||
|
|
|
@ -10,15 +10,11 @@ use panic_semihosting as _;
|
|||
|
||||
use log::{info, warn};
|
||||
|
||||
use core::ops::DerefMut;
|
||||
use core::fmt::Write;
|
||||
use cortex_m::asm::wfi;
|
||||
use cortex_m_rt::entry;
|
||||
use stm32f4xx_hal::{
|
||||
hal::{
|
||||
self,
|
||||
watchdog::{WatchdogEnable, Watchdog},
|
||||
},
|
||||
hal::watchdog::{WatchdogEnable, Watchdog},
|
||||
rcc::RccExt,
|
||||
watchdog::IndependentWatchdog,
|
||||
time::{U32Ext, MegaHertz},
|
||||
|
@ -353,8 +349,6 @@ fn main() -> ! {
|
|||
max.into_format_args(ampere, Abbreviation),
|
||||
);
|
||||
}
|
||||
_ =>
|
||||
unreachable!(),
|
||||
}
|
||||
}
|
||||
Command::Pid { channel, parameter, value } => {
|
||||
|
|
|
@ -6,13 +6,11 @@ use stm32f4xx_hal::{
|
|||
gpioa::*,
|
||||
gpiob::*,
|
||||
gpioc::*,
|
||||
gpiod::*,
|
||||
gpioe::*,
|
||||
gpiof::*,
|
||||
gpiog::*,
|
||||
GpioExt,
|
||||
Output, PushPull,
|
||||
Speed::VeryHigh,
|
||||
},
|
||||
otg_fs::USB,
|
||||
rcc::Clocks,
|
||||
|
|
|
@ -6,10 +6,10 @@ use stm32f4xx_hal::{
|
|||
};
|
||||
use usb_device::{
|
||||
class_prelude::{UsbBusAllocator},
|
||||
prelude::{UsbError, UsbDevice, UsbDeviceBuilder, UsbVidPid},
|
||||
prelude::{UsbDevice, UsbDeviceBuilder, UsbVidPid},
|
||||
};
|
||||
use usbd_serial::SerialPort;
|
||||
use log::{Record, Level, Log, Metadata};
|
||||
use log::{Record, Log, Metadata};
|
||||
|
||||
static mut EP_MEMORY: [u32; 1024] = [0; 1024];
|
||||
|
||||
|
@ -30,7 +30,7 @@ impl State {
|
|||
let serial = SerialPort::new(bus);
|
||||
let dev = UsbDeviceBuilder::new(bus, UsbVidPid(0x16c0, 0x27dd))
|
||||
.manufacturer("M-Labs")
|
||||
.product("thermostat")
|
||||
.product("tecpak")
|
||||
.device_release(0x20)
|
||||
.self_powered(true)
|
||||
.device_class(usbd_serial::USB_CLASS_CDC)
|
||||
|
|
Loading…
Reference in New Issue