gpio: Add AD7172 phy gpio init
- Will not function on rev0_2 kirdy due to wrong hardware connection
This commit is contained in:
parent
af8d361b95
commit
cdf900a5b6
|
@ -41,7 +41,7 @@ pub fn bootup(
|
|||
|
||||
sys_timer::setup(core_perif.SYST, clocks);
|
||||
|
||||
let (_eth_pins, usb, current_source_phy, max1968_phy) = gpio::setup(
|
||||
let (_eth_pins, usb, current_source_phy, _ad7172_phy, max1968_phy) = gpio::setup(
|
||||
clocks,
|
||||
perif.TIM4,
|
||||
perif.GPIOA,
|
||||
|
@ -51,6 +51,7 @@ pub fn bootup(
|
|||
perif.GPIOG,
|
||||
perif.SPI1,
|
||||
perif.SPI2,
|
||||
perif.SPI3,
|
||||
perif.OTG_FS_GLOBAL,
|
||||
perif.OTG_FS_DEVICE,
|
||||
perif.OTG_FS_PWRCLK,
|
||||
|
|
|
@ -2,12 +2,13 @@ use crate::laser_diode::current_sources::{self, CurrentSourcePhy};
|
|||
use crate::laser_diode::max5719;
|
||||
use crate::thermostat::ad5680;
|
||||
use crate::thermostat::max1968::{self, MAX1968PinSet, MAX1968Phy, PWM_FREQ_KHZ};
|
||||
use crate::thermostat::ad7172;
|
||||
use stm32_eth::EthPins;
|
||||
use stm32f4xx_hal::{
|
||||
gpio::{gpioa::*, gpiob::*, gpioc::*, gpiog::*, GpioExt, Input},
|
||||
otg_fs::USB,
|
||||
pac::{
|
||||
GPIOA, GPIOB, GPIOC, GPIOD, GPIOG, OTG_FS_DEVICE, OTG_FS_GLOBAL, OTG_FS_PWRCLK, SPI1, SPI2,
|
||||
GPIOA, GPIOB, GPIOC, GPIOD, GPIOG, OTG_FS_DEVICE, OTG_FS_GLOBAL, OTG_FS_PWRCLK, SPI1, SPI2, SPI3,
|
||||
TIM4,
|
||||
},
|
||||
rcc::Clocks,
|
||||
|
@ -28,6 +29,7 @@ pub fn setup(
|
|||
gpiog: GPIOG,
|
||||
spi1: SPI1,
|
||||
spi2: SPI2,
|
||||
spi3: SPI3,
|
||||
otg_fs_global: OTG_FS_GLOBAL,
|
||||
otg_fs_device: OTG_FS_DEVICE,
|
||||
otg_fs_pwrclk: OTG_FS_PWRCLK,
|
||||
|
@ -35,6 +37,7 @@ pub fn setup(
|
|||
EthernetPins,
|
||||
USB,
|
||||
CurrentSourcePhy<current_sources::Channel0>,
|
||||
ad7172::AdcPhy,
|
||||
MAX1968Phy<max1968::Channel0>,
|
||||
// thermostat_phy
|
||||
) {
|
||||
|
@ -118,5 +121,19 @@ pub fn setup(
|
|||
max_i_neg: max_i_neg0,
|
||||
});
|
||||
|
||||
(eth_pins, usb, current_source_phy, max1968_phy)
|
||||
let ad7172_phy = ad7172::Adc::new(
|
||||
Spi::new(spi3,
|
||||
(
|
||||
gpioc.pc10.into_alternate(),
|
||||
gpioc.pc11.into_alternate(),
|
||||
gpioc.pc12.into_alternate(),
|
||||
),
|
||||
ad7172::SPI_MODE,
|
||||
ad7172::SPI_CLOCK_MHZ.convert(),
|
||||
&clocks
|
||||
),
|
||||
gpiod.pd0.into_push_pull_output(),
|
||||
).unwrap();
|
||||
|
||||
(eth_pins, usb, current_source_phy, ad7172_phy, max1968_phy)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
use core::fmt;
|
||||
use log::{info, warn};
|
||||
use stm32f4xx_hal::hal::{
|
||||
blocking::spi::Transfer,
|
||||
digital::v2::OutputPin,
|
||||
use stm32f4xx_hal::
|
||||
{
|
||||
spi::{Spi, TransferModeNormal},
|
||||
pac::SPI3,
|
||||
gpio::{PC10, PC11, PC12, PD0, Alternate, Output, PushPull},
|
||||
hal::{
|
||||
blocking::spi::Transfer,
|
||||
digital::v2::OutputPin,
|
||||
},
|
||||
};
|
||||
use uom::si::{
|
||||
f64::ElectricPotential,
|
||||
|
@ -23,7 +29,16 @@ pub struct Adc<SPI: Transfer<u8>, NSS: OutputPin> {
|
|||
checksum_mode: ChecksumMode,
|
||||
}
|
||||
|
||||
type AdcSpi = Spi<SPI3, (PC10<Alternate<6>>, PC11<Alternate<6>>, PC12<Alternate<6>>), TransferModeNormal>;
|
||||
type AdcNss = PD0<Output<PushPull>>;
|
||||
pub type AdcPhy = Adc<AdcSpi, AdcNss>;
|
||||
|
||||
impl<SPI: Transfer<u8, Error = E>, NSS: OutputPin, E: fmt::Debug> Adc<SPI, NSS> {
|
||||
#[deprecated(note=
|
||||
"To be removed when rev0_3 has arrived.
|
||||
Rev0_2 has wrong SPI hardware connection bug.
|
||||
AD7172-2 is not accessible.
|
||||
")]
|
||||
pub fn new(spi: SPI, mut nss: NSS) -> Result<Self, SPI::Error> {
|
||||
let _ = nss.set_high();
|
||||
let mut adc = Adc {
|
||||
|
|
Loading…
Reference in New Issue