1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef CHRE_PLATFORM_SLPI_SYSTEM_TIMER_BASE_H_
18#define CHRE_PLATFORM_SLPI_SYSTEM_TIMER_BASE_H_
19
20extern "C" {
21
22#ifdef CHRE_SLPI_UIMG_ENABLED
23#include "utimer.h"
24
25typedef utimer_type SlpiTimerHandle;
26typedef utimer_cb_data_type SlpiTimerCallbackDataType;
27typedef utimer_timetick_type SlpiTimerTickType;
28typedef utimer_error_type SlpiTimerErrorType;
29
30#define SlpiTimerTickUnit UT_TICK
31#define SlpiTimerMicroUnit UT_USEC
32#define SLPI_TIMER_SUCCESS UTE_SUCCESS
33#define slpiTimerClr64 utimer_clr_64
34#define slpiTimerGet64 utimer_get_64
35#define slpiTimerSet64 utimer_set_64
36#define slpiTimerUndef utimer_undef
37#else
38#include "timer.h"
39
40typedef timer_type SlpiTimerHandle;
41typedef timer_cb_data_type SlpiTimerCallbackDataType;
42typedef time_timetick_type SlpiTimerTickType;
43typedef timer_error_type SlpiTimerErrorType;
44
45#define SlpiTimerTickUnit T_TICK
46#define SlpiTimerMicroUnit T_USEC
47#define SLPI_TIMER_SUCCESS TE_SUCCESS
48#define slpiTimerClr64 timer_clr_64
49#define slpiTimerGet64 timer_get_64
50#define slpiTimerSet64 timer_set_64
51#define slpiTimerUndef timer_undef
52#endif  // CHRE_SLPI_UIMG_ENABLED
53
54}  // extern "C"
55
56namespace chre {
57
58class SystemTimerBase {
59 public:
60  //! The underlying QURT timer.
61  SlpiTimerHandle mTimerHandle;
62
63  //! Tracks whether the timer has been initialized correctly.
64  bool mInitialized = false;
65
66  //! A static method that is invoked by the underlying QURT timer.
67  static void systemTimerNotifyCallback(SlpiTimerCallbackDataType data);
68};
69
70}  // namespace chre
71
72#endif  // CHRE_PLATFORM_SLPI_SYSTEM_TIMER_BASE_H_
73