use crate::mcu::Mcu;
use crate::sidecar::{InterruptLine, SidecarCommand};
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>;
#[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
}
#[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 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 target(&self, name: &str) -> Option<usize> {
self.target_names().iter().position(|&had| had == name)
}
}
pub struct Target<'a> {
pub name: &'static str,
pub mcu: &'a mut dyn Mcu,
pub sidecar: SidecarCommand,
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("sidecar", &self.sidecar)
.finish_non_exhaustive()
}
}