Skip to content

Commit

Permalink
Fix all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Jun 5, 2023
1 parent c765117 commit 5d847d9
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 26 deletions.
8 changes: 1 addition & 7 deletions src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ pub mod config {
}

/// Sets the input type per channel
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Default)]
pub struct DifferentialSelection(pub(crate) u32);
impl DifferentialSelection {
/// Set pin to Single-Ended or Differential
Expand Down Expand Up @@ -602,12 +602,6 @@ pub mod config {
}
}

impl Default for DifferentialSelection {
fn default() -> Self {
DifferentialSelection(0)
}
}

/// Configuration for the adc.
/// There are some additional parameters on the adc peripheral that can be
/// added here when needed but this covers several basic usecases.
Expand Down
1 change: 1 addition & 0 deletions src/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod sealed {
}

/// Select an FDCAN Clock Source
#[allow(clippy::upper_case_acronyms)]
#[allow(dead_code)]
enum FdCanClockSource {
/// Select HSE as the FDCAN clock source
Expand Down
1 change: 1 addition & 0 deletions src/dma/mux.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::upper_case_acronyms)]
pub enum DmaMuxResources {
DMAMUXReqG0 = 1,
DMAMUXReqG1 = 2,
Expand Down
4 changes: 2 additions & 2 deletions src/dma/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ where
{
/// Return the number of elements available to read
pub fn elements_available(&mut self) -> usize {
let blen = unsafe { self.transfer.buf.static_write_buffer().1 } as usize;
let blen = unsafe { self.transfer.buf.static_write_buffer().1 };
let ndtr = STREAM::get_number_of_transfers() as usize;
let pos_at = self.r_pos;

Expand Down Expand Up @@ -341,7 +341,7 @@ where
&mut self,
dat: &mut [<PERIPHERAL as TargetAddress<PeripheralToMemory>>::MemSize],
) -> usize {
let blen = unsafe { self.transfer.buf.static_write_buffer().1 } as usize;
let blen = unsafe { self.transfer.buf.static_write_buffer().1 };
let pos = self.r_pos;
let read = dat.len();

Expand Down
11 changes: 7 additions & 4 deletions src/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<'a, const SECTOR_SZ_KB: u32> FlashWriter<'a, SECTOR_SZ_KB> {
if offset
.checked_add(length as u32)
.ok_or(Error::LengthTooLong)?
> self.flash_sz.kbytes() as u32
> self.flash_sz.kbytes()
{
Err(Error::LengthTooLong)
} else if length & 0x1 != 0 {
Expand All @@ -128,7 +128,7 @@ impl<'a, const SECTOR_SZ_KB: u32> FlashWriter<'a, SECTOR_SZ_KB> {
// Set Page Erase
self.flash.cr.cr().modify(|_, w| w.per().set_bit());

let page = start_offset / (SECTOR_SZ_KB as u32);
let page = start_offset / SECTOR_SZ_KB;

// Write address bits
// NOTE(unsafe) This sets the page address in the Address Register.
Expand Down Expand Up @@ -170,7 +170,7 @@ impl<'a, const SECTOR_SZ_KB: u32> FlashWriter<'a, SECTOR_SZ_KB> {
let size = SECTOR_SZ_KB;
let start = start_offset & !(size - 1);
for idx in (start..start + size).step_by(2) {
let write_address = (FLASH_START + idx as u32) as *const u16;
let write_address = (FLASH_START + idx) as *const u16;
let verify: u16 = unsafe { core::ptr::read_volatile(write_address) };
if verify != 0xFFFF {
return Err(Error::VerifyError);
Expand Down Expand Up @@ -201,7 +201,7 @@ impl<'a, const SECTOR_SZ_KB: u32> FlashWriter<'a, SECTOR_SZ_KB> {
pub fn read(&self, offset: u32, length: usize) -> Result<&[u8]> {
self.valid_address(offset)?;

if offset + length as u32 > self.flash_sz.kbytes() as u32 {
if offset + length as u32 > self.flash_sz.kbytes() {
return Err(Error::LengthTooLong);
}

Expand Down Expand Up @@ -324,6 +324,7 @@ pub struct Parts {
pub(crate) cr: CR,

/// Opaque ECCR register
#[allow(unused)]
pub(crate) eccr: ECCR,

/// Opaque KEYR register
Expand All @@ -342,9 +343,11 @@ pub struct Parts {
pub(crate) _pcrop1er: PCROP1ER,

/// Opaque PDKEYR register
#[allow(unused)]
pub(crate) pdkeyr: PDKEYR,

/// Opaque SEC1R register
#[allow(unused)]
pub(crate) sec1r: SEC1R,

/// Opaque SR register
Expand Down
2 changes: 1 addition & 1 deletion src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ fn calculate_deadtime(base_freq: Hertz, deadtime: NanoSecond) -> (u8, u8) {
let deadtime_ticks = deadtime_ticks as u64 * 429497;
let deadtime_ticks = (deadtime_ticks >> 32) as u32;

let deadtime_ticks = deadtime_ticks as u32;
let deadtime_ticks = deadtime_ticks;

// Choose CR1 CKD divider of 1, 2, or 4 to determine tDTS
let (deadtime_ticks, ckd) = match deadtime_ticks {
Expand Down
20 changes: 10 additions & 10 deletions src/rcc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ pub enum PllMDiv {

impl PllMDiv {
pub fn divisor(&self) -> u32 {
(self.clone() as u32) + 1
(*self as u32) + 1
}

pub fn register_setting(&self) -> u8 {
self.clone() as u8
*self as u8
}
}

Expand All @@ -90,11 +90,11 @@ pub enum PllQDiv {

impl PllQDiv {
pub fn divisor(&self) -> u32 {
((self.clone() as u32) + 1) * 2
((*self as u32) + 1) * 2
}

pub fn register_setting(&self) -> u8 {
self.clone() as u8
*self as u8
}
}

Expand All @@ -109,11 +109,11 @@ pub enum PllRDiv {

impl PllRDiv {
pub fn divisor(&self) -> u32 {
((self.clone() as u32) + 1) * 2
((*self as u32) + 1) * 2
}

pub fn register_setting(&self) -> u8 {
self.clone() as u8
*self as u8
}
}

Expand Down Expand Up @@ -158,11 +158,11 @@ pub enum PllPDiv {

impl PllPDiv {
pub fn divisor(&self) -> u32 {
self.clone() as u32
*self as u32
}

pub fn register_setting(&self) -> u8 {
self.clone() as u8
*self as u8
}
}

Expand Down Expand Up @@ -293,11 +293,11 @@ pub enum PllNMul {

impl PllNMul {
pub fn multiplier(&self) -> u32 {
self.clone() as u32
*self as u32
}

pub fn register_setting(&self) -> u8 {
self.clone() as u8
*self as u8
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/rcc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ impl AHB1 {
fn rstr(rcc: &RccRB) -> &rcc::AHB1RSTR {
&rcc.ahb1rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::AHB1SMENR {
&rcc.ahb1smenr
Expand All @@ -346,6 +347,7 @@ impl AHB2 {
fn rstr(rcc: &RccRB) -> &rcc::AHB2RSTR {
&rcc.ahb2rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::AHB2SMENR {
&rcc.ahb2smenr
Expand All @@ -364,6 +366,7 @@ impl AHB3 {
fn rstr(rcc: &RccRB) -> &rcc::AHB3RSTR {
&rcc.ahb3rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::AHB3SMENR {
&rcc.ahb3smenr
Expand All @@ -382,6 +385,7 @@ impl APB1_1 {
fn rstr(rcc: &RccRB) -> &rcc::APB1RSTR1 {
&rcc.apb1rstr1
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::APB1SMENR1 {
&rcc.apb1smenr1
Expand All @@ -400,6 +404,7 @@ impl APB1_2 {
fn rstr(rcc: &RccRB) -> &rcc::APB1RSTR2 {
&rcc.apb1rstr2
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::APB1SMENR2 {
&rcc.apb1smenr2
Expand All @@ -418,6 +423,7 @@ impl APB2 {
fn rstr(rcc: &RccRB) -> &rcc::APB2RSTR {
&rcc.apb2rstr
}
#[allow(unused)]
#[inline(always)]
fn smenr(rcc: &RccRB) -> &rcc::APB2SMENR {
&rcc.apb2smenr
Expand Down
5 changes: 3 additions & 2 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ impl MonoTimer {
dwt.enable_cycle_counter();

// now the CYCCNT counter can't be stopped or reset
#[allow(clippy::drop_non_drop)]
drop(dwt);

MonoTimer {
Expand All @@ -158,7 +159,7 @@ impl MonoTimer {
/// Returns an `Instant` corresponding to "now"
pub fn now(self) -> Instant {
Instant {
now: DWT::get_cycle_count(),
now: DWT::cycle_count(),
}
}
}
Expand All @@ -172,7 +173,7 @@ pub struct Instant {
impl Instant {
/// Ticks elapsed since the `Instant` was created
pub fn elapsed(self) -> u32 {
DWT::get_cycle_count().wrapping_sub(self.now)
DWT::cycle_count().wrapping_sub(self.now)
}
}

Expand Down

0 comments on commit 5d847d9

Please sign in to comment.