diff --git a/Documentation/DeveloperInfo/USB_protocol_v12.pdf b/Documentation/DeveloperInfo/USB_protocol_v12.pdf index ff1faf1..38c1508 100644 Binary files a/Documentation/DeveloperInfo/USB_protocol_v12.pdf and b/Documentation/DeveloperInfo/USB_protocol_v12.pdf differ diff --git a/Documentation/DeveloperInfo/USB_protocol_v12.tex b/Documentation/DeveloperInfo/USB_protocol_v12.tex index 75e9e56..ce9732f 100644 --- a/Documentation/DeveloperInfo/USB_protocol_v12.tex +++ b/Documentation/DeveloperInfo/USB_protocol_v12.tex @@ -248,6 +248,8 @@ The following packet types are available: 27 & VNADatapoint & D$\rightarrow$H & Sent for every sampled frequency within the sweep in VNA mode &None \\ 28 & SetTrigger & D$\leftrightarrow$H & Updates the trigger status for synchronization over USB & None\\ 29 & ClearTrigger & D$\leftrightarrow$H & Updates the trigger status for synchronization over USB & None\\ +30 & StopStatusUpdates & H$\rightarrow$D & Stops the automatic transmission of device status packets & None\\ +31 & StartStatusUpdates & H$\rightarrow$D & Starts the automatic transmission of device status packets & None\\ \end{longtable} \end{ThreePartTable} An Ack is transmitted by the device for every received command after it has been handled successfully. If additional responses are triggered by the command, they are transmitted after this Ack. @@ -1010,4 +1012,10 @@ This packet is used when multiple devices are synchronized over USB and can be t \subsection{ClearTrigger} This packet is used when multiple devices are synchronized over USB and can be transmitted in both directions. It has no payload. Synchronized devices must be logically organized in a closed loop. When a ClearTrigger packet is received from any devices in the loop it must be passed on to the next device in the loop. +\subsection{StopStatusUpdates} +This packet instructs the device to stop sending automatically scheduled DeviceStatusV1 packets. Device status can still be requested explicitly via RequestDeviceStatus packets. + +\subsection{StartStatusUpdates} +This packet instructs the device to start sending automatically scheduled DeviceStatusV1 packets. This restores default update behaviour if a StopStatusUpdates packet has previously been sent. + \end{document} diff --git a/Software/VNA_embedded/Application/App.cpp b/Software/VNA_embedded/Application/App.cpp index adfd421..34e78d9 100644 --- a/Software/VNA_embedded/Application/App.cpp +++ b/Software/VNA_embedded/Application/App.cpp @@ -173,6 +173,16 @@ inline void App_Process() { Communication::Send(p); } break; + case Protocol::PacketType::StopStatusUpdates: { + HW::setStatusUpdateFlag(false); + Communication::SendWithoutPayload(Protocol::PacketType::Ack); + } + break; + case Protocol::PacketType::StartStatusUpdates: { + HW::setStatusUpdateFlag(true); + Communication::SendWithoutPayload(Protocol::PacketType::Ack); + } + break; case Protocol::PacketType::SetIdle: HW::SetMode(HW::Mode::Idle); sweepActive = false; diff --git a/Software/VNA_embedded/Application/Communication/Protocol.cpp b/Software/VNA_embedded/Application/Communication/Protocol.cpp index 793f8c1..e302a33 100644 --- a/Software/VNA_embedded/Application/Communication/Protocol.cpp +++ b/Software/VNA_embedded/Application/Communication/Protocol.cpp @@ -123,6 +123,8 @@ uint16_t Protocol::EncodePacket(const PacketInfo &packet, uint8_t *dest, uint16_ case PacketType::RequestDeviceStatus: case PacketType::SetTrigger: case PacketType::ClearTrigger: + case PacketType::StopStatusUpdates: + case PacketType::StartStatusUpdates: // 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 5a2a3bd..f50f7af 100644 --- a/Software/VNA_embedded/Application/Communication/Protocol.hpp +++ b/Software/VNA_embedded/Application/Communication/Protocol.hpp @@ -364,6 +364,8 @@ enum class PacketType : uint8_t { VNADatapoint = 27, SetTrigger = 28, ClearTrigger = 29, + StopStatusUpdates = 30, + StartStatusUpdates = 31, }; using PacketInfo = struct _packetinfo { diff --git a/Software/VNA_embedded/Application/Hardware.cpp b/Software/VNA_embedded/Application/Hardware.cpp index 2406f54..f45fb78 100644 --- a/Software/VNA_embedded/Application/Hardware.cpp +++ b/Software/VNA_embedded/Application/Hardware.cpp @@ -21,6 +21,8 @@ static bool extRefInUse = false; HW::Mode activeMode; static bool unlevel = false; +static bool StatusUpdateFlag = true; + static Protocol::ReferenceSettings ref; static volatile uint64_t lastISR; @@ -438,8 +440,16 @@ uint64_t HW::getLastISRTimestamp() { return lastISR; } +bool HW::getStatusUpdateFlag(){ + return StatusUpdateFlag; +} + +void HW::setStatusUpdateFlag(bool flag){ + StatusUpdateFlag = flag; +} + void HW::updateDeviceStatus() { - if(activeMode == Mode::Idle || activeMode == Mode::Generator) { + if(StatusUpdateFlag && (activeMode == Mode::Idle || activeMode == Mode::Generator)) { static uint32_t last_update = 0; if(HAL_GetTick() - last_update >= 1000) { last_update = HAL_GetTick(); diff --git a/Software/VNA_embedded/Application/Hardware.hpp b/Software/VNA_embedded/Application/Hardware.hpp index a6d029d..d3efb4b 100644 --- a/Software/VNA_embedded/Application/Hardware.hpp +++ b/Software/VNA_embedded/Application/Hardware.hpp @@ -102,6 +102,10 @@ uint64_t getLastISRTimestamp(); void SetOutputUnlevel(bool unlev); +bool getStatusUpdateFlag(); + +void setStatusUpdateFlag(bool flag); + void updateDeviceStatus(); using AmplitudeSettings = struct _amplitudeSettings { diff --git a/Software/VNA_embedded/Application/Manual.cpp b/Software/VNA_embedded/Application/Manual.cpp index e1bc3a8..33ed532 100644 --- a/Software/VNA_embedded/Application/Manual.cpp +++ b/Software/VNA_embedded/Application/Manual.cpp @@ -123,18 +123,21 @@ void Manual::Work() { HW::GetTemps(&p.manualStatusV1.temp_source, &p.manualStatusV1.temp_LO); Communication::Send(p); HW::Ref::update(); - Protocol::PacketInfo packet; - packet.type = Protocol::PacketType::DeviceStatusV1; - // Enable PLL chips for temperature reading - bool srcEn = FPGA::IsEnabled(FPGA::Periphery::SourceChip); - bool LOEn = FPGA::IsEnabled(FPGA::Periphery::LO1Chip); - FPGA::Enable(FPGA::Periphery::SourceChip); - FPGA::Enable(FPGA::Periphery::LO1Chip); - HW::getDeviceStatus(&packet.statusV1, true); - // restore PLL state - FPGA::Enable(FPGA::Periphery::SourceChip, srcEn); - FPGA::Enable(FPGA::Periphery::LO1Chip, LOEn); - Communication::Send(packet); + if(HW::getStatusUpdateFlag()) { + Protocol::PacketInfo packet; + packet.type = Protocol::PacketType::DeviceStatusV1; + // Enable PLL chips for temperature reading + bool srcEn = FPGA::IsEnabled(FPGA::Periphery::SourceChip); + bool LOEn = FPGA::IsEnabled(FPGA::Periphery::LO1Chip); + FPGA::Enable(FPGA::Periphery::SourceChip); + FPGA::Enable(FPGA::Periphery::LO1Chip); + HW::getDeviceStatus(&packet.statusV1, true); + // restore PLL state + FPGA::Enable(FPGA::Periphery::SourceChip, srcEn); + FPGA::Enable(FPGA::Periphery::LO1Chip, LOEn); + Communication::Send(packet); + } + // Trigger next status update FPGA::StartSweep(); } diff --git a/Software/VNA_embedded/Application/SpectrumAnalyzer.cpp b/Software/VNA_embedded/Application/SpectrumAnalyzer.cpp index 4943086..150b32e 100644 --- a/Software/VNA_embedded/Application/SpectrumAnalyzer.cpp +++ b/Software/VNA_embedded/Application/SpectrumAnalyzer.cpp @@ -428,7 +428,7 @@ void SA::Work() { // setup for next step signalIDstep = 0; - if(pointCnt % 10 == 0) { + if(HW::getStatusUpdateFlag() && pointCnt % 10 == 0) { // send device info every nth point FPGA::Enable(FPGA::Periphery::SourceChip); // needs to enable the chip to get a valid temperature reading Protocol::PacketInfo packet; diff --git a/Software/VNA_embedded/Application/VNA.cpp b/Software/VNA_embedded/Application/VNA.cpp index 2f8e2fe..5dc7cd0 100644 --- a/Software/VNA_embedded/Application/VNA.cpp +++ b/Software/VNA_embedded/Application/VNA.cpp @@ -325,8 +325,10 @@ void VNA::Work() { // Compile info packet Protocol::PacketInfo packet; packet.type = Protocol::PacketType::DeviceStatusV1; - HW::getDeviceStatus(&packet.statusV1, true); - Communication::Send(packet); + if(HW::getStatusUpdateFlag()) { + HW::getDeviceStatus(&packet.statusV1, true); + 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();