1/*
2 * Copyright (c) 2020 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef KAL_H_
17#define KAL_H_
18#include <signal.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24typedef void (*KalTimerProc)(union sigval);
25typedef void *KalTimerId;
26
27typedef enum {
28    KAL_TIMER_ONCE = 0,    // /< One-shot timer.
29    KAL_TIMER_PERIODIC = 1 // /< Repeating timer.
30} KalTimerType;
31
32typedef enum {
33    KAL_OK = 0,
34    KAL_ERR_PARA = 1,
35    KAL_ERR_INNER = 2,
36    KAL_ERR_TIMER_STATE = 0x100,
37} KalErrCode;
38
39KalTimerId KalTimerCreate(KalTimerProc func, KalTimerType type, void* arg, unsigned int millisec);
40KalErrCode KalTimerStart(KalTimerId timerId);
41KalErrCode KalTimerChange(KalTimerId timerId, unsigned int millisec);
42KalErrCode KalTimerStop(KalTimerId timerId);
43KalErrCode KalTimerDelete(KalTimerId timerId);
44unsigned int KalTimerIsRunning(KalTimerId timerId);
45
46#ifdef __cplusplus
47}
48#endif
49
50#endif // KAL_H_
51