Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sys_time_arch.c
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2009-2011 The Paparazzi Team
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, write to
19 * the Free Software Foundation, 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
28#include "mcu_periph/sys_time.h"
29#include "std.h"
30#include <time.h>
31
32// number of milliseconds since midnight at the start time.
34
35void sys_tick_handler(void);
36
38{
39 // simulate 1us cpu ticks
42
43
44 struct timespec now;
45 struct tm local_time;
47 gmtime_r(&now.tv_sec, &local_time);
48 rtc_ms_start = (local_time.tm_hour * 3600 + local_time.tm_min * 60 + local_time.tm_sec) * 1000
49 + now.tv_nsec / 1000000;
50}
51
57
63
69
71{
77 }
78 for (unsigned int i = 0; i < SYS_TIME_NB_TIMER; i++) {
79 if (sys_time.timer[i].in_use &&
82 sys_time.timer[i].elapsed = true;
83 if (sys_time.timer[i].cb) {
84 sys_time.timer[i].cb(i);
85 }
86 }
87 }
88}
89
91
93 sys_time_usleep(ms*1000);
94}
95
void sys_time_msleep(uint32_t ms)
Sleep.
uint32_t sys_time_rtc_millisecond()
Get the RTC time in milliseconds since midnight.
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
uint32_t get_sys_time_usec100(void)
Get the time in microseconds divided by 100 since startup.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
void sys_time_arch_init(void)
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
void sys_tick_handler(void)
uint16_t foo
Definition main_demo5.c:58
static uint32_t rtc_ms_start
Architecture independent timing functions.
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
Definition sys_time.h:74
static uint32_t msec_of_cpu_ticks(uint32_t cpu_ticks)
Definition sys_time.h:238
volatile uint32_t nb_sec
full seconds since startup
Definition sys_time.h:72
uint32_t cpu_ticks_per_sec
cpu ticks per second
Definition sys_time.h:80
uint32_t duration
in SYS_TIME_TICKS
Definition sys_time.h:68
uint32_t resolution_cpu_ticks
sys_time_timer resolution in cpu ticks
Definition sys_time.h:79
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
Definition sys_time.h:73
float resolution
sys_time_timer resolution in seconds
Definition sys_time.h:77
sys_time_cb cb
Definition sys_time.h:65
#define SYS_TIME_NB_TIMER
Definition sys_time.h:44
uint32_t end_time
in SYS_TIME_TICKS
Definition sys_time.h:67
struct sys_time_timer timer[SYS_TIME_NB_TIMER]
Definition sys_time.h:75
static uint32_t usec_of_cpu_ticks(uint32_t cpu_ticks)
Definition sys_time.h:243
volatile bool elapsed
Definition sys_time.h:66
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned long long uint64_t