diff --git a/boards/pimoroni-pico-explorer/src/lib.rs b/boards/pimoroni-pico-explorer/src/lib.rs index 9622848..3dbbb6c 100644 --- a/boards/pimoroni-pico-explorer/src/lib.rs +++ b/boards/pimoroni-pico-explorer/src/lib.rs @@ -270,15 +270,7 @@ impl PicoExplorer { pub fn get_adc>(&mut self, channel: &mut Pin) -> f32 { // scale raw 12-bit adc value to 0 .. 1 float let adc_value: u16 = self.adc.read(channel).unwrap(); - let mut result: f32 = f32::from(adc_value) / f32::from(1u16 << 12); - // clamp result to 0 .. 1 - if result > 1.0 { - result = 1.0 - } - - if result < 0.0 { - result = 0.0 - } - result + let result: f32 = f32::from(adc_value) / f32::from(1u16 << 12); + result.clamp(0.0, 1.0) } } diff --git a/boards/rp-pico/examples/pico_rtic_monotonic.rs b/boards/rp-pico/examples/pico_rtic_monotonic.rs index f5922f8..4db5197 100644 --- a/boards/rp-pico/examples/pico_rtic_monotonic.rs +++ b/boards/rp-pico/examples/pico_rtic_monotonic.rs @@ -8,7 +8,6 @@ mod app { use embedded_hal::digital::v2::OutputPin; use fugit::ExtU64; - use fugit::MicrosDurationU32; use rp_pico::{ hal::{ self, @@ -20,8 +19,6 @@ mod app { XOSC_CRYSTAL_FREQ, }; - const SCAN_TIME_US: MicrosDurationU32 = MicrosDurationU32::secs(1); - #[shared] struct Shared { led: hal::gpio::Pin, diff --git a/rp2040-hal/src/pio.rs b/rp2040-hal/src/pio.rs index 2b9e435..541496f 100644 --- a/rp2040-hal/src/pio.rs +++ b/rp2040-hal/src/pio.rs @@ -216,7 +216,7 @@ impl PIO

{ }); self.used_instruction_space |= Self::instruction_mask(p.code.len()) << offset; Ok(InstalledProgram { - offset: offset as u8, + offset, length: p.code.len() as u8, side_set: p.side_set, wrap: p.wrap, @@ -2028,9 +2028,8 @@ impl PIOBuilder

{ w.out_sticky().bit(self.out_sticky); - w.wrap_top().bits(offset as u8 + self.program.wrap.source); - w.wrap_bottom() - .bits(offset as u8 + self.program.wrap.target); + w.wrap_top().bits(offset + self.program.wrap.source); + w.wrap_bottom().bits(offset + self.program.wrap.target); let n = match self.mov_status { MovStatusConfig::Tx(n) => { @@ -2085,7 +2084,7 @@ impl PIOBuilder

{ // to the beginning of the program we loaded in. let instr = InstructionOperands::JMP { condition: pio::JmpCondition::Always, - address: offset as u8, + address: offset, } .encode(); // Safety: Only instance owning the SM diff --git a/rp2040-hal/src/sio.rs b/rp2040-hal/src/sio.rs index 36aa331..873a8b7 100644 --- a/rp2040-hal/src/sio.rs +++ b/rp2040-hal/src/sio.rs @@ -157,7 +157,7 @@ impl SioFifo { // Write the value to the FIFO - the other core will now be able to // pop it off its end of the FIFO. - self.write(value as u32); + self.write(value); // Fire off an event to the other core cortex_m::asm::sev(); diff --git a/rp2040-hal/src/spi.rs b/rp2040-hal/src/spi.rs index 233fb0b..637e4d6 100644 --- a/rp2040-hal/src/spi.rs +++ b/rp2040-hal/src/spi.rs @@ -158,7 +158,7 @@ impl Spi { self.device.reset_bring_up(resets); self.set_baudrate(peri_frequency, baudrate); - self.set_format(DS as u8, mode); + self.set_format(DS, mode); // Always enable DREQ signals -- harmless if DMA is not listening self.device .sspdmacr diff --git a/rp2040-hal/src/uart/peripheral.rs b/rp2040-hal/src/uart/peripheral.rs index b0e5f3b..0ff2502 100644 --- a/rp2040-hal/src/uart/peripheral.rs +++ b/rp2040-hal/src/uart/peripheral.rs @@ -280,7 +280,7 @@ fn configure_baudrate( // First we load the integer part of the divider. device.uartibrd.write(|w| unsafe { - w.baud_divint().bits(baud_div_int as u16); + w.baud_divint().bits(baud_div_int); w }); diff --git a/rp2040-hal/src/usb.rs b/rp2040-hal/src/usb.rs index 0609695..a98ba08 100644 --- a/rp2040-hal/src/usb.rs +++ b/rp2040-hal/src/usb.rs @@ -124,6 +124,7 @@ use usb_device::{ #[cfg(feature = "rp2040-e5")] mod errata5; +#[allow(clippy::bool_to_int_with_if)] fn ep_addr_to_ep_buf_ctrl_idx(ep_addr: EndpointAddress) -> usize { ep_addr.index() * 2 + (if ep_addr.is_in() { 0 } else { 1 }) }