Included pin subcommand with auditing and assignment
This commit is contained in:
@@ -15,6 +15,8 @@ pub struct ProjectConfig {
|
||||
pub monitor: MonitorConfig,
|
||||
#[serde(default)]
|
||||
pub boards: HashMap<String, BoardProfile>,
|
||||
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||
pub pins: HashMap<String, BoardPinConfig>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
@@ -51,6 +53,32 @@ pub struct BoardProfile {
|
||||
pub baud: Option<u32>,
|
||||
}
|
||||
|
||||
/// Pin configuration for a specific board.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
pub struct BoardPinConfig {
|
||||
/// Individual pin assignments: name -> { pin, mode }
|
||||
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||
pub assignments: HashMap<String, PinAssignment>,
|
||||
/// Bus group reservations: "spi" -> { cs = 10 }, "i2c" -> {}
|
||||
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||
pub buses: HashMap<String, BusConfig>,
|
||||
}
|
||||
|
||||
/// A single pin assignment with a friendly name.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PinAssignment {
|
||||
pub pin: u8,
|
||||
pub mode: String,
|
||||
}
|
||||
|
||||
/// Configuration for a claimed bus group.
|
||||
/// User-selectable pins (like CS for SPI) are stored as flattened keys.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
pub struct BusConfig {
|
||||
#[serde(flatten)]
|
||||
pub user_pins: HashMap<String, u8>,
|
||||
}
|
||||
|
||||
impl ProjectConfig {
|
||||
/// Create a new project config with sensible defaults.
|
||||
pub fn new(name: &str) -> Self {
|
||||
@@ -76,6 +104,7 @@ impl ProjectConfig {
|
||||
port: None,
|
||||
},
|
||||
boards,
|
||||
pins: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user