Skip to content

Commit

Permalink
update for ads1x1x api change. Ongoing lora/spi testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdgilbert committed Sep 5, 2024
1 parent 4eff72c commit 6ce2830
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 63 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down
5 changes: 4 additions & 1 deletion dev-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
4 changes: 2 additions & 2 deletions examples/driver-examples/ads1015-adc-display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions examples/misc-i2c-drivers/ads_ina_ssd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions examples/misc-i2c-drivers/xca9548a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions examples/misc/battery_monitor_ads1015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/misc/oled_temperature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 10 additions & 10 deletions examples/projects/temperature-display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions examples/projects/temperature-display_4jst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions examples/radio-sx127x/lora_spi_send.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 5 additions & 5 deletions examples/rtic/ads_ina_ssd_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions examples/rtic/battery_monitor_ads1015_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};

Expand Down Expand Up @@ -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.
Expand Down
20 changes: 12 additions & 8 deletions src/PinMap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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.
Expand All @@ -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 ///////////////////////////////
Expand Down Expand Up @@ -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
Expand Down
20 changes: 13 additions & 7 deletions src/setup_all_stm32f4xx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}},
};
Expand Down Expand Up @@ -62,10 +63,15 @@ pub type TxType = Tx1Type;
pub type RxType = Rx1Type;

pub type SpiType = Spi<SPI1>;
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<Output<PushPull>>,
pub busy: PB4<Input<>>,
pub ready: PB5<Input<>>,
pub reset: PA0<Output<PushPull>>
}


Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/setup_all_stm32g4xx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -75,7 +75,7 @@ pub type TxType = Tx1Type;
pub type RxType = Rx1Type;

pub type SpiType = Spi<SPI1,(PA5<Alternate<5>>, PA6<Alternate<5>>, PA7<Alternate<5>>)>;
pub struct SpiExt { pub cs: PA11<Output<PushPull>>,
pub struct SpiExt { pub cs: PA4<Output<PushPull>>,
pub busy: PB4<Input<Floating>>,
pub ready: PB5<Input<Floating>>,
pub reset: PA0<Output<PushPull>>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6ce2830

Please sign in to comment.