OLE Developer Guide  Latest Git
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
coarse_timer.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * coarse_timer.h
17  * Copyright (C) 2015 Simon Newton
18  */
19 
33 #ifndef FIRMWARE_SRC_COARSE_TIMER_H_
34 #define FIRMWARE_SRC_COARSE_TIMER_H_
35 
36 #include <stdbool.h>
37 #include <stdint.h>
38 
39 #include "system_config.h"
40 #include "peripheral/tmr/plib_tmr.h"
41 #include "system/int/sys_int.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
50 typedef struct {
51  TMR_MODULE_ID timer_id;
52  INT_SOURCE interrupt_source;
54 
58 typedef uint32_t CoarseTimer_Value;
59 
77 void CoarseTimer_Initialize(const CoarseTimer_Settings *settings);
78 
95 
103 CoarseTimer_Value CoarseTimer_GetTime();
104 
114 uint32_t CoarseTimer_ElapsedTime(CoarseTimer_Value start_time);
115 
127 uint32_t CoarseTimer_Delta(CoarseTimer_Value start_time,
128  CoarseTimer_Value end_time);
129 
136 bool CoarseTimer_HasElapsed(CoarseTimer_Value start_time, uint32_t interval);
137 
143 void CoarseTimer_SetCounter(uint32_t count);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
153 #endif // FIRMWARE_SRC_COARSE_TIMER_H_
void CoarseTimer_TimerEvent()
Update the timer.
Settings for the CoarseTimer module.
Definition: coarse_timer.h:50
bool CoarseTimer_HasElapsed(CoarseTimer_Value start_time, uint32_t interval)
Check if a time interval has passed.
INT_SOURCE interrupt_source
The interrupt source to use.
Definition: coarse_timer.h:52
void CoarseTimer_SetCounter(uint32_t count)
Manually set the internal counter.
uint32_t CoarseTimer_Delta(CoarseTimer_Value start_time, CoarseTimer_Value end_time)
Return the interval between two times.
uint32_t CoarseTimer_ElapsedTime(CoarseTimer_Value start_time)
Return the interval since the start_time.
uint32_t CoarseTimer_Value
An opaque type used to represent a time stamp.
Definition: coarse_timer.h:58
TMR_MODULE_ID timer_id
The timer module to use.
Definition: coarse_timer.h:51
CoarseTimer_Value CoarseTimer_GetTime()
Get the current value of the timer.
void CoarseTimer_Initialize(const CoarseTimer_Settings *settings)
Initialize the timer.