From 0b4f7c9201404fe6a0dc8fd9e8d6a5507e4c7c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Mon, 11 Nov 2019 12:04:50 +0100 Subject: [PATCH] remove unused code, deny warnings --- src/eeprom.rs | 13 ------------- src/eth.rs | 18 ------------------ src/i2c.rs | 39 --------------------------------------- src/iir.rs | 1 - src/main.rs | 4 +++- 5 files changed, 3 insertions(+), 72 deletions(-) diff --git a/src/eeprom.rs b/src/eeprom.rs index 5f54d1f..70cb3cf 100644 --- a/src/eeprom.rs +++ b/src/eeprom.rs @@ -8,16 +8,3 @@ pub fn read_eui48<'a>(i2c: &pac::I2C2) -> Result<[u8; 6], i2c::Error> { i2c::write_read(i2c, I2C_ADDR, &[0xFAu8], &mut buffer)?; Ok(buffer) } - -pub fn read(i2c: &pac::I2C2, addr: u8, mut buffer: &mut [u8]) -> Result<(), i2c::Error> { - i2c::write_read(i2c, I2C_ADDR, &[addr], &mut buffer)?; - Ok(()) -} - -pub fn write(i2c: &pac::I2C2, addr: u8, buffer: &[u8]) -> Result<(), i2c::Error> { - for (i, &byte) in buffer.iter().enumerate() { - i2c::write(i2c, I2C_ADDR, &[addr+i as u8, byte])?; - } - - Ok(()) -} diff --git a/src/eth.rs b/src/eth.rs index 1ddd1c8..603dc40 100644 --- a/src/eth.rs +++ b/src/eth.rs @@ -557,21 +557,3 @@ impl<'a> phy::TxToken for TxToken<'a> { result } } - -pub unsafe fn interrupt_handler(eth_dma: &pac::ETHERNET_DMA) { - eth_dma.dmacsr.write(|w| - w - .nis().set_bit() - .ri().set_bit() - .ti().set_bit() - ); -} - -pub unsafe fn enable_interrupt(eth_dma: &pac::ETHERNET_DMA) { - eth_dma.dmacier.modify(|_, w| - w - .nie().set_bit() - .rie().set_bit() - .tie().set_bit() - ); -} diff --git a/src/i2c.rs b/src/i2c.rs index e6c0266..bf508e2 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -109,25 +109,6 @@ fn poll_for_start_ack( } -pub fn write( - i2c: &pac::I2C2, - addr: u8, - bytes: &[u8] -) -> Result<(), Error> { - assert!(bytes.len() < 256 && bytes.len() > 0); - - poll_for_start_ack(i2c, addr|0, false, bytes.len(), true, true)?; - - for byte in bytes { - busy_wait_errors!(i2c, txis); - i2c.txdr.write(|w| w.txdata().bits(*byte)); - } - // automatic STOP - - Ok(()) -} - - pub fn write_read( i2c: &pac::I2C2, addr: u8, @@ -160,23 +141,3 @@ pub fn write_read( // automatic STOP Ok(()) } - - -pub fn read( - i2c: &pac::I2C2, - addr: u8, - buffer: &mut [u8], -) -> Result<(), Error> { - assert!(buffer.len() < 256 && buffer.len() > 0); - - poll_for_start_ack(i2c, addr|0, true, buffer.len(), true, true)?; - - for byte in buffer { - // Wait until we have received something - busy_wait_errors!(i2c, rxne); - *byte = i2c.rxdr.read().rxdata().bits(); - } - - // automatic STOP - Ok(()) -} diff --git a/src/iir.rs b/src/iir.rs index 344028f..85c3787 100644 --- a/src/iir.rs +++ b/src/iir.rs @@ -39,7 +39,6 @@ fn macc(y0: T, x: &[T], a: &[T]) -> T x.iter().zip(a.iter()).map(|(&i, &j)| i * j).fold(y0, |y, xa| y + xa) } -#[allow(unused)] impl IIR { pub fn set_pi(&mut self, kp: f32, ki: f32, g: f32) -> Result<(), &str> { let ki = copysign(ki, kp); diff --git a/src/main.rs b/src/main.rs index 96ad21e..1995992 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![deny(warnings)] + #![no_std] #![no_main] #![cfg_attr(feature = "nightly", feature(asm))] @@ -41,7 +43,7 @@ mod eth; mod iir; use iir::*; -pub mod i2c; +mod i2c; mod eeprom; #[cfg(not(feature = "semihosting"))]