Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sys_time.h File Reference

Architecture independent timing functions. More...

#include <inttypes.h>
#include <stdlib.h>
#include "std.h"
#include <BOARD_CONFIG>
Include dependency graph for sys_time.h:

Go to the source code of this file.

Data Structures

struct  sys_time_timer
struct  sys_time

Macros

#define SYS_TIME_NB_TIMER   16
#define SYS_TIME_FREQUENCY   1000
 (Default) sys_time timer frequency in Hz.
#define SYS_TIME_MSEC_PER_WEEK   (1000UL * 60 * 60 * 24 * 7)
#define SYS_TIME_UNIX_GPS_EPOCH_MS   315964800000ULL
 unix time of the GPS epoch (1980-01-06) in ms
#define SYS_TIME_GPS_LEAP_SECONDS   18
 Difference between GPS time and UTC.
#define USEC_OF_SEC(sec)
#define SysTimeTimerStart(_t)
#define SysTimeTimer(_t)
#define SysTimeTimerStop(_t)

Typedefs

typedef int8_t tid_t
 sys_time timer id type
typedef void(* sys_time_cb) (uint8_t id)

Functions

void sys_time_init (void)
void sys_time_usleep (uint32_t us)
 Sleep.
void sys_time_msleep (uint32_t ms)
 Sleep.
uint32_t get_sys_time_usec (void)
 Get the time in microseconds since startup.
uint32_t get_sys_time_usec100 (void)
 Get the time in 100microseconds since startup.
uint32_t get_sys_time_msec (void)
 Get the time in milliseconds since startup.
uint32_t sys_time_rtc_millisecond (void)
 Get the RTC time in milliseconds since midnight.
uint32_t get_sys_time_tow (void)
 Get the GPS time of week in milliseconds.
uint32_t get_sys_time_unix (void)
 Get the UTC unix time in seconds.
uint64_t get_sys_time_unix_msec (void)
 Get the UTC unix time in milliseconds.
void sys_time_sync_gps (uint16_t week, uint32_t tow, uint32_t stamp)
 Synchronize the time with a GPS measurement (has priority over the ground).
void sys_time_sync_unix (uint32_t unix_time, uint16_t unix_ms, uint32_t stamp)
 Synchronize the time with the ground, only used without recent GPS sync.
void sys_time_parse_TIME_SYNC (uint8_t *buf)
 Parse the TIME_SYNC datalink message (ground time).
void sys_time_rtc_set (uint32_t unix_time, uint16_t unix_ms)
 Set the RTC to the UTC unix time (architecture specific, may do nothing).
tid_t sys_time_register_timer (float duration, sys_time_cb cb)
 Register a new system timer.
tid_t sys_time_register_timer_offset (tid_t timer, float offset, sys_time_cb cb)
 Register a new system timer with an fixed offset from another one.
void sys_time_cancel_timer (tid_t id)
 Cancel a system timer by id.
void sys_time_update_timer (tid_t id, float duration)
 Update the duration until a timer elapses.
static bool sys_time_check_and_ack_timer (tid_t id)
 Check if timer has elapsed.
static float get_sys_time_float (void)
 Get the time in seconds since startup.
static uint32_t sys_time_ticks_of_sec (float seconds)
static uint32_t sys_time_ticks_of_msec (uint32_t msec)
static uint32_t sys_time_ticks_of_usec (uint32_t usec)
static float sec_of_sys_time_ticks (uint32_t ticks)
static uint32_t msec_of_sys_time_ticks (uint32_t ticks)
static uint32_t usec_of_sys_time_ticks (uint32_t ticks)
static uint32_t cpu_ticks_of_sec (float seconds)
static uint32_t cpu_ticks_of_usec (uint32_t usec)
static int32_t signed_cpu_ticks_of_usec (int32_t usec)
static uint32_t cpu_ticks_of_nsec (uint32_t nsec)
static uint32_t msec_of_cpu_ticks (uint32_t cpu_ticks)
static uint32_t usec_of_cpu_ticks (uint32_t cpu_ticks)
static uint32_t nsec_of_cpu_ticks (uint32_t cpu_ticks)
void sys_time_arch_init (void)

Variables

struct sys_time sys_time

Detailed Description

Architecture independent timing functions.

