Hi I am trying to enable streaming CIR data through the UART when running Fira application with the CLI firmware written into two DWM3001CDK kits.
I have followed the suggestions in the post: https://forum.qorvo.com/t/how-to-get-the-raw-data-and-transmit-through-usb/21254/8
Currently I can enable this when the RX is running the LISTENR command by modifying the rx_listener_cb
function in the listener.c
file:
/** @brief ISR level TWR application Rx callback to be called from dwt_isr() as an Rx call-back. */
void rx_listener_cb(const dwt_cb_data_t *rxd)
{
listener_info_t *pListenerInfo = getListenerInfoPtr();
if (!pListenerInfo)
{
return;
}
const int size = sizeof(pListenerInfo->rxPcktBuf.buf) / sizeof(pListenerInfo->rxPcktBuf.buf[0]);
int head = pListenerInfo->rxPcktBuf.head;
int tail = pListenerInfo->rxPcktBuf.tail;
if (CIRC_SPACE(head, tail, size) > 0)
{
rx_listener_pckt_t *p = &pListenerInfo->rxPcktBuf.buf[head];
/* Raw Rx TimeStamp (STS or IPATOV based on STS config). */
dwt_readrxtimestamp(p->timeStamp, DWT_COMPAT_NONE);
/* Reading Clock offset for any Rx packets. */
p->clock_offset = dwt_readclockoffset();
p->status = rxd->status;
p->cir_data = (uint32_t *)malloc((CIR_SAMPLE) * sizeof(uint32_t));
if (p->cir_data == NULL)
{
error_handler(1, _ERR_Cannot_Alloc_Memory); // Handle memory allocation failure
return;
}
/* Read RX diag data. */
p->all_diag.diag_type = IPATOV;
dwt_nlos_alldiag(&p->all_diag);
// dwt_nlos_ipdiag_t ip_diag;
dwt_nlos_ipdiag(&p->ip_diag);
uint16_t FPI = p->ip_diag.index_fp_u32 / 64; // first path index stored in 10.6 fixed point format, divide by 64 to get the index
/* Read CIR Data */
dwt_readcir(p->cir_data, DWT_ACC_IDX_IP_M, FPI - 5, CIR_SAMPLE, DWT_CIR_READ_LO);
// ....
Basically calling the driver APIs by myself.
Then I tried to add similar code to the Fira application. I add similar code to fira_session_info_ntf_twr_cb
function in the fira_app.c
:
static void fira_session_info_ntf_twr_cb(const struct fira_twr_ranging_results *results, void *user_data)
{
int len = 0;
struct string_measurement *str_result = (struct string_measurement *)user_data;
struct fira_twr_measurements *rm;
// /* Read RX diag data. */
dwt_nlos_ipdiag_t ip_diag;
dwt_nlos_alldiag_t all_diag;
all_diag.diag_type = IPATOV;
dwt_nlos_alldiag(&all_diag);
dwt_nlos_ipdiag(&ip_diag);
uint16_t FPI = ip_diag.index_fp_u32 / 64; // first path index stored in 10.6 fixed point format, divide by 64 to get the index
/* Print the FPI */
len += snprintf(&str_result->str[len], str_result->len - len, ", FPI=%u", FPI);
uint32_t *cir_data = (uint32_t *)malloc((8) * sizeof(uint32_t));
dwt_readcir(cir_data, DWT_ACC_IDX_IP_M, FPI, 8, DWT_CIR_READ_LO);
/* Print cir_data */
uint32_t cnt;
for (cnt = 0; cnt < 8; cnt++) // Ensure space remains
{
uint16_t real_part = (cir_data[cnt] >> 16) & 0xFFFF;
uint16_t imag_part = cir_data[cnt] & 0xFFFF;
len += snprintf(&str_result->str[len], str_result->len - len, ", cir_data[%lu]=%04X+j%04X,", cnt, real_part, imag_part);
}
free(cir_data);
// ....
But all I got about FPI and CIR data are all 0.
I am assuming it is because that this function is only called when a ranging session is ended, and the values in these registers have been reset.
So here is my question, if I wish to enable reading and streaming CIR values in the Fira application, what should I do? Which part of code should I tweak with?
Any help and suggestions would be really appreciated!
Best,
Shanmu