add stop mode rcc data

This commit is contained in:
xoviat 2023-11-05 15:52:50 -06:00
parent 133a32cbbd
commit b9efaf36d8
4 changed files with 36 additions and 1 deletions

View File

@ -6,7 +6,7 @@ use std::hash::Hash;
use anyhow::{anyhow, Ok}; use anyhow::{anyhow, Ok};
use chiptool::ir::{BlockItemInner, Enum}; use chiptool::ir::{BlockItemInner, Enum};
use stm32_data_serde::chip::core::peripheral; use stm32_data_serde::chip::core::peripheral;
use stm32_data_serde::chip::core::peripheral::rcc::Mux; use stm32_data_serde::chip::core::peripheral::rcc::{Mux, StopMode};
use crate::regex; use crate::regex;
use crate::registers::Registers; use crate::registers::Registers;
@ -245,6 +245,13 @@ impl PeripheralToClock {
for field in &body.fields { for field in &body.fields {
if let Some(peri) = field.name.strip_suffix("EN") { if let Some(peri) = field.name.strip_suffix("EN") {
let peri = if peri == "RTCAPB" { "RTC" } else { peri }; let peri = if peri == "RTCAPB" { "RTC" } else { peri };
let stop_mode = if peri == "RTC" {
StopMode::Standby
} else if peri.starts_with("LP") {
StopMode::Stop2
} else {
StopMode::Stop1
};
// Timers are a bit special, they may have a x2 freq // Timers are a bit special, they may have a x2 freq
let peri_clock = { let peri_clock = {
@ -280,6 +287,7 @@ impl PeripheralToClock {
register: reg.to_ascii_lowercase(), register: reg.to_ascii_lowercase(),
field: field.name.to_ascii_lowercase(), field: field.name.to_ascii_lowercase(),
}, },
stop_mode,
reset, reset,
mux, mux,
}); });

View File

@ -116,6 +116,7 @@ pub mod chip {
pub reset: Option<rcc::Reset>, pub reset: Option<rcc::Reset>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub mux: Option<rcc::Mux>, pub mux: Option<rcc::Mux>,
pub stop_mode: rcc::StopMode,
} }
pub mod rcc { pub mod rcc {
@ -138,6 +139,13 @@ pub mod chip {
pub register: String, pub register: String,
pub field: String, pub field: String,
} }
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
pub enum StopMode {
Stop1, // Peripheral prevents chip from entering Stop1
Stop2, // Peripheral prevents chip from entering Stop2
Standby, // Peripheral does not prevent chip from entering Stop
}
} }
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]

View File

@ -182,6 +182,7 @@ pub struct PeripheralRcc {
pub enable: Option<PeripheralRccRegister>, pub enable: Option<PeripheralRccRegister>,
pub reset: Option<PeripheralRccRegister>, pub reset: Option<PeripheralRccRegister>,
pub mux: Option<PeripheralRccRegister>, pub mux: Option<PeripheralRccRegister>,
pub stop_mode: StopMode,
} }
#[derive(Debug, Eq, PartialEq, Clone)] #[derive(Debug, Eq, PartialEq, Clone)]
@ -190,6 +191,14 @@ pub struct PeripheralRccRegister {
pub field: &'static str, pub field: &'static str,
} }
#[derive(Debug, Eq, PartialEq, Clone, Default)]
pub enum StopMode {
#[default]
Stop1, // Peripheral prevents chip from entering Stop1
Stop2, // Peripheral prevents chip from entering Stop2
Standby, // Peripheral does not prevent chip from entering Stop
}
#[derive(Debug, Eq, PartialEq, Clone)] #[derive(Debug, Eq, PartialEq, Clone)]
pub struct PeripheralPin { pub struct PeripheralPin {
pub pin: &'static str, pub pin: &'static str,

View File

@ -325,6 +325,8 @@ pub struct PeripheralRcc {
pub reset: Option<PeripheralRccRegister>, pub reset: Option<PeripheralRccRegister>,
#[serde(default)] #[serde(default)]
pub mux: Option<PeripheralRccRegister>, pub mux: Option<PeripheralRccRegister>,
#[serde(default)]
pub stop_mode: StopMode,
} }
#[derive(Debug, Eq, PartialEq, Clone, Deserialize)] #[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
@ -333,6 +335,14 @@ pub struct PeripheralRccRegister {
pub field: String, pub field: String,
} }
#[derive(EnumDebug, Eq, PartialEq, Clone, Deserialize, Default)]
pub enum StopMode {
#[default]
Stop1, // Peripheral prevents chip from entering Stop1
Stop2, // Peripheral prevents chip from entering Stop2
Standby, // Peripheral does not prevent chip from entering Stop
}
#[derive(Debug, Eq, PartialEq, Clone, Deserialize)] #[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
pub struct PeripheralPin { pub struct PeripheralPin {
pub pin: String, pub pin: String,