10e98b08fSopenharmony_ci/*
20e98b08fSopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd.
30e98b08fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40e98b08fSopenharmony_ci * you may not use this file except in compliance with the License.
50e98b08fSopenharmony_ci * You may obtain a copy of the License at
60e98b08fSopenharmony_ci *
70e98b08fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80e98b08fSopenharmony_ci *
90e98b08fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100e98b08fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110e98b08fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120e98b08fSopenharmony_ci * See the License for the specific language governing permissions and
130e98b08fSopenharmony_ci * limitations under the License.
140e98b08fSopenharmony_ci */
150e98b08fSopenharmony_ci
160e98b08fSopenharmony_ci#ifndef KAL_H_
170e98b08fSopenharmony_ci#define KAL_H_
180e98b08fSopenharmony_ci#include <signal.h>
190e98b08fSopenharmony_ci
200e98b08fSopenharmony_ci#ifdef __cplusplus
210e98b08fSopenharmony_ciextern "C" {
220e98b08fSopenharmony_ci#endif
230e98b08fSopenharmony_ci
240e98b08fSopenharmony_citypedef void (*KalTimerProc)(union sigval);
250e98b08fSopenharmony_citypedef void *KalTimerId;
260e98b08fSopenharmony_ci
270e98b08fSopenharmony_citypedef enum {
280e98b08fSopenharmony_ci    KAL_TIMER_ONCE = 0,    // /< One-shot timer.
290e98b08fSopenharmony_ci    KAL_TIMER_PERIODIC = 1 // /< Repeating timer.
300e98b08fSopenharmony_ci} KalTimerType;
310e98b08fSopenharmony_ci
320e98b08fSopenharmony_citypedef enum {
330e98b08fSopenharmony_ci    KAL_OK = 0,
340e98b08fSopenharmony_ci    KAL_ERR_PARA = 1,
350e98b08fSopenharmony_ci    KAL_ERR_INNER = 2,
360e98b08fSopenharmony_ci    KAL_ERR_TIMER_STATE = 0x100,
370e98b08fSopenharmony_ci} KalErrCode;
380e98b08fSopenharmony_ci
390e98b08fSopenharmony_ciKalTimerId KalTimerCreate(KalTimerProc func, KalTimerType type, void* arg, unsigned int millisec);
400e98b08fSopenharmony_ciKalErrCode KalTimerStart(KalTimerId timerId);
410e98b08fSopenharmony_ciKalErrCode KalTimerChange(KalTimerId timerId, unsigned int millisec);
420e98b08fSopenharmony_ciKalErrCode KalTimerStop(KalTimerId timerId);
430e98b08fSopenharmony_ciKalErrCode KalTimerDelete(KalTimerId timerId);
440e98b08fSopenharmony_ciunsigned int KalTimerIsRunning(KalTimerId timerId);
450e98b08fSopenharmony_ci
460e98b08fSopenharmony_ci#ifdef __cplusplus
470e98b08fSopenharmony_ci}
480e98b08fSopenharmony_ci#endif
490e98b08fSopenharmony_ci
500e98b08fSopenharmony_ci#endif // KAL_H_
51