42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
use stm32f4xx_hal::{
|
|
adc::Adc,
|
|
gpio::{
|
|
AF5, Alternate,
|
|
gpioa::*,
|
|
gpiob::*,
|
|
gpioe::*,
|
|
Output,
|
|
PushPull,
|
|
},
|
|
hal::{self, blocking::spi::Transfer, digital::v2::OutputPin},
|
|
spi::{Spi, NoMiso, TransferModeNormal},
|
|
pac::SPI2,
|
|
};
|
|
|
|
pub trait current_source_phy {
|
|
type max5719_spi: Transfer<u8>;
|
|
type max5719_load: OutputPin;
|
|
type current_source_ldo_en: OutputPin;
|
|
type current_source_short: OutputPin;
|
|
}
|
|
|
|
pub struct current_source_construct<C: current_source_phy> {
|
|
pub max5719_spi: C::max5719_spi,
|
|
pub max5719_load: C::max5719_load,
|
|
pub current_source_ldo_en: C::current_source_ldo_en,
|
|
pub current_source_short: C::current_source_short,
|
|
pub output_current : f32,
|
|
}
|
|
|
|
pub struct current_source_0;
|
|
|
|
impl current_source_phy for current_source_0 {
|
|
type max5719_spi = Spi<SPI2, (PB10<Alternate<5>>, NoMiso, PB15<Alternate<5>>), TransferModeNormal>;
|
|
type max5719_load = PE4<Output<PushPull>>;
|
|
type current_source_ldo_en = PE10<Output<PushPull>>;
|
|
type current_source_short = PA4<Output<PushPull>>;
|
|
}
|
|
|
|
|
|
|