Skip to content

Commit

Permalink
Adjusting to changes in driver
Browse files Browse the repository at this point in the history
  • Loading branch information
playfulFence committed Jan 5, 2024
1 parent 87815e4 commit 153f201
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 34 deletions.
11 changes: 3 additions & 8 deletions esp-hal-common/src/rtc_cntl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ use crate::efuse::Efuse;
use crate::peripherals::{LPWR, TIMG0};
#[cfg(any(esp32c6, esp32h2))]
use crate::peripherals::{LP_TIMER, LP_WDT};
#[cfg(any(esp32, esp32s3, esp32c3))]
#[cfg(any(esp32, esp32s3, esp32c3, esp32c6))]
use crate::rtc_cntl::sleep::{RtcSleepConfig, WakeSource, WakeTriggers};
use crate::{
clock::Clock,
Expand All @@ -95,11 +95,6 @@ use crate::{
#[cfg(any(esp32, esp32s3, esp32c3, esp32c6))]
pub mod sleep;

#[cfg(any(esp32c6, esp32h2))]
type LowPowerDomain = crate::peripherals::LPWR;
#[cfg(not(any(esp32c6, esp32h2)))]
type LowPowerDomain = crate::peripherals::LPWR;

#[cfg_attr(esp32, path = "rtc/esp32.rs")]
#[cfg_attr(esp32c2, path = "rtc/esp32c2.rs")]
#[cfg_attr(esp32c3, path = "rtc/esp32c3.rs")]
Expand Down Expand Up @@ -194,14 +189,14 @@ pub(crate) enum RtcCalSel {

/// Low-power Management
pub struct Rtc<'d> {
_inner: PeripheralRef<'d, LowPowerDomain>,
_inner: PeripheralRef<'d, crate::peripherals::LPWR>,
pub rwdt: Rwdt,
#[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3))]
pub swd: Swd,
}

impl<'d> Rtc<'d> {
pub fn new(rtc_cntl: impl Peripheral<P = LowPowerDomain> + 'd) -> Self {
pub fn new(rtc_cntl: impl Peripheral<P = crate::peripherals::LPWR> + 'd) -> Self {
rtc::init();
rtc::configure_clock();

Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/soc/esp32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! The `SOC` module provides access, functions and structures that are useful
//! for interacting with various system-related peripherals on `ESP32` chip.
use self::peripherals::{RTC_CNTL, TIMG0, TIMG1};
use self::peripherals::{LPWR, TIMG0, TIMG1};
use crate::{timer::Wdt, Rtc};

pub mod cpu_control;
Expand Down Expand Up @@ -74,7 +74,7 @@ pub extern "Rust" fn __init_data() -> bool {
#[export_name = "__post_init"]
unsafe fn post_init() {
// RTC domain must be enabled before we try to disable
let mut rtc = Rtc::new(RTC_CNTL::steal());
let mut rtc = Rtc::new(LPWR::steal());
rtc.rwdt.disable();

Wdt::<TIMG0>::set_wdt_enabled(false);
Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/soc/esp32c2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! The `SOC` module provides access, functions and structures that are useful
//! for interacting with various system-related peripherals on `ESP32-C2` chip.
use self::peripherals::{RTC_CNTL, TIMG0};
use self::peripherals::{LPWR, TIMG0};
use crate::{timer::Wdt, Rtc};

pub mod efuse;
Expand All @@ -25,7 +25,7 @@ pub(crate) mod constants {
#[export_name = "__post_init"]
unsafe fn post_init() {
// RTC domain must be enabled before we try to disable
let mut rtc = Rtc::new(RTC_CNTL::steal());
let mut rtc = Rtc::new(LPWR::steal());
rtc.swd.disable();
rtc.rwdt.disable();

Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/soc/esp32c3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! * I2S_SCLK: 160_000_000 - I2S clock frequency
//! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source
use self::peripherals::{RTC_CNTL, TIMG0, TIMG1};
use self::peripherals::{LPWR, TIMG0, TIMG1};
use crate::{timer::Wdt, Rtc};

pub mod efuse;
Expand Down Expand Up @@ -37,7 +37,7 @@ pub(crate) mod constants {
#[export_name = "__post_init"]
unsafe fn post_init() {
// RTC domain must be enabled before we try to disable
let mut rtc = Rtc::new(RTC_CNTL::steal());
let mut rtc = Rtc::new(LPWR::steal());
rtc.swd.disable();
rtc.rwdt.disable();

Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/soc/esp32c6/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source
//! * I2S_SCLK: 160_000_000 - I2S clock frequency
use self::peripherals::{LP_CLKRST, TIMG0, TIMG1};
use self::peripherals::{LPWR, TIMG0, TIMG1};
use crate::{timer::Wdt, Rtc};

pub mod efuse;
Expand Down Expand Up @@ -43,7 +43,7 @@ pub(crate) mod constants {
#[export_name = "__post_init"]
unsafe fn post_init() {
// RTC domain must be enabled before we try to disable
let mut rtc = Rtc::new(LP_CLKRST::steal());
let mut rtc = Rtc::new(LPWR::steal());
rtc.swd.disable();
rtc.rwdt.disable();

Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/soc/esp32h2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! * I2S_DEFAULT_CLK_SRC: 1 - I2S clock source
//! * I2S_SCLK: 96_000_000 - I2S clock frequency
use self::peripherals::{LP_CLKRST, TIMG0, TIMG1};
use self::peripherals::{LPWR, TIMG0, TIMG1};
use crate::{timer::Wdt, Rtc};

pub mod efuse;
Expand Down Expand Up @@ -42,7 +42,7 @@ pub(crate) mod constants {
#[export_name = "__post_init"]
unsafe fn post_init() {
// RTC domain must be enabled before we try to disable
let mut rtc = Rtc::new(LP_CLKRST::steal());
let mut rtc = Rtc::new(LPWR::steal());
rtc.swd.disable();
rtc.rwdt.disable();

Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/soc/esp32s2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! * I2S_SCLK: 160_000_000 - I2S clock frequency
//! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source
use self::peripherals::{RTC_CNTL, TIMG0, TIMG1};
use self::peripherals::{LPWR, TIMG0, TIMG1};
use crate::{timer::Wdt, Rtc};

pub mod efuse;
Expand Down Expand Up @@ -78,7 +78,7 @@ pub extern "Rust" fn __init_data() -> bool {
#[export_name = "__post_init"]
unsafe fn post_init() {
// RTC domain must be enabled before we try to disable
let mut rtc = Rtc::new(RTC_CNTL::steal());
let mut rtc = Rtc::new(LPWR::steal());
rtc.rwdt.disable();

Wdt::<TIMG0>::set_wdt_enabled(false);
Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/soc/esp32s3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! * I2S_SCLK: 160_000_000 - I2S clock frequency
//! * I2S_DEFAULT_CLK_SRC: 2 - I2S clock source
use self::peripherals::{RTC_CNTL, TIMG0, TIMG1};
use self::peripherals::{LPWR, TIMG0, TIMG1};
use crate::{timer::Wdt, Rtc};

pub mod cpu_control;
Expand Down Expand Up @@ -113,7 +113,7 @@ pub extern "Rust" fn __init_data() -> bool {
#[export_name = "__post_init"]
unsafe fn post_init() {
// RTC domain must be enabled before we try to disable
let mut rtc = Rtc::new(RTC_CNTL::steal());
let mut rtc = Rtc::new(LPWR::steal());
rtc.rwdt.disable();

Wdt::<TIMG0>::set_wdt_enabled(false);
Expand Down
3 changes: 2 additions & 1 deletion esp32c2-hal/examples/rtc_watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use esp32c2_hal::{
interrupt,
peripherals::{self, Peripherals},
prelude::*,
Rtc, Rwdt,
Rtc,
Rwdt,
};
use esp_backtrace as _;

Expand Down
7 changes: 6 additions & 1 deletion esp32c3-hal/examples/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
#![no_main]

use esp32c3_hal::{
clock::ClockControl, macros::ram, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc,
clock::ClockControl,
macros::ram,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
};
use esp_backtrace as _;
use esp_println::println;
Expand Down
3 changes: 2 additions & 1 deletion esp32c3-hal/examples/rtc_watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use esp32c3_hal::{
interrupt,
peripherals::{self, Peripherals},
prelude::*,
Rtc, Rwdt,
Rtc,
Rwdt,
};
use esp_backtrace as _;

Expand Down
4 changes: 3 additions & 1 deletion esp32c3-hal/examples/sleep_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use esp32c3_hal::{
peripherals::Peripherals,
prelude::*,
rtc_cntl::{get_reset_reason, get_wakeup_cause, sleep::TimerWakeupSource, SocResetReason},
Cpu, Delay, Rtc,
Cpu,
Delay,
Rtc,
};
use esp_backtrace as _;
use esp_println::println;
Expand Down
8 changes: 6 additions & 2 deletions esp32c3-hal/examples/sleep_timer_rtcio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ use esp32c3_hal::{
peripherals::Peripherals,
prelude::*,
rtc_cntl::{
get_reset_reason, get_wakeup_cause,
get_reset_reason,
get_wakeup_cause,
sleep::{RtcioWakeupSource, TimerWakeupSource, WakeupLevel},
SocResetReason,
},
Cpu, Delay, Rtc, IO,
Cpu,
Delay,
Rtc,
IO,
};
use esp_backtrace as _;
use esp_println::println;
Expand Down
6 changes: 5 additions & 1 deletion esp32c6-hal/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
use core::fmt::Write;

use esp32c6_hal::{
clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup, Uart,
clock::ClockControl,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Uart,
};
use esp_backtrace as _;
use nb::block;
Expand Down
7 changes: 6 additions & 1 deletion esp32c6-hal/examples/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
#![no_main]

use esp32c6_hal::{
clock::ClockControl, macros::ram, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc,
clock::ClockControl,
macros::ram,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
};
use esp_backtrace as _;
use esp_println::println;
Expand Down
3 changes: 2 additions & 1 deletion esp32c6-hal/examples/rtc_watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use esp32c6_hal::{
interrupt,
peripherals::{self, Peripherals},
prelude::*,
Rtc, Rwdt,
Rtc,
Rwdt,
};
use esp_backtrace as _;

Expand Down
2 changes: 1 addition & 1 deletion esp32c6-hal/examples/sleep_lpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() -> ! {
let system = peripherals.SYSTEM.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let mut rtc = Rtc::new(peripherals.LP_CLKRST);
let mut rtc = Rtc::new(peripherals.LPWR);

let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let mut pin2 = io.pins.gpio2;
Expand Down
7 changes: 6 additions & 1 deletion esp32h2-hal/examples/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
#![no_main]

use esp32h2_hal::{
clock::ClockControl, macros::ram, peripherals::Peripherals, prelude::*, timer::TimerGroup, Rtc,
clock::ClockControl,
macros::ram,
peripherals::Peripherals,
prelude::*,
timer::TimerGroup,
Rtc,
};
use esp_backtrace as _;
use esp_println::println;
Expand Down
3 changes: 2 additions & 1 deletion esp32h2-hal/examples/rtc_watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use esp32h2_hal::{
interrupt,
peripherals::{self, Peripherals},
prelude::*,
Rtc, Rwdt,
Rtc,
Rwdt,
};
use esp_backtrace as _;

Expand Down

0 comments on commit 153f201

Please sign in to comment.