Skip to content

Commit

Permalink
Fixup from defaulting to eh1
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Mar 20, 2024
1 parent cc384f1 commit e47a73b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 28 deletions.
3 changes: 3 additions & 0 deletions esp-hal/src/analog/adc/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ impl RegisterAccess for ADC2 {
/// Analog-to-Digital Converter peripheral driver.
pub struct ADC<'d, ADC> {
_adc: PeripheralRef<'d, ADC>,
#[allow(dead_code)] // FIXME
attenuations: [Option<Attenuation>; 10],
#[allow(dead_code)] // FIXME
active_channel: Option<u8>,
}

Expand Down Expand Up @@ -418,6 +420,7 @@ macro_rules! impl_adc_interface {
}

mod adc_implementation {
#[cfg(feature = "embedded-hal-02")]
use crate::peripherals::{ADC1, ADC2};

impl_adc_interface! {
Expand Down
6 changes: 6 additions & 0 deletions esp-hal/src/analog/adc/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,9 @@ impl CalibrationAccess for crate::peripherals::ADC2 {
/// Analog-to-Digital Converter peripheral driver.
pub struct ADC<'d, ADCI> {
_adc: PeripheralRef<'d, ADCI>,
#[allow(dead_code)] // FIXME
attenuations: [Option<Attenuation>; NUM_ATTENS],
#[allow(dead_code)] // FIXME
active_channel: Option<u8>,
}

Expand Down Expand Up @@ -648,6 +650,7 @@ macro_rules! impl_adc_interface {

#[cfg(esp32c2)]
mod adc_implementation {
#[cfg(feature = "embedded-hal-02")]
use crate::peripherals::ADC1;

impl_adc_interface! {
Expand All @@ -663,6 +666,7 @@ mod adc_implementation {

#[cfg(esp32c3)]
mod adc_implementation {
#[cfg(feature = "embedded-hal-02")]
use crate::peripherals::{ADC1, ADC2};

impl_adc_interface! {
Expand All @@ -684,6 +688,7 @@ mod adc_implementation {

#[cfg(esp32c6)]
mod adc_implementation {
#[cfg(feature = "embedded-hal-02")]
use crate::peripherals::ADC1;

impl_adc_interface! {
Expand All @@ -701,6 +706,7 @@ mod adc_implementation {

#[cfg(esp32h2)]
mod adc_implementation {
#[cfg(feature = "embedded-hal-02")]
use crate::peripherals::ADC1;

impl_adc_interface! {
Expand Down
3 changes: 3 additions & 0 deletions esp-hal/src/analog/adc/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ impl CalibrationAccess for crate::peripherals::ADC2 {
/// Analog-to-Digital Converter peripheral driver.
pub struct ADC<'d, ADC> {
_adc: PeripheralRef<'d, ADC>,
#[allow(dead_code)] // FIXME
attenuations: [Option<Attenuation>; 10],
#[allow(dead_code)] // FIXME
active_channel: Option<u8>,
}

Expand Down Expand Up @@ -719,6 +721,7 @@ macro_rules! impl_adc_interface {
}

mod adc_implementation {
#[cfg(feature = "embedded-hal-02")]
use crate::peripherals::{ADC1, ADC2};

impl_adc_interface! {
Expand Down
4 changes: 2 additions & 2 deletions esp-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ where
self.peripheral.master_write_read(address, bytes, buffer)
}

fn transaction<'a>(
fn transaction(
&mut self,
_address: u8,
_operations: &mut [embedded_hal::i2c::Operation<'a>],
_operations: &mut [embedded_hal::i2c::Operation<'_>],
) -> Result<(), Self::Error> {
todo!()
}
Expand Down
4 changes: 3 additions & 1 deletion esp-hal/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
//! rng.read(&mut buffer).unwrap();
//! ```
use core::{convert::Infallible, marker::PhantomData};
#[cfg(feature = "embedded-hal-02")]
use core::convert::Infallible;
use core::marker::PhantomData;

use crate::{peripheral::Peripheral, peripherals::RNG};

Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/rtc_cntl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ impl Rwdt {
self.set_write_protection(true);
}

fn set_timeout(&mut self, timeout: MicrosDurationU64) {
pub fn set_timeout(&mut self, timeout: MicrosDurationU64) {
#[cfg(not(any(esp32c6, esp32h2)))]
let rtc_cntl = unsafe { &*LPWR::PTR };
#[cfg(any(esp32c6, esp32h2))]
Expand Down
42 changes: 20 additions & 22 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1532,29 +1532,27 @@ pub mod dma {
}

fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
Ok(
if !crate::soc::is_valid_ram_address(&words[0] as *const _ as u32) {
for chunk in words.chunks(SIZE) {
self.buffer[..chunk.len()].copy_from_slice(chunk);
self.inner.write(&self.buffer[..chunk.len()])?;
}
} else {
self.inner.write(words)?;
},
)
if !crate::soc::is_valid_ram_address(&words[0] as *const _ as u32) {
for chunk in words.chunks(SIZE) {
self.buffer[..chunk.len()].copy_from_slice(chunk);
self.inner.write(&self.buffer[..chunk.len()])?;
}
} else {
self.inner.write(words)?;
}
Ok(())
}

fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> {
Ok(
if !crate::soc::is_valid_ram_address(&write[0] as *const _ as u32) {
for (read, write) in read.chunks_mut(SIZE).zip(write.chunks(SIZE)) {
self.buffer[..write.len()].copy_from_slice(write);
self.inner.transfer(read, &self.buffer[..write.len()])?;
}
} else {
self.inner.transfer(read, write)?;
},
)
if !crate::soc::is_valid_ram_address(&write[0] as *const _ as u32) {
for (read, write) in read.chunks_mut(SIZE).zip(write.chunks(SIZE)) {
self.buffer[..write.len()].copy_from_slice(write);
self.inner.transfer(read, &self.buffer[..write.len()])?;
}
} else {
self.inner.transfer(read, write)?;
}
Ok(())
}

fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> {
Expand Down Expand Up @@ -1608,9 +1606,9 @@ mod ehal1 {

fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> {
// Optimizations
if read.len() == 0 {
if read.is_empty() {
SpiBus::write(self, write)?;
} else if write.len() == 0 {
} else if write.is_empty() {
SpiBus::read(self, read)?;
}

Expand Down
7 changes: 5 additions & 2 deletions esp-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use core::{
};

use fugit::{HertzU32, MicrosDurationU64};
#[cfg(feature = "embedded-hal-02")]
use void::Void;

#[cfg(timg1)]
Expand Down Expand Up @@ -221,6 +222,7 @@ where
/// General-purpose Timer driver
pub struct Timer<T> {
timg: T,
#[allow(dead_code)] // FIXME
apb_clk_freq: HertzU32,
}

Expand Down Expand Up @@ -638,6 +640,7 @@ where
}
}

#[allow(dead_code)] // FIXME
fn timeout_to_ticks<T, F>(timeout: T, clock: F, divider: u32) -> u64
where
T: Into<MicrosDurationU64>,
Expand Down Expand Up @@ -781,7 +784,7 @@ where
.write(|w| unsafe { w.wdt_wkey().bits(0u32) });
}

fn feed(&mut self) {
pub fn feed(&mut self) {
let reg_block = unsafe { &*TG::register_block() };

reg_block
Expand All @@ -795,7 +798,7 @@ where
.write(|w| unsafe { w.wdt_wkey().bits(0u32) });
}

fn set_timeout(&mut self, timeout: MicrosDurationU64) {
pub fn set_timeout(&mut self, timeout: MicrosDurationU64) {
let timeout_raw = (timeout.to_nanos() * 10 / 125) as u32;

let reg_block = unsafe { &*TG::register_block() };
Expand Down

0 comments on commit e47a73b

Please sign in to comment.