Definition in file sys_time.h.


Data Structure Documentation

◆ sys_time_timer

struct sys_time_timer

Definition at line 71 of file sys_time.h.

Data Fields
sys_time_cb cb
uint32_t duration in SYS_TIME_TICKS
volatile bool elapsed
uint32_t end_time in SYS_TIME_TICKS
bool in_use

◆ sys_time

struct sys_time

Definition at line 79 of file sys_time.h.

Collaboration diagram for sys_time:
Data Fields
uint32_t cpu_ticks_per_sec cpu ticks per second
uint32_t gps_tow_sync uptime in ms of the last GPS time of week sync
bool gps_tow_synced time of week synced with a GPS
uint32_t gps_unix_sync uptime in ms of the last GPS unix time sync
bool gps_unix_synced unix time synced with a GPS
uint64_t ground_offset last applied ground UTC unix time at startup in ms
bool ground_synced a ground time was applied
volatile uint32_t nb_sec full seconds since startup
volatile uint32_t nb_sec_rem remainder of seconds since startup in CPU_TICKS
volatile uint32_t nb_tick SYS_TIME_TICKS since startup.
float resolution sys_time_timer resolution in seconds
uint32_t resolution_cpu_ticks sys_time_timer resolution in cpu ticks
uint32_t rtc_sync uptime in ms of the last RTC update
uint32_t ticks_per_sec sys_time ticks per second (SYS_TIME_FREQUENCY)
struct sys_time_timer timer[SYS_TIME_NB_TIMER]
uint32_t tow_offset GPS time of week at startup in ms (0 until synced).
uint64_t unix_offset UTC unix time at startup in ms.
bool unix_synced unix time synced (GPS or ground)

Macro Definition Documentation

◆ SYS_TIME_FREQUENCY

#define SYS_TIME_FREQUENCY   1000

(Default) sys_time timer frequency in Hz.

sys_time.resolution is set from this define.

Definition at line 56 of file sys_time.h.

Referenced by pca9685_i2c_init(), sys_time_init(), and thd_sys_tick().

◆ SYS_TIME_GPS_LEAP_SECONDS

#define SYS_TIME_GPS_LEAP_SECONDS   18

Difference between GPS time and UTC.

Definition at line 65 of file sys_time.h.

Referenced by gps_feed_value().

◆ SYS_TIME_MSEC_PER_WEEK

#define SYS_TIME_MSEC_PER_WEEK   (1000UL * 60 * 60 * 24 * 7)

◆ SYS_TIME_NB_TIMER

#define SYS_TIME_NB_TIMER   16

◆ SYS_TIME_UNIX_GPS_EPOCH_MS

#define SYS_TIME_UNIX_GPS_EPOCH_MS   315964800000ULL

unix time of the GPS epoch (1980-01-06) in ms

Definition at line 61 of file sys_time.h.

Referenced by gps_feed_value(), sys_time_sync_gps(), and sys_time_sync_unix().

◆ SysTimeTimer

#define SysTimeTimer ( _t)
Value:
( get_sys_time_usec() - (_t))
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.

Definition at line 330 of file sys_time.h.

Referenced by actuators_asctec_v2_commit(), airspeed_ets_read_periodic(), baro_ets_read_periodic(), event_sysmon(), hott_event(), and periodic_sysmon().

◆ SysTimeTimerStart

#define SysTimeTimerStart ( _t)

◆ SysTimeTimerStop

#define SysTimeTimerStop ( _t)
Value:
{ _t = ( get_sys_time_usec() - (_t)); }

Definition at line 331 of file sys_time.h.

◆ USEC_OF_SEC

#define USEC_OF_SEC ( sec)
Value:
((sec) * 1e6)

Definition at line 322 of file sys_time.h.

Referenced by actuators_asctec_v2_commit(), airspeed_ets_read_periodic(), baro_ets_read_periodic(), and thd_sys_tick().

Typedef Documentation

◆ sys_time_cb

typedef void(* sys_time_cb) (uint8_t id)

Definition at line 69 of file sys_time.h.

◆ tid_t

typedef int8_t tid_t

sys_time timer id type

Definition at line 68 of file sys_time.h.

Function Documentation

◆ cpu_ticks_of_nsec()

