mirror of
https://github.com/hubaldv/bioz-firmware-rs.git
synced 2025-12-06 05:01:18 +00:00
Created basic lib for AD5940.
This commit is contained in:
46
src/main.rs
46
src/main.rs
@@ -4,23 +4,57 @@
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::{spi, Config};
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
mod ad5940;
|
||||
use ad5940::AD5940;
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
let mut config = Config::default();
|
||||
{
|
||||
use embassy_stm32::rcc::*;
|
||||
config.rcc.pll1 = Some(Pll {
|
||||
source: PllSource::HSI,
|
||||
prediv: PllPreDiv::DIV4,
|
||||
mul: PllMul::MUL8,
|
||||
divp: Some(PllDiv::DIV2),
|
||||
divq: Some(PllDiv::DIV2),
|
||||
divr: Some(PllDiv::DIV2),
|
||||
})
|
||||
}
|
||||
|
||||
let p = embassy_stm32::init(config);
|
||||
info!("Hello World!");
|
||||
|
||||
let mut led = Output::new(p.PA5, Level::High, Speed::Low);
|
||||
// let mut led = Output::new(p.PA5, Level::High, Speed::Low);
|
||||
|
||||
let cs = Output::new(p.PC9, Level::High, Speed::Low);
|
||||
|
||||
let spi = spi::Spi::new_blocking(
|
||||
p.SPI1,
|
||||
p.PA5, // SCK
|
||||
p.PA7, // MOSI
|
||||
p.PA6, // MISO
|
||||
spi::Config::default()
|
||||
);
|
||||
|
||||
let mut ad5940 = AD5940::new(spi, cs);
|
||||
|
||||
loop {
|
||||
info!("high");
|
||||
led.set_high();
|
||||
// Read chip id
|
||||
let chip_id = ad5940.get_chipid().unwrap();
|
||||
info!("Chip ID: 0x{:04X}", chip_id);
|
||||
|
||||
// info!("high");
|
||||
// led.set_high();
|
||||
Timer::after_millis(500).await;
|
||||
|
||||
info!("low");
|
||||
led.set_low();
|
||||
// info!("low");
|
||||
// led.set_low();
|
||||
Timer::after_millis(500).await;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user