STM32: combine RccPeripherals reset() and enable() to reset_and_enable()
This commit is contained in:
parent
eb368f77a4
commit
f65a96c541
@ -559,6 +559,7 @@ fn main() {
|
|||||||
fn enable() {
|
fn enable() {
|
||||||
critical_section::with(|_cs| {
|
critical_section::with(|_cs| {
|
||||||
#before_enable
|
#before_enable
|
||||||
|
#rst
|
||||||
#[cfg(feature = "low-power")]
|
#[cfg(feature = "low-power")]
|
||||||
crate::rcc::clock_refcount_add(_cs);
|
crate::rcc::clock_refcount_add(_cs);
|
||||||
crate::pac::RCC.#en_reg().modify(|w| w.#set_en_field(true));
|
crate::pac::RCC.#en_reg().modify(|w| w.#set_en_field(true));
|
||||||
@ -573,9 +574,6 @@ fn main() {
|
|||||||
crate::rcc::clock_refcount_sub(_cs);
|
crate::rcc::clock_refcount_sub(_cs);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn reset() {
|
|
||||||
#rst
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::rcc::RccPeripheral for peripherals::#pname {}
|
impl crate::rcc::RccPeripheral for peripherals::#pname {}
|
||||||
|
@ -51,8 +51,7 @@ impl<T: Instance> super::sealed::AdcPin<T> for Temperature {
|
|||||||
impl<'d, T: Instance> Adc<'d, T> {
|
impl<'d, T: Instance> Adc<'d, T> {
|
||||||
pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
|
pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
|
||||||
into_ref!(adc);
|
into_ref!(adc);
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
T::regs().cr2().modify(|reg| reg.set_adon(true));
|
T::regs().cr2().modify(|reg| reg.set_adon(true));
|
||||||
|
|
||||||
// 11.4: Before starting a calibration, the ADC must have been in power-on state (ADON bit = ‘1’)
|
// 11.4: Before starting a calibration, the ADC must have been in power-on state (ADON bit = ‘1’)
|
||||||
|
@ -64,8 +64,7 @@ impl<'d, T: Instance> Adc<'d, T> {
|
|||||||
|
|
||||||
into_ref!(adc);
|
into_ref!(adc);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
// Enable the adc regulator
|
// Enable the adc regulator
|
||||||
T::regs().cr().modify(|w| w.set_advregen(vals::Advregen::INTERMEDIATE));
|
T::regs().cr().modify(|w| w.set_advregen(vals::Advregen::INTERMEDIATE));
|
||||||
|
@ -61,8 +61,7 @@ impl<'d, T: Instance> Adc<'d, T> {
|
|||||||
delay: &mut impl DelayUs<u32>,
|
delay: &mut impl DelayUs<u32>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
into_ref!(adc);
|
into_ref!(adc);
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
// Delay 1μs when using HSI14 as the ADC clock.
|
// Delay 1μs when using HSI14 as the ADC clock.
|
||||||
//
|
//
|
||||||
|
@ -95,8 +95,7 @@ where
|
|||||||
{
|
{
|
||||||
pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
|
pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
|
||||||
into_ref!(adc);
|
into_ref!(adc);
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
let presc = Prescaler::from_pclk2(T::frequency());
|
let presc = Prescaler::from_pclk2(T::frequency());
|
||||||
T::common_regs().ccr().modify(|w| w.set_adcpre(presc.adcpre()));
|
T::common_regs().ccr().modify(|w| w.set_adcpre(presc.adcpre()));
|
||||||
|
@ -127,8 +127,7 @@ impl Prescaler {
|
|||||||
impl<'d, T: Instance> Adc<'d, T> {
|
impl<'d, T: Instance> Adc<'d, T> {
|
||||||
pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u16>) -> Self {
|
pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u16>) -> Self {
|
||||||
embassy_hal_internal::into_ref!(adc);
|
embassy_hal_internal::into_ref!(adc);
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
let prescaler = Prescaler::from_ker_ck(T::frequency());
|
let prescaler = Prescaler::from_ker_ck(T::frequency());
|
||||||
|
|
||||||
|
@ -136,8 +136,7 @@ impl<'d, T: Instance> Can<'d, T> {
|
|||||||
rx.set_as_af(rx.af_num(), AFType::Input);
|
rx.set_as_af(rx.af_num(), AFType::Input);
|
||||||
tx.set_as_af(tx.af_num(), AFType::OutputPushPull);
|
tx.set_as_af(tx.af_num(), AFType::OutputPushPull);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
use crate::pac::can::vals::{Errie, Fmpie, Tmeie};
|
use crate::pac::can::vals::{Errie, Fmpie, Tmeie};
|
||||||
|
@ -16,9 +16,7 @@ impl<'d> Crc<'d> {
|
|||||||
|
|
||||||
// Note: enable and reset come from RccPeripheral.
|
// Note: enable and reset come from RccPeripheral.
|
||||||
// enable CRC clock in RCC.
|
// enable CRC clock in RCC.
|
||||||
CRC::enable();
|
CRC::reset_and_enable();
|
||||||
// Reset CRC to default values.
|
|
||||||
CRC::reset();
|
|
||||||
// Peripheral the peripheral
|
// Peripheral the peripheral
|
||||||
let mut instance = Self { _peri: peripheral };
|
let mut instance = Self { _peri: peripheral };
|
||||||
instance.reset();
|
instance.reset();
|
||||||
|
@ -69,16 +69,13 @@ impl<'d> Crc<'d> {
|
|||||||
/// Instantiates the CRC32 peripheral and initializes it to default values.
|
/// Instantiates the CRC32 peripheral and initializes it to default values.
|
||||||
pub fn new(peripheral: impl Peripheral<P = CRC> + 'd, config: Config) -> Self {
|
pub fn new(peripheral: impl Peripheral<P = CRC> + 'd, config: Config) -> Self {
|
||||||
// Note: enable and reset come from RccPeripheral.
|
// Note: enable and reset come from RccPeripheral.
|
||||||
// enable CRC clock in RCC.
|
// reset to default values and enable CRC clock in RCC.
|
||||||
CRC::enable();
|
CRC::reset_and_enable();
|
||||||
// Reset CRC to default values.
|
|
||||||
CRC::reset();
|
|
||||||
into_ref!(peripheral);
|
into_ref!(peripheral);
|
||||||
let mut instance = Self {
|
let mut instance = Self {
|
||||||
_peripheral: peripheral,
|
_peripheral: peripheral,
|
||||||
_config: config,
|
_config: config,
|
||||||
};
|
};
|
||||||
CRC::reset();
|
|
||||||
instance.reconfigure();
|
instance.reconfigure();
|
||||||
instance.reset();
|
instance.reset();
|
||||||
instance
|
instance
|
||||||
|
@ -255,8 +255,7 @@ impl<'d, T: Instance, Tx> DacCh1<'d, T, Tx> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
pin.set_as_analog();
|
pin.set_as_analog();
|
||||||
into_ref!(peri, dma);
|
into_ref!(peri, dma);
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
let mut dac = Self { _peri: peri, dma };
|
let mut dac = Self { _peri: peri, dma };
|
||||||
|
|
||||||
@ -366,8 +365,7 @@ impl<'d, T: Instance, Tx> DacCh2<'d, T, Tx> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
pin.set_as_analog();
|
pin.set_as_analog();
|
||||||
into_ref!(_peri, dma);
|
into_ref!(_peri, dma);
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
let mut dac = Self {
|
let mut dac = Self {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
@ -483,8 +481,7 @@ impl<'d, T: Instance, TxCh1, TxCh2> Dac<'d, T, TxCh1, TxCh2> {
|
|||||||
pin_ch1.set_as_analog();
|
pin_ch1.set_as_analog();
|
||||||
pin_ch2.set_as_analog();
|
pin_ch2.set_as_analog();
|
||||||
into_ref!(peri, dma_ch1, dma_ch2);
|
into_ref!(peri, dma_ch1, dma_ch2);
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
let mut dac_ch1 = DacCh1 {
|
let mut dac_ch1 = DacCh1 {
|
||||||
_peri: peri,
|
_peri: peri,
|
||||||
@ -570,15 +567,10 @@ foreach_peripheral!(
|
|||||||
critical_section::with(|_| unsafe { crate::rcc::get_freqs().apb1 })
|
critical_section::with(|_| unsafe { crate::rcc::get_freqs().apb1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset() {
|
fn reset_and_enable() {
|
||||||
critical_section::with(|_| {
|
critical_section::with(|_| {
|
||||||
crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(true));
|
crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(true));
|
||||||
crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(false));
|
crate::pac::RCC.apb1lrstr().modify(|w| w.set_dac12rst(false));
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enable() {
|
|
||||||
critical_section::with(|_| {
|
|
||||||
crate::pac::RCC.apb1lenr().modify(|w| w.set_dac12en(true));
|
crate::pac::RCC.apb1lenr().modify(|w| w.set_dac12en(true));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -330,8 +330,7 @@ where
|
|||||||
use_embedded_synchronization: bool,
|
use_embedded_synchronization: bool,
|
||||||
edm: u8,
|
edm: u8,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
T::reset();
|
T::reset_and_enable();
|
||||||
T::enable();
|
|
||||||
|
|
||||||
peri.regs().cr().modify(|r| {
|
peri.regs().cr().modify(|r| {
|
||||||
r.set_cm(true); // disable continuous mode (snapshot mode)
|
r.set_cm(true); // disable continuous mode (snapshot mode)
|
||||||
|
@ -19,8 +19,7 @@ where
|
|||||||
const REGISTERS: *const () = T::REGS.as_ptr() as *const _;
|
const REGISTERS: *const () = T::REGS.as_ptr() as *const _;
|
||||||
|
|
||||||
fn enable(&mut self) {
|
fn enable(&mut self) {
|
||||||
<T as crate::rcc::sealed::RccPeripheral>::enable();
|
T::reset_and_enable();
|
||||||
<T as crate::rcc::sealed::RccPeripheral>::reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn memory_controller_enable(&mut self) {
|
fn memory_controller_enable(&mut self) {
|
||||||
|
@ -759,7 +759,7 @@ foreach_pin!(
|
|||||||
|
|
||||||
pub(crate) unsafe fn init() {
|
pub(crate) unsafe fn init() {
|
||||||
#[cfg(afio)]
|
#[cfg(afio)]
|
||||||
<crate::peripherals::AFIO as crate::rcc::sealed::RccPeripheral>::enable();
|
<crate::peripherals::AFIO as crate::rcc::sealed::RccPeripheral>::reset_and_enable();
|
||||||
|
|
||||||
crate::_generated::init_gpio();
|
crate::_generated::init_gpio();
|
||||||
}
|
}
|
||||||
|
@ -157,8 +157,7 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> {
|
|||||||
fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self {
|
fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self {
|
||||||
into_ref!(tim);
|
into_ref!(tim);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
<T as crate::rcc::sealed::RccPeripheral>::reset();
|
|
||||||
|
|
||||||
#[cfg(stm32f334)]
|
#[cfg(stm32f334)]
|
||||||
if unsafe { get_freqs() }.hrtim.is_some() {
|
if unsafe { get_freqs() }.hrtim.is_some() {
|
||||||
|
@ -56,8 +56,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
into_ref!(scl, sda, tx_dma, rx_dma);
|
into_ref!(scl, sda, tx_dma, rx_dma);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
scl.set_as_af_pull(
|
scl.set_as_af_pull(
|
||||||
scl.af_num(),
|
scl.af_num(),
|
||||||
|
@ -86,8 +86,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
into_ref!(peri, scl, sda, tx_dma, rx_dma);
|
into_ref!(peri, scl, sda, tx_dma, rx_dma);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
scl.set_as_af_pull(
|
scl.set_as_af_pull(
|
||||||
scl.af_num(),
|
scl.af_num(),
|
||||||
|
@ -93,8 +93,7 @@ pub struct Ipcc;
|
|||||||
|
|
||||||
impl Ipcc {
|
impl Ipcc {
|
||||||
pub fn enable(_config: Config) {
|
pub fn enable(_config: Config) {
|
||||||
IPCC::enable();
|
IPCC::reset_and_enable();
|
||||||
IPCC::reset();
|
|
||||||
IPCC::set_cpu2(true);
|
IPCC::set_cpu2(true);
|
||||||
|
|
||||||
_configure_pwr();
|
_configure_pwr();
|
||||||
|
@ -186,11 +186,11 @@ pub fn init(config: Config) -> Peripherals {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(stm32f1, stm32wb, stm32wl)))]
|
#[cfg(not(any(stm32f1, stm32wb, stm32wl)))]
|
||||||
peripherals::SYSCFG::enable();
|
peripherals::SYSCFG::reset_and_enable();
|
||||||
#[cfg(not(any(stm32h5, stm32h7, stm32wb, stm32wl)))]
|
#[cfg(not(any(stm32h5, stm32h7, stm32wb, stm32wl)))]
|
||||||
peripherals::PWR::enable();
|
peripherals::PWR::reset_and_enable();
|
||||||
#[cfg(not(any(stm32f2, stm32f4, stm32f7, stm32l0, stm32h5, stm32h7)))]
|
#[cfg(not(any(stm32f2, stm32f4, stm32f7, stm32l0, stm32h5, stm32h7)))]
|
||||||
peripherals::FLASH::enable();
|
peripherals::FLASH::reset_and_enable();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
#[cfg(feature = "_split-pins-enabled")]
|
#[cfg(feature = "_split-pins-enabled")]
|
||||||
|
@ -177,8 +177,7 @@ impl<'d, T: Instance, Dma> Qspi<'d, T, Dma> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
into_ref!(peri, dma);
|
into_ref!(peri, dma);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
while T::REGS.sr().read().busy() {}
|
while T::REGS.sr().read().busy() {}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ pub(crate) unsafe fn init(config: Config) {
|
|||||||
|
|
||||||
// Enable and setup CRS if needed
|
// Enable and setup CRS if needed
|
||||||
if let Some(crs_config) = crs_config {
|
if let Some(crs_config) = crs_config {
|
||||||
crate::peripherals::CRS::enable();
|
crate::peripherals::CRS::reset_and_enable();
|
||||||
|
|
||||||
let sync_src = match crs_config.sync_src {
|
let sync_src = match crs_config.sync_src {
|
||||||
CrsSyncSource::Gpio => crate::pac::crs::vals::Syncsrc::GPIO,
|
CrsSyncSource::Gpio => crate::pac::crs::vals::Syncsrc::GPIO,
|
||||||
|
@ -231,8 +231,7 @@ pub mod low_level {
|
|||||||
pub(crate) mod sealed {
|
pub(crate) mod sealed {
|
||||||
pub trait RccPeripheral {
|
pub trait RccPeripheral {
|
||||||
fn frequency() -> crate::time::Hertz;
|
fn frequency() -> crate::time::Hertz;
|
||||||
fn reset();
|
fn reset_and_enable();
|
||||||
fn enable();
|
|
||||||
fn disable();
|
fn disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,7 @@ impl<'d, T: Instance> Rng<'d, T> {
|
|||||||
inner: impl Peripheral<P = T> + 'd,
|
inner: impl Peripheral<P = T> + 'd,
|
||||||
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
into_ref!(inner);
|
into_ref!(inner);
|
||||||
let mut random = Self { _inner: inner };
|
let mut random = Self { _inner: inner };
|
||||||
random.reset();
|
random.reset();
|
||||||
|
@ -184,7 +184,7 @@ impl Default for RtcCalibrationCyclePeriod {
|
|||||||
impl Rtc {
|
impl Rtc {
|
||||||
pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self {
|
pub fn new(_rtc: impl Peripheral<P = RTC>, rtc_config: RtcConfig) -> Self {
|
||||||
#[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))]
|
#[cfg(not(any(stm32l0, stm32f3, stm32l1, stm32f0, stm32f2)))]
|
||||||
<RTC as crate::rcc::sealed::RccPeripheral>::enable();
|
<RTC as crate::rcc::sealed::RccPeripheral>::reset_and_enable();
|
||||||
|
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
#[cfg(feature = "low-power")]
|
#[cfg(feature = "low-power")]
|
||||||
|
@ -531,10 +531,13 @@ pub struct SubBlock<'d, T: Instance, C: Channel, W: word::Word> {
|
|||||||
pub struct SubBlockA {}
|
pub struct SubBlockA {}
|
||||||
pub struct SubBlockB {}
|
pub struct SubBlockB {}
|
||||||
|
|
||||||
|
pub struct SubBlockAPeripheral<'d, T>(PeripheralRef<'d, T>);
|
||||||
|
pub struct SubBlockBPeripheral<'d, T>(PeripheralRef<'d, T>);
|
||||||
|
|
||||||
pub struct Sai<'d, T: Instance> {
|
pub struct Sai<'d, T: Instance> {
|
||||||
_peri: PeripheralRef<'d, T>,
|
_peri: PeripheralRef<'d, T>,
|
||||||
sub_block_a_peri: Option<PeripheralRef<'d, T>>,
|
sub_block_a_peri: Option<SubBlockAPeripheral<'d, T>>,
|
||||||
sub_block_b_peri: Option<PeripheralRef<'d, T>>,
|
sub_block_b_peri: Option<SubBlockBPeripheral<'d, T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the type for (sd, sck)
|
// return the type for (sd, sck)
|
||||||
@ -577,17 +580,16 @@ fn get_ring_buffer<'d, T: Instance, C: Channel, W: word::Word>(
|
|||||||
|
|
||||||
impl<'d, T: Instance> Sai<'d, T> {
|
impl<'d, T: Instance> Sai<'d, T> {
|
||||||
pub fn new(peri: impl Peripheral<P = T> + 'd) -> Self {
|
pub fn new(peri: impl Peripheral<P = T> + 'd) -> Self {
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
_peri: unsafe { peri.clone_unchecked().into_ref() },
|
_peri: unsafe { peri.clone_unchecked().into_ref() },
|
||||||
sub_block_a_peri: Some(unsafe { peri.clone_unchecked().into_ref() }),
|
sub_block_a_peri: Some(SubBlockAPeripheral(unsafe { peri.clone_unchecked().into_ref() })),
|
||||||
sub_block_b_peri: Some(peri.into_ref()),
|
sub_block_b_peri: Some(SubBlockBPeripheral(peri.into_ref())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_sub_block_a(self: &mut Self) -> Option<PeripheralRef<'d, T>> {
|
pub fn take_sub_block_a(self: &mut Self) -> Option<SubBlockAPeripheral<'d, T>> {
|
||||||
if self.sub_block_a_peri.is_some() {
|
if self.sub_block_a_peri.is_some() {
|
||||||
self.sub_block_a_peri.take()
|
self.sub_block_a_peri.take()
|
||||||
} else {
|
} else {
|
||||||
@ -595,7 +597,7 @@ impl<'d, T: Instance> Sai<'d, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_sub_block_b(self: &mut Self) -> Option<PeripheralRef<'d, T>> {
|
pub fn take_sub_block_b(self: &mut Self) -> Option<SubBlockBPeripheral<'d, T>> {
|
||||||
if self.sub_block_b_peri.is_some() {
|
if self.sub_block_b_peri.is_some() {
|
||||||
self.sub_block_b_peri.take()
|
self.sub_block_b_peri.take()
|
||||||
} else {
|
} else {
|
||||||
@ -623,7 +625,7 @@ fn update_synchronous_config(config: &mut Config) {
|
|||||||
|
|
||||||
impl SubBlockA {
|
impl SubBlockA {
|
||||||
pub fn new_asynchronous_with_mclk<'d, T: Instance, C: Channel, W: word::Word>(
|
pub fn new_asynchronous_with_mclk<'d, T: Instance, C: Channel, W: word::Word>(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: SubBlockAPeripheral<'d, T>,
|
||||||
sck: impl Peripheral<P = impl SckAPin<T>> + 'd,
|
sck: impl Peripheral<P = impl SckAPin<T>> + 'd,
|
||||||
sd: impl Peripheral<P = impl SdAPin<T>> + 'd,
|
sd: impl Peripheral<P = impl SdAPin<T>> + 'd,
|
||||||
fs: impl Peripheral<P = impl FsAPin<T>> + 'd,
|
fs: impl Peripheral<P = impl FsAPin<T>> + 'd,
|
||||||
@ -631,7 +633,7 @@ impl SubBlockA {
|
|||||||
dma: impl Peripheral<P = C> + 'd,
|
dma: impl Peripheral<P = C> + 'd,
|
||||||
dma_buf: &'d mut [W],
|
dma_buf: &'d mut [W],
|
||||||
mut config: Config,
|
mut config: Config,
|
||||||
) -> SubBlock<T, C, W>
|
) -> SubBlock<'d, T, C, W>
|
||||||
where
|
where
|
||||||
C: Channel + DmaA<T>,
|
C: Channel + DmaA<T>,
|
||||||
{
|
{
|
||||||
@ -650,17 +652,18 @@ impl SubBlockA {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_asynchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
pub fn new_asynchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: SubBlockAPeripheral<'d, T>,
|
||||||
sck: impl Peripheral<P = impl SckAPin<T>> + 'd,
|
sck: impl Peripheral<P = impl SckAPin<T>> + 'd,
|
||||||
sd: impl Peripheral<P = impl SdAPin<T>> + 'd,
|
sd: impl Peripheral<P = impl SdAPin<T>> + 'd,
|
||||||
fs: impl Peripheral<P = impl FsAPin<T>> + 'd,
|
fs: impl Peripheral<P = impl FsAPin<T>> + 'd,
|
||||||
dma: impl Peripheral<P = C> + 'd,
|
dma: impl Peripheral<P = C> + 'd,
|
||||||
dma_buf: &'d mut [W],
|
dma_buf: &'d mut [W],
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> SubBlock<T, C, W>
|
) -> SubBlock<'d, T, C, W>
|
||||||
where
|
where
|
||||||
C: Channel + DmaA<T>,
|
C: Channel + DmaA<T>,
|
||||||
{
|
{
|
||||||
|
let peri = peri.0;
|
||||||
into_ref!(peri, dma, sck, sd, fs);
|
into_ref!(peri, dma, sck, sd, fs);
|
||||||
|
|
||||||
let (sd_af_type, ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
let (sd_af_type, ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
||||||
@ -688,17 +691,18 @@ impl SubBlockA {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_synchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
pub fn new_synchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: SubBlockAPeripheral<'d, T>,
|
||||||
sd: impl Peripheral<P = impl SdAPin<T>> + 'd,
|
sd: impl Peripheral<P = impl SdAPin<T>> + 'd,
|
||||||
dma: impl Peripheral<P = C> + 'd,
|
dma: impl Peripheral<P = C> + 'd,
|
||||||
dma_buf: &'d mut [W],
|
dma_buf: &'d mut [W],
|
||||||
mut config: Config,
|
mut config: Config,
|
||||||
) -> SubBlock<T, C, W>
|
) -> SubBlock<'d, T, C, W>
|
||||||
where
|
where
|
||||||
C: Channel + DmaA<T>,
|
C: Channel + DmaA<T>,
|
||||||
{
|
{
|
||||||
update_synchronous_config(&mut config);
|
update_synchronous_config(&mut config);
|
||||||
|
|
||||||
|
let peri = peri.0;
|
||||||
into_ref!(dma, peri, sd);
|
into_ref!(dma, peri, sd);
|
||||||
|
|
||||||
let (sd_af_type, _ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
let (sd_af_type, _ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
||||||
@ -724,7 +728,7 @@ impl SubBlockA {
|
|||||||
|
|
||||||
impl SubBlockB {
|
impl SubBlockB {
|
||||||
pub fn new_asynchronous_with_mclk<'d, T: Instance, C: Channel, W: word::Word>(
|
pub fn new_asynchronous_with_mclk<'d, T: Instance, C: Channel, W: word::Word>(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: SubBlockBPeripheral<'d, T>,
|
||||||
sck: impl Peripheral<P = impl SckBPin<T>> + 'd,
|
sck: impl Peripheral<P = impl SckBPin<T>> + 'd,
|
||||||
sd: impl Peripheral<P = impl SdBPin<T>> + 'd,
|
sd: impl Peripheral<P = impl SdBPin<T>> + 'd,
|
||||||
fs: impl Peripheral<P = impl FsBPin<T>> + 'd,
|
fs: impl Peripheral<P = impl FsBPin<T>> + 'd,
|
||||||
@ -732,7 +736,7 @@ impl SubBlockB {
|
|||||||
dma: impl Peripheral<P = C> + 'd,
|
dma: impl Peripheral<P = C> + 'd,
|
||||||
dma_buf: &'d mut [W],
|
dma_buf: &'d mut [W],
|
||||||
mut config: Config,
|
mut config: Config,
|
||||||
) -> SubBlock<T, C, W>
|
) -> SubBlock<'d, T, C, W>
|
||||||
where
|
where
|
||||||
C: Channel + DmaB<T>,
|
C: Channel + DmaB<T>,
|
||||||
{
|
{
|
||||||
@ -751,17 +755,18 @@ impl SubBlockB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_asynchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
pub fn new_asynchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: SubBlockBPeripheral<'d, T>,
|
||||||
sck: impl Peripheral<P = impl SckBPin<T>> + 'd,
|
sck: impl Peripheral<P = impl SckBPin<T>> + 'd,
|
||||||
sd: impl Peripheral<P = impl SdBPin<T>> + 'd,
|
sd: impl Peripheral<P = impl SdBPin<T>> + 'd,
|
||||||
fs: impl Peripheral<P = impl FsBPin<T>> + 'd,
|
fs: impl Peripheral<P = impl FsBPin<T>> + 'd,
|
||||||
dma: impl Peripheral<P = C> + 'd,
|
dma: impl Peripheral<P = C> + 'd,
|
||||||
dma_buf: &'d mut [W],
|
dma_buf: &'d mut [W],
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> SubBlock<T, C, W>
|
) -> SubBlock<'d, T, C, W>
|
||||||
where
|
where
|
||||||
C: Channel + DmaB<T>,
|
C: Channel + DmaB<T>,
|
||||||
{
|
{
|
||||||
|
let peri = peri.0;
|
||||||
into_ref!(dma, peri, sck, sd, fs);
|
into_ref!(dma, peri, sck, sd, fs);
|
||||||
|
|
||||||
let (sd_af_type, ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
let (sd_af_type, ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
||||||
@ -790,17 +795,17 @@ impl SubBlockB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_synchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
pub fn new_synchronous<'d, T: Instance, C: Channel, W: word::Word>(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: SubBlockBPeripheral<'d, T>,
|
||||||
sd: impl Peripheral<P = impl SdBPin<T>> + 'd,
|
sd: impl Peripheral<P = impl SdBPin<T>> + 'd,
|
||||||
dma: impl Peripheral<P = C> + 'd,
|
dma: impl Peripheral<P = C> + 'd,
|
||||||
dma_buf: &'d mut [W],
|
dma_buf: &'d mut [W],
|
||||||
mut config: Config,
|
mut config: Config,
|
||||||
) -> SubBlock<T, C, W>
|
) -> SubBlock<'d, T, C, W>
|
||||||
where
|
where
|
||||||
C: Channel + DmaB<T>,
|
C: Channel + DmaB<T>,
|
||||||
{
|
{
|
||||||
update_synchronous_config(&mut config);
|
update_synchronous_config(&mut config);
|
||||||
|
let peri = peri.0;
|
||||||
into_ref!(dma, peri, sd);
|
into_ref!(dma, peri, sd);
|
||||||
|
|
||||||
let (sd_af_type, _ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
let (sd_af_type, _ck_af_type) = get_af_types(config.mode, config.tx_rx);
|
||||||
@ -853,10 +858,6 @@ impl<'d, T: Instance, C: Channel, W: word::Word> SubBlock<'d, T, C, W> {
|
|||||||
ring_buffer: RingBuffer<'d, C, W>,
|
ring_buffer: RingBuffer<'d, C, W>,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
T::enable();
|
|
||||||
|
|
||||||
// can't reset here because the other sub-block might be in use
|
|
||||||
|
|
||||||
#[cfg(any(sai_v1, sai_v2, sai_v3, sai_v4))]
|
#[cfg(any(sai_v1, sai_v2, sai_v3, sai_v4))]
|
||||||
{
|
{
|
||||||
let ch = T::REGS.ch(sub_block as usize);
|
let ch = T::REGS.ch(sub_block as usize);
|
||||||
@ -959,8 +960,7 @@ impl<'d, T: Instance, C: Channel, W: word::Word> SubBlock<'d, T, C, W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset() {
|
pub fn reset() {
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush(&mut self) {
|
pub fn flush(&mut self) {
|
||||||
|
@ -452,8 +452,7 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
into_ref!(sdmmc, dma);
|
into_ref!(sdmmc, dma);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
T::Interrupt::unpend();
|
T::Interrupt::unpend();
|
||||||
unsafe { T::Interrupt::enable() };
|
unsafe { T::Interrupt::enable() };
|
||||||
|
@ -230,8 +230,7 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> {
|
|||||||
|
|
||||||
let lsbfirst = config.raw_byte_order();
|
let lsbfirst = config.raw_byte_order();
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
#[cfg(any(spi_v1, spi_f1))]
|
#[cfg(any(spi_v1, spi_f1))]
|
||||||
{
|
{
|
||||||
|
@ -155,8 +155,7 @@ impl RtcDriver {
|
|||||||
fn init(&'static self) {
|
fn init(&'static self) {
|
||||||
let r = T::regs_gp16();
|
let r = T::regs_gp16();
|
||||||
|
|
||||||
<T as RccPeripheral>::enable();
|
<T as RccPeripheral>::reset_and_enable();
|
||||||
<T as RccPeripheral>::reset();
|
|
||||||
|
|
||||||
let timer_freq = T::frequency();
|
let timer_freq = T::frequency();
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ impl<'d, T: ComplementaryCaptureCompare16bitInstance> ComplementaryPwm<'d, T> {
|
|||||||
fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self {
|
fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self {
|
||||||
into_ref!(tim);
|
into_ref!(tim);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
<T as crate::rcc::sealed::RccPeripheral>::reset();
|
|
||||||
|
|
||||||
let mut this = Self { inner: tim };
|
let mut this = Self { inner: tim };
|
||||||
|
|
||||||
|
@ -55,8 +55,7 @@ impl<'d, T: CaptureCompare16bitInstance> Qei<'d, T> {
|
|||||||
fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self {
|
fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self {
|
||||||
into_ref!(tim);
|
into_ref!(tim);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
<T as crate::rcc::sealed::RccPeripheral>::reset();
|
|
||||||
|
|
||||||
// Configure TxC1 and TxC2 as captures
|
// Configure TxC1 and TxC2 as captures
|
||||||
T::regs_gp16().ccmr_input(0).modify(|w| {
|
T::regs_gp16().ccmr_input(0).modify(|w| {
|
||||||
|
@ -63,8 +63,7 @@ impl<'d, T: CaptureCompare16bitInstance> SimplePwm<'d, T> {
|
|||||||
fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self {
|
fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz) -> Self {
|
||||||
into_ref!(tim);
|
into_ref!(tim);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
<T as crate::rcc::sealed::RccPeripheral>::reset();
|
|
||||||
|
|
||||||
let mut this = Self { inner: tim };
|
let mut this = Self { inner: tim };
|
||||||
|
|
||||||
|
@ -152,9 +152,8 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
|
|||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
// UartRx and UartTx have one refcount ea.
|
// UartRx and UartTx have one refcount ea.
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
Self::new_inner(peri, rx, tx, tx_buffer, rx_buffer, config)
|
Self::new_inner(peri, rx, tx, tx_buffer, rx_buffer, config)
|
||||||
}
|
}
|
||||||
@ -173,9 +172,8 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
|
|||||||
into_ref!(cts, rts);
|
into_ref!(cts, rts);
|
||||||
|
|
||||||
// UartRx and UartTx have one refcount ea.
|
// UartRx and UartTx have one refcount ea.
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
|
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
|
||||||
cts.set_as_af(cts.af_num(), AFType::Input);
|
cts.set_as_af(cts.af_num(), AFType::Input);
|
||||||
@ -201,9 +199,8 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
|
|||||||
into_ref!(de);
|
into_ref!(de);
|
||||||
|
|
||||||
// UartRx and UartTx have one refcount ea.
|
// UartRx and UartTx have one refcount ea.
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
de.set_as_af(de.af_num(), AFType::OutputPushPull);
|
de.set_as_af(de.af_num(), AFType::OutputPushPull);
|
||||||
T::regs().cr3().write(|w| {
|
T::regs().cr3().write(|w| {
|
||||||
|
@ -228,8 +228,7 @@ impl<'d, T: BasicInstance, TxDma> UartTx<'d, T, TxDma> {
|
|||||||
tx_dma: impl Peripheral<P = TxDma> + 'd,
|
tx_dma: impl Peripheral<P = TxDma> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
Self::new_inner(peri, tx, tx_dma, config)
|
Self::new_inner(peri, tx, tx_dma, config)
|
||||||
}
|
}
|
||||||
@ -243,8 +242,7 @@ impl<'d, T: BasicInstance, TxDma> UartTx<'d, T, TxDma> {
|
|||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
into_ref!(cts);
|
into_ref!(cts);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
cts.set_as_af(cts.af_num(), AFType::Input);
|
cts.set_as_af(cts.af_num(), AFType::Input);
|
||||||
T::regs().cr3().write(|w| {
|
T::regs().cr3().write(|w| {
|
||||||
@ -321,8 +319,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> {
|
|||||||
rx_dma: impl Peripheral<P = RxDma> + 'd,
|
rx_dma: impl Peripheral<P = RxDma> + 'd,
|
||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
Self::new_inner(peri, rx, rx_dma, config)
|
Self::new_inner(peri, rx, rx_dma, config)
|
||||||
}
|
}
|
||||||
@ -337,8 +334,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> {
|
|||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
into_ref!(rts);
|
into_ref!(rts);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
|
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
|
||||||
T::regs().cr3().write(|w| {
|
T::regs().cr3().write(|w| {
|
||||||
@ -695,9 +691,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
|||||||
config: Config,
|
config: Config,
|
||||||
) -> Result<Self, ConfigError> {
|
) -> Result<Self, ConfigError> {
|
||||||
// UartRx and UartTx have one refcount ea.
|
// UartRx and UartTx have one refcount ea.
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config)
|
Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config)
|
||||||
}
|
}
|
||||||
@ -716,9 +711,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
|||||||
into_ref!(cts, rts);
|
into_ref!(cts, rts);
|
||||||
|
|
||||||
// UartRx and UartTx have one refcount ea.
|
// UartRx and UartTx have one refcount ea.
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
|
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
|
||||||
cts.set_as_af(cts.af_num(), AFType::Input);
|
cts.set_as_af(cts.af_num(), AFType::Input);
|
||||||
@ -743,9 +737,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
|||||||
into_ref!(de);
|
into_ref!(de);
|
||||||
|
|
||||||
// UartRx and UartTx have one refcount ea.
|
// UartRx and UartTx have one refcount ea.
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
T::reset();
|
|
||||||
|
|
||||||
de.set_as_af(de.af_num(), AFType::OutputPushPull);
|
de.set_as_af(de.af_num(), AFType::OutputPushPull);
|
||||||
T::regs().cr3().write(|w| {
|
T::regs().cr3().write(|w| {
|
||||||
|
@ -269,8 +269,7 @@ impl<'d, T: Instance> Driver<'d, T> {
|
|||||||
#[cfg(pwr_h5)]
|
#[cfg(pwr_h5)]
|
||||||
crate::pac::PWR.usbscr().modify(|w| w.set_usb33sv(true));
|
crate::pac::PWR.usbscr().modify(|w| w.set_usb33sv(true));
|
||||||
|
|
||||||
<T as RccPeripheral>::enable();
|
<T as RccPeripheral>::reset_and_enable();
|
||||||
<T as RccPeripheral>::reset();
|
|
||||||
|
|
||||||
regs.cntr().write(|w| {
|
regs.cntr().write(|w| {
|
||||||
w.set_pdwn(false);
|
w.set_pdwn(false);
|
||||||
|
@ -632,8 +632,7 @@ impl<'d, T: Instance> Bus<'d, T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
<T as RccPeripheral>::enable();
|
<T as RccPeripheral>::reset_and_enable();
|
||||||
<T as RccPeripheral>::reset();
|
|
||||||
|
|
||||||
T::Interrupt::unpend();
|
T::Interrupt::unpend();
|
||||||
unsafe { T::Interrupt::enable() };
|
unsafe { T::Interrupt::enable() };
|
||||||
|
@ -79,7 +79,7 @@ async fn dac_task1(mut dac: Dac1Type) {
|
|||||||
dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap();
|
dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap();
|
||||||
dac.enable_channel().unwrap();
|
dac.enable_channel().unwrap();
|
||||||
|
|
||||||
TIM6::enable();
|
TIM6::reset_and_enable();
|
||||||
TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
||||||
TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
||||||
TIM6::regs().cr1().modify(|w| {
|
TIM6::regs().cr1().modify(|w| {
|
||||||
@ -118,7 +118,7 @@ async fn dac_task2(mut dac: Dac2Type) {
|
|||||||
error!("Reload value {} below threshold!", reload);
|
error!("Reload value {} below threshold!", reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIM7::enable();
|
TIM7::reset_and_enable();
|
||||||
TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
||||||
TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
||||||
TIM7::regs().cr1().modify(|w| {
|
TIM7::regs().cr1().modify(|w| {
|
||||||
|
@ -73,8 +73,7 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
into_ref!(tim, ch1, ch2, ch3, ch4);
|
into_ref!(tim, ch1, ch2, ch3, ch4);
|
||||||
|
|
||||||
T::enable();
|
T::reset_and_enable();
|
||||||
<T as embassy_stm32::rcc::low_level::RccPeripheral>::reset();
|
|
||||||
|
|
||||||
ch1.set_speed(Speed::VeryHigh);
|
ch1.set_speed(Speed::VeryHigh);
|
||||||
ch1.set_as_af(ch1.af_num(), AFType::OutputPushPull);
|
ch1.set_as_af(ch1.af_num(), AFType::OutputPushPull);
|
||||||
|
@ -51,7 +51,7 @@ async fn dac_task1(mut dac: Dac1Type) {
|
|||||||
dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap();
|
dac.select_trigger(embassy_stm32::dac::Ch1Trigger::Tim6).unwrap();
|
||||||
dac.enable_channel().unwrap();
|
dac.enable_channel().unwrap();
|
||||||
|
|
||||||
TIM6::enable();
|
TIM6::reset_and_enable();
|
||||||
TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
TIM6::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
||||||
TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
TIM6::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
||||||
TIM6::regs().cr1().modify(|w| {
|
TIM6::regs().cr1().modify(|w| {
|
||||||
@ -90,7 +90,7 @@ async fn dac_task2(mut dac: Dac2Type) {
|
|||||||
error!("Reload value {} below threshold!", reload);
|
error!("Reload value {} below threshold!", reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIM7::enable();
|
TIM7::reset_and_enable();
|
||||||
TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
TIM7::regs().arr().modify(|w| w.set_arr(reload as u16 - 1));
|
||||||
TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
TIM7::regs().cr2().modify(|w| w.set_mms(Mms::UPDATE));
|
||||||
TIM7::regs().cr1().modify(|w| {
|
TIM7::regs().cr1().modify(|w| {
|
||||||
|
Loading…
Reference in New Issue
Block a user