diff --git a/README.md b/README.md index c825bd4..d5875cc 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ The jobs provide information from `cargo build` and from `cargo tree` for debugg Different MCUs and boards have different hardware capabilities and the hal crates must reflect this. To accommodate these differences there are setup functions for each board/MCU. These pass a standardized set of devices to the application code. The standardized set (serial ports, -I2C pins, ...) is organized reduce changes in my hardware testing. -The setup is selected by environmental variables discussed further below. +I2C pins, ...) is organized to reduce hardware changes in my testing. +The setup is selected by environment variables discussed further below. The examples in `examples/misc` mostly contain their own copy of the setup functions, so they are self contained and easier to read. @@ -94,7 +94,7 @@ https://github.com/eldruin/driver-examples. I found this a very good starting pl The `radio-sx127x` examples are based on https://github.com/rust-iot/rust-radio-sx127x. -In the transition to `embedded-hal 1.0` there is some use of forks an branches that are ahead of the +In the transition to `embedded-hal 1.0` there is some use of forks and branches that are ahead of the main branch of official repositories. Hopefully it is a temporary situation. This can be checked in the Cargo.toml file. diff --git a/dev-testing/Cargo.toml b/dev-testing/Cargo.toml index 527d70f..5b73965 100644 --- a/dev-testing/Cargo.toml +++ b/dev-testing/Cargo.toml @@ -120,7 +120,10 @@ ina219 = { git = "https://github.com/tdittr/ina219", branch = "add-con #htu2xd = { git = "https://github.com/samcrow/HTU2XD" } htu21df-sensor = "0.1.4" #htu21df-sensor = { git = "https://gitlab.com/phgsng/htu21df-sensor" } -xca9548a = { git = "https://github.com/eldruin/xca9548a-rs" } +xca9548a = { git = "https://github.com/eldruin/xca9548a-rs", rev = "d0debd2" } +#xca9548a = { git = "https://github.com/eldruin/xca9548a-rs", rev = "f7ef250" } +#xca9548a = ">=1.0.0" +#xca9548a = { git = "https://github.com/eldruin/xca9548a-rs" } ens160 = { git = "https://github.com/teamplayer3/ens160", default-features = false } #ens160 = { git = "https://github.com/pdgilbert/ens160", features = ["no-std"], default-features = false } diff --git a/examples/driver-examples/ads1015-adc-display.rs b/examples/driver-examples/ads1015-adc-display.rs index 047e3ed..235f05a 100644 --- a/examples/driver-examples/ads1015-adc-display.rs +++ b/examples/driver-examples/ads1015-adc-display.rs @@ -26,7 +26,7 @@ use rtt_target::{rprintln, rtt_init_print}; use cortex_m_rt::entry; ///////////////////// ads -use ads1x1x::{Ads1x1x, channel, FullScaleRange, SlaveAddr}; +use ads1x1x::{Ads1x1x, channel, FullScaleRange, TargetAddr}; ///////////////////// ssd use ssd1306::{ prelude::*, I2CDisplayInterface, Ssd1306}; @@ -65,7 +65,7 @@ fn main() -> ! { let ssd_rcd = RefCellDevice::new(&i2cset_ref_cell); ///////////////////// ads - let mut adc = Ads1x1x::new_ads1015(adc_rcd, SlaveAddr::default()); //addr = Gnd + let mut adc = Ads1x1x::new_ads1015(adc_rcd, TargetAddr::default()); //addr = Gnd // need to be able to measure [0-5V] adc.set_full_scale_range(FullScaleRange::Within6_144V).unwrap(); diff --git a/examples/misc-i2c-drivers/ads_ina_ssd.rs b/examples/misc-i2c-drivers/ads_ina_ssd.rs index 882ed93..9d5d6bc 100644 --- a/examples/misc-i2c-drivers/ads_ina_ssd.rs +++ b/examples/misc-i2c-drivers/ads_ina_ssd.rs @@ -12,7 +12,7 @@ use panic_halt as _; use cortex_m_rt::entry; ///////////////////// ads -use ads1x1x::{Ads1x1x, channel, FullScaleRange, SlaveAddr}; +use ads1x1x::{Ads1x1x, channel, FullScaleRange, TargetAddr}; ///////////////////// ina use ina219::{address::{Address, Pin}, measurements::BusVoltage, SyncIna219}; @@ -175,8 +175,8 @@ fn main() -> ! { let ssd_rcd = RefCellDevice::new(&i2cset_ref_cell); ///////////////////// ads - let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, SlaveAddr::Gnd); - let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, SlaveAddr::Vdd); + let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, TargetAddr::Gnd); + let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, TargetAddr::Vdd); // set FullScaleRange to measure expected max voltage. adc_a.set_full_scale_range(FullScaleRange::Within4_096V).unwrap(); diff --git a/examples/misc-i2c-drivers/xca9548a.rs b/examples/misc-i2c-drivers/xca9548a.rs index 77e87aa..136f546 100644 --- a/examples/misc-i2c-drivers/xca9548a.rs +++ b/examples/misc-i2c-drivers/xca9548a.rs @@ -48,7 +48,7 @@ use shared_bus::cortex_m::prelude::_embedded_hal_blocking_i2c_WriteRead; //use embedded_io; //use embedded_io::{Read, Write, WriteRead}; -use xca9548a::{SlaveAddr, Xca9548a, I2cSlave}; //Error as xca9548aError, +use xca9548a::{Error as xca9548aError, TargetAddr, Xca9548a, I2cSlave}; //Error as xca9548aError, #[cfg(debug_assertions)] use panic_semihosting as _; @@ -240,11 +240,12 @@ fn main() -> ! { let slave_address = 0b010_0000; // example slave address let write_data = [0b0101_0101, 0b1010_1010]; // some data to be sent - let mut switch1 = Xca9548a::new(i2c2, SlaveAddr::default()); + let mut switch1 = Xca9548a::new(i2c2, TargetAddr::default()); // Enable channel 0 switch1.select_channels(0b0000_0001).unwrap(); +use embedded_hal::i2c::I2c; // write to device connected to channel 0 using the I2C switch if switch1.write(slave_address, &write_data).is_err() { //hprintln!("Error write channel 0!").unwrap(); diff --git a/examples/misc/battery_monitor_ads1015.rs b/examples/misc/battery_monitor_ads1015.rs index 17cce6e..2a5500a 100644 --- a/examples/misc/battery_monitor_ads1015.rs +++ b/examples/misc/battery_monitor_ads1015.rs @@ -38,7 +38,7 @@ use cortex_m_rt::entry; //use embedded_hal::delay::DelayNs; ///////////////////// ads -use ads1x1x::{Ads1x1x, channel, FullScaleRange, SlaveAddr, mode::OneShot, +use ads1x1x::{Ads1x1x, channel, FullScaleRange, TargetAddr, mode::OneShot, ic::{Ads1015, Resolution12Bit}}; ///////////////////// ssd @@ -184,11 +184,11 @@ fn main() -> ! { ///////////////////// ads - //let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, SlaveAddr::default()); //addr = GND - let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, SlaveAddr::Gnd); - let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, SlaveAddr::Vdd); - //let mut adc_c = Ads1x1x::new_ads1015(adc_c_rcd, SlaveAddr::Sda); - //let mut adc_d = Ads1x1x::new_ads1015(adc_d_rcd, SlaveAddr::Scl); + //let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, TargetAddr::default()); //addr = GND + let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, TargetAddr::Gnd); + let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, TargetAddr::Vdd); + //let mut adc_c = Ads1x1x::new_ads1015(adc_c_rcd, TargetAddr::Sda); + //let mut adc_d = Ads1x1x::new_ads1015(adc_d_rcd, TargetAddr::Scl); // set FullScaleRange to measure expected max voltage. // This is very small for diff across low value shunt resistors diff --git a/examples/misc/oled_temperature.rs b/examples/misc/oled_temperature.rs index d5507dc..7d06488 100644 --- a/examples/misc/oled_temperature.rs +++ b/examples/misc/oled_temperature.rs @@ -45,7 +45,7 @@ use cortex_m_rt::entry; use cortex_m_semihosting::hprintln; ///////////////////// ads -use ads1x1x::{Ads1x1x, channel, FullScaleRange, SlaveAddr}; +use ads1x1x::{Ads1x1x, channel, FullScaleRange, TargetAddr}; ///////////////////// ssd @@ -141,7 +141,7 @@ fn main() -> ! { led.blink(500_u16, &mut delay); // to confirm startup ///////////////////// ads - let mut adc = Ads1x1x::new_ads1015(adc_rcd, SlaveAddr::default()); //addr = Gnd + let mut adc = Ads1x1x::new_ads1015(adc_rcd, TargetAddr::default()); //addr = Gnd // to measure [0-5V] use FullScaleRange::Within6_144V adc.set_full_scale_range(FullScaleRange::Within6_144V).unwrap(); diff --git a/examples/projects/temperature-display.rs b/examples/projects/temperature-display.rs index b52ec41..04ffcdc 100644 --- a/examples/projects/temperature-display.rs +++ b/examples/projects/temperature-display.rs @@ -43,13 +43,13 @@ systick_monotonic!(Mono, 1000); #[cfg_attr(feature = "stm32l4xx", app(device = stm32l4xx_hal::pac, dispatchers = [TIM2, TIM3]))] mod app { -// use ads1x1x::{Ads1x1x, DynamicOneShot, FullScaleRange, SlaveAddr, +// use ads1x1x::{Ads1x1x, DynamicOneShot, FullScaleRange, TargetAddr, // ChannelSelection, // ic::{Ads1015, Resolution12Bit}, // interface::I2cInterface}; use ads1x1x::{Ads1x1x, ic::Ads1015, ic::Resolution12Bit, channel, - FullScaleRange, SlaveAddr}; + FullScaleRange, TargetAddr}; //use cortex_m_semihosting::{debug, hprintln}; @@ -200,15 +200,15 @@ mod app { // ADS11x5 chips allows four different I2C addresses using one address pin ADDR. // Connect ADDR pin to GND for 0x48(1001000) , to VCC for 0x49. to SDA for 0x4A, and to SCL for 0x4B. - let mut adc_a = Ads1x1x::new_ads1015(manager1.acquire_i2c(), SlaveAddr::Gnd); - let mut adc_b = Ads1x1x::new_ads1015(manager1.acquire_i2c(), SlaveAddr::Vdd); - let mut adc_c = Ads1x1x::new_ads1015(manager1.acquire_i2c(), SlaveAddr::Sda); - let mut adc_d = Ads1x1x::new_ads1015(manager1.acquire_i2c(), SlaveAddr::Scl); + let mut adc_a = Ads1x1x::new_ads1015(manager1.acquire_i2c(), TargetAddr::Gnd); + let mut adc_b = Ads1x1x::new_ads1015(manager1.acquire_i2c(), TargetAddr::Vdd); + let mut adc_c = Ads1x1x::new_ads1015(manager1.acquire_i2c(), TargetAddr::Sda); + let mut adc_d = Ads1x1x::new_ads1015(manager1.acquire_i2c(), TargetAddr::Scl); - // let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, SlaveAddr::Gnd); - // let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, SlaveAddr::Vdd); - // let mut adc_c = Ads1x1x::new_ads1015(adc_c_rcd, SlaveAddr::Sda); - // let mut adc_d = Ads1x1x::new_ads1015(adc_d_rcd, SlaveAddr::Scl); + // let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, TargetAddr::Gnd); + // let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, TargetAddr::Vdd); + // let mut adc_c = Ads1x1x::new_ads1015(adc_c_rcd, TargetAddr::Sda); + // let mut adc_d = Ads1x1x::new_ads1015(adc_d_rcd, TargetAddr::Scl); // set FullScaleRange to measure expected max voltage. // This is very small if measuring diff across low value shunt resistors for current diff --git a/examples/projects/temperature-display_4jst.rs b/examples/projects/temperature-display_4jst.rs index a49c8f3..711bf61 100644 --- a/examples/projects/temperature-display_4jst.rs +++ b/examples/projects/temperature-display_4jst.rs @@ -64,7 +64,7 @@ systick_monotonic!(Mono, 1000); mod app { - use ads1x1x::{Ads1x1x, ic::Ads1115, ic::Resolution16Bit, channel, FullScaleRange, SlaveAddr}; + use ads1x1x::{Ads1x1x, ic::Ads1115, ic::Resolution16Bit, channel, FullScaleRange, TargetAddr}; //use cortex_m_semihosting::{debug, hprintln}; //use cortex_m_semihosting::{hprintln}; @@ -215,10 +215,10 @@ mod app { // Connect ADDR pin to GND for 0x48(1001000) , to VCC for 0x49. to SDA for 0x4A, and to SCL for 0x4B. // also set j0 to 0 / 4 / 8 / 12 in show_display() - let mut adc = Ads1x1x::new_ads1115(i2c1, SlaveAddr::Gnd); - //let mut adc = Ads1x1x::new_ads1115(i2c1, SlaveAddr::Vdd); - //let mut adc = Ads1x1x::new_ads1115(i2c1, SlaveAddr::Sda); - //let mut adc = Ads1x1x::new_ads1115(i2c1, SlaveAddr::Scl); + let mut adc = Ads1x1x::new_ads1115(i2c1, TargetAddr::Gnd); + //let mut adc = Ads1x1x::new_ads1115(i2c1, TargetAddr::Vdd); + //let mut adc = Ads1x1x::new_ads1115(i2c1, TargetAddr::Sda); + //let mut adc = Ads1x1x::new_ads1115(i2c1, TargetAddr::Scl); //hprintln!("adc initialized.").unwrap(); show_message("adc initialized.", &mut display); diff --git a/examples/radio-sx127x/lora_spi_send.rs b/examples/radio-sx127x/lora_spi_send.rs index b31e96a..35b2b31 100644 --- a/examples/radio-sx127x/lora_spi_send.rs +++ b/examples/radio-sx127x/lora_spi_send.rs @@ -1,5 +1,8 @@ //! Transmit a simple message with LoRa using crate radio_sx127x (on SPI). //! +//! Status: tested working on stm32g474 in debug with probe, Sept 5, 2024. +//! Does not work on battery without debug because of hprintln. +//! //! The setup() functions make the application code common. They are in src/setup_all*. //! The specific function used will depend on the HAL setting (see README.md). //! See the setup() corresponding to the HAL for details on pin connections. diff --git a/examples/rtic/ads_ina_ssd_rtic.rs b/examples/rtic/ads_ina_ssd_rtic.rs index 3230e74..1f3e668 100644 --- a/examples/rtic/ads_ina_ssd_rtic.rs +++ b/examples/rtic/ads_ina_ssd_rtic.rs @@ -47,7 +47,7 @@ mod app { use ads1x1x::{Ads1x1x, channel, mode::OneShot, //Ads1015, Resolution12Bit, PRIVATE? - FullScaleRange, SlaveAddr}; + FullScaleRange, TargetAddr}; ///////////////////// ina use ina219::{address::{Address, Pin}, @@ -176,14 +176,14 @@ mod app { // let ssd_rcd = RefCellDevice::new(&i2cset_ref_cell); ///////////////////// ads -// let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, SlaveAddr::Gnd); -// let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, SlaveAddr::Vdd); +// let mut adc_a = Ads1x1x::new_ads1015(adc_a_rcd, TargetAddr::Gnd); +// let mut adc_b = Ads1x1x::new_ads1015(adc_b_rcd, TargetAddr::Vdd); // // set FullScaleRange to measure expected max voltage. // adc_a.set_full_scale_range(FullScaleRange::Within4_096V).unwrap(); // adc_b.set_full_scale_range(FullScaleRange::Within4_096V).unwrap(); - let mut adc_a = Ads1x1x::new_ads1015(ArbiterDevice::new(i2c_arbiter), SlaveAddr::Gnd); - let mut adc_b = Ads1x1x::new_ads1015(ArbiterDevice::new(i2c_arbiter), SlaveAddr::Vdd); + let mut adc_a = Ads1x1x::new_ads1015(ArbiterDevice::new(i2c_arbiter), TargetAddr::Gnd); + let mut adc_b = Ads1x1x::new_ads1015(ArbiterDevice::new(i2c_arbiter), TargetAddr::Vdd); // set FullScaleRange to measure expected max voltage. adc_a.set_full_scale_range(FullScaleRange::Within4_096V).unwrap(); adc_b.set_full_scale_range(FullScaleRange::Within4_096V).unwrap(); diff --git a/examples/rtic/battery_monitor_ads1015_rtic.rs b/examples/rtic/battery_monitor_ads1015_rtic.rs index d1690d0..1388508 100644 --- a/examples/rtic/battery_monitor_ads1015_rtic.rs +++ b/examples/rtic/battery_monitor_ads1015_rtic.rs @@ -46,12 +46,12 @@ mod app { use rtic_monotonics::systick::prelude::*; ///////////////////// ads - // use ads1x1x::{Ads1x1x, DynamicOneShot, FullScaleRange, SlaveAddr, + // use ads1x1x::{Ads1x1x, DynamicOneShot, FullScaleRange, TargetAddr, // ChannelSelection, // ic::{Ads1015, Resolution12Bit}, // interface::I2cInterface}; - use ads1x1x::{Ads1x1x, channel, FullScaleRange, SlaveAddr, + use ads1x1x::{Ads1x1x, channel, FullScaleRange, TargetAddr, ic::{Ads1015, Resolution12Bit}, }; @@ -216,10 +216,10 @@ mod app { // let manager: &'static _ = shared_bus::new_cortexm!(I2c2Type = i2c2).unwrap(); - let mut adc_a = Ads1x1x::new_ads1015(i2c2, SlaveAddr::Gnd); -// let mut adc_b = Ads1x1x::new_ads1015(i2c2, SlaveAddr::Vdd); -// let mut adc_a = Ads1x1x::new_ads1015(manager.acquire_i2c(), SlaveAddr::Gnd); -// let mut adc_b = Ads1x1x::new_ads1015(manager.acquire_i2c(), SlaveAddr::Vdd); + let mut adc_a = Ads1x1x::new_ads1015(i2c2, TargetAddr::Gnd); +// let mut adc_b = Ads1x1x::new_ads1015(i2c2, TargetAddr::Vdd); +// let mut adc_a = Ads1x1x::new_ads1015(manager.acquire_i2c(), TargetAddr::Gnd); +// let mut adc_b = Ads1x1x::new_ads1015(manager.acquire_i2c(), TargetAddr::Vdd); // FullScaleRange is very small for diff across low value shunt resistors for current // but up to 5v when measuring usb power. diff --git a/src/PinMap.txt b/src/PinMap.txt index f656190..7168e90 100644 --- a/src/PinMap.txt +++ b/src/PinMap.txt @@ -62,6 +62,7 @@ PA0 PA1 PA2 PA3 PA5 PA6 PA7 PA8 PA9 PA10 PA11 /////////////////////////////// stm32f4xx /////////////////////////////// +https://stm32world.com/wiki/Black_Pill TIM5 delay = dp.TIM5.delay::<1000000_u32>(&clocks); @@ -88,10 +89,12 @@ PA3 rx2 gpioa.pa3.into_alternate(), PA11 tx3 on USART6 gpioa.pa11.into_alternate(), TRY TO RESOLVE CONFILICT WITH CsPin below PA12 rx3 gpioa.pa12.into_alternate(), -PA5 sck dp.SPI1 gpioa.pa5.into_alternate(), // sck -PA6 miso gpioa.pa6.into_alternate(), // miso -PA7 mosi gpioa.pa7.into_alternate(), // mosi - MODE, 8.MHz(), +PA4 nss1 SHOULD PROBABLY USE THIS IN PLACE OF PA11 (Cs) BUT NEED TO CONFIRM +PA5 sck1 dp.SPI1 gpioa.pa5.into_alternate(), // sck +PA6 miso1 gpioa.pa6.into_alternate(), // miso +PA7 mosi1 gpioa.pa7.into_alternate(), // mosi MODE, 8.MHz(), + +nss vs cs ?? https://stackoverflow.com/questions/35780290/how-can-i-use-hardware-nss-spi-on-stm32f4 PA11 CsPin Sx127x::spi( gpioa.pa11.into_push_pull_output(), //CsPin (still unresolved conflict with tx3 above) PB4 BusyPin gpiob.pb8.into_floating_input(), //BusyPin DI00 triggers RxDone/TxDone status. @@ -103,7 +106,7 @@ PA1 adc1 AdcSensor1Type ch: gpioa.pa1.into_analog(), PC13 PB3 PB8 PB9 PB10 -PA0 PA1 PA2 PA3 PA5 PA6 PA7 PA8 PA9 PA10 PA11 +PA0 PA1 PA2 PA3 PA5 PA6 PA7 PA8 PA9 PA10 PA11 PA12 /////////////////////////////// stm32g4xx /////////////////////////////// @@ -134,9 +137,10 @@ PA3 rx2 gpioa.pa3.into_alternate(), PB10 tx3 USART3 gpiob.pb10.into_alternate(), PB11 rx3 gpiob.pb11.into_alternate(), -PA5 sck SPI1.spi( (gpioa.pa5.into_alternate(), // sck -PA6 miso gpioa.pa6.into_alternate(), // miso -PA7 mosi gpioa.pa7.into_alternate(), // mosi +PA4 nss1 SHOULD PROBABLY USE THIS IN PLACE OF PA11 (Cs) BUT NEED TO CONFIRM +PA5 sck1 SPI1.spi( (gpioa.pa5.into_alternate(), // sck +PA6 miso1 gpioa.pa6.into_alternate(), // miso +PA7 mosi1 gpioa.pa7.into_alternate(), // mosi ), MODE_0, 400.kHz(), &mut rcc, ); PA11 CsPin Sx127x gpioa.pa11.into_push_pull_output(), //CsPin diff --git a/src/setup_all_stm32f4xx.rs b/src/setup_all_stm32f4xx.rs index 1339256..55eac38 100644 --- a/src/setup_all_stm32f4xx.rs +++ b/src/setup_all_stm32f4xx.rs @@ -7,7 +7,7 @@ pub use hal::{ spi::{Spi}, i2c::I2c, //this is a type serial::{Serial, Tx, Rx, Error}, - gpio::{Output, OpenDrain, PushPull, Analog, GpioExt}, + gpio::{Output, OpenDrain, PushPull, Analog, GpioExt, Input}, adc::Adc, prelude::*, prelude, @@ -22,7 +22,8 @@ pub use stm32f4xx_hal::{ timer::{TimerExt}, serial::{config::Config}, gpio::{Pin}, - gpio::{gpioa::{PA1, PA8, }}, + gpio::{gpioa::{PA0, PA1, PA8, PA4, PA5, PA6, PA7}}, + gpio::{gpiob::{PB4, PB5}}, gpio::{gpioc::{PC13 as LEDPIN}}, adc::{config::{AdcConfig, SampleTime}}, }; @@ -62,10 +63,15 @@ pub type TxType = Tx1Type; pub type RxType = Rx1Type; pub type SpiType = Spi; -pub struct SpiExt { pub cs: Pin<'A', 11, Output>, - pub busy: Pin<'B', 4>, - pub ready: Pin<'B', 5>, - pub reset: Pin<'A', 0, Output> +//pub struct SpiExt { pub cs: Pin<'A', 4, Output>, +// pub busy: Pin<'B', 4>, +// pub ready: Pin<'B', 5>, +// pub reset: Pin<'A', 0, Output> +//} +pub struct SpiExt { pub cs: PA4>, + pub busy: PB4>, + pub ready: PB5>, + pub reset: PA0> } @@ -134,7 +140,7 @@ pub fn all_from_dp(dp: Peripherals) -> ); let spiext = SpiExt { - cs: gpioa.pa11.into_push_pull_output(), //CsPin + cs: gpioa.pa4.into_push_pull_output(), //CsPin busy: gpiob.pb4.into_floating_input(), //BusyPin DI00 ready: gpiob.pb5.into_floating_input(), //ReadyPin DI01 reset: gpioa.pa0.into_push_pull_output(), //ResetPin diff --git a/src/setup_all_stm32g4xx.rs b/src/setup_all_stm32g4xx.rs index 22e184b..b11991b 100644 --- a/src/setup_all_stm32g4xx.rs +++ b/src/setup_all_stm32g4xx.rs @@ -26,7 +26,7 @@ pub use stm32g4xx_hal::{ spi::{Mode, Phase, Polarity}, serial::{FullConfig, NoDMA}, gpio::{Alternate, AlternateOD, Input, Floating, - gpioa::{PA0, PA1, PA2, PA3, PA5, PA6, PA7, PA8, PA9, PA10, PA11}, + gpioa::{PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10}, gpiob::{PB4, PB5, PB7, PB8, PB9}, gpioc::{PC4, PC6 as LEDPIN}}, // weact-stm32g474CEU6 has onboard led on PC6 adc::{config::{SampleTime}, Disabled, AdcClaim, ClockSource}, @@ -75,7 +75,7 @@ pub type TxType = Tx1Type; pub type RxType = Rx1Type; pub type SpiType = Spi>, PA6>, PA7>)>; -pub struct SpiExt { pub cs: PA11>, +pub struct SpiExt { pub cs: PA4>, pub busy: PB4>, pub ready: PB5>, pub reset: PA0> @@ -141,7 +141,7 @@ pub fn all_from_dp(dp: Peripherals) -> ); let spiext = SpiExt { - cs: gpioa.pa11.into_push_pull_output(), //CsPin + cs: gpioa.pa4.into_push_pull_output(), //CsPin busy: gpiob.pb4.into_floating_input(), //BusyPin DI00 ready: gpiob.pb5.into_floating_input(), //ReadyPin DI01 reset: gpioa.pa0.into_push_pull_output(), //ResetPin