From 08fa3fa0a069e02e38ea4ca56d775d01c5c72b33 Mon Sep 17 00:00:00 2001 From: Andre Dunford Date: Fri, 16 Dec 2022 23:41:59 -0800 Subject: [PATCH] implement sweep standby configuration --- Software/VNA_embedded/Application/App.cpp | 7 +++++- .../Application/Communication/Protocol.cpp | 1 + .../Application/Communication/Protocol.hpp | 3 ++- Software/VNA_embedded/Application/VNA.cpp | 25 ++++++++++++++++--- Software/VNA_embedded/Application/VNA.hpp | 2 ++ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Software/VNA_embedded/Application/App.cpp b/Software/VNA_embedded/Application/App.cpp index 34e78d9..9882420 100644 --- a/Software/VNA_embedded/Application/App.cpp +++ b/Software/VNA_embedded/Application/App.cpp @@ -183,6 +183,11 @@ inline void App_Process() { Communication::SendWithoutPayload(Protocol::PacketType::Ack); } break; + case Protocol::PacketType::InitiateSweep: { + VNA::InitiateSweep(); + Communication::SendWithoutPayload(Protocol::PacketType::Ack); + } + break; case Protocol::PacketType::SetIdle: HW::SetMode(HW::Mode::Idle); sweepActive = false; @@ -314,7 +319,7 @@ inline void App_Process() { } } } - if(HW::TimedOut()) { + if(!VNA::GetStandbyMode() && HW::TimedOut()) { HW::SetMode(HW::Mode::Idle); // insert the last received packet (restarts the timed out operation) Communication::BlockNextAck(); diff --git a/Software/VNA_embedded/Application/Communication/Protocol.cpp b/Software/VNA_embedded/Application/Communication/Protocol.cpp index e302a33..f16f621 100644 --- a/Software/VNA_embedded/Application/Communication/Protocol.cpp +++ b/Software/VNA_embedded/Application/Communication/Protocol.cpp @@ -125,6 +125,7 @@ uint16_t Protocol::EncodePacket(const PacketInfo &packet, uint8_t *dest, uint16_ case PacketType::ClearTrigger: case PacketType::StopStatusUpdates: case PacketType::StartStatusUpdates: + case PacketType::InitiateSweep: // no payload break; case PacketType::VNADatapoint: payload_size = packet.VNAdatapoint->requiredBufferSize(); break; diff --git a/Software/VNA_embedded/Application/Communication/Protocol.hpp b/Software/VNA_embedded/Application/Communication/Protocol.hpp index f50f7af..11f9f02 100644 --- a/Software/VNA_embedded/Application/Communication/Protocol.hpp +++ b/Software/VNA_embedded/Application/Communication/Protocol.hpp @@ -159,7 +159,7 @@ using SweepSettings = struct _sweepSettings { uint16_t points; uint32_t if_bandwidth; int16_t cdbm_excitation_start; // in 1/100 dbm - uint16_t unused:1; + uint16_t standby:1; uint16_t syncMaster:1; uint16_t suppressPeaks:1; uint16_t fixedPowerSetting:1; // if set the attenuator and source PLL power will not be changed across the sweep @@ -366,6 +366,7 @@ enum class PacketType : uint8_t { ClearTrigger = 29, StopStatusUpdates = 30, StartStatusUpdates = 31, + InitiateSweep = 32 }; using PacketInfo = struct _packetinfo { diff --git a/Software/VNA_embedded/Application/VNA.cpp b/Software/VNA_embedded/Application/VNA.cpp index 5dc7cd0..2f2c588 100644 --- a/Software/VNA_embedded/Application/VNA.cpp +++ b/Software/VNA_embedded/Application/VNA.cpp @@ -258,12 +258,26 @@ bool VNA::Setup(Protocol::SweepSettings s) { // Enable new data and sweep halt interrupt FPGA::EnableInterrupt(FPGA::Interrupt::NewData); FPGA::EnableInterrupt(FPGA::Interrupt::SweepHalted); - // Start the sweep + // Start the sweep if not configured for standby firstPoint = true; - FPGA::StartSweep(); + if(!settings.standby){ + FPGA::StartSweep(); + } return true; } +void VNA::InitiateSweep() { + // Invoked by a host via InitiateSweep packet + if(settings.standby){ + // make sure that SweepSettings have been configured for standby operation + FPGA::StartSweep(); + } +} + +bool VNA::GetStandbyMode() { + return settings.standby; +} + static void PassOnData() { Protocol::PacketInfo info; info.type = Protocol::PacketType::VNADatapoint; @@ -330,8 +344,11 @@ void VNA::Work() { Communication::Send(packet); } // do not reset unlevel flag here, as it is calculated only once at the setup of the sweep - // Start next sweep - FPGA::StartSweep(); + // Start next sweep if not configured for standby + if (!settings.standby){ + FPGA::StartSweep(); + } + } void VNA::SweepHalted() { diff --git a/Software/VNA_embedded/Application/VNA.hpp b/Software/VNA_embedded/Application/VNA.hpp index 2960c95..1c4b352 100644 --- a/Software/VNA_embedded/Application/VNA.hpp +++ b/Software/VNA_embedded/Application/VNA.hpp @@ -7,6 +7,8 @@ namespace VNA { bool Setup(Protocol::SweepSettings s); +void InitiateSweep(); +bool GetStandbyMode(); bool MeasurementDone(const FPGA::SamplingResult &result); void Work(); void SweepHalted();