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 /* TYPE DEFINITIONS */ 38 /****************************************************************************************/ 39 40 typedef struct { 41 /* 42 * The memory area created using this structure is internally 43 * typecast to LVM_Timer_Instance_Private_t and used. 44 * The LVM_Timer_Instance_Private_t structure has 3 pointer type elements 45 * 2 elements of type LVM_INT32 and one element of type LVM_INT16. 46 * Inorder to cater both 32 and 64 bit builds, Storage array should 47 * have a minimum of 9 elements of type LVM_INT32. 48 */ 49 LVM_INT32 Storage[9]; 50 51 } LVM_Timer_Instance_t; 52 53 typedef struct { 54 LVM_INT32 SamplingRate; 55 LVM_INT16 TimeInMs; 56 LVM_INT32 CallBackParam; 57 void* pCallBackParams; 58 void* pCallbackInstance; 59 void (*pCallBack)(void*, void*, LVM_INT32); 60 61 } LVM_Timer_Params_t; 62 63 /****************************************************************************************/ 64 /* FUNCTION PROTOTYPES */ 65 /****************************************************************************************/ 66 67 void LVM_Timer_Init(LVM_Timer_Instance_t* pInstance, LVM_Timer_Params_t* pParams); 68 69 void LVM_Timer(LVM_Timer_Instance_t* pInstance, LVM_INT16 BlockSize); 70 71 /****************************************************************************************/ 72 /* END OF HEADER */ 73 /****************************************************************************************/ 74 75 #endif /* __LVM_TIMER_H__ */ 76