1 /*
2  * Copyright (C) 2004-2010 NXP Software
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __LVM_TIMER_H__
19 #define __LVM_TIMER_H__
20 
21 #include "LVM_Types.h"
22 
23 /****************************************************************************************/
24 /*                                                                                      */
25 /*  Header file for the LVM_Timer library                                               */
26 /*                                                                                      */
27 /*  Functionality:                                                                      */
28 /*  The timer will count down a number of ms, based on the number of samples it         */
29 /*  sees and the curent sampling rate.  When the timer expires, a registered            */
30 /*  callback function will be called.                                                   */
31 /*  The maximal number of sampless that can be called by the timer is 2^32, which       */
32 /*  corresponds to 24.8 hours at a sampling rate of 48 kHz                              */
33 /*  The timer currently does not suport changes in sampling rate while timing.          */
34 /****************************************************************************************/
35 
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40 
41 /****************************************************************************************/
42 /*  TYPE DEFINITIONS                                                                    */
43 /****************************************************************************************/
44 
45 typedef struct
46 {
47     LVM_INT32 Storage[6];
48 
49 } LVM_Timer_Instance_t;
50 
51 typedef struct
52 {
53     LVM_INT32  SamplingRate;
54     LVM_INT16  TimeInMs;
55     LVM_INT32  CallBackParam;
56     void       *pCallBackParams;
57     void       *pCallbackInstance;
58     void       (*pCallBack)(void*,void*,LVM_INT32);
59 
60 } LVM_Timer_Params_t;
61 
62 /****************************************************************************************/
63 /*  FUNCTION PROTOTYPES                                                                 */
64 /****************************************************************************************/
65 
66 void LVM_Timer_Init (   LVM_Timer_Instance_t       *pInstance,
67                         LVM_Timer_Params_t         *pParams     );
68 
69 
70 void LVM_Timer      (   LVM_Timer_Instance_t       *pInstance,
71                         LVM_INT16                       BlockSize );
72 
73 
74 /****************************************************************************************/
75 /*  END OF HEADER                                                                       */
76 /****************************************************************************************/
77 
78 #ifdef __cplusplus
79 }
80 #endif /* __cplusplus */
81 
82 #endif  /* __LVM_TIMER_H__ */
83