implement optional device status updates
This commit is contained in:
parent
35cdfa5922
commit
9b38a1fc3d
@ -173,6 +173,16 @@ inline void App_Process() {
|
|||||||
Communication::Send(p);
|
Communication::Send(p);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case Protocol::PacketType::SetIdle:
|
||||||
HW::SetMode(HW::Mode::Idle);
|
HW::SetMode(HW::Mode::Idle);
|
||||||
sweepActive = false;
|
sweepActive = false;
|
||||||
|
@ -123,6 +123,8 @@ uint16_t Protocol::EncodePacket(const PacketInfo &packet, uint8_t *dest, uint16_
|
|||||||
case PacketType::RequestDeviceStatus:
|
case PacketType::RequestDeviceStatus:
|
||||||
case PacketType::SetTrigger:
|
case PacketType::SetTrigger:
|
||||||
case PacketType::ClearTrigger:
|
case PacketType::ClearTrigger:
|
||||||
|
case PacketType::StopStatusUpdates:
|
||||||
|
case PacketType::StartStatusUpdates:
|
||||||
// no payload
|
// no payload
|
||||||
break;
|
break;
|
||||||
case PacketType::VNADatapoint: payload_size = packet.VNAdatapoint->requiredBufferSize(); break;
|
case PacketType::VNADatapoint: payload_size = packet.VNAdatapoint->requiredBufferSize(); break;
|
||||||
|
@ -364,6 +364,8 @@ enum class PacketType : uint8_t {
|
|||||||
VNADatapoint = 27,
|
VNADatapoint = 27,
|
||||||
SetTrigger = 28,
|
SetTrigger = 28,
|
||||||
ClearTrigger = 29,
|
ClearTrigger = 29,
|
||||||
|
StopStatusUpdates = 30,
|
||||||
|
StartStatusUpdates = 31,
|
||||||
};
|
};
|
||||||
|
|
||||||
using PacketInfo = struct _packetinfo {
|
using PacketInfo = struct _packetinfo {
|
||||||
|
@ -21,6 +21,8 @@ static bool extRefInUse = false;
|
|||||||
HW::Mode activeMode;
|
HW::Mode activeMode;
|
||||||
static bool unlevel = false;
|
static bool unlevel = false;
|
||||||
|
|
||||||
|
static bool StatusUpdateFlag = true;
|
||||||
|
|
||||||
static Protocol::ReferenceSettings ref;
|
static Protocol::ReferenceSettings ref;
|
||||||
static volatile uint64_t lastISR;
|
static volatile uint64_t lastISR;
|
||||||
|
|
||||||
@ -438,8 +440,16 @@ uint64_t HW::getLastISRTimestamp() {
|
|||||||
return lastISR;
|
return lastISR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HW::getStatusUpdateFlag(){
|
||||||
|
return StatusUpdateFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HW::setStatusUpdateFlag(bool flag){
|
||||||
|
StatusUpdateFlag = flag;
|
||||||
|
}
|
||||||
|
|
||||||
void HW::updateDeviceStatus() {
|
void HW::updateDeviceStatus() {
|
||||||
if(activeMode == Mode::Idle || activeMode == Mode::Generator) {
|
if(StatusUpdateFlag && (activeMode == Mode::Idle || activeMode == Mode::Generator)) {
|
||||||
static uint32_t last_update = 0;
|
static uint32_t last_update = 0;
|
||||||
if(HAL_GetTick() - last_update >= 1000) {
|
if(HAL_GetTick() - last_update >= 1000) {
|
||||||
last_update = HAL_GetTick();
|
last_update = HAL_GetTick();
|
||||||
|
@ -102,6 +102,10 @@ uint64_t getLastISRTimestamp();
|
|||||||
|
|
||||||
void SetOutputUnlevel(bool unlev);
|
void SetOutputUnlevel(bool unlev);
|
||||||
|
|
||||||
|
bool getStatusUpdateFlag();
|
||||||
|
|
||||||
|
void setStatusUpdateFlag(bool flag);
|
||||||
|
|
||||||
void updateDeviceStatus();
|
void updateDeviceStatus();
|
||||||
|
|
||||||
using AmplitudeSettings = struct _amplitudeSettings {
|
using AmplitudeSettings = struct _amplitudeSettings {
|
||||||
|
@ -123,18 +123,21 @@ void Manual::Work() {
|
|||||||
HW::GetTemps(&p.manualStatusV1.temp_source, &p.manualStatusV1.temp_LO);
|
HW::GetTemps(&p.manualStatusV1.temp_source, &p.manualStatusV1.temp_LO);
|
||||||
Communication::Send(p);
|
Communication::Send(p);
|
||||||
HW::Ref::update();
|
HW::Ref::update();
|
||||||
Protocol::PacketInfo packet;
|
if(HW::getStatusUpdateFlag()) {
|
||||||
packet.type = Protocol::PacketType::DeviceStatusV1;
|
Protocol::PacketInfo packet;
|
||||||
// Enable PLL chips for temperature reading
|
packet.type = Protocol::PacketType::DeviceStatusV1;
|
||||||
bool srcEn = FPGA::IsEnabled(FPGA::Periphery::SourceChip);
|
// Enable PLL chips for temperature reading
|
||||||
bool LOEn = FPGA::IsEnabled(FPGA::Periphery::LO1Chip);
|
bool srcEn = FPGA::IsEnabled(FPGA::Periphery::SourceChip);
|
||||||
FPGA::Enable(FPGA::Periphery::SourceChip);
|
bool LOEn = FPGA::IsEnabled(FPGA::Periphery::LO1Chip);
|
||||||
FPGA::Enable(FPGA::Periphery::LO1Chip);
|
FPGA::Enable(FPGA::Periphery::SourceChip);
|
||||||
HW::getDeviceStatus(&packet.statusV1, true);
|
FPGA::Enable(FPGA::Periphery::LO1Chip);
|
||||||
// restore PLL state
|
HW::getDeviceStatus(&packet.statusV1, true);
|
||||||
FPGA::Enable(FPGA::Periphery::SourceChip, srcEn);
|
// restore PLL state
|
||||||
FPGA::Enable(FPGA::Periphery::LO1Chip, LOEn);
|
FPGA::Enable(FPGA::Periphery::SourceChip, srcEn);
|
||||||
Communication::Send(packet);
|
FPGA::Enable(FPGA::Periphery::LO1Chip, LOEn);
|
||||||
|
Communication::Send(packet);
|
||||||
|
}
|
||||||
|
|
||||||
// Trigger next status update
|
// Trigger next status update
|
||||||
FPGA::StartSweep();
|
FPGA::StartSweep();
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ void SA::Work() {
|
|||||||
// setup for next step
|
// setup for next step
|
||||||
signalIDstep = 0;
|
signalIDstep = 0;
|
||||||
|
|
||||||
if(pointCnt % 10 == 0) {
|
if(HW::getStatusUpdateFlag() && pointCnt % 10 == 0) {
|
||||||
// send device info every nth point
|
// send device info every nth point
|
||||||
FPGA::Enable(FPGA::Periphery::SourceChip); // needs to enable the chip to get a valid temperature reading
|
FPGA::Enable(FPGA::Periphery::SourceChip); // needs to enable the chip to get a valid temperature reading
|
||||||
Protocol::PacketInfo packet;
|
Protocol::PacketInfo packet;
|
||||||
|
@ -325,8 +325,10 @@ void VNA::Work() {
|
|||||||
// Compile info packet
|
// Compile info packet
|
||||||
Protocol::PacketInfo packet;
|
Protocol::PacketInfo packet;
|
||||||
packet.type = Protocol::PacketType::DeviceStatusV1;
|
packet.type = Protocol::PacketType::DeviceStatusV1;
|
||||||
HW::getDeviceStatus(&packet.statusV1, true);
|
if(HW::getStatusUpdateFlag()) {
|
||||||
Communication::Send(packet);
|
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
|
// do not reset unlevel flag here, as it is calculated only once at the setup of the sweep
|
||||||
// Start next sweep
|
// Start next sweep
|
||||||
FPGA::StartSweep();
|
FPGA::StartSweep();
|
||||||
|
Loading…
Reference in New Issue
Block a user