Added lineairmap to lib for sequencer.

This commit is contained in:
2025-08-14 13:23:23 +02:00
parent f1015ee00d
commit 03a04bf789
5 changed files with 88 additions and 26 deletions

View File

@@ -88,7 +88,7 @@ async fn main(spawner: Spawner) {
ad5940.system_init().await.unwrap();
// ad5940.init_temperature().await.unwrap();
ad5940.init_waveform().await.unwrap();
// ad5940.init_waveform().await.unwrap();
ad5940.init_impedance().await.unwrap();
// // Set up I2C for ADG2128
@@ -116,22 +116,26 @@ async fn main(spawner: Spawner) {
// Sequencer test
ad5940.sequencer_enable(true).await;
ad5940.wgfcw(100).await;
ad5940.wgfcw(50000).await;
let wg_amplitude = 2047; // 2047 is the maximum amplitude for a 12-bit DAC --> 1.62V peak-to-peak
ad5940.write_reg(ad5940::Register::WGAMPLITUDE, wg_amplitude).await.unwrap();
// Rcal
ad5940.swcon(SWCON::DMUXCON_DR0 | SWCON::PMUXCON_PR0 | SWCON::NMUXCON_NR1 | SWCON::TMUXCON_TR1 | SWCON::T9CON).await; // RCAL0 -->
ad5940.afecon(AFECON::WAVEGENEN | AFECON::ADCEN, true).await;
ad5940.sequencer_wait(16*10).await; // 10 us
ad5940.afecon(AFECON::ADCCONVEN | AFECON::DFTEN, true).await;
ad5940.sequencer_wait(16 * 1_500_000).await; // 1.5 second
ad5940.sequencer_wait(16 * 750_000).await; // 0.75 second
ad5940.afecon(AFECON::WAVEGENEN | AFECON:: ADCEN | AFECON::ADCCONVEN | AFECON::DFTEN, false).await;
ad5940.write_reg(ad5940::Register::AFECON, 0x0000_FFFF).await.unwrap();
// Rz
ad5940.swcon(SWCON::DMUXCON_D5 | SWCON::PMUXCON_P11 | SWCON::NMUXCON_N2 | SWCON::TMUXCON_MSK | SWCON::TMUXCON_T2).await;
ad5940.swcon(SWCON::DMUXCON_D5 | SWCON::PMUXCON_P11 | SWCON::NMUXCON_N2 | SWCON::TMUXCON_T2 | SWCON::T9CON).await;
ad5940.afecon(AFECON::WAVEGENEN | AFECON::ADCEN, true).await;
ad5940.sequencer_wait(16*10).await; // 10 us
ad5940.afecon(AFECON::ADCCONVEN | AFECON::DFTEN, true).await;
ad5940.sequencer_wait(16 * 1_500_000).await; // 1.5 second
ad5940.sequencer_wait(16 * 750_000).await; // 0.75 second
ad5940.afecon(AFECON::WAVEGENEN | AFECON:: ADCEN | AFECON::ADCCONVEN | AFECON::DFTEN, false).await;
// Toggle leds
@@ -174,7 +178,7 @@ async fn main(spawner: Spawner) {
// info!("Mainloop still running!");
Timer::after_millis(3500).await;
Timer::after_millis(1750).await;
// let test = ad5940.read_reg_raw(0x2200).await.unwrap();
// info!("FIFOCNTSTA: {}", (test>>16) & 0b111_1111_1111);
@@ -222,7 +226,6 @@ async fn green_led(mut led: Output<'static>) {
async fn ad5940_readout_task(mut pin: ExtiInput<'static>) {
loop {
pin.wait_for_falling_edge().await;
info!("AD5940 interrupt triggered!");
}
}