uint32_t cpu_ticks_of_nsec ( uint32_t nsec)
inlinestatic

Definition at line 300 of file sys_time.h.

References sys_time::cpu_ticks_per_sec.

Referenced by sys_tick_handler().

Here is the caller graph for this function:

◆ cpu_ticks_of_sec()

uint32_t cpu_ticks_of_sec ( float seconds)
inlinestatic

Definition at line 285 of file sys_time.h.

References sys_time::cpu_ticks_per_sec.

Referenced by sys_tick_handler().

Here is the caller graph for this function:

◆ cpu_ticks_of_usec()

uint32_t cpu_ticks_of_usec ( uint32_t usec)
inlinestatic

Definition at line 290 of file sys_time.h.

References sys_time::cpu_ticks_per_sec.

Referenced by xtend_rssi_periodic().

Here is the caller graph for this function:

◆ get_sys_time_float()

float get_sys_time_float ( void )
inlinestatic

Get the time in seconds since startup.

Returns
current system time as float with sys_time.resolution

Definition at line 241 of file sys_time.h.

References sys_time::cpu_ticks_per_sec, sys_time::nb_sec, and sys_time::nb_sec_rem.

Referenced by accel_sp_cb(), actuators_faulhaber_periodic(), actuators_t4_uart_event(), actuators_uavcan_esc_status_cb(), agl_cb(), agl_dist_init(), agl_dist_timeout(), air_data_finish_calibration(), air_data_periodic(), air_data_start_calibration(), airspeed_cb(), airspeed_raw_cb(), autopilot_arming_check_motors_on(), autopilot_arming_set(), baro_raw_cb(), cc2500_delayMicroseconds(), check_anchor_timeout(), chirp_call(), ctrl_module_run(), dc_periodic(), diff_raw_cb(), ekf_run(), get_uavcan_status(), gps_cb(), gps_fix_valid(), guidance_indi_run_mode(), guidance_indi_run_mode(), gyro_cb(), hmc58xx_start_configure(), hx711_event(), imu_aspirin2_configure_mag_slave(), imu_mpu9250_configure_mag_slave(), incidence_cb(), ins_flow_init(), ins_flow_update(), logger_control_effectiveness_periodic(), logger_file_write_row(), mag_cb(), nav_lace_run(), nav_rosette_run(), nav_rosette_setup(), nav_trinity_run(), optical_flow_landing_init(), periodic_report_sysmon(), periodic_sys_id_auto_doublets(), pfc_actuators_run(), PID_divergence_control(), preflight_check(), pressure_diff_cb(), px4flow_i2c_downlink(), px4flow_i2c_frame_cb(), read_rc_setpoint_heading(), reset_all_vars(), reset_horizontal_vars(), reset_vertical_vars(), rotwing_state_feedback_cb(), rotwing_state_hover_motors_idling(), rotwing_state_hover_motors_running(), rotwing_state_periodic(), rotwing_state_pusher_motor_running(), rotwing_state_skew_angle_valid(), rpm_cb(), sdlog_chibios_init(), sdlog_write(), send_filter_status(), stabilization_attitude_read_rc_setpoint_eulers(), stabilization_attitude_read_rc_setpoint_eulers_f(), start_chirp(), start_doublet(), start_wave(), stop_chirp(), stop_doublet(), stop_wave(), sys_id_auto_doublets_on_activation(), sys_id_chirp_activate_handler(), sys_id_chirp_init(), sys_id_chirp_run(), sys_id_doublet_activate_handler(), sys_id_doublet_init(), sys_id_doublet_run(), sys_id_wave_activate_handler(), sys_id_wave_frequency_hz_set(), sys_id_wave_init(), sys_id_wave_lag_rad_set(), sys_id_wave_run(), temp_raw_cb(), uwb_ranging_cb(), vel_sp_cb(), vertical_ctrl_module_run(), and vertical_ctrl_optical_flow_cb().

◆ get_sys_time_msec()

uint32_t get_sys_time_msec ( void )

◆ get_sys_time_tow()

uint32_t get_sys_time_tow ( void )

Get the GPS time of week in milliseconds.

Synced from the GPS, or from the ground (TIME_SYNC) without GPS. Until synced this is the time since startup.

