Commit d2b71073 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

add new functions to retrieve absolute radio RX/TX active time

parent 1c8366d4
......@@ -674,6 +674,7 @@ uint8_t radio_get_preamble_counter(void)
return preamble_detected_counter;
}
void radio_reset_sync_counter(void)
{
sync_detected_counter = 0;
......@@ -692,12 +693,24 @@ uint32_t radio_get_rx_dc(void)
}
uint64_t radio_get_rx_time(void)
{
return dcstat_get_active_time(&radio_dc_rx);
}
uint32_t radio_get_tx_dc(void)
{
return dcstat_get_dc(&radio_dc_tx);
}
uint64_t radio_get_tx_time(void)
{
return dcstat_get_active_time(&radio_dc_tx);
}
void radio_dc_counter_reset(void)
{
dcstat_reset(&radio_dc_rx);
......
......@@ -113,7 +113,9 @@ uint8_t radio_get_preamble_counter(void);
void radio_reset_sync_counter(void);
uint8_t radio_get_sync_counter(void);
uint32_t radio_get_rx_dc(void);
uint64_t radio_get_rx_time(void);
uint32_t radio_get_tx_dc(void);
uint64_t radio_get_tx_time(void);
void radio_dc_counter_reset(void);
uint32_t radio_get_prr(bool reset); /* returns the packet reception rate in [% * 10^2] */
......
......@@ -78,3 +78,16 @@ uint32_t dcstat_get_dc(const dcstat_t* const dc)
}
return 1000000;
}
uint64_t dcstat_get_active_time(const dcstat_t* const dc)
{
if (dc) {
uint64_t active = dc->active_time;
if (dc->start_time) {
active += (lptimer_now() - dc->start_time);
}
return active;
}
return 0;
}
......@@ -40,13 +40,15 @@ typedef struct
} dcstat_t;
#define DCSTAT_FREQUENCY LPTIMER_SECOND
#define DCSTAT_ACTIVE_TIME_MS(dc) (((dc)->active_time * 1000) / LPTIMER_SECOND)
void dcstat_start(dcstat_t* dc); /* continue counting */
void dcstat_stop(dcstat_t* dc); /* stop counting */
void dcstat_reset(dcstat_t* dc); /* reset counter */
uint32_t dcstat_get_dc(const dcstat_t* const dc); /* get duty cycle in ppm */
void dcstat_start(dcstat_t* dc); /* continue counting */
void dcstat_stop(dcstat_t* dc); /* stop counting */
void dcstat_reset(dcstat_t* dc); /* reset counter */
uint32_t dcstat_get_dc(const dcstat_t* const dc); /* get duty cycle in ppm */
uint64_t dcstat_get_active_time(const dcstat_t* const dc); /* get active time in ticks */
#endif /* UTILS_DCSTAT_H_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment