Auto-enable all GPIOs during init().
This commit is contained in:
parent
e91c04a673
commit
13873df30b
@ -449,3 +449,13 @@ crate::pac::pins!(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
pub(crate) unsafe fn init() {
|
||||||
|
crate::pac::gpio_rcc! {
|
||||||
|
($name:ident, $clock:ident, $en_reg:ident, $rst_reg:ident, $en_fn:ident, $rst_fn:ident) => {
|
||||||
|
crate::pac::RCC.$en_reg().modify(|reg| {
|
||||||
|
reg.$en_fn(true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -89,6 +89,7 @@ pub fn init(config: Config) -> Peripherals {
|
|||||||
let p = Peripherals::take();
|
let p = Peripherals::take();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
gpio::init();
|
||||||
dma::init();
|
dma::init();
|
||||||
#[cfg(exti)]
|
#[cfg(exti)]
|
||||||
exti::init();
|
exti::init();
|
||||||
|
@ -71,22 +71,10 @@ fn main() -> ! {
|
|||||||
.pll1_q_ck(48.mhz())
|
.pll1_q_ck(48.mhz())
|
||||||
.freeze(pwrcfg, &pp.SYSCFG);
|
.freeze(pwrcfg, &pp.SYSCFG);
|
||||||
|
|
||||||
let pp = unsafe { pac::Peripherals::steal() };
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Dbgmcu::enable_all();
|
Dbgmcu::enable_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
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) };
|
unsafe { embassy::time::set_clock(&ZeroClock) };
|
||||||
|
|
||||||
let executor = EXECUTOR.put(Executor::new());
|
let executor = EXECUTOR.put(Executor::new());
|
||||||
|
@ -287,6 +287,7 @@ pub fn gen(options: Options) {
|
|||||||
let mut peripheral_counts: HashMap<String, u8> = HashMap::new();
|
let mut peripheral_counts: HashMap<String, u8> = HashMap::new();
|
||||||
let mut dma_channel_counts: HashMap<String, u8> = HashMap::new();
|
let mut dma_channel_counts: HashMap<String, u8> = HashMap::new();
|
||||||
let mut dbgmcu_table: Vec<Vec<String>> = Vec::new();
|
let mut dbgmcu_table: Vec<Vec<String>> = Vec::new();
|
||||||
|
let mut gpio_rcc_table: Vec<Vec<String>> = Vec::new();
|
||||||
|
|
||||||
let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address;
|
let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address;
|
||||||
let gpio_stride = 0x400;
|
let gpio_stride = 0x400;
|
||||||
@ -465,7 +466,6 @@ pub fn gen(options: Options) {
|
|||||||
clock.to_ascii_lowercase()
|
clock.to_ascii_lowercase()
|
||||||
};
|
};
|
||||||
|
|
||||||
if !name.starts_with("GPIO") {
|
|
||||||
let mut row = Vec::with_capacity(6);
|
let mut row = Vec::with_capacity(6);
|
||||||
row.push(name.clone());
|
row.push(name.clone());
|
||||||
row.push(clock);
|
row.push(clock);
|
||||||
@ -487,7 +487,11 @@ pub fn gen(options: Options) {
|
|||||||
enable_field.to_ascii_lowercase()
|
enable_field.to_ascii_lowercase()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !name.starts_with("GPIO") {
|
||||||
peripheral_rcc_table.push(row);
|
peripheral_rcc_table.push(row);
|
||||||
|
} else {
|
||||||
|
gpio_rcc_table.push(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(None, Some(_)) => {
|
(None, Some(_)) => {
|
||||||
@ -586,6 +590,7 @@ pub fn gen(options: Options) {
|
|||||||
&peripheral_dma_channels_table,
|
&peripheral_dma_channels_table,
|
||||||
);
|
);
|
||||||
make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table);
|
make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table);
|
||||||
|
make_table(&mut extra, "gpio_rcc", &gpio_rcc_table);
|
||||||
make_table(&mut extra, "dma_channels", &dma_channels_table);
|
make_table(&mut extra, "dma_channels", &dma_channels_table);
|
||||||
make_table(&mut extra, "dbgmcu", &dbgmcu_table);
|
make_table(&mut extra, "dbgmcu", &dbgmcu_table);
|
||||||
make_peripheral_counts(&mut extra, &peripheral_counts);
|
make_peripheral_counts(&mut extra, &peripheral_counts);
|
||||||
|
Loading…
Reference in New Issue
Block a user