handle _C pins

This commit is contained in:
JuliDi 2023-09-13 21:16:27 +02:00
parent 7bc57ca3f7
commit 5924cc8b49
No known key found for this signature in database
GPG Key ID: E1E90AE563D09D63
3 changed files with 87 additions and 2 deletions

View File

@ -134,6 +134,22 @@ time-driver-tim12 = ["_time-driver"]
time-driver-tim15 = ["_time-driver"]
#! ## Analog Switch Pins (Pxy_C) on STM32H7 series
#! Get `PXY` and `PXY_C` singletons. Digital impls are on `PXY`, Analog impls are on `PXY_C`
#! If disabled, you get only the `PXY` singleton. It has both digital and analog impls.
## Split PA0
split-pa0 = ["_split-pins-enabled"]
## Split PA1
split-pa1 = ["_split-pins-enabled"]
## Split PC2
split-pc2 = ["_split-pins-enabled"]
## Split PC3
split-pc3 = ["_split-pins-enabled"]
## internal use only
_split-pins-enabled = []
#! ## Chip-selection features
#! Select your chip by specifying the model as a feature, e.g. `stm32c011d6`.
#! Check the `Cargo.toml` for the latest list of supported chips.

View File

@ -81,6 +81,16 @@ fn main() {
singletons.push(c.name.to_string());
}
// Extra analog switch pins available on most H7 chips
#[cfg(feature = "split-pa0")]
singletons.push("PA0_C".into());
#[cfg(feature = "split-pa1")]
singletons.push("PA1_C".into());
#[cfg(feature = "split-pc2")]
singletons.push("PC2_C".into());
#[cfg(feature = "split-pc3")]
singletons.push("PC3_C".into());
// ========
// Handle time-driver-XXXX features.
@ -679,7 +689,31 @@ fn main() {
let key = (regs.kind, pin.signal);
if let Some(tr) = signals.get(&key) {
let mut peri = format_ident!("{}", p.name);
let pin_name = format_ident!("{}", pin.pin);
let pin_name = {
#[allow(unused_mut)]
let mut pin_name = pin.pin;
#[cfg(not(feature = "split-pa0"))]
if pin.pin == "PA0_C" {
pin_name = "PA0";
}
#[cfg(not(feature = "split-pa1"))]
if pin.pin == "PA1_C" {
pin_name = "PA1";
}
#[cfg(not(feature = "split-pc2"))]
if pin.pin == "PC2_C" {
pin_name = "PC2";
}
#[cfg(not(feature = "split-pc3"))]
if pin.pin == "PC3_C" {
pin_name = "PC3";
}
format_ident!("{}", pin_name)
};
let af = pin.af.unwrap_or(0);
// MCO is special
@ -716,7 +750,30 @@ fn main() {
}
let peri = format_ident!("{}", p.name);
let pin_name = format_ident!("{}", pin.pin);
let pin_name = {
#[allow(unused_mut)]
let mut pin_name = pin.pin;
#[cfg(not(feature = "split-pa0"))]
if pin.pin == "PA0_C" {
pin_name = "PA0";
}
#[cfg(not(feature = "split-pa1"))]
if pin.pin == "PA1_C" {
pin_name = "PA1";
}
#[cfg(not(feature = "split-pc2"))]
if pin.pin == "PC2_C" {
pin_name = "PC2";
}
#[cfg(not(feature = "split-pc3"))]
if pin.pin == "PC3_C" {
pin_name = "PC3";
}
format_ident!("{}", pin_name)
};
// H7 has differential voltage measurements
let ch: Option<u8> = if pin.signal.starts_with("INP") {

View File

@ -191,6 +191,18 @@ pub fn init(config: Config) -> Peripherals {
peripherals::FLASH::enable();
unsafe {
#[cfg(feature = "_split-pins-enabled")]
crate::pac::SYSCFG.pmcr().modify(|pmcr| {
#[cfg(feature = "split-pa0")]
pmcr.set_pa0so(true);
#[cfg(feature = "split-pa1")]
pmcr.set_pa1so(true);
#[cfg(feature = "split-pc2")]
pmcr.set_pc2so(true);
#[cfg(feature = "split-pc3")]
pmcr.set_pc3so(true);
});
gpio::init();
dma::init(
#[cfg(bdma)]