|  | Dual Active Bridge Development Board (Part-No. ) |
Content |  |  |  |  |  |

Loading...
Searching...
No Matches
os_timer.h
1
2//=======================================================================================================
3// @file os_timer.h
4//
5// @brief contains the functions for using software timers
6//
7// @note in this file you will find functions for using timers and countdowns for your application
8// These software timers are updated by the hardware timer interrupt of the os_scheduler
9// The number of timers need to be defined in main/project_settings.h :
10// #define OS_TIMER_NUMBER_OF_TIMERS 3
11// You should also put your your individual Timer defines with the corresponding index there
12// #define OS_TIMER_COUNTDOWN_EXAMPLE_SWITCHOFFTHELIGHT 0
13// #define OS_TIMER_COUNTDOWN_EXAMPLE_SWITCHOFFCOFFEEMACHINE 1
14// #define OS_TIMER_COUNTDOWN_EXAMPLE_IAMGOINGHOMENOW 2
15//
16//
17// @version v1.0
18// @date 2019-09-03
19// @author M52409
20//
21//=======================================================================================================
22
23#ifndef OS_TIMER_H
24#define OS_TIMER_H
25
26#include <stdbool.h>
27#include "os_config.h"
28
29#ifndef OS_TIMER_NUMBER_OF_TIMERS
30 #error OS_TIMER_NUMBER_OF_TIMERS needs to be defined in the file project_settings.h
31#endif //OS_TIMER_NUMBER_OF_TIMERS
32
33#ifdef __cplusplus
34extern "C" {
35#endif // __cplusplus
36
37#ifdef __cplusplus
38}
39#endif // __cplusplus
40
41//=======================================================================================================
42// @brief OS_Timer_Init initializes the Software Timers
43// @note call this function at boot up to initialize the Software Timers
44//=======================================================================================================
45void OS_Timer_Init(void);
46
47
48//=======================================================================================================
49// @brief OS_Timer_StartCountdown_100us/1ms starts a new Countdown
50// @note call this function if you want to use a new countdown
51// @param timer_index - index of the timer that should be used for that countdown
52// @param numOfTicks - depending on the scheduler timing, the number of 100µs or 1ms ticks to count
53//=======================================================================================================
54#if OS_USE_SCHEDULER_100us == 1
55void OS_Timer_StartCountdown_100us(uint8_t timer_index, uint16_t numOfTicks);
56#elif OS_USE_SCHEDULER_1ms == 1
57void OS_Timer_StartCountdown_1ms(uint8_t timer_index, uint16_t numOfTicks);
58#else
59#error OS_USE_SCHEDULER_100us or OS_USE_SCHEDULER_1ms needs to be definied as 1 to get the right timer functions
60#endif
61
62
63//=======================================================================================================
64// @brief OS_Timer_IsCountdownExpired returns the if the countdown is already expired
65// @returns true, if the countdown is expired
66//=======================================================================================================
67bool OS_Timer_IsCountdownExpired(uint8_t timer_index);
68
69//=======================================================================================================
70// @brief OS_Timer_Tick counts the Timer ticks
71// @note Call this function as a countdown timer
72//=======================================================================================================
73void OS_Timer_Tick(void);
74
75#endif // OS_TIMER_H
76