Returns
GPS time of week in milliseconds

Definition at line 72 of file sys_time.c.

References SYS_TIME_MSEC_PER_WEEK, sys_time::tow_offset, and uptime_msec().

Referenced by gps_tow_from_sys_ticks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_sys_time_unix()

uint32_t get_sys_time_unix ( void )

Get the UTC unix time in seconds.

Synced from the GPS, or from the ground (TIME_SYNC) without GPS.

Returns
unix time in seconds, 0 until synced

Definition at line 87 of file sys_time.c.

References get_sys_time_unix_msec().

Here is the call graph for this function:

◆ get_sys_time_unix_msec()

uint64_t get_sys_time_unix_msec ( void )

Get the UTC unix time in milliseconds.

Returns
unix time in milliseconds, 0 until synced

Definition at line 77 of file sys_time.c.

References sys_time::unix_offset, sys_time::unix_synced, and uptime_msec().

Referenced by get_sys_time_unix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_sys_time_usec()

uint32_t get_sys_time_usec ( void )

Get the time in microseconds since startup.

WARNING: overflows after 70min!

Returns
microseconds since startup as uint32_t

WARNING: overflows after 71min34seconds!

Returns
current system time as uint32_t

Definition at line 78 of file sys_time_arch.c.

References cpu_counter, sys_time::nb_sec, sys_time::nb_sec_rem, startup_time, and usec_of_cpu_ticks().

Referenced by ahrs_aligner_run(), ahrs_vectornav_event(), airspeed_adc_update(), airspeed_amsys_read_event(), airspeed_amsys_read_periodic(), airspeed_cb(), airspeed_ets_read_event(), airspeed_ets_read_periodic(), airspeed_uavcan_cb(), baro_amsys_read_event(), baro_apogee_event(), baro_bmp280_event(), baro_bmp3_event(), baro_bmp_event(), baro_dps310_event(), baro_ets_read_event(), baro_hca_read_event(), baro_mpl3115_read_event(), baro_MS5534A_event(), baro_ms5611_event(), baro_scp_event(), baro_sim_periodic(), baro_spa06_event(), bf_micros(), cloud_sensor_callback(), cloud_sim_detect(), decode_optical_flow_msg(), dps310_i2c_event(), dps310_i2c_periodic(), ekf2_time_us(), ekf_aw_propagate(), gps_cb(), gps_datalink_publish(), gps_feed_value(), gps_intermcu_parse_IMCU_REMOTE_GPS(), gps_mtk_msg(), gps_piksi_publish(), gps_sim_publish(), gps_sirf_msg(), gps_skytraq_msg(), gps_uavcan_cb(), gps_ubx_msg(), gps_ubx_parse_nav_daheading(), gps_ubx_parse_nav_relposned(), gps_udp_parse(), handle_ins_msg(), hott_periodic_event(), hx711_event(), imu_apogee_event(), imu_aspirin2_event(), imu_aspirin_event(), imu_aspirin_i2c_event(), imu_bebop_event(), imu_bmi088_event(), imu_cube_event(), imu_disco_event(), imu_heater_run(), imu_mpu9250_event(), imu_mpu_hmc_event(), imu_mpu_i2c_event(), imu_mpu_spi_event(), imu_nps_event(), imu_px4_event(), imu_px4fmu_event(), ins_alt_float_update_baro(), ins_alt_float_update_gps(), ins_ekf2_init(), ins_ekf2_parse_EXTERNAL_POSE(), ins_ekf2_update(), ins_ekf2_update_system_flags(), ins_ext_pose_msg_update(), invensense2_config(), invensense2_parse_data(), invensense3_456_config(), invensense3_456_parse_fifo_data(), invensense3_config(), invensense3_parse_fifo_data(), invensense3_parse_reg_data(), laser_range_array_parse_msg(), lidar_lite_periodic(), lidar_sf11_periodic(), lidar_vl53l5cx_periodic(), LWC_callback(), mag_hmc58xx_module_event(), mag_ist8310_module_event(), mag_lis3mdl_module_event(), mag_pitot_parse_msg(), mag_qmc5883l_module_event(), mag_rm3100_module_event(), mag_uavcan_cb(), mag_uavcan_cb2(), main(), mateksys3901l0x_parse(), mavlink_send_gps_global_origin(), mavlink_send_gps_raw_int(), meteo_stick_event(), ms45xx_i2c_event(), msec_of_stamp(), nmea_gps_msg(), nps_autopilot_run_step(), opticflow_module_run(), opticflow_pmw3901_event(), pdec_dispatch_frame(), pose_periodic(), px4flow_i2c_frame_cb(), range_msg_callback(), range_sensor_uavcan_cb(), reset_ref(), reset_vertical_ref(), sdp3x_event(), send_anchor_data(), send_filter_status(), send_filter_status(), send_filter_status(), send_filter_status(), send_filter_status(), send_filter_status(), send_filter_status(), send_filter_status(), send_filter_status(), sensors_hitl_event(), sensors_hitl_parse_HITL_AIR_DATA(), sensors_hitl_parse_HITL_GPS(), sonar_adc_periodic(), sonar_bebop_event(), sonar_i2c_periodic(), sonar_pwm_read(), sonar_vl53l1x_publish(), spa06_event(), spa06_periodic(), stereocam_parse_msg(), sts3032_event(), superbitrf_event(), superbitrf_receive_packet_cb(), sys_time_parse_TIME_SYNC(), teraranger_event(), tfmini_i2c_periodic(), tfmini_send_abi(), v4l2_capture_thread(), video_thread_function(), and wind_estimation_quadrotor_periodic().

