From a4dde1b8ca10e5d726a4f81be3740046cc807c01 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 18 Sep 2020 00:55:53 +0200 Subject: [PATCH] delint --- src/ad7172/adc.rs | 18 ------------------ src/ad7172/mod.rs | 2 -- src/channels.rs | 5 ++--- src/command_parser.rs | 24 ------------------------ src/init_log.rs | 2 +- src/main.rs | 8 +------- src/pins.rs | 2 -- src/usb.rs | 6 +++--- 8 files changed, 7 insertions(+), 60 deletions(-) diff --git a/src/ad7172/adc.rs b/src/ad7172/adc.rs index fcde70e..20bc616 100644 --- a/src/ad7172/adc.rs +++ b/src/ad7172/adc.rs @@ -100,24 +100,6 @@ impl, NSS: OutputPin, E: fmt::Debug> Adc 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 { let offset = self.read_reg(®s::Offset { index })?.offset(); let gain = self.read_reg(®s::Gain { index })?.gain(); diff --git a/src/ad7172/mod.rs b/src/ad7172/mod.rs index 6e6921d..21afe57 100644 --- a/src/ad7172/mod.rs +++ b/src/ad7172/mod.rs @@ -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)] diff --git a/src/channels.rs b/src/channels.rs index 196c927..df53ac2 100644 --- a/src/channels.rs +++ b/src/channels.rs @@ -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; } diff --git a/src/command_parser.rs b/src/command_parser.rs index dbb6ab4..5f8548a 100644 --- a/src/command_parser.rs +++ b/src/command_parser.rs @@ -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> { - 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> { let (input, sign) = opt(is_a("-"))(input)?; let negative = sign.is_some(); diff --git a/src/init_log.rs b/src/init_log.rs index 0935a6b..1ac9fd7 100644 --- a/src/init_log.rs +++ b/src/init_log.rs @@ -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")] diff --git a/src/main.rs b/src/main.rs index 60b058b..ee7cf2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 } => { diff --git a/src/pins.rs b/src/pins.rs index b12813e..52c97ac 100644 --- a/src/pins.rs +++ b/src/pins.rs @@ -6,13 +6,11 @@ use stm32f4xx_hal::{ gpioa::*, gpiob::*, gpioc::*, - gpiod::*, gpioe::*, gpiof::*, gpiog::*, GpioExt, Output, PushPull, - Speed::VeryHigh, }, otg_fs::USB, rcc::Clocks, diff --git a/src/usb.rs b/src/usb.rs index 8166538..b571501 100644 --- a/src/usb.rs +++ b/src/usb.rs @@ -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)