I'm linking the libtimescale_core.a_xtensa library to my application, but during the call to timescale_main it crashes. I'm unable to get a backtrace currently probably due to missing symbols etc. But it may be due to the initialization/variable allocation that may be a problem.
If its not too much could you please include a sample program with sample inputs that could show the correct sequence of initialization and calling of timescale_main?
Here's a sample of the functions I've used, copied from mynewt application:
#include <timescale/timescale.h>
// 'Model Variance'
#define TIMESCALE_QVAR (double)(128e65123e-20)
// 'Observation Variance'
#define TIMESCALE_RVAR (double)(128e65126e-20)
struct _timescale_instance_t * timescale;
double x0[TIMESCALE_N];
double q[TIMESCALE_N];
double r[TIMESCALE_M];
double timescale_skew;
void dwm1000_tdoa_init()
{
#ifdef FS_XTALT_AUTOTUNE_ENABLED
xtalt_sos = sosfilt_init(NULL, sizeof(g_fs_xtalt_b)/sizeof(float)/BIQUAD_N);
#endif
#ifdef TIMESCALE_PROCESSING_ENABLED
double x0[] = {0};
q[0] = (TIMESCALE_QVAR) * 1.0;
q[1] = (TIMESCALE_QVAR) * 0.1;
r[0] = (TIMESCALE_RVAR);
// peroid in sec
double T = 1e-6l * SYNC_PERIOD * UUS_TO_DWT_TIME;
timescale = timescale_init(NULL, x0, q, T);
// Ignore X0 values, until we get first event
timescale->status.initialized = 0;
timescale_skew = 1.0f;
#endif
}
void dwm1000_tdoa_sync_rx(TdoaContext *tdoaContext)
{
#ifdef TIMESCALE_PROCESSING_ENABLED
int16_t nT = (int16_t)(tdoaContext->curr_seq_number - tdoaContext->prev_seq_number);
nT = (nT < 0) ? 0x100+nT : nT;
timescale_states_t *states = (timescale_states_t *)(timescale->eke->x);
if(timescale->status.initialized == 0)
{
states->time = tdoaContext->curr_sync_rx_ts;
states->skew = ((double) ((uint64_t)1 << 16) / 1e-6l);
timescale->status.initialized = 1;
}
else
{
// Period in sec
double T = 1e-6l * SYNC_PERIOD * UUS_TO_DWT_TIME * nT;
timescale->status.valid = timescale_main(timescale, tdoaContext->curr_sync_rx_ts, q, r, T).valid;
}
timescale_skew = states->skew * (1e-6l/((uint64_t)1 << 16));
uint64_t interval = (uint64_t)((uint64_t)(tdoaContext->curr_sync_rx_ts) - (uint64_t)(tdoaContext->prev_sync_rx_ts)) & 0xFFFFFFFFFULL;
timescale_skew = (double) interval / (double)(nT * ((uint64_t)SYNC_PERIOD * ((uint64_t)1 <<16)));
#endif
}