Add function to read max DL ToA
Protect with mutex to allow reading from another thread.
This commit is contained in:
@@ -159,6 +159,7 @@ void init_nr_prs_ue_vars(PHY_VARS_NR_UE *ue)
|
||||
AssertFatal((prs_vars[idx]->prs_resource[k].prs_meas[j]!=NULL), "%s: PRS measurements malloc failed for gNB_id %d, rx_ant %d\n", __FUNCTION__, idx, j);
|
||||
prs_meas_t *m = prs_vars[idx]->prs_resource[k].prs_meas[j];
|
||||
m->next_dl_toa = m->dl_toa;
|
||||
pthread_mutex_init(&m->dl_toa_mtx, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,10 +73,28 @@ void peak_estimator(c16_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t *
|
||||
|
||||
void set_prs_dl_toa(prs_meas_t *prs_meas, float dl_toa)
|
||||
{
|
||||
int rc = pthread_mutex_lock(&prs_meas->dl_toa_mtx);
|
||||
AssertFatal(rc == 0, "pthread_mutex_lock() failed: errno %d, %s\n", errno, strerror(errno));
|
||||
*prs_meas->next_dl_toa++ = dl_toa;
|
||||
if (prs_meas->next_dl_toa >= prs_meas->dl_toa + sizeofArray(prs_meas->dl_toa))
|
||||
prs_meas->next_dl_toa = prs_meas->dl_toa;
|
||||
LOG_D(NR_PHY, "next_dl_toa %p\n", prs_meas->next_dl_toa);
|
||||
rc = pthread_mutex_unlock(&prs_meas->dl_toa_mtx);
|
||||
AssertFatal(rc == 0, "pthread_mutex_unlock() failed: errno %d, %s\n", errno, strerror(errno));
|
||||
}
|
||||
|
||||
float get_prs_max_dl_toa(prs_meas_t *prs_meas)
|
||||
{
|
||||
float max = 0.0f;
|
||||
int rc = pthread_mutex_lock(&prs_meas->dl_toa_mtx);
|
||||
AssertFatal(rc == 0, "pthread_mutex_lock() failed: errno %d, %s\n", errno, strerror(errno));
|
||||
for (int i = 0; i < sizeofArray(prs_meas->dl_toa); ++i) {
|
||||
max = cmax(max, prs_meas->dl_toa[i]);
|
||||
LOG_I(NR_PHY, "i %d dl_toa %.3f max %.3f\n", i, prs_meas->dl_toa[i], max);
|
||||
}
|
||||
rc = pthread_mutex_unlock(&prs_meas->dl_toa_mtx);
|
||||
AssertFatal(rc == 0, "pthread_mutex_unlock() failed: errno %d, %s\n", errno, strerror(errno));
|
||||
return max;
|
||||
}
|
||||
|
||||
int nr_prs_channel_estimation(uint8_t gNB_id,
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include "impl_defs_nr.h"
|
||||
#include "PHY/CODING/nrPolar_tools/nr_polar_defs.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define MAX_NUM_SUBCARRIER_SPACING 5
|
||||
#define NR_MAX_OFDM_SYMBOL_SIZE 8192
|
||||
|
||||
@@ -312,6 +314,7 @@ typedef struct {
|
||||
int32_t sfn;
|
||||
int8_t slot;
|
||||
int8_t rxAnt_idx;
|
||||
pthread_mutex_t dl_toa_mtx; // protect reading of max from write
|
||||
// circular buffer to be able to read maximum of last estimations
|
||||
float dl_toa[128]; // set through set_prs_dl_toa()
|
||||
float *next_dl_toa;
|
||||
|
||||
Reference in New Issue
Block a user