1 // Copyright (c) 2010, Atmel Corporation. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are met: 6 // * Redistributions of source code must retain the above copyright 7 // notice, this list of conditions and the following disclaimer. 8 // * Redistributions in binary form must reproduce the above copyright 9 // notice, this list of conditions and the following disclaimer in the 10 // documentation and/or other materials provided with the distribution. 11 // * Neither the name of Atmel nor the 12 // names of its contributors may be used to endorse or promote products 13 // derived from this software without specific prior written permission. 14 // 15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 19 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26 #ifndef ACCY_DET_H 27 #define ACCY_DET_H 28 29 #define LOG_TAG "whisperd" 30 31 #include <cutils/log.h> 32 #include <stdint.h> 33 34 #define MAX_IO_TIMEOUT 85 //85 ms 35 #define LOG_SIZE_LIMIT 10000 36 37 #define LOG_ACCY_ANDROID 38 39 #if defined(LOG_ACCY_ANDROID) 40 #define DBG_TRACE(fmt,x...) \ 41 do \ 42 { \ 43 ALOGD(fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); \ 44 }while(0) 45 #define DBG_ERROR(fmt,x...) \ 46 do \ 47 { \ 48 ALOGE(fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); \ 49 }while(0) 50 51 #elif defined(LOG_ACCY_FS) 52 53 #define DBG_TRACE(fmt,x...) \ 54 if(logFp != NULL) {if(currLogSize++ > LOG_SIZE_LIMIT){ currLogSize = 0; fseek(logFp, SEEK_SET, 0);} \ 55 fprintf(logFp,"ACCYDET :"fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); fflush(logFp);} \ 56 else { } 57 58 59 #define DBG_ERROR(fmt,x...) \ 60 if(logFp != NULL) {fprintf(logFp,"whisperd : ERROR = "fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); fflush(logFp);} \ 61 else { } 62 63 #else 64 65 #define DBG_TRACE(fmt,x...) do{} while (0) 66 #define DBG_ERROR(fmt,x...) do{} while (0) 67 68 #endif 69 70 enum { 71 GLOBAL_STATE_UNDOCKED, 72 GLOBAL_STATE_DOCKED, 73 GLOBAL_STATE_DOCKED_IDSUCC, 74 GLOBAL_STATE_DOCKED_IDFAIL 75 }; 76 77 enum { 78 NO_DOCK, 79 DESK_DOCK, 80 CAR_DOCK, 81 LE_DOCK, 82 HE_DOCK 83 }; 84 85 enum { 86 PROTOCOL_UART, 87 PROTOCOL_HID 88 }; 89 90 extern int ttyFd; 91 extern FILE *logFp; 92 extern int currLogSize; 93 94 #endif 95