Here is the call graph for this function:

◆ get_sys_time_usec100()

uint32_t get_sys_time_usec100 ( void )

Get the time in 100microseconds since startup.

WARNING: overflows after 7000min!

Returns
100microseconds since startup as uint32_t

Get the time in 100microseconds since startup.

WARNING: overflows after 7000min!

Returns
100microseconds since startup as uint32_t

WARNING: overflows after 7000 minutes!

Returns
current system time as uint32_t

Definition at line 94 of file sys_time_arch.c.

References cpu_counter, sys_time::nb_sec, sys_time::nb_sec_rem, startup_time, and usec_of_cpu_ticks().

Referenced by pprzlog_tp_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msec_of_cpu_ticks()

uint32_t msec_of_cpu_ticks ( uint32_t cpu_ticks)
inlinestatic

Definition at line 305 of file sys_time.h.

References cpu_ticks, and sys_time::cpu_ticks_per_sec.

Referenced by get_sys_time_msec().

Here is the caller graph for this function:

◆ msec_of_sys_time_ticks()

uint32_t msec_of_sys_time_ticks ( uint32_t ticks)
inlinestatic

Definition at line 270 of file sys_time.h.

References ticks, and sys_time::ticks_per_sec.

Referenced by windturbine_periodic().

Here is the caller graph for this function:

◆ nsec_of_cpu_ticks()

uint32_t nsec_of_cpu_ticks ( uint32_t cpu_ticks)
inlinestatic

Definition at line 315 of file sys_time.h.

References cpu_ticks, and sys_time::cpu_ticks_per_sec.

◆ sec_of_sys_time_ticks()

float sec_of_sys_time_ticks ( uint32_t ticks)
inlinestatic

Definition at line 265 of file sys_time.h.

References sys_time::resolution, and ticks.

◆ signed_cpu_ticks_of_usec()

int32_t signed_cpu_ticks_of_usec ( int32_t usec)
inlinestatic

Definition at line 295 of file sys_time.h.

References sys_time::cpu_ticks_per_sec.

◆ sys_time_arch_init()

void sys_time_arch_init ( void )

Definition at line 59 of file sys_time_arch.c.

References CH_CFG_ST_FREQUENCY, sys_time::cpu_ticks_per_sec, sys_time::resolution, sys_time::resolution_cpu_ticks, rtc_ms_start, startup_time, sys_time_thread_main(), and thd_sys_tick().

Referenced by sys_time_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_time_cancel_timer()

void sys_time_cancel_timer ( tid_t id)
extern

Cancel a system timer by id.

Parameters
idTimer id.

Definition at line 205 of file sys_time.c.

References sys_time_timer::cb, sys_time_timer::duration, sys_time_timer::elapsed, sys_time_timer::end_time, sys_time_timer::in_use, and sys_time::timer.

