use stm32f4xx_hal::{ adc::Adc, gpio::{ AF5, Alternate, Analog, Input, gpioa::*, gpiob::*, gpioc::*, gpiod::*, gpioe::*, gpiof::*, gpiog::*, GpioExt, Output, PushPull, }, hal::{self, blocking::spi::Transfer, digital::v2::OutputPin}, otg_fs::USB, rcc::Clocks, spi, spi::{Spi, NoMiso, TransferModeNormal}, pac::{ ADC1, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, OTG_FS_GLOBAL, OTG_FS_DEVICE, OTG_FS_PWRCLK, SPI1, SPI2, SPI3, TIM4 }, timer::Timer, time::U32Ext, time::MegaHertz }; use fugit::RateExtU32; use stm32_eth::EthPins; use crate::laser_diode::current_sources::*; pub type EthernetPins = EthPins< PA1, PA7, PB11, PG13, PB13, PC4, PC5, >; pub fn setup( clocks: Clocks, tim4: TIM4, gpioa: GPIOA, gpiob: GPIOB, gpioc: GPIOC, gpiod: GPIOD, gpioe: GPIOE, gpiof: GPIOF, gpiog: GPIOG, spi1: SPI1, spi2: SPI2, spi3: SPI3, adc1: ADC1, otg_fs_global: OTG_FS_GLOBAL, otg_fs_device: OTG_FS_DEVICE, otg_fs_pwrclk: OTG_FS_PWRCLK, ) -> ( EthernetPins, USB, current_source_phy_construct, // photo_diode_phy, // thermostat_phy ) { let gpioa = gpioa.split(); let gpiob = gpiob.split(); let gpioc = gpioc.split(); let gpiod = gpiod.split(); let gpioe = gpioe.split(); let gpiof = gpiof.split(); let gpiog = gpiog.split(); let usb = USB { usb_global: otg_fs_global, usb_device: otg_fs_device, usb_pwrclk: otg_fs_pwrclk, pin_dm: gpioa.pa11.into_alternate(), pin_dp: gpioa.pa12.into_alternate(), hclk: clocks.hclk(), }; let eth_pins = EthPins { ref_clk: gpioa.pa1, crs: gpioa.pa7, tx_en: gpiob.pb11, tx_d0: gpiog.pg13, tx_d1: gpiob.pb13, rx_d0: gpioc.pc4, rx_d1: gpioc.pc5, }; let current_source_phy = current_source_phy_construct { max5719_spi: Spi::new( spi2, (gpiob.pb10.into_alternate(), NoMiso {}, gpiob.pb15.into_alternate()), spi::Mode { polarity: spi::Polarity::IdleLow, phase: spi::Phase::CaptureOnFirstTransition, }, 10_u32.MHz(), &clocks), max5719_load: gpiob.pb14.into_push_pull_output(), max5719_cs: gpiod.pd8.into_push_pull_output(), current_source_ldo_en: gpiod.pd9.into_push_pull_output(), current_source_short: gpioa.pa4.into_push_pull_output() }; (eth_pins, usb, current_source_phy) }