stm32: No need to enable GPIO clocks manually
This commit is contained in:
@ -28,8 +28,7 @@ fn main() -> ! {
|
||||
|
||||
let rcc = pp.RCC.constrain();
|
||||
|
||||
rcc
|
||||
.sys_ck(96.mhz())
|
||||
rcc.sys_ck(96.mhz())
|
||||
.pclk1(48.mhz())
|
||||
.pclk2(48.mhz())
|
||||
.pclk3(48.mhz())
|
||||
@ -47,16 +46,6 @@ fn main() -> ! {
|
||||
w
|
||||
});
|
||||
|
||||
pp.RCC.ahb4enr.modify(|_, w| {
|
||||
w.gpioaen().set_bit();
|
||||
w.gpioben().set_bit();
|
||||
w.gpiocen().set_bit();
|
||||
w.gpioden().set_bit();
|
||||
w.gpioeen().set_bit();
|
||||
w.gpiofen().set_bit();
|
||||
w
|
||||
});
|
||||
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
|
||||
|
@ -13,9 +13,9 @@ use embassy_stm32::gpio::NoPin;
|
||||
use example_common::*;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embassy_stm32::dac::{Channel, Dac, Value};
|
||||
use stm32h7::stm32h743 as pac;
|
||||
use stm32h7xx_hal::prelude::*;
|
||||
use embassy_stm32::dac::{Dac, Value, Channel};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
@ -23,13 +23,11 @@ fn main() -> ! {
|
||||
|
||||
let pp = pac::Peripherals::take().unwrap();
|
||||
|
||||
let pwrcfg = pp.PWR.constrain()
|
||||
.freeze();
|
||||
let pwrcfg = pp.PWR.constrain().freeze();
|
||||
|
||||
let rcc = pp.RCC.constrain();
|
||||
|
||||
rcc
|
||||
.sys_ck(96.mhz())
|
||||
rcc.sys_ck(96.mhz())
|
||||
.pclk1(48.mhz())
|
||||
.pclk2(48.mhz())
|
||||
.pclk3(48.mhz())
|
||||
@ -47,21 +45,11 @@ fn main() -> ! {
|
||||
w
|
||||
});
|
||||
|
||||
pp.RCC.apb1lenr.modify(|_, w|{
|
||||
pp.RCC.apb1lenr.modify(|_, w| {
|
||||
w.dac12en().set_bit();
|
||||
w
|
||||
});
|
||||
|
||||
pp.RCC.ahb4enr.modify(|_, w| {
|
||||
w.gpioaen().set_bit();
|
||||
w.gpioben().set_bit();
|
||||
w.gpiocen().set_bit();
|
||||
w.gpioden().set_bit();
|
||||
w.gpioeen().set_bit();
|
||||
w.gpiofen().set_bit();
|
||||
w
|
||||
});
|
||||
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
let mut dac = Dac::new(p.DAC1, p.PA4, NoPin);
|
||||
@ -79,11 +67,11 @@ use micromath::F32Ext;
|
||||
fn to_sine_wave(v: u8) -> u8 {
|
||||
if v >= 128 {
|
||||
// top half
|
||||
let r = 3.14 * ( (v-128) as f32/ 128.0) ;
|
||||
let r = 3.14 * ((v - 128) as f32 / 128.0);
|
||||
(r.sin() * 128.0 + 127.0) as u8
|
||||
} else {
|
||||
// bottom half
|
||||
let r = 3.14 + 3.14 * (v as f32/ 128.0);
|
||||
let r = 3.14 + 3.14 * (v as f32 / 128.0);
|
||||
(r.sin() * 128.0 + 127.0) as u8
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +106,6 @@ static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new();
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
use stm32_metapac::RCC;
|
||||
|
||||
info!("Hello World!");
|
||||
|
||||
info!("Setup RCC...");
|
||||
@ -123,16 +121,6 @@ fn main() -> ! {
|
||||
let mut rcc = Rcc::new(&mut p.RCC, RccConfig::default());
|
||||
rcc.enable_debug_wfe(&mut p.DBGMCU, true);
|
||||
|
||||
unsafe {
|
||||
RCC.ahb4enr().modify(|w| {
|
||||
w.set_gpioaen(true);
|
||||
w.set_gpioben(true);
|
||||
w.set_gpiocen(true);
|
||||
w.set_gpioden(true);
|
||||
w.set_gpioien(true);
|
||||
});
|
||||
}
|
||||
|
||||
let rtc_int = interrupt_take!(TIM2);
|
||||
let rtc = TIMER_RTC.put(Clock::new(p.TIM2, rtc_int));
|
||||
rtc.start();
|
||||
|
@ -77,16 +77,6 @@ fn main() -> ! {
|
||||
w
|
||||
});
|
||||
|
||||
pp.RCC.ahb4enr.modify(|_, w| {
|
||||
w.gpioaen().set_bit();
|
||||
w.gpioben().set_bit();
|
||||
w.gpiocen().set_bit();
|
||||
w.gpioden().set_bit();
|
||||
w.gpioeen().set_bit();
|
||||
w.gpiofen().set_bit();
|
||||
w
|
||||
});
|
||||
|
||||
unsafe { embassy::time::set_clock(&ZeroClock) };
|
||||
|
||||
let executor = EXECUTOR.put(Executor::new());
|
||||
|
@ -12,18 +12,18 @@ use core::fmt::Write;
|
||||
use embassy::executor::Executor;
|
||||
use embassy::time::Clock;
|
||||
use embassy::util::Forever;
|
||||
use embassy_stm32::dbgmcu::Dbgmcu;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::usart::{Config, Uart};
|
||||
use embassy_stm32::dbgmcu::Dbgmcu;
|
||||
use example_common::*;
|
||||
use embassy_traits::uart::Write as _Write;
|
||||
use example_common::*;
|
||||
|
||||
use hal::prelude::*;
|
||||
use stm32h7xx_hal as hal;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use stm32h7::stm32h743 as pac;
|
||||
use heapless::String;
|
||||
use stm32h7::stm32h743 as pac;
|
||||
|
||||
#[embassy::task]
|
||||
async fn main_task() {
|
||||
@ -40,7 +40,6 @@ async fn main_task() {
|
||||
|
||||
info!("wrote DMA");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct ZeroClock;
|
||||
|
Reference in New Issue
Block a user