Referenced by mavlink_mission_cancel_timer(), and px4flash_event().

Here is the caller graph for this function:

◆ sys_time_check_and_ack_timer()

bool sys_time_check_and_ack_timer ( tid_t id)
inlinestatic

Check if timer has elapsed.

Parameters
idTimer id
Returns
TRUE if timer has elapsed

Definition at line 226 of file sys_time.h.

References sys_time_timer::elapsed, SYS_TIME_NB_TIMER, and sys_time::timer.

Referenced by main(), main_ap_periodic(), main_fbw_periodic(), main_recovery_periodic(), mavlink_mission_periodic(), and px4flash_event().

Here is the caller graph for this function:

◆ sys_time_init()

◆ sys_time_msleep()

void sys_time_msleep ( uint32_t ms)

Sleep.

Parameters
msmilliseconds

Definition at line 135 of file sys_time_arch.c.

References sys_time_usleep().

Referenced by uavcan_tx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_time_parse_TIME_SYNC()

void sys_time_parse_TIME_SYNC ( uint8_t * buf)

Parse the TIME_SYNC datalink message (ground time).

Definition at line 221 of file sys_time.c.

References get_sys_time_usec(), and sys_time_sync_unix().

Here is the call graph for this function:

◆ sys_time_register_timer()

tid_t sys_time_register_timer ( float duration,
sys_time_cb cb )
extern

Register a new system timer.

Parameters
durationDuration in seconds until the timer elapses.
cbCallback function that is called from the ISR when timer elapses, or NULL
Returns
-1 if it failed, the timer id otherwise

Definition at line 172 of file sys_time.c.

References sys_time_timer::cb, sys_time_timer::duration, sys_time_timer::elapsed, sys_time_timer::end_time, sys_time_timer::in_use, sys_time::nb_tick, start_time, SYS_TIME_NB_TIMER, sys_time_ticks_of_sec(), and sys_time::timer.

Referenced by main_ap_init(), main_fbw_init(), main_init(), main_init(), main_init(), main_init(), main_init(), main_recovery_init(), mavlink_mission_set_timer(), and px4flash_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_time_register_timer_offset()

tid_t sys_time_register_timer_offset ( tid_t timer,
float offset,
sys_time_cb cb )
extern

Register a new system timer with an fixed offset from another one.

Parameters
timertimer providing start time and duration
offsetoffset in seconds beetween the timers (will overlap if longer than duration)
cbCallback function that is called from the ISR when timer elapses, or NULL
Returns
-1 if it failed, the timer id otherwise

Definition at line 188 of file sys_time.c.

References sys_time_timer::cb, sys_time_timer::duration, sys_time_timer::elapsed, sys_time_timer::end_time, sys_time_timer::in_use, offset, SYS_TIME_NB_TIMER, sys_time_ticks_of_sec(), and sys_time::timer.

Referenced by main_ap_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_time_rtc_millisecond()

uint32_t sys_time_rtc_millisecond ( void )

Get the RTC time in milliseconds since midnight.

Returns
milliseconds since midnight as uint32_t

Definition at line 190 of file sys_time_arch.c.

References sys_time::cpu_ticks_per_sec, sys_time::nb_sec, sys_time::nb_sec_rem, and rtc_ms_start.

◆ sys_time_rtc_set()

void sys_time_rtc_set ( uint32_t unix_time,
uint16_t unix_ms )

Set the RTC to the UTC unix time (architecture specific, may do nothing).

Parameters
unix_timeUTC unix time in seconds
unix_msmilliseconds part of the unix time

Set the RTC to the UTC unix time (architecture specific, may do nothing).

Definition at line 200 of file sys_time_arch.c.

Referenced by set_unix().

Here is the caller graph for this function:

◆ sys_time_sync_gps()

void sys_time_sync_gps ( uint16_t week,
uint32_t tow,
uint32_t stamp )

Synchronize the time with a GPS measurement (has priority over the ground).

Parameters
weekGPS week, 0 if unknown (only syncs the time of week)
towGPS time of week in milliseconds
stampget_sys_time_usec() timestamp at which tow was valid

Definition at line 120 of file sys_time.c.

