Skip to content

Commit

Permalink
[sys_time] if PERIODIC_FREQUENCY is defined, set default SYS_TIME_RES…
Browse files Browse the repository at this point in the history
…OLUTION to twice that
  • Loading branch information
flixr committed Feb 13, 2013
1 parent 9bbe2da commit ed28e4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sw/airborne/mcu_periph/sys_time.c
Expand Up @@ -32,6 +32,8 @@

struct sys_time sys_time;

PRINT_CONFIG_VAR(SYS_TIME_RESOLUTION)

int sys_time_register_timer(float duration, sys_time_cb cb) {

uint32_t start_time = sys_time.nb_tick;
Expand Down
4 changes: 4 additions & 0 deletions sw/airborne/mcu_periph/sys_time.h
Expand Up @@ -103,8 +103,12 @@ static inline bool_t sys_time_check_and_ack_timer(tid_t id) {

/** system time resolution in seconds */
#ifndef SYS_TIME_RESOLUTION
#if defined PERIODIC_FREQUENCY
#define SYS_TIME_RESOLUTION ( 1./(2*PERIODIC_FREQUENCY) )
#else
#define SYS_TIME_RESOLUTION ( 1./1024. )
#endif
#endif
#define SYS_TIME_RESOLUTION_CPU_TICKS CPU_TICKS_OF_SEC(SYS_TIME_RESOLUTION)

#define SYS_TIME_TICKS_OF_SEC(s) (uint32_t)((s) / SYS_TIME_RESOLUTION + 0.5)
Expand Down

0 comments on commit ed28e4d

Please sign in to comment.