Combine bounded nRF USB and scheduler isolation for explicit HIL trials
This commit is contained in:
1 parent
286f3f730d
commit
1b97c089a7
9 files changed
+335
-8
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <hal/Arduino/ArduinoHal.h>
|
||||
#include "NrfRadioProfileExperimentConfig.h"
|
||||
|
||||
#ifndef MC_NRF_RADIO_PROFILE_PRIORITY
|
||||
#define MC_NRF_RADIO_PROFILE_PRIORITY 0
|
||||
@@ -62,6 +63,12 @@ public:
|
||||
// An unused budget can reach a later non-BUSY wait; this is not BUSY-only
|
||||
// detection. No GPIO reads, status checks, timeouts or interrupts change.
|
||||
void yield() override {
|
||||
#if MC_NRF_RADIO_PROFILE_PRIORITY
|
||||
// In the explicit combined test, suppress a cooperative task switch
|
||||
// before the USB guard can yield to the already queued USB worker.
|
||||
const auto decision = mesh::radiopriority::beforeYield();
|
||||
if (decision == mesh::radiopriority::Suppress) return;
|
||||
#endif
|
||||
#if MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD
|
||||
if (mesh::radiousb::beforeYield()) {
|
||||
// Normal Arduino yield flushes TinyUSB CDC. While its IRQ is deferred,
|
||||
@@ -71,8 +78,8 @@ public:
|
||||
}
|
||||
#endif
|
||||
#if MC_NRF_RADIO_PROFILE_PRIORITY
|
||||
const auto decision = mesh::radiopriority::beforeYield();
|
||||
if (decision == mesh::radiopriority::Suppress) return;
|
||||
// Expiry can restore priority while the independent USB deadline still
|
||||
// owns its IRQ. Always consult that guard before a normal CDC flush.
|
||||
if (decision == mesh::radiopriority::Expired) {
|
||||
ArduinoHal::yield();
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "NrfRadioProfileExperimentConfig.h"
|
||||
|
||||
#ifndef MC_NRF_RADIO_PROFILE_PRIORITY
|
||||
#define MC_NRF_RADIO_PROFILE_PRIORITY 0
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MC_NRF_RADIO_PROFILE_PRIORITY
|
||||
#define MC_NRF_RADIO_PROFILE_PRIORITY 0
|
||||
#endif
|
||||
#ifndef MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD
|
||||
#define MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD 0
|
||||
#endif
|
||||
#ifndef MC_NRF_RADIO_PROFILE_COMBINED
|
||||
#define MC_NRF_RADIO_PROFILE_COMBINED 0
|
||||
#endif
|
||||
#if MC_NRF_RADIO_PROFILE_COMBINED != 0 && MC_NRF_RADIO_PROFILE_COMBINED != 1
|
||||
#error "Combined radio profile experiment must be 0 or 1"
|
||||
#endif
|
||||
#if MC_NRF_RADIO_PROFILE_COMBINED && (!MC_NRF_RADIO_PROFILE_PRIORITY || !MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD)
|
||||
#error "Combined radio profile experiment requires both priority and USB IRQ experiments"
|
||||
#endif
|
||||
#if MC_NRF_RADIO_PROFILE_PRIORITY && MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD && !MC_NRF_RADIO_PROFILE_COMBINED
|
||||
#error "Measure the USB IRQ and task-priority experiments separately unless explicitly opting into the combined HIL experiment"
|
||||
#endif
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "NrfRadioProfileExperimentConfig.h"
|
||||
|
||||
#ifndef MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD
|
||||
#define MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD 0
|
||||
#endif
|
||||
@@ -10,9 +12,6 @@
|
||||
#if !defined(NRF52_PLATFORM) || !defined(MESH_HIL_PROFILE_TIMING) || !MESH_HIL_PROFILE_TIMING
|
||||
#error "Radio USB IRQ experiment requires nRF52 HIL profile timing"
|
||||
#endif
|
||||
#if defined(MC_NRF_RADIO_PROFILE_PRIORITY) && MC_NRF_RADIO_PROFILE_PRIORITY
|
||||
#error "Measure the USB IRQ and task-priority experiments separately"
|
||||
#endif
|
||||
#include <Arduino.h>
|
||||
#include <atomic>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -645,13 +645,25 @@ mesh::RadioParamApplyResult RadioLibWrapper::tuneProfile(uint8_t profile) {
|
||||
mesh::profiletiming::begin(_active_profile, profile, mesh::profiletiming::readClock());
|
||||
#endif
|
||||
beginProfileRetune(isInRecvMode() && !_rx_ps_armed && !_rx_ps_enabled);
|
||||
#if MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD
|
||||
// The combined HIL experiment must admit the IRQ guard while the loop
|
||||
// still has its ordinary priority; its deadline remains independent.
|
||||
mesh::radiousb::Guard profile_usb_irq(dual_profile && _active_profile != profile
|
||||
&& ownsWarmProfileRetune());
|
||||
#endif
|
||||
#if MC_NRF_RADIO_PROFILE_PRIORITY
|
||||
mesh::radiopriority::Lease profile_priority(dual_profile && _active_profile != profile
|
||||
&& ownsWarmProfileRetune());
|
||||
#endif
|
||||
#if MC_NRF_RADIO_PROFILE_USB_IRQ_GUARD
|
||||
mesh::radiousb::Guard profile_usb_irq(dual_profile && _active_profile != profile
|
||||
&& ownsWarmProfileRetune());
|
||||
#if MC_NRF_RADIO_PROFILE_COMBINED
|
||||
// Explicit exits release in this order below. Preserve it for any future
|
||||
// early exit as well, before reverse member/local destruction can let a
|
||||
// queued USB worker run while its IRQ is still deferred.
|
||||
struct OrderedProfileRelease {
|
||||
mesh::radiousb::Guard& usb;
|
||||
mesh::radiopriority::Lease& priority;
|
||||
~OrderedProfileRelease() { usb.release(); priority.release(); }
|
||||
} ordered_profile_release{profile_usb_irq, profile_priority};
|
||||
#endif
|
||||
const uint8_t resume = beginReconfigure();
|
||||
if (resume > 1) {
|
||||
|
||||
Reference in new issue
Block a user