mirror of
https://github.com/hubaldv/bioz-firmware-rs.git
synced 2025-12-06 05:01:18 +00:00
Working waveform (sinus) generator.
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -43,6 +43,7 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
// Set up SPI for AD5940
|
||||
let cs = Output::new(p.PC9, Level::High, Speed::Low);
|
||||
let rst = Output::new(p.PB3, Level::High, Speed::Low);
|
||||
|
||||
let spi = spi::Spi::new_blocking(
|
||||
p.SPI1,
|
||||
@@ -52,10 +53,13 @@ async fn main(_spawner: Spawner) {
|
||||
spi::Config::default()
|
||||
);
|
||||
|
||||
let mut ad5940 = AD5940::new(spi, cs);
|
||||
let mut ad5940 = AD5940::new(spi, cs, rst);
|
||||
ad5940.reset().await.unwrap();
|
||||
Timer::after_millis(1).await;
|
||||
ad5940.system_init().await.unwrap();
|
||||
|
||||
ad5940.init_temperature().await.unwrap();
|
||||
// ad5940.init_temperature().await.unwrap();
|
||||
ad5940.init_waveform().await.unwrap();
|
||||
|
||||
// Set up I2C for ADG2128
|
||||
let i2c = i2c::I2c::new_blocking(
|
||||
@@ -69,17 +73,18 @@ async fn main(_spawner: Spawner) {
|
||||
// Initialize electrodes
|
||||
let mut electrodes = Electrodes::new(i2c);
|
||||
electrodes.reset_all();
|
||||
electrodes.set(Electrode::E11, AD5940Pin::CE0, State::ENABLED);
|
||||
electrodes.set(Electrode::E12, AD5940Pin::RE0, State::ENABLED);
|
||||
|
||||
electrodes.set(Electrode::E1, AD5940Pin::CE0, State::ENABLED);
|
||||
electrodes.set(Electrode::E3, AD5940Pin::AIN1, State::ENABLED);
|
||||
// electrodes.set(Electrode::E12, AD5940Pin::RE0, State::ENABLED);
|
||||
|
||||
loop {
|
||||
// Read chip id
|
||||
// let chip_id = ad5940.get_chipid().await.unwrap();
|
||||
// info!("Chip ID: 0x{:04X}", chip_id);
|
||||
|
||||
// Read temperature
|
||||
let temp = ad5940.get_temperature().await.unwrap();
|
||||
info!("Temperature: {}°C", temp);
|
||||
// let temp = ad5940.get_temperature().await.unwrap();
|
||||
// info!("Temperature: {}°C", temp);
|
||||
|
||||
let result = electrodes.get_all();
|
||||
info!("Electrodes states: {:?}", result);
|
||||
|
||||
Reference in New Issue
Block a user