mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-03 15:15:01 +00:00
Reformat code
This commit is contained in:
parent
b3e8f930cf
commit
72913a6e50
@ -219,13 +219,13 @@ type System = crate::pac::DPORT;
|
|||||||
#[cfg(not(feature = "esp32"))]
|
#[cfg(not(feature = "esp32"))]
|
||||||
type System = crate::pac::SYSTEM;
|
type System = crate::pac::SYSTEM;
|
||||||
|
|
||||||
|
|
||||||
impl<T> I2C<T>
|
impl<T> I2C<T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
/// Create a new I2C instance
|
/// Create a new I2C instance
|
||||||
/// This will enable the peripheral but the periphal won't get automatically disabled when this gets dropped.
|
/// This will enable the peripheral but the periphal won't get automatically
|
||||||
|
/// disabled when this gets dropped.
|
||||||
pub fn new<
|
pub fn new<
|
||||||
SDA: OutputPin<OutputSignal = OutputSignal> + InputPin<InputSignal = InputSignal>,
|
SDA: OutputPin<OutputSignal = OutputSignal> + InputPin<InputSignal = InputSignal>,
|
||||||
SCL: OutputPin<OutputSignal = OutputSignal> + InputPin<InputSignal = InputSignal>,
|
SCL: OutputPin<OutputSignal = OutputSignal> + InputPin<InputSignal = InputSignal>,
|
||||||
@ -275,7 +275,7 @@ fn enable_peripheral<T: Instance>(i2c: &T, system: &mut System) {
|
|||||||
system
|
system
|
||||||
.perip_rst_en
|
.perip_rst_en
|
||||||
.modify(|_, w| w.i2c0_ext0_rst().clear_bit());
|
.modify(|_, w| w.i2c0_ext0_rst().clear_bit());
|
||||||
},
|
}
|
||||||
1 => {
|
1 => {
|
||||||
system
|
system
|
||||||
.perip_clk_en
|
.perip_clk_en
|
||||||
@ -283,7 +283,7 @@ fn enable_peripheral<T: Instance>(i2c: &T, system: &mut System) {
|
|||||||
system
|
system
|
||||||
.perip_rst_en
|
.perip_rst_en
|
||||||
.modify(|_, w| w.i2c_ext1_rst().clear_bit());
|
.modify(|_, w| w.i2c_ext1_rst().clear_bit());
|
||||||
},
|
}
|
||||||
_ => panic!(), // will never happen
|
_ => panic!(), // will never happen
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "esp32"))]
|
#[cfg(not(feature = "esp32"))]
|
||||||
@ -298,7 +298,7 @@ fn enable_peripheral<T: Instance>(i2c: &T, system: &mut System) {
|
|||||||
system
|
system
|
||||||
.perip_rst_en0
|
.perip_rst_en0
|
||||||
.modify(|_, w| w.i2c_ext0_rst().clear_bit());
|
.modify(|_, w| w.i2c_ext0_rst().clear_bit());
|
||||||
},
|
}
|
||||||
1 => {
|
1 => {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(not(feature = "esp32c3"))] {
|
if #[cfg(not(feature = "esp32c3"))] {
|
||||||
@ -316,7 +316,7 @@ fn enable_peripheral<T: Instance>(i2c: &T, system: &mut System) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => panic!(), // will never happen
|
_ => panic!(), // will never happen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,10 +353,9 @@ pub trait Instance {
|
|||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(feature = "esp32s2")]
|
#[cfg(feature = "esp32s2")]
|
||||||
self.register_block().ctr.modify(|_, w|
|
self.register_block()
|
||||||
w.ref_always_on()
|
.ctr
|
||||||
.set_bit()
|
.modify(|_, w| w.ref_always_on().set_bit());
|
||||||
);
|
|
||||||
|
|
||||||
// Configure filter
|
// Configure filter
|
||||||
self.set_filter(Some(7), Some(7));
|
self.set_filter(Some(7), Some(7));
|
||||||
@ -533,10 +532,9 @@ pub trait Instance {
|
|||||||
|
|
||||||
// we already did that above but on S2 we need this to make it work
|
// we already did that above but on S2 we need this to make it work
|
||||||
#[cfg(feature = "esp32s2")]
|
#[cfg(feature = "esp32s2")]
|
||||||
self.register_block().scl_high_period.write(|w| {
|
self.register_block()
|
||||||
w.scl_wait_high_period()
|
.scl_high_period
|
||||||
.bits(scl_wait_high)
|
.write(|w| w.scl_wait_high_period().bits(scl_wait_high));
|
||||||
});
|
|
||||||
|
|
||||||
// sda sample
|
// sda sample
|
||||||
self.register_block()
|
self.register_block()
|
||||||
@ -908,10 +906,8 @@ fn read_fifo(register_block: &RegisterBlock) -> u8 {
|
|||||||
0x6001301c
|
0x6001301c
|
||||||
} else {
|
} else {
|
||||||
0x6002701c
|
0x6002701c
|
||||||
}) as *mut u32;
|
}) as *mut u32;
|
||||||
unsafe {
|
unsafe { (fifo_ptr.read() & 0xff) as u8 }
|
||||||
(fifo_ptr.read() & 0xff) as u8
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "esp32")]
|
#[cfg(feature = "esp32")]
|
||||||
|
@ -18,7 +18,9 @@ impl RtcCntl {
|
|||||||
/// Global switch for RTC_CNTL watchdog functionality
|
/// Global switch for RTC_CNTL watchdog functionality
|
||||||
pub fn set_wdt_global_enable(&mut self, enable: bool) {
|
pub fn set_wdt_global_enable(&mut self, enable: bool) {
|
||||||
self.set_wdt_write_protection(false);
|
self.set_wdt_write_protection(false);
|
||||||
self.rtc_cntl.wdtconfig0.modify(|_, w| w.wdt_en().bit(enable).wdt_flashboot_mod_en().clear_bit());
|
self.rtc_cntl
|
||||||
|
.wdtconfig0
|
||||||
|
.modify(|_, w| w.wdt_en().bit(enable).wdt_flashboot_mod_en().clear_bit());
|
||||||
self.set_wdt_write_protection(true);
|
self.set_wdt_write_protection(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user