References sys_time::gps_tow_sync, sys_time::gps_tow_synced, sys_time::gps_unix_sync, sys_time::gps_unix_synced, msec_of_stamp(), set_tow(), set_unix(), SYS_TIME_GPS_LEAP_MS, SYS_TIME_MSEC_PER_WEEK, and SYS_TIME_UNIX_GPS_EPOCH_MS.

Referenced by gps_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_time_sync_unix()

void sys_time_sync_unix ( uint32_t unix_time,
uint16_t unix_ms,
uint32_t stamp )

Synchronize the time with the ground, only used without recent GPS sync.

Parameters
unix_timeUTC unix time in seconds
unix_msmilliseconds part of the unix time
stampget_sys_time_usec() timestamp at which the time was valid

Definition at line 137 of file sys_time.c.

References sys_time::gps_tow_sync, sys_time::gps_tow_synced, sys_time::gps_unix_sync, sys_time::gps_unix_synced, sys_time::ground_offset, sys_time::ground_synced, msec_of_stamp(), offset, set_tow(), set_unix(), SYS_TIME_GPS_LEAP_MS, SYS_TIME_GPS_SYNC_TIMEOUT, SYS_TIME_GROUND_SYNC_THRESHOLD, SYS_TIME_MSEC_PER_WEEK, and SYS_TIME_UNIX_GPS_EPOCH_MS.

Referenced by sys_time_parse_TIME_SYNC().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_time_ticks_of_msec()

uint32_t sys_time_ticks_of_msec ( uint32_t msec)
inlinestatic

Definition at line 255 of file sys_time.h.

References sys_time::ticks_per_sec.

◆ sys_time_ticks_of_sec()

uint32_t sys_time_ticks_of_sec ( float seconds)
inlinestatic

Definition at line 250 of file sys_time.h.

References sys_time::ticks_per_sec.

Referenced by sys_tick_handler(), sys_time_register_timer(), sys_time_register_timer_offset(), and sys_time_update_timer().

Here is the caller graph for this function:

◆ sys_time_ticks_of_usec()

uint32_t sys_time_ticks_of_usec ( uint32_t usec)
inlinestatic

Definition at line 260 of file sys_time.h.

References sys_time::ticks_per_sec.

Referenced by sys_tick_handler().

Here is the caller graph for this function:

◆ sys_time_update_timer()

void sys_time_update_timer ( tid_t id,
float duration )
extern

Update the duration until a timer elapses.

Parameters
idTimer id
durationDuration in seconds until the timer elapses.

Definition at line 215 of file sys_time.c.

References sys_time_timer::duration, sys_time_timer::end_time, sys_time_ticks_of_sec(), and sys_time::timer.

Referenced by mavlink_mission_set_timer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_time_usleep()

void sys_time_usleep ( uint32_t us)

Sleep.

Parameters
usmicroseconds

Sleep.

using intermediate 64 bits variable to avoid wrapping

max sleep time is around 10 days (2^32 / CH_CFG_ST_FREQUENCY) at 10kHz

Definition at line 123 of file sys_time_arch.c.

Referenced by bf_delayMicroseconds(), cyrf6936_init(), humid_sht_thd(), initializeSensor(), main(), pcap01_init(), px4flash_event(), readRegister_blocking(), received_spektrum_soft_bind(), send_spektrum_bind(), sht_read_humid(), sht_read_serial(), sht_read_temp(), spektrum_bind(), spektrum_try_bind(), sys_time_msleep(), video_thread_function(), w5100_init(), writeRegister_blocking(), and xbee_dl_init().

Here is the caller graph for this function:

◆ usec_of_cpu_ticks()

uint32_t usec_of_cpu_ticks ( uint32_t cpu_ticks)
inlinestatic

Definition at line 310 of file sys_time.h.

References cpu_ticks, and sys_time::cpu_ticks_per_sec.

Referenced by get_sys_time_usec(), and get_sys_time_usec100().

Here is the caller graph for this function:

◆ usec_of_sys_time_ticks()

uint32_t usec_of_sys_time_ticks ( uint32_t ticks)
inlinestatic

Definition at line 275 of file sys_time.h.

References ticks, and sys_time::ticks_per_sec.

Variable Documentation

◆ sys_time

struct sys_time sys_time
extern

Definition at line 42 of file sys_time.c.