1515
1616#include "util/memq.h"
1717
18+ #include "ticker/ticker.h"
19+
1820#include "pdu_df.h"
1921#include "pdu_vendor.h"
2022#include "pdu.h"
2325
2426static int send (struct node_rx_pdu * rx );
2527static inline void sample (uint32_t * timestamp );
28+ static inline void sample_ticks (uint32_t * timestamp_ticks );
2629static inline void delta (uint32_t timestamp , uint16_t * cputime );
30+ static inline void delta_ticks (uint32_t timestamp_ticks , uint8_t * cputime_ticks );
2731
2832static uint32_t timestamp_radio ;
2933static uint32_t timestamp_lll ;
@@ -41,44 +45,61 @@ static uint16_t cputime_max;
4145static uint16_t cputime_prev ;
4246static uint32_t timestamp_latency ;
4347
48+ static uint32_t timestamp_ticks_radio ;
49+ static uint32_t timestamp_ticks_lll ;
50+ static uint32_t timestamp_ticks_ull_high ;
51+ static uint32_t timestamp_ticks_ull_low ;
52+ static uint8_t cputime_ticks_radio ;
53+ static uint8_t cputime_ticks_lll ;
54+ static uint8_t cputime_ticks_ull_high ;
55+ static uint8_t cputime_ticks_ull_low ;
56+
4457void lll_prof_enter_radio (void )
4558{
4659 sample (& timestamp_radio );
60+ sample_ticks (& timestamp_ticks_radio );
4761}
4862
4963void lll_prof_exit_radio (void )
5064{
5165 delta (timestamp_radio , & cputime_radio );
66+ delta_ticks (timestamp_ticks_radio , & cputime_ticks_radio );
5267}
5368
5469void lll_prof_enter_lll (void )
5570{
5671 sample (& timestamp_lll );
72+ sample_ticks (& timestamp_ticks_lll );
5773}
5874
5975void lll_prof_exit_lll (void )
6076{
6177 delta (timestamp_lll , & cputime_lll );
78+ delta_ticks (timestamp_ticks_lll , & cputime_ticks_lll );
6279}
6380
6481void lll_prof_enter_ull_high (void )
6582{
6683 sample (& timestamp_ull_high );
84+ sample_ticks (& timestamp_ticks_ull_high );
6785}
6886
6987void lll_prof_exit_ull_high (void )
7088{
7189 delta (timestamp_ull_high , & cputime_ull_high );
90+ delta_ticks (timestamp_ticks_ull_high , & cputime_ticks_ull_high );
7291}
7392
7493void lll_prof_enter_ull_low (void )
7594{
7695 sample (& timestamp_ull_low );
96+ sample_ticks (& timestamp_ticks_ull_low );
7797}
7898
7999void lll_prof_exit_ull_low (void )
80100{
81101 delta (timestamp_ull_low , & cputime_ull_low );
102+ delta_ticks (timestamp_ticks_ull_low , & cputime_ticks_ull_low );
82103}
83104
84105void lll_prof_latency_capture (void )
@@ -236,6 +257,10 @@ static int send(struct node_rx_pdu *rx)
236257 p -> lll = cputime_lll ;
237258 p -> ull_high = cputime_ull_high ;
238259 p -> ull_low = cputime_ull_low ;
260+ p -> radio_ticks = cputime_ticks_radio ;
261+ p -> lll_ticks = cputime_ticks_lll ;
262+ p -> ull_high_ticks = cputime_ticks_ull_high ;
263+ p -> ull_low_ticks = cputime_ticks_ull_low ;
239264
240265 ull_rx_put_sched (rx -> hdr .link , rx );
241266
@@ -248,6 +273,11 @@ static inline void sample(uint32_t *timestamp)
248273 * timestamp = radio_tmr_sample_get ();
249274}
250275
276+ static inline void sample_ticks (uint32_t * timestamp_ticks )
277+ {
278+ * timestamp_ticks = ticker_ticks_now_get ();
279+ }
280+
251281static inline void delta (uint32_t timestamp , uint16_t * cputime )
252282{
253283 uint32_t delta ;
@@ -258,3 +288,13 @@ static inline void delta(uint32_t timestamp, uint16_t *cputime)
258288 * cputime = delta ;
259289 }
260290}
291+
292+ static inline void delta_ticks (uint32_t timestamp_ticks , uint8_t * cputime_ticks )
293+ {
294+ uint32_t delta ;
295+
296+ delta = ticker_ticks_now_get () - timestamp_ticks ;
297+ if (delta < UINT8_MAX && delta > * cputime_ticks ) {
298+ * cputime_ticks = delta ;
299+ }
300+ }
0 commit comments