STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
board_time.h
Go to the documentation of this file.
1
#ifndef STAR_BOARD_TIME_H
2
#define STAR_BOARD_TIME_H
3
4
/*
5
* Microsecond timebase: TIM2, a 32-bit counter at 1 MHz (prescaler 63 in the
6
* .ioc at today's 64 MHz timer clock), free running, wrapping every ~71.6 min.
7
* Every sample is stamped with it. TIM2 CH4 captures the GPS TIMEPULSE (PB11)
8
* on the same counter, so samples can be placed on GPS time.
9
*/
10
11
#include <stdbool.h>
12
#include <stdint.h>
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
18
/* Start the counter and the CH4 capture interrupt. Returns false if TIM2 does
19
* not actually tick at 1 MHz (e.g. the clock tree changed but the .ioc
20
* prescaler did not), in which case timestamps are not trustworthy. */
21
bool
board_time_start
(
void
);
22
23
/* Microseconds since board_time_start(), modulo 2^32. ISR-safe. */
24
uint32_t
board_time_us
(
void
);
25
26
/* Most recent GPS TIMEPULSE edge (rising), in board_time_us() units, and how
27
* many have been captured. count == 0 means none yet. */
28
typedef
struct
{
29
uint32_t
edge_us
;
30
uint32_t
count
;
31
}
board_pps_t
;
32
33
board_pps_t
board_time_last_pps
(
void
);
34
35
#ifdef __cplusplus
36
}
37
#endif
38
#endif
board_time_last_pps
board_pps_t board_time_last_pps(void)
Definition
board_time.c:38
board_time_us
uint32_t board_time_us(void)
Definition
board_time.c:34
board_time_start
bool board_time_start(void)
Definition
board_time.c:27
board_pps_t
Definition
board_time.h:28
board_pps_t::count
uint32_t count
Definition
board_time.h:30
board_pps_t::edge_us
uint32_t edge_us
Definition
board_time.h:29
firmware
Flight_Computer
src
board
board_time.h
Generated by
1.15.0