AFBR-S50 API Reference Manual  v1.6.5
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
time.h
Go to the documentation of this file.
1 /*************************************************************************/
37 #ifndef TIME_H
38 #define TIME_H
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /*!***************************************************************************
44  * @defgroup argus_time Time Utility
45  * @ingroup argus_util
46  *
47  * @brief Timer utilities for time measurement duties.
48  *
49  * @details This module provides time measurement utility functions like
50  * delay or time measurement methods, or time math functions.
51  *
52  * @addtogroup argus_time
53  * @{
54  *****************************************************************************/
55 
56 #include "platform/argus_timer.h"
57 #include <assert.h>
58 #include <stdint.h>
59 #include <stdbool.h>
60 
61 /*!***************************************************************************
62  * @brief A data structure to represent current time.
63  *
64  * @details Value is obtained from the PIT time which must be configured as
65  * lifetime counter.
66  *
67  * Range: [0.000000, 4294967296.999999] seconds
68  *****************************************************************************/
69 typedef struct ltc_t
70 {
73  uint32_t sec;
74 
77  uint32_t usec;
78 
79 } ltc_t;
80 
81 /*!***************************************************************************
82  * @brief Converts #ltc_t to microseconds (uint32_t).
83  * @details The specified time value (type #ltc_t) is converted to microseconds.
84  * The value is truncated to UINT32_MAX value if the result would
85  * exceed UINT32_MAX microseconds.
86  * @param t Input #ltc_t structure.
87  * @return Time value in microseconds.
88  *****************************************************************************/
89 inline uint32_t Time_ToUSec(ltc_t const * t)
90 {
91  assert(t != 0);
92 
93  // max. value to convert correctly is 4294.967295 sec (UINT32_MAX/1000000)
94  return ((t->sec < 4294U) || (t->sec == 4294U && t->usec < 967295U)) ?
95  t->usec + t->sec * 1000000U : UINT32_MAX;
96 }
97 
98 /*!***************************************************************************
99  * @brief Converts #ltc_t to milliseconds (uint32_t).
100  * @details The specified time value (type #ltc_t) is converted to milliseconds.
101  * The value is truncated to UINT32_MAX value if the result would
102  * exceed UINT32_MAX milliseconds.
103  * The returned value is correctly rounded to the nearest value.
104  * @param t Input #ltc_t structure.
105  * @return Time value in milliseconds.
106  *****************************************************************************/
107 inline uint32_t Time_ToMSec(ltc_t const * t)
108 {
109  assert(t != 0);
110 
111  // max. value to convert correctly is 4294967.295499 sec (UINT32_MAX/1000)
112  return ((t->sec < 4294967U) || (t->sec == 4294967U && t->usec < 295500U)) ?
113  (t->usec + 500U) / 1000U + t->sec * 1000U : UINT32_MAX;
114 }
115 
116 /*!***************************************************************************
117  * @brief Converts #ltc_t to seconds (uint32_t).
118  * @details The specified time value (type #ltc_t) is converted to seconds.
119  * The returned value is correctly rounded to the nearest value.
120  * @param t Input #ltc_t structure.
121  * @return Time value in seconds.
122  *****************************************************************************/
123 inline uint32_t Time_ToSec(ltc_t const * t)
124 {
125  assert(t != 0);
126 
127  // max. value to convert correctly is 4294967295.499999 sec (UINT32_MAX/1000)
128  return (t->sec < 4294967295U || t->usec < 500000U) ?
129  (t->usec + 500000U) / 1000000U + t->sec : UINT32_MAX;
130 }
131 
132 /*!***************************************************************************
133  * @brief Converts microseconds (uint32_t) to #ltc_t.
134  * @details The specified time value in microseconds is converted to type #ltc_t.
135  * @param t Output #ltc_t structure.
136  * @param t_usec Input time in microseconds.
137  *****************************************************************************/
138 inline void Time_FromUSec(ltc_t * t, uint32_t t_usec)
139 {
140  assert(t != 0);
141  t->sec = t_usec / 1000000U;
142  t->usec = t_usec % 1000000U;
143 }
144 
145 /*!***************************************************************************
146  * @brief Converts milliseconds (uint32_t) to #ltc_t.
147  * @details The specified time value in milliseconds is converted to type #ltc_t.
148  * @param t Output #ltc_t structure.
149  * @param t_msec Input time in milliseconds.
150  *****************************************************************************/
151 inline void Time_FromMSec(ltc_t * t, uint32_t t_msec)
152 {
153  assert(t != 0);
154  t->sec = t_msec / 1000U;
155  t->usec = (t_msec % 1000U) * 1000U;
156 }
157 
158 /*!***************************************************************************
159  * @brief Converts seconds (uint32_t) to #ltc_t.
160  * @details The specified time value in seconds is converted to type #ltc_t.
161  * @param t Output #ltc_t structure.
162  * @param t_sec Input time in seconds.
163  *****************************************************************************/
164 inline void Time_FromSec(ltc_t * t, uint32_t t_sec)
165 {
166  assert(t != 0);
167  t->usec = 0;
168  t->sec = t_sec;
169 }
170 
171 
172 /*!***************************************************************************
173  * @brief Checks if /p t1 is greater or equal that /p t2.
174  * @details Handles overflow.
175  * @param t1 1st operand.
176  * @param t2 2nd operand.
177  * @return Returns (t1 >= t2);
178  *****************************************************************************/
179 inline bool Time_GreaterEqual(ltc_t const * t1, ltc_t const * t2)
180 {
181  assert(t1 != 0);
182  assert(t2 != 0);
183  return (t1->sec == t2->sec) ? (t1->usec >= t2->usec) : (t1->sec > t2->sec);
184 }
185 
186 
187 /*!***************************************************************************
188  * @brief Obtains the elapsed time since MCU startup.
189  * @param t_now returned current time
190  *****************************************************************************/
191 inline void Time_GetNow(ltc_t * t_now)
192 {
193  assert(t_now != 0);
194  Timer_GetCounterValue(&(t_now->sec), &(t_now->usec));
195  assert(t_now->usec < 1000000U);
196 }
197 
198 /*!***************************************************************************
199  * @brief Obtains the elapsed time since MCU startup.
200  * @return Returns the current time.
201  *****************************************************************************/
202 inline ltc_t Time_Now(void)
203 {
204  ltc_t t_now;
205  Time_GetNow(&t_now);
206  return t_now;
207 }
208 
209 /*!***************************************************************************
210  * @brief Obtains the elapsed microseconds since MCU startup.
211  * @details Wrap around effect due to uint32_t result format!!
212  * @return Elapsed microseconds since MCU startup as uint32_t.
213  *****************************************************************************/
214 inline uint32_t Time_GetNowUSec(void)
215 {
216  ltc_t t_now = Time_Now();
217  return Time_ToUSec(&t_now);
218 }
219 
220 /*!***************************************************************************
221  * @brief Obtains the elapsed milliseconds (rounded) since MCU startup.
222  * @details Wrap around effect due to uint32_t result format!!
223  * @return Elapsed milliseconds since MCU startup as uint32_t.
224  *****************************************************************************/
225 inline uint32_t Time_GetNowMSec(void)
226 {
227  ltc_t t_now = Time_Now();
228  return Time_ToMSec(&t_now);
229 }
230 
231 /*!***************************************************************************
232  * @brief Obtains the elapsed seconds (rounded) since MCU startup.
233  * @return Elapsed seconds since MCU startup as uint32_t.
234  *****************************************************************************/
235 inline uint32_t Time_GetNowSec(void)
236 {
237  ltc_t t_now = Time_Now();
238  return Time_ToSec(&t_now);
239 }
240 
241 
242 /*!***************************************************************************
243  * @brief Obtains the time difference between two given time points.
244  * @details Result is defined as t_diff = t_end - t_start.
245  * Note: since no negative time differences are supported, t_end has
246  * to be later/larger than t_start. Otherwise, the result is undefined!
247  * @param t_diff Returned time difference.
248  * @param t_start Start time point.
249  * @param t_end End time point.
250  *****************************************************************************/
251 inline void Time_Diff(ltc_t * t_diff, ltc_t const * t_start, ltc_t const * t_end)
252 {
253  assert(t_diff != 0);
254  assert(t_start != 0);
255  assert(t_end != 0);
256  assert(t_diff != t_start);
257  assert(t_diff != t_end);
258  assert(Time_GreaterEqual(t_end, t_start));
259 
260  if (t_start->usec <= t_end->usec) // no carry over
261  {
262  t_diff->sec = t_end->sec - t_start->sec;
263  t_diff->usec = t_end->usec - t_start->usec;
264  }
265  else // with carry over
266  {
267  t_diff->sec = t_end->sec - 1 - t_start->sec;
268  t_diff->usec = (1000000U - t_start->usec) + t_end->usec;
269  }
270 }
271 
272 /*!***************************************************************************
273  * @brief Obtains the time difference between two given time points in
274  * microseconds.
275  * @details Result is defined as t_diff = t_end - t_start.
276  * Refers to Time_Diff() and handles overflow such that to large
277  * values are limited by 0xFFFFFFFF µs.
278  * @param t_start Start time point.
279  * @param t_end End time point.
280  * @return Time difference in microseconds.
281  *****************************************************************************/
282 inline uint32_t Time_DiffUSec(ltc_t const * t_start, ltc_t const * t_end)
283 {
284  ltc_t t_diff;
285  Time_Diff(&t_diff, t_start, t_end);
286  return Time_ToUSec(&t_diff);
287 }
288 
289 /*!***************************************************************************
290  * @brief Obtains the time difference between two given time points in
291  * milliseconds.
292  * @details Result is defined as t_diff = t_end - t_start.
293  * Refers to Time_Diff() and handles overflow.
294  * Wrap around effect due to uint32_t result format!!
295  * @param t_start Start time point.
296  * @param t_end End time point.
297  * @return Time difference in milliseconds.
298  *****************************************************************************/
299 inline uint32_t Time_DiffMSec(ltc_t const * t_start, ltc_t const * t_end)
300 {
301  ltc_t t_diff;
302  Time_Diff(&t_diff, t_start, t_end);
303  return Time_ToMSec(&t_diff);
304 }
305 
306 /*!***************************************************************************
307  * @brief Obtains the time difference between two given time points in
308  * seconds.
309  * @details Result is defined as t_diff = t_end - t_start.
310  * Refers to Time_Diff() and handles overflow.
311  * @param t_start Start time point.
312  * @param t_end End time point.
313  * @return Time difference in seconds.
314  *****************************************************************************/
315 inline uint32_t Time_DiffSec(ltc_t const * t_start, ltc_t const * t_end)
316 {
317  ltc_t t_diff;
318  Time_Diff(&t_diff, t_start, t_end);
319  return Time_ToSec(&t_diff);
320 }
321 
322 
323 /*!***************************************************************************
324  * @brief Obtains the elapsed time since a given time point.
325  * @details Calculates the currently elapsed time since a specified start time
326  * (/p t_start).
327  *
328  * Note that /p t_start must be in the past! Otherwise, the behavior is
329  * undefined!
330  *
331  * @param t_elapsed Returns the elapsed time since /p t_start.
332  * @param t_start Start time point.
333  *****************************************************************************/
334 inline void Time_GetElapsed(ltc_t * t_elapsed, ltc_t const * t_start)
335 {
336  assert(t_elapsed != 0);
337  assert(t_start != 0);
338  assert(t_elapsed != t_start);
339  ltc_t t_now = Time_Now();
340  Time_Diff(t_elapsed, t_start, &t_now);
341 }
342 
343 /*!***************************************************************************
344  * @brief Obtains the elapsed microseconds since a given time point.
345  * @details Wrap around effect due to uint32_t result format!!
346  * @param t_start Start time point.
347  * @return Elapsed microseconds since t_start as uint32_t.
348  *****************************************************************************/
349 inline uint32_t Time_GetElapsedUSec(ltc_t const * t_start)
350 {
351  assert(t_start != 0);
352  ltc_t t_now = Time_Now();
353  return Time_DiffUSec(t_start, &t_now);
354 }
355 
356 /*!***************************************************************************
357  * @brief Obtains the elapsed milliseconds since a given time point.
358  * @details Wrap around effect due to uint32_t result format!!
359  * @param t_start Start time point.
360  * @return Elapsed milliseconds since t_start as uint32_t.
361  *****************************************************************************/
362 inline uint32_t Time_GetElapsedMSec(ltc_t const * t_start)
363 {
364  assert(t_start != 0);
365  ltc_t t_now = Time_Now();
366  return Time_DiffMSec(t_start, &t_now);
367 }
368 
369 /*!***************************************************************************
370  * @brief Obtains the elapsed seconds since a given time point.
371  * @param t_start Start time point.
372  * @return Elapsed seconds since t_start as uint32_t.
373  *****************************************************************************/
374 inline uint32_t Time_GetElapsedSec(ltc_t const * t_start)
375 {
376  assert(t_start != 0);
377  ltc_t t_now = Time_Now();
378  return Time_DiffSec(t_start, &t_now);
379 }
380 
381 
382 /*!***************************************************************************
383  * @brief Adds two #ltc_t values.
384  * @details Result is defined as t = t1 + t2.
385  * The results are wrapped around at maximum values just like integers.
386  * The references for t, t1 and t2 may point to the same instance(s).
387  *
388  * @param t Return value: t = t1 + t2.
389  * @param t1 1st operand.
390  * @param t2 2nd operand.
391  *****************************************************************************/
392 inline void Time_Add(ltc_t * t, ltc_t const * t1, ltc_t const * t2)
393 {
394  assert(t != 0);
395  assert(t1 != 0);
396  assert(t2 != 0);
397 
398  t->sec = t1->sec + t2->sec;
399  t->usec = t1->usec + t2->usec;
400  if (t->usec > 999999U)
401  {
402  t->sec += 1U;
403  t->usec -= 1000000U;
404  }
405 }
406 
407 /*!***************************************************************************
408  * @brief Adds a given time in microseconds to an #ltc_t value.
409  * @details Result is defined as t = t1 + t2.
410  * The results are wrapped around at maximum values just like integers.
411  * The references for t and t1 may point to the same instance.
412  *
413  * @param t Return value: t = t1 + t2.
414  * @param t1 1st operand.
415  * @param t2_usec 2nd operand in microseconds.
416  *****************************************************************************/
417 inline void Time_AddUSec(ltc_t * t, ltc_t const * t1, uint32_t t2_usec)
418 {
419  assert(t != 0);
420  assert(t1 != 0);
421  ltc_t t2;
422  Time_FromUSec(&t2, t2_usec);
423  Time_Add(t, t1, &t2);
424 }
425 
426 /*!***************************************************************************
427  * @brief Adds a given time in milliseconds to an #ltc_t value.
428  * @details Result is defined as t = t1 + t2.
429  * The results are wrapped around at maximum values just like integers.
430  * The references for t and t1 may point to the same instance.
431  *
432  * @param t Return value: t = t1 + t2.
433  * @param t1 1st operand.
434  * @param t2_msec 2nd operand in milliseconds.
435  *****************************************************************************/
436 inline void Time_AddMSec(ltc_t * t, ltc_t const * t1, uint32_t t2_msec)
437 {
438  assert(t != 0);
439  assert(t1 != 0);
440  ltc_t t2;
441  Time_FromMSec(&t2, t2_msec);
442  Time_Add(t, t1, &t2);
443 }
444 
445 /*!***************************************************************************
446  * @brief Adds a given time in seconds to an #ltc_t value.
447  * @details Result is defined as t = t1 + t2.
448  * The results are wrapped around at maximum values just like integers.
449  * The references for t and t1 may point to the same instance.
450  *
451  * @param t Return value: t = t1 + t2.
452  * @param t1 1st operand.
453  * @param t2_sec 2nd operand in seconds.
454  *****************************************************************************/
455 inline void Time_AddSec(ltc_t * t, ltc_t const * t1, uint32_t t2_sec)
456 {
457  assert(t != 0);
458  assert(t1 != 0);
459  ltc_t t2;
460  Time_FromSec(&t2, t2_sec);
461  Time_Add(t, t1, &t2);
462 }
463 
464 
465 /*!***************************************************************************
466  * @brief Checks if /p t is within the time interval /p t_start and /p t_end.
467  * @details The interval is from /p t_start to /p t_end.
468  * The function returns true if /p t >= /p t_start AND /p t < /p t_end.
469  * If /p t_end is before /p t_start, /p t_end is consider to be wrapped
470  * around and the condition inverts (i.e. the function returns true if
471  * /p < /p t_end OR /p t >= t_start.
472  * @param t_start The start of the time interval.
473  * @param t_end The end of the time interval.
474  * @param t The time to be checked if it is with the interval.
475  * @return True if t is within t_start and t_stop.
476  *****************************************************************************/
477 inline bool Time_CheckWithin(ltc_t const * t_start, ltc_t const * t_end, ltc_t const * t)
478 {
479  if (Time_GreaterEqual(t_end, t_start))
480  return Time_GreaterEqual(t, t_start) && !Time_GreaterEqual(t, t_end);
481  else
482  return Time_GreaterEqual(t, t_start) || !Time_GreaterEqual(t, t_end);
483 }
484 
485 
486 /*!***************************************************************************
487  * @brief Checks if timeout is reached from a given starting time.
488  * @details Checks if a specified time (/p t_timeout) has elapsed since a
489  * specified start time (/p t_start).
490  * Handles overflow/wraparound of time values at the maximum value.
491  * @param t_start Start time.
492  * @param t_timeout Timeout period.
493  * @return Timeout elapsed? True/False (boolean value)
494  *****************************************************************************/
495 inline bool Time_CheckTimeout(ltc_t const * t_start, ltc_t const * t_timeout)
496 {
497  assert(t_start != 0);
498  assert(t_timeout != 0);
499 
500  ltc_t t_end;
501  ltc_t t_now = Time_Now();
502  Time_Add(&t_end, t_start, t_timeout);
503  return !Time_CheckWithin(t_start, &t_end, &t_now);
504 }
505 
506 /*!***************************************************************************
507  * @brief Checks if timeout is reached from a given starting time.
508  * @details Handles overflow.
509  * @param t_start Start time.
510  * @param t_timeout_usec Timeout period in microseconds.
511  * @return Timeout elapsed? True/False (boolean value)
512  *****************************************************************************/
513 inline bool Time_CheckTimeoutUSec(ltc_t const * t_start, uint32_t const t_timeout_usec)
514 {
515  ltc_t t_timeout;
516  Time_FromUSec(&t_timeout, t_timeout_usec);
517  return Time_CheckTimeout(t_start, &t_timeout);
518 }
519 
520 /*!***************************************************************************
521  * @brief Checks if timeout is reached from a given starting time.
522  * @details Handles overflow.
523  * @param t_start Start time.
524  * @param t_timeout_msec Timeout period in milliseconds.
525  * @return Timeout elapsed? True/False (boolean value)
526  *****************************************************************************/
527 inline bool Time_CheckTimeoutMSec(ltc_t const * t_start, uint32_t const t_timeout_msec)
528 {
529  ltc_t t_timeout;
530  Time_FromMSec(&t_timeout, t_timeout_msec);
531  return Time_CheckTimeout(t_start, &t_timeout);
532 }
533 
534 /*!***************************************************************************
535  * @brief Checks if timeout is reached from a given starting time.
536  * @details Handles overflow.
537  * @param t_start Start time.
538  * @param t_timeout_sec Timeout period in seconds.
539  * @return Timeout elapsed? True/False (boolean value)
540  *****************************************************************************/
541 inline bool Time_CheckTimeoutSec(ltc_t const * t_start, uint32_t const t_timeout_sec)
542 {
543  ltc_t t_timeout;
544  Time_FromSec(&t_timeout, t_timeout_sec);
545  return Time_CheckTimeout(t_start, &t_timeout);
546 }
547 
548 
549 /*!***************************************************************************
550  * @brief Time delay for a given time period.
551  * @param dt Delay time.
552  *****************************************************************************/
553 inline void Time_Delay(ltc_t const * dt)
554 {
555  assert(dt != 0);
556  ltc_t t_start = Time_Now();
557  while (!Time_CheckTimeout(&t_start, dt));
558 }
559 
560 /*!***************************************************************************
561  * @brief Time delay for a given time period in microseconds.
562  * @param dt_usec Delay time in microseconds.
563  *****************************************************************************/
564 inline void Time_DelayUSec(uint32_t dt_usec)
565 {
566  ltc_t t_start = Time_Now();
567  while (!Time_CheckTimeoutUSec(&t_start, dt_usec));
568 }
569 
570 /*!***************************************************************************
571  * @brief Time delay for a given time period in milliseconds.
572  * @param dt_msec Delay time in milliseconds.
573  *****************************************************************************/
574 inline void Time_DelayMSec(uint32_t dt_msec)
575 {
576  ltc_t t_start = Time_Now();
577  while (!Time_CheckTimeoutMSec(&t_start, dt_msec));
578 }
579 
580 /*!***************************************************************************
581  * @brief Time delay for a given time period in seconds.
582  * @param dt_sec Delay time in seconds.
583  *****************************************************************************/
584 inline void Time_DelaySec(uint32_t dt_sec)
585 {
586  ltc_t t_start = Time_Now();
587  while (!Time_CheckTimeoutSec(&t_start, dt_sec));
588 }
589 
590 
592 #ifdef __cplusplus
593 } // extern "C"
594 #endif
595 #endif /* TIME_H */
Time_CheckTimeoutSec
bool Time_CheckTimeoutSec(ltc_t const *t_start, uint32_t const t_timeout_sec)
Checks if timeout is reached from a given starting time.
Definition: time.h:541
Time_FromMSec
void Time_FromMSec(ltc_t *t, uint32_t t_msec)
Converts milliseconds (uint32_t) to ltc_t.
Definition: time.h:151
Time_DiffSec
uint32_t Time_DiffSec(ltc_t const *t_start, ltc_t const *t_end)
Obtains the time difference between two given time points in seconds.
Definition: time.h:315
Time_Now
ltc_t Time_Now(void)
Obtains the elapsed time since MCU startup.
Definition: time.h:202
Time_DiffMSec
uint32_t Time_DiffMSec(ltc_t const *t_start, ltc_t const *t_end)
Obtains the time difference between two given time points in milliseconds.
Definition: time.h:299
Time_AddUSec
void Time_AddUSec(ltc_t *t, ltc_t const *t1, uint32_t t2_usec)
Adds a given time in microseconds to an ltc_t value.
Definition: time.h:417
Time_DelayUSec
void Time_DelayUSec(uint32_t dt_usec)
Time delay for a given time period in microseconds.
Definition: time.h:564
Time_ToUSec
uint32_t Time_ToUSec(ltc_t const *t)
Converts ltc_t to microseconds (uint32_t).
Definition: time.h:89
Time_Diff
void Time_Diff(ltc_t *t_diff, ltc_t const *t_start, ltc_t const *t_end)
Obtains the time difference between two given time points.
Definition: time.h:251
Time_Delay
void Time_Delay(ltc_t const *dt)
Time delay for a given time period.
Definition: time.h:553
Time_ToMSec
uint32_t Time_ToMSec(ltc_t const *t)
Converts ltc_t to milliseconds (uint32_t).
Definition: time.h:107
Time_GetNowUSec
uint32_t Time_GetNowUSec(void)
Obtains the elapsed microseconds since MCU startup.
Definition: time.h:214
Time_GetElapsed
void Time_GetElapsed(ltc_t *t_elapsed, ltc_t const *t_start)
Obtains the elapsed time since a given time point.
Definition: time.h:334
Time_AddMSec
void Time_AddMSec(ltc_t *t, ltc_t const *t1, uint32_t t2_msec)
Adds a given time in milliseconds to an ltc_t value.
Definition: time.h:436
Timer_GetCounterValue
void Timer_GetCounterValue(uint32_t *hct, uint32_t *lct)
Obtains the lifetime counter value from the timers.
Time_FromSec
void Time_FromSec(ltc_t *t, uint32_t t_sec)
Converts seconds (uint32_t) to ltc_t.
Definition: time.h:164
Time_GetElapsedUSec
uint32_t Time_GetElapsedUSec(ltc_t const *t_start)
Obtains the elapsed microseconds since a given time point.
Definition: time.h:349
Time_CheckTimeout
bool Time_CheckTimeout(ltc_t const *t_start, ltc_t const *t_timeout)
Checks if timeout is reached from a given starting time.
Definition: time.h:495
Time_GetNowMSec
uint32_t Time_GetNowMSec(void)
Obtains the elapsed milliseconds (rounded) since MCU startup.
Definition: time.h:225
Time_Add
void Time_Add(ltc_t *t, ltc_t const *t1, ltc_t const *t2)
Adds two ltc_t values.
Definition: time.h:392
Time_AddSec
void Time_AddSec(ltc_t *t, ltc_t const *t1, uint32_t t2_sec)
Adds a given time in seconds to an ltc_t value.
Definition: time.h:455
Time_ToSec
uint32_t Time_ToSec(ltc_t const *t)
Converts ltc_t to seconds (uint32_t).
Definition: time.h:123
Time_GetElapsedMSec
uint32_t Time_GetElapsedMSec(ltc_t const *t_start)
Obtains the elapsed milliseconds since a given time point.
Definition: time.h:362
Time_GetNowSec
uint32_t Time_GetNowSec(void)
Obtains the elapsed seconds (rounded) since MCU startup.
Definition: time.h:235
Time_GreaterEqual
bool Time_GreaterEqual(ltc_t const *t1, ltc_t const *t2)
Checks if /p t1 is greater or equal that /p t2.
Definition: time.h:179
Time_DiffUSec
uint32_t Time_DiffUSec(ltc_t const *t_start, ltc_t const *t_end)
Obtains the time difference between two given time points in microseconds.
Definition: time.h:282
Time_CheckTimeoutUSec
bool Time_CheckTimeoutUSec(ltc_t const *t_start, uint32_t const t_timeout_usec)
Checks if timeout is reached from a given starting time.
Definition: time.h:513
ltc_t
A data structure to represent current time.
Definition: time.h:69
ltc_t::usec
uint32_t usec
Definition: time.h:77
Time_CheckWithin
bool Time_CheckWithin(ltc_t const *t_start, ltc_t const *t_end, ltc_t const *t)
Checks if /p t is within the time interval /p t_start and /p t_end.
Definition: time.h:477
Time_FromUSec
void Time_FromUSec(ltc_t *t, uint32_t t_usec)
Converts microseconds (uint32_t) to ltc_t.
Definition: time.h:138
Time_DelayMSec
void Time_DelayMSec(uint32_t dt_msec)
Time delay for a given time period in milliseconds.
Definition: time.h:574
Time_DelaySec
void Time_DelaySec(uint32_t dt_sec)
Time delay for a given time period in seconds.
Definition: time.h:584
Time_GetNow
void Time_GetNow(ltc_t *t_now)
Obtains the elapsed time since MCU startup.
Definition: time.h:191
Time_GetElapsedSec
uint32_t Time_GetElapsedSec(ltc_t const *t_start)
Obtains the elapsed seconds since a given time point.
Definition: time.h:374
argus_timer.h
This file is part of the AFBR-S50 API.
ltc_t::sec
uint32_t sec
Definition: time.h:73
Time_CheckTimeoutMSec
bool Time_CheckTimeoutMSec(ltc_t const *t_start, uint32_t const t_timeout_msec)
Checks if timeout is reached from a given starting time.
Definition: time.h:527