xref: /btstack/port/stm32-f4discovery-usb/Drivers/CMSIS/RTOS2/Include/os_tick.h (revision a8f7f3fcbcd51f8d2e92aca076b6a9f812db358c)
1*a8f7f3fcSMatthias Ringwald /**************************************************************************//**
2*a8f7f3fcSMatthias Ringwald  * @file     os_tick.h
3*a8f7f3fcSMatthias Ringwald  * @brief    CMSIS OS Tick header file
4*a8f7f3fcSMatthias Ringwald  * @version  V1.0.1
5*a8f7f3fcSMatthias Ringwald  * @date     24. November 2017
6*a8f7f3fcSMatthias Ringwald  ******************************************************************************/
7*a8f7f3fcSMatthias Ringwald /*
8*a8f7f3fcSMatthias Ringwald  * Copyright (c) 2017-2017 ARM Limited. All rights reserved.
9*a8f7f3fcSMatthias Ringwald  *
10*a8f7f3fcSMatthias Ringwald  * SPDX-License-Identifier: Apache-2.0
11*a8f7f3fcSMatthias Ringwald  *
12*a8f7f3fcSMatthias Ringwald  * Licensed under the Apache License, Version 2.0 (the License); you may
13*a8f7f3fcSMatthias Ringwald  * not use this file except in compliance with the License.
14*a8f7f3fcSMatthias Ringwald  * You may obtain a copy of the License at
15*a8f7f3fcSMatthias Ringwald  *
16*a8f7f3fcSMatthias Ringwald  * www.apache.org/licenses/LICENSE-2.0
17*a8f7f3fcSMatthias Ringwald  *
18*a8f7f3fcSMatthias Ringwald  * Unless required by applicable law or agreed to in writing, software
19*a8f7f3fcSMatthias Ringwald  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20*a8f7f3fcSMatthias Ringwald  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21*a8f7f3fcSMatthias Ringwald  * See the License for the specific language governing permissions and
22*a8f7f3fcSMatthias Ringwald  * limitations under the License.
23*a8f7f3fcSMatthias Ringwald  */
24*a8f7f3fcSMatthias Ringwald 
25*a8f7f3fcSMatthias Ringwald #ifndef OS_TICK_H
26*a8f7f3fcSMatthias Ringwald #define OS_TICK_H
27*a8f7f3fcSMatthias Ringwald 
28*a8f7f3fcSMatthias Ringwald #include <stdint.h>
29*a8f7f3fcSMatthias Ringwald 
30*a8f7f3fcSMatthias Ringwald /// IRQ Handler.
31*a8f7f3fcSMatthias Ringwald #ifndef IRQHANDLER_T
32*a8f7f3fcSMatthias Ringwald #define IRQHANDLER_T
33*a8f7f3fcSMatthias Ringwald typedef void (*IRQHandler_t) (void);
34*a8f7f3fcSMatthias Ringwald #endif
35*a8f7f3fcSMatthias Ringwald 
36*a8f7f3fcSMatthias Ringwald /// Setup OS Tick timer to generate periodic RTOS Kernel Ticks
37*a8f7f3fcSMatthias Ringwald /// \param[in]     freq         tick frequency in Hz
38*a8f7f3fcSMatthias Ringwald /// \param[in]     handler      tick IRQ handler
39*a8f7f3fcSMatthias Ringwald /// \return 0 on success, -1 on error.
40*a8f7f3fcSMatthias Ringwald int32_t  OS_Tick_Setup (uint32_t freq, IRQHandler_t handler);
41*a8f7f3fcSMatthias Ringwald 
42*a8f7f3fcSMatthias Ringwald /// Enable OS Tick timer interrupt
43*a8f7f3fcSMatthias Ringwald void     OS_Tick_Enable (void);
44*a8f7f3fcSMatthias Ringwald 
45*a8f7f3fcSMatthias Ringwald /// Disable OS Tick timer interrupt
46*a8f7f3fcSMatthias Ringwald void     OS_Tick_Disable (void);
47*a8f7f3fcSMatthias Ringwald 
48*a8f7f3fcSMatthias Ringwald /// Acknowledge execution of OS Tick timer interrupt
49*a8f7f3fcSMatthias Ringwald void     OS_Tick_AcknowledgeIRQ (void);
50*a8f7f3fcSMatthias Ringwald 
51*a8f7f3fcSMatthias Ringwald /// Get OS Tick timer IRQ number
52*a8f7f3fcSMatthias Ringwald /// \return OS Tick IRQ number
53*a8f7f3fcSMatthias Ringwald int32_t  OS_Tick_GetIRQn (void);
54*a8f7f3fcSMatthias Ringwald 
55*a8f7f3fcSMatthias Ringwald /// Get OS Tick timer clock frequency
56*a8f7f3fcSMatthias Ringwald /// \return OS Tick timer clock frequency in Hz
57*a8f7f3fcSMatthias Ringwald uint32_t OS_Tick_GetClock (void);
58*a8f7f3fcSMatthias Ringwald 
59*a8f7f3fcSMatthias Ringwald /// Get OS Tick timer interval reload value
60*a8f7f3fcSMatthias Ringwald /// \return OS Tick timer interval reload value
61*a8f7f3fcSMatthias Ringwald uint32_t OS_Tick_GetInterval (void);
62*a8f7f3fcSMatthias Ringwald 
63*a8f7f3fcSMatthias Ringwald /// Get OS Tick timer counter value
64*a8f7f3fcSMatthias Ringwald /// \return OS Tick timer counter value
65*a8f7f3fcSMatthias Ringwald uint32_t OS_Tick_GetCount (void);
66*a8f7f3fcSMatthias Ringwald 
67*a8f7f3fcSMatthias Ringwald /// Get OS Tick timer overflow status
68*a8f7f3fcSMatthias Ringwald /// \return OS Tick overflow status (1 - overflow, 0 - no overflow).
69*a8f7f3fcSMatthias Ringwald uint32_t OS_Tick_GetOverflow (void);
70*a8f7f3fcSMatthias Ringwald 
71*a8f7f3fcSMatthias Ringwald #endif  /* OS_TICK_H */
72