Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Architecture independent timing functions. More...
#include <inttypes.h>
#include <stdlib.h>
#include "std.h"
#include <BOARD_CONFIG>
#include "mcu_periph/sys_time_arch.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. More... | |
#define | USEC_OF_SEC(sec) ((sec) * 1e6) |
#define | SysTimeTimerStart(_t) { _t = get_sys_time_usec(); } |
#define | SysTimeTimer(_t) ( get_sys_time_usec() - (_t)) |
#define | SysTimeTimerStop(_t) { _t = ( get_sys_time_usec() - (_t)); } |
Typedefs | |
typedef int8_t | tid_t |
sys_time timer id type More... | |
typedef void(* | sys_time_cb) (uint8_t id) |
Variables | |
struct sys_time | sys_time |
Architecture independent timing functions.
Definition in file sys_time.h.
struct sys_time_timer |
Definition at line 63 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 |
struct sys_time |
Definition at line 71 of file sys_time.h.
Data Fields | ||
---|---|---|
uint32_t | cpu_ticks_per_sec | cpu ticks per second |
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 | ticks_per_sec | sys_time ticks per second (SYS_TIME_FREQUENCY) |
struct sys_time_timer | timer[SYS_TIME_NB_TIMER] |
#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.
#define SYS_TIME_NB_TIMER 16 |
Definition at line 44 of file sys_time.h.
#define SysTimeTimer | ( | _t | ) | ( get_sys_time_usec() - (_t)) |
Definition at line 228 of file sys_time.h.
#define SysTimeTimerStart | ( | _t | ) | { _t = get_sys_time_usec(); } |
Definition at line 227 of file sys_time.h.
#define SysTimeTimerStop | ( | _t | ) | { _t = ( get_sys_time_usec() - (_t)); } |
Definition at line 229 of file sys_time.h.
#define USEC_OF_SEC | ( | sec | ) | ((sec) * 1e6) |
Definition at line 219 of file sys_time.h.
typedef void(* sys_time_cb) (uint8_t id) |
Definition at line 61 of file sys_time.h.
sys_time timer id type
Definition at line 60 of file sys_time.h.
Definition at line 197 of file sys_time.h.
References sys_time::cpu_ticks_per_sec.
Referenced by ms2100_reset_cb(), and sys_tick_handler().
|
inlinestatic |
Definition at line 182 of file sys_time.h.
References sys_time::cpu_ticks_per_sec.
Referenced by sys_tick_handler().
Definition at line 187 of file sys_time.h.
References sys_time::cpu_ticks_per_sec.
Referenced by sys_time_usleep(), and xtend_rssi_periodic().
|
inlinestatic |
Get the time in seconds since startup.
Definition at line 138 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_uavcan_esc_status_cb(), agl_cb(), agl_dist_init(), airspeed_cb(), autopilot_arming_check_motors_on(), autopilot_arming_set(), baro_cb(), cc2500_delayMicroseconds(), check_anchor_timeout(), chirp_call(), ctrl_module_run(), dc_periodic(), ekf_run(), fill_anchor(), gps_cb(), gps_fix_valid(), gyro_cb(), hmc58xx_start_configure(), i2c_blocking_receive(), i2c_blocking_transceive(), i2c_blocking_transmit(), 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_rosette_setup(), 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(), spi_blocking_transceive(), 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(), vel_sp_cb(), vertical_ctrl_module_run(), and vertical_ctrl_optical_flow_cb().
Definition at line 202 of file sys_time.h.
References cpu_ticks, and sys_time::cpu_ticks_per_sec.
Referenced by get_sys_time_msec().
Definition at line 167 of file sys_time.h.
References ticks, and sys_time::ticks_per_sec.
Referenced by gps_tow_from_sys_ticks(), and windturbine_periodic().
Definition at line 212 of file sys_time.h.
References cpu_ticks, and sys_time::cpu_ticks_per_sec.
|
inlinestatic |
Definition at line 162 of file sys_time.h.
References sys_time::resolution, and ticks.
Definition at line 192 of file sys_time.h.
References sys_time::cpu_ticks_per_sec.
void sys_time_arch_init | ( | void | ) |
Initialize SysTick.
Generate SysTick interrupt every sys_time.resolution_cpu_ticks
Definition at line 52 of file sys_time_arch.c.
References AHB_CLK, CH_CFG_ST_FREQUENCY, sys_time::cpu_ticks_per_sec, sys_time::resolution, sys_time::resolution_cpu_ticks, startup_time, sys_time_thread_main(), and thd_sys_tick().
Referenced by sys_time_init().
void sys_time_cancel_timer | ( | tid_t | id | ) |
Cancel a system timer by id.
id | Timer id. |
Definition at line 76 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().
|
inlinestatic |
Check if timer has elapsed.
id | Timer id |
Definition at line 123 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().
void sys_time_init | ( | void | ) |
Definition at line 92 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_sec, sys_time::nb_sec_rem, sys_time::nb_tick, sys_time::resolution, sys_time_arch_init(), SYS_TIME_FREQUENCY, SYS_TIME_NB_TIMER, sys_time::ticks_per_sec, and sys_time::timer.
Referenced by main(), and mcu_init().
tid_t sys_time_register_timer | ( | float | duration, |
sys_time_cb | cb | ||
) |
Register a new system timer.
duration | Duration in seconds until the timer elapses. |
cb | Callback function that is called from the ISR when timer elapses, or NULL |
Definition at line 43 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 intermcu_init(), main(), main_ap_init(), main_fbw_init(), main_init(), main_recovery_init(), mavlink_mission_set_timer(), and px4flash_init().
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.
timer | timer providing start time and duration |
offset | offset in seconds beetween the timers (will overlap if longer than duration) |
cb | Callback function that is called from the ISR when timer elapses, or NULL |
Definition at line 59 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().
Definition at line 152 of file sys_time.h.
References sys_time::ticks_per_sec.
|
inlinestatic |
Definition at line 147 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().
Definition at line 157 of file sys_time.h.
References sys_time::ticks_per_sec.
Referenced by sys_tick_handler().
void sys_time_update_timer | ( | tid_t | id, |
float | duration | ||
) |
Update the duration until a timer elapses.
id | Timer id |
duration | Duration in seconds until the timer elapses. |
Definition at line 86 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().
Definition at line 207 of file sys_time.h.
References cpu_ticks, and sys_time::cpu_ticks_per_sec.
Referenced by get_sys_time_usec(), get_sys_time_usec100(), and sys_time_usleep().
Definition at line 172 of file sys_time.h.
References ticks, and sys_time::ticks_per_sec.
Definition at line 1 of file sys_time.c.