Bar Logo 4kW dsPIC33C PSFB DC-DC DA (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
os_timer.h
1//=======================================================================================================
2// Copyright(c) 2018 Microchip Technology Inc. and its subsidiaries.
3// Subject to your compliance with these terms, you may use Microchip software and any derivatives
4// exclusively with Microchip products. It is your responsibility to comply with third party license
5// terms applicable to your use of third-party software (including open source software) that may
6// accompany Microchip software.
7// THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY,
8// APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND
9// FITNESS FOR A PARTICULAR PURPOSE.
10// IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
11// LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
12// MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
13// ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT
14// EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
15//=======================================================================================================
16
17//=======================================================================================================
18// @file os_timer.h
19//
20// @brief contains the functions for using software timers
21//
22// @note in this file you will find functions for using timers and countdowns for your application
23// These software timers are updated by the hardware timer interrupt of the os_scheduler
24// The number of timers need to be defined in main/project_settings.h :
25// #define OS_TIMER_NUMBER_OF_TIMERS 3
26// You should also put your your individual Timer defines with the corresponding index there
27// #define OS_TIMER_COUNTDOWN_EXAMPLE_SWITCHOFFTHELIGHT 0
28// #define OS_TIMER_COUNTDOWN_EXAMPLE_SWITCHOFFCOFFEEMACHINE 1
29// #define OS_TIMER_COUNTDOWN_EXAMPLE_IAMGOINGHOMENOW 2
30//
31//
32// @version v1.0
33// @date 2019-09-03
34// @author M52409
35//
36//=======================================================================================================
37
38#ifndef OS_TIMER_H
39#define OS_TIMER_H
40
41#include <stdbool.h>
42#include "../project_settings.h"
43
44#ifndef OS_TIMER_NUMBER_OF_TIMERS
45 #error OS_TIMER_NUMBER_OF_TIMERS needs to be defined in the file project_settings.h
46#endif //OS_TIMER_NUMBER_OF_TIMERS
47
48#ifdef __cplusplus
49extern "C" {
50#endif // __cplusplus
51
52#ifdef __cplusplus
53}
54#endif // __cplusplus
55
56//=======================================================================================================
57// @brief OS_Timer_Init initializes the Software Timers
58// @note call this function at boot up to initialize the Software Timers
59//=======================================================================================================
60void OS_Timer_Init(void);
61
62
63//=======================================================================================================
64// @brief OS_Timer_StartCountdown_100us/1ms starts a new Countdown
65// @note call this function if you want to use a new countdown
66// @param timer_index - index of the timer that should be used for that countdown
67// @param numOfTicks - depending on the scheduler timing, the number of 100µs or 1ms ticks to count
68//=======================================================================================================
69#if OS_USE_SCHEDULER_100us == 1
70void OS_Timer_StartCountdown_100us(uint8_t timer_index, uint16_t numOfTicks);
71#elif OS_USE_SCHEDULER_1ms == 1
72void OS_Timer_StartCountdown_1ms(uint8_t timer_index, uint16_t numOfTicks);
73#else
74#error OS_USE_SCHEDULER_100us or OS_USE_SCHEDULER_1ms needs to be definied as 1 to get the right timer functions
75#endif
76
77
78//=======================================================================================================
79// @brief OS_Timer_IsCountdownExpired returns the if the countdown is already expired
80// @returns true, if the countdown is expired
81//=======================================================================================================
82bool OS_Timer_IsCountdownExpired(uint8_t timer_index);
83
84//=======================================================================================================
85// @brief OS_Timer_Tick counts the Timer ticks
86// @note Call this function as a countdown timer
87//=======================================================================================================
88void OS_Timer_Tick(void);
89
90#endif // OS_TIMER_H
91