use core::marker::PhantomData;
pub trait IsUnlocked {}
pub trait InputMode {}
pub trait OutputMode {}
pub trait OpenDrainMode {
fn pup() -> bool;
}
pub trait AlternateFunctionChoice {
fn number() -> u32;
}
pub struct Input<MODE>
where
MODE: InputMode,
{
_mode: PhantomData<MODE>,
}
impl<MODE> IsUnlocked for Input<MODE> where MODE: InputMode {}
pub struct Floating;
impl InputMode for Floating {}
impl OpenDrainMode for Floating {
fn pup() -> bool {
false
}
}
pub struct PullDown;
impl InputMode for PullDown {}
pub struct PullUp;
impl InputMode for PullUp {}
impl OpenDrainMode for PullUp {
fn pup() -> bool {
true
}
}
pub struct Tristate;
impl IsUnlocked for Tristate {}
pub struct Output<MODE>
where
MODE: OutputMode,
{
_mode: PhantomData<MODE>,
}
impl<MODE> IsUnlocked for Output<MODE> where MODE: OutputMode {}
pub struct AlternateFunction<AF, MODE>
where
AF: AlternateFunctionChoice,
MODE: OutputMode,
{
_func: PhantomData<AF>,
_mode: PhantomData<MODE>,
}
impl<AF, MODE> IsUnlocked for AlternateFunction<AF, MODE>
where
AF: AlternateFunctionChoice,
MODE: OutputMode,
{
}
pub struct PushPull;
impl OutputMode for PushPull {}
impl OutputMode for PullDown {}
impl OutputMode for PullUp {}
pub struct OpenDrain<ODM>
where
ODM: OpenDrainMode,
{
_pull: PhantomData<ODM>,
}
impl<ODM> OutputMode for OpenDrain<ODM> where ODM: OpenDrainMode {}
pub struct AF1;
impl AlternateFunctionChoice for AF1 {
fn number() -> u32 {
1
}
}
pub struct AF2;
impl AlternateFunctionChoice for AF2 {
fn number() -> u32 {
2
}
}
pub struct AF3;
impl AlternateFunctionChoice for AF3 {
fn number() -> u32 {
3
}
}
pub struct AF4;
impl AlternateFunctionChoice for AF4 {
fn number() -> u32 {
4
}
}
pub struct AF5;
impl AlternateFunctionChoice for AF5 {
fn number() -> u32 {
5
}
}
pub struct AF6;
impl AlternateFunctionChoice for AF6 {
fn number() -> u32 {
6
}
}
pub struct AF7;
impl AlternateFunctionChoice for AF7 {
fn number() -> u32 {
7
}
}
pub struct AF8;
impl AlternateFunctionChoice for AF8 {
fn number() -> u32 {
8
}
}
pub struct AF9;
impl AlternateFunctionChoice for AF9 {
fn number() -> u32 {
9
}
}
pub struct AF14;
impl AlternateFunctionChoice for AF14 {
fn number() -> u32 {
14
}
}
pub struct Locked;
pub enum InterruptMode {
LevelLow,
LevelHigh,
EdgeRising,
EdgeFalling,
EdgeBoth,
Disabled,
}