Skip to content

Commit

Permalink
Clean up passing clocks to drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Aug 27, 2024
1 parent 560dde6 commit c6d6ea3
Show file tree
Hide file tree
Showing 150 changed files with 660 additions and 818 deletions.
8 changes: 4 additions & 4 deletions esp-hal-embassy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ impl<const N: usize> TimerCollection for &'static mut [Timer; N] {
#[doc = esp_hal::before_snippet!()]
/// use esp_hal::timg::TimerGroup;
///
/// let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks);
/// esp_hal_embassy::init(&clocks, timg0.timer0);
/// let timg0 = TimerGroup::new(peripherals.TIMG0);
/// esp_hal_embassy::init(timg0.timer0);
///
/// // ... now you can spawn embassy tasks or use `Timer::after` etc.
/// # }
/// ```
pub fn init(clocks: &Clocks, time_driver: impl TimerCollection) {
EmbassyTimer::init(clocks, time_driver.timers())
pub fn init(time_driver: impl TimerCollection) {
EmbassyTimer::init(time_driver.timers())
}
2 changes: 1 addition & 1 deletion esp-hal-embassy/src/time_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ embassy_time_driver::time_driver_impl!(static DRIVER: EmbassyTimer = EmbassyTime
});

impl EmbassyTimer {
pub(super) fn init(_clocks: &Clocks, timers: &'static mut [Timer]) {
pub(super) fn init(timers: &'static mut [Timer]) {
if timers.len() > MAX_SUPPORTED_ALARM_COUNT {
panic!(
"Maximum of {} timers can be used.",
Expand Down
10 changes: 6 additions & 4 deletions esp-hal-smartled/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
//!
//! ```rust,ignore
//! let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
//! let rmt = Rmt::new(peripherals.RMT, 80.MHz(), &clocks, None).unwrap();
//! let rmt = Rmt::new(peripherals.RMT, 80.MHz(), None).unwrap();
//!
//! let rmt_buffer = smartLedBuffer!(1);
//! let mut led = SmartLedsAdapter::new(rmt.channel0, io.pins.gpio2, rmt_buffer, &clocks);
//! let mut led = SmartLedsAdapter::new(rmt.channel0, io.pins.gpio2, rmt_buffer);
//! ```
//!
//! ## Feature Flags
Expand Down Expand Up @@ -89,7 +89,6 @@ where
channel: C,
pin: impl Peripheral<P = O> + 'd,
rmt_buffer: [u32; BUFFER_SIZE],
clocks: &Clocks,
) -> SmartLedsAdapter<TX, BUFFER_SIZE>
where
O: OutputPin + 'd,
Expand All @@ -107,7 +106,10 @@ where
let channel = channel.configure(pin, config).unwrap();

// Assume the RMT peripheral is set up to use the APB clock
let src_clock = clocks.apb_clock.to_MHz();
let src_clock = critical_section::with(|cs| {
let clocks = Clocks::get(cs);
clocks.apb_clock.to_MHz();
});

Self {
channel: Some(channel),
Expand Down
1 change: 1 addition & 0 deletions esp-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ defmt = [
"esp32h2?/defmt",
"esp32s2?/defmt",
"esp32s3?/defmt",
"fugit/defmt",
]
## Implement the traits defined in the `1.0.0` releases of `embedded-hal` and
## `embedded-hal-nb` for the relevant peripherals.
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/doc-helper/before
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# loop {}
# }
# fn main() {
# let (peripherals, clocks) = esp_hal::init(Config::default());
# let peripherals = esp_hal::init(Config::default());
2 changes: 1 addition & 1 deletion esp-hal/src/analog/adc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
//! );
//! let mut adc1 = Adc::new(peripherals.ADC1, adc1_config);
//!
//! let mut delay = Delay::new(&clocks);
//! let mut delay = Delay::new();
//!
//! loop {
//! let pin_value: u16 = nb::block!(adc1.read_oneshot(&mut pin)).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/analog/dac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#![cfg_attr(esp32s2, doc = "let dac1_pin = io.pins.gpio17;")]
//! let mut dac1 = Dac::new(peripherals.DAC1, dac1_pin);
//!
//! let mut delay = Delay::new(&clocks);
//! let mut delay = Delay::new();
//!
//! let mut voltage_dac1 = 200u8;
//!
Expand Down
Loading

0 comments on commit c6d6ea3

Please sign in to comment.