use crate::chip::uart;
use crate::edge::Actuator;
use crate::emulator::{EmulatorCommand, InterruptLine};
use crate::mcu::Mcu;
use crate::soc::Error;
pub mod armv7m;
#[cfg(feature = "stm32f427")]
pub mod pixracer;
#[cfg(feature = "stm32f427")]
pub mod stm32f427_bench;
pub type Constructor = fn() -> Result<Box<dyn Board>, Error>;
pub type CoupledConstructor = fn() -> Result<Box<dyn crate::edge::Coupled>, Error>;
#[must_use]
pub fn all() -> &'static [(&'static str, Constructor)] {
const MACHINES: &[(&str, Constructor)] = &[
#[cfg(feature = "stm32f427")]
(pixracer::NAME, pixracer::boxed),
#[cfg(feature = "stm32f427")]
(stm32f427_bench::NAME, stm32f427_bench::boxed),
];
MACHINES
}
#[must_use]
pub fn coupled() -> &'static [(&'static str, CoupledConstructor)] {
const COUPLED: &[(&str, CoupledConstructor)] = &[
#[cfg(feature = "stm32f427")]
(pixracer::NAME, pixracer::coupled),
];
COUPLED
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Crystal(pub u64);
impl Crystal {
pub const NONE: Self = Self(0);
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct HostWire {
pub name: &'static str,
pub port: u16,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Supply(pub u32);
pub trait Board: Send + std::fmt::Debug {
fn name(&self) -> &'static str;
fn targets(&mut self) -> Vec<Target<'_>>;
fn target_names(&self) -> Vec<&'static str>;
fn mcu(&mut self, target: usize) -> Option<&mut dyn Mcu>;
fn target(&self, name: &str) -> Option<usize> {
self.target_names().iter().position(|&had| had == name)
}
fn actuators(&mut self) -> Vec<Actuator> {
Vec::new()
}
fn hosts(&self) -> Vec<HostWire> {
Vec::new()
}
fn attach_host(&mut self, _name: &str, _peer: Box<dyn uart::Peer>) -> bool {
false
}
}
pub struct Target<'a> {
pub name: &'static str,
pub mcu: &'a mut dyn Mcu,
pub emulator: EmulatorCommand,
pub interrupt_line: fn(u16) -> Option<InterruptLine>,
}
impl std::fmt::Debug for Target<'_> {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter
.debug_struct("Target")
.field("name", &self.name)
.field("emulator", &self.emulator)
.finish_non_exhaustive()
}
}