Fix mutability assumptions of RTC_CNTL for ESP32C3

This commit is contained in:
Robert Wiewel 2022-02-25 23:27:35 +01:00
parent f2884bd3b8
commit fe03af805b
4 changed files with 7 additions and 7 deletions

View File

@ -11,7 +11,7 @@ fn main() -> ! {
// Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT,
// the RTC WDT, and the TIMG WDTs.
let rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut timer0 = Timer::new(peripherals.TIMG0);
let mut timer1 = Timer::new(peripherals.TIMG1);

View File

@ -33,7 +33,7 @@ fn main() -> ! {
// Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT,
// the RTC WDT, and the TIMG WDTs.
let rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut timer0 = Timer::new(peripherals.TIMG0);
let mut timer1 = Timer::new(peripherals.TIMG1);
let serial0 = Serial::new(peripherals.UART0).unwrap();

View File

@ -12,7 +12,7 @@ use riscv_rt::entry;
fn main() -> ! {
let peripherals = Peripherals::take().unwrap();
let rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL);
let mut serial0 = Serial::new(peripherals.UART0).unwrap();
let mut timer0 = Timer::new(peripherals.TIMG0);
let mut timer1 = Timer::new(peripherals.TIMG1);

View File

@ -9,7 +9,7 @@ impl RtcCntl {
Self { rtc_cntl }
}
pub fn set_super_wdt_enable(&self, enable: bool) {
pub fn set_super_wdt_enable(&mut self, enable: bool) {
self.set_swd_write_protection(false);
self.rtc_cntl
@ -19,7 +19,7 @@ impl RtcCntl {
self.set_swd_write_protection(true);
}
fn set_swd_write_protection(&self, enable: bool) {
fn set_swd_write_protection(&mut self, enable: bool) {
let wkey = if enable { 0u32 } else { 0x8F1D_312A };
self.rtc_cntl
@ -27,7 +27,7 @@ impl RtcCntl {
.write(|w| unsafe { w.swd_wkey().bits(wkey) });
}
pub fn set_wdt_enable(&self, enable: bool) {
pub fn set_wdt_enable(&mut self, enable: bool) {
self.set_wdt_write_protection(false);
if !enable {
@ -41,7 +41,7 @@ impl RtcCntl {
self.set_wdt_write_protection(true);
}
fn set_wdt_write_protection(&self, enable: bool) {
fn set_wdt_write_protection(&mut self, enable: bool) {
let wkey = if enable { 0u32 } else { 0x50D8_3AA1 };
self.rtc_cntl