openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
uwb_rxdiag.c File Reference

— Diagnostic RX/TX event tallies + ranging heartbeat. More...

#include <stdint.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <deca_device_api.h>
#include "ccc_shim.h"
#include "fira_session.h"
#include "uwb_cirdiag.h"
#include "uwb_rxdiag.h"
#include "uwb_seam.h"
#include "woz_diag.h"
#include "woz_alloc.h"
Include dependency graph for uwb_rxdiag.c:

Macros

#define RXDIAG_EVENT_LOG    4 /* trimmed from 24: per-event printk starves the RX re-arm (Pre-POLL hunt) */
 Per-event frame-structure log (first RXDIAG_EVENT_LOG RX events).
 
#define CAD_BLOCK_US   192000u
 RX-arrival cadence histogram: bins each RX phase within the 192 ms block grid.
 
#define RXDIAG_SYS_CFG   0x10UL
 SYS_CFG + STS-packet-config (CP_SPC): the armed SP mode (0=SP0..3=SP3).
 
#define RXDIAG_CFG_LOG   8
 Budget for full-PHY-config logs (rare: session setup + reconfigs).
 

Functions

static void cad_mark (void)
 Bin one RX detection's phase within the 192 ms block grid.
 
static void rxdiag_ev_log (const char *cls, const dwt_cb_data_t *d)
 Log one RX event's frame structure until the budget is spent.
 
static void cirdiag_emit (struct k_work *work)
 Task-side emitter for the latched CIA diagnostics (uwb_cirdiag).
 
static void shim_rxok (const dwt_cb_data_t *d)
 RX-good callback shim: log RX diagnostics, invoke the armed CCC callback, then decode the Pre-POLL frame off the critical path.
 
static void shim_rxto (const dwt_cb_data_t *d)
 RX-timeout shim: tally, then run the blob's handler.
 
static void shim_rxerr (const dwt_cb_data_t *d)
 RX-error shim: tally + latch status (STS/CIA bits), then chain.
 
static void shim_txdone (const dwt_cb_data_t *d)
 TX-done shim: tally, then run the blob's handler.
 
void woz_uwb_set_callbacks (dwt_callbacks_s *callbacks)
 Intercept the callback registration and insert counting shims.
 
int32_t woz_uwb_configure_phy (dwt_config_t *config)
 Log every full PHY configuration the engine applies.
 
static void rxdiag_log (struct k_work *work)
 Periodic ranging heartbeat (every 2 s); re-arms itself while streaming.
 
void uwb_rxdiag_get_counts (uint32_t *rxok, uint32_t *rxerr, uint32_t *rxto, uint32_t *txdone, uint32_t *last_err, uint32_t *last_ok)
 Snapshot the running RX/TX event tallies; out-params optional (NULL to skip).
 
void uwb_rxdiag_stream_set (bool on)
 Arm or cancel the periodic ranging heartbeat (backs aliro log on|off).
 
bool uwb_rxdiag_stream_get (void)
 Whether the periodic ranging heartbeat is currently armed.
 
void uwb_rxdiag_rng_set (bool on)
 Arm or cancel the per-block distance stream (backs aliro frames on|off).
 
bool uwb_rxdiag_rng_get (void)
 Whether the per-block distance stream is currently armed.
 
static int rxdiag_init (void)
 Arm the periodic heartbeat at application init.
 

Variables

static volatile bool g_stream
 Runtime arm state for the periodic heartbeat (backs aliro log).
 
static volatile bool g_rng_stream
 Runtime arm state for the per-block distance stream (backs aliro frames).
 
static dwt_cb_t g_chain_rxok
 The MAC's own callbacks, saved so our shims can chain to them.
 
static volatile uint32_t g_rxok
 Running RX/TX event tallies + the last status word per class.
 
uint32_t g_ccc_dbg_decode
 RX-good shim: tally + latch status, feed the index tracker, then chain.
 

Detailed Description

— Diagnostic RX/TX event tallies + ranging heartbeat.

Function Documentation

◆ shim_rxok()

static void shim_rxok ( const dwt_cb_data_t *  d)
static

RX-good callback shim: log RX diagnostics, invoke the armed CCC callback, then decode the Pre-POLL frame off the critical path.

Parameters
dDW3000 RX callback data (may be NULL on POLL event).

Variable Documentation

◆ g_ccc_dbg_decode

uint32_t g_ccc_dbg_decode

RX-good shim: tally + latch status, feed the index tracker, then chain.

try_prepoll() decode duration (hi32 ~4 ns units), reported on the ARM-FAIL line to attribute the pre-arm latency.

Decode-cost probe: last try_prepoll() duration, hi32 (~4 ns) units.