vlx lib

Committer:
vijaynvr
Date:
Sun Feb 08 14:26:51 2015 +0000
Revision:
0:bc9f26b5dadf
working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vijaynvr 0:bc9f26b5dadf 1 /*******************************************************************************
vijaynvr 0:bc9f26b5dadf 2 ################################################################################
vijaynvr 0:bc9f26b5dadf 3 # (C) STMicroelectronics 2014
vijaynvr 0:bc9f26b5dadf 4 #
vijaynvr 0:bc9f26b5dadf 5 # This program is free software; you can redistribute it and/or modify it under
vijaynvr 0:bc9f26b5dadf 6 # the terms of the GNU General Public License version 2 and only version 2 as
vijaynvr 0:bc9f26b5dadf 7 # published by the Free Software Foundation.
vijaynvr 0:bc9f26b5dadf 8 #
vijaynvr 0:bc9f26b5dadf 9 # This program is distributed in the hope that it will be useful, but WITHOUT
vijaynvr 0:bc9f26b5dadf 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
vijaynvr 0:bc9f26b5dadf 11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
vijaynvr 0:bc9f26b5dadf 12 # details.
vijaynvr 0:bc9f26b5dadf 13 #
vijaynvr 0:bc9f26b5dadf 14 # You should have received a copy of the GNU General Public License along with
vijaynvr 0:bc9f26b5dadf 15 # this program; if not, write to the Free Software Foundation, Inc.,
vijaynvr 0:bc9f26b5dadf 16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
vijaynvr 0:bc9f26b5dadf 17 #
vijaynvr 0:bc9f26b5dadf 18 #------------------------------------------------------------------------------
vijaynvr 0:bc9f26b5dadf 19 # Imaging Division
vijaynvr 0:bc9f26b5dadf 20 ################################################################################
vijaynvr 0:bc9f26b5dadf 21 ********************************************************************************/
vijaynvr 0:bc9f26b5dadf 22
vijaynvr 0:bc9f26b5dadf 23 /*!
vijaynvr 0:bc9f26b5dadf 24 *\file debug.h
vijaynvr 0:bc9f26b5dadf 25 *\brief All debug related features to be used with the High Level API are defined here.
vijaynvr 0:bc9f26b5dadf 26 */
vijaynvr 0:bc9f26b5dadf 27
vijaynvr 0:bc9f26b5dadf 28 #ifndef SENSOR_DEBUG
vijaynvr 0:bc9f26b5dadf 29 #define SENSOR_DEBUG
vijaynvr 0:bc9f26b5dadf 30 #ifndef __KERNEL__
vijaynvr 0:bc9f26b5dadf 31 #include <stdio.h>
vijaynvr 0:bc9f26b5dadf 32 #include "host_serial.h"
vijaynvr 0:bc9f26b5dadf 33 #endif
vijaynvr 0:bc9f26b5dadf 34 #include "definitions.h"
vijaynvr 0:bc9f26b5dadf 35 //Debug Enable Switch
vijaynvr 0:bc9f26b5dadf 36 #define DEBUG_ENABLE 1 /*!< Set to 1 to enable Function Logging feature */
vijaynvr 0:bc9f26b5dadf 37 #define I2CLOG_ENABLE 0 /*!< Set to 1 to enable I2C Logging feature */
vijaynvr 0:bc9f26b5dadf 38
vijaynvr 0:bc9f26b5dadf 39 /* Error code definition */
vijaynvr 0:bc9f26b5dadf 40 #define SENSOR_ERROR_NONE 0 /*!< No error, Function executed successfully */
vijaynvr 0:bc9f26b5dadf 41 #define SENSOR_ERROR 1 /*!< Generic error code */
vijaynvr 0:bc9f26b5dadf 42
vijaynvr 0:bc9f26b5dadf 43 #define COMMON_ERROR_BASE 0x0100 /*!< Base number for all errors common to all function */
vijaynvr 0:bc9f26b5dadf 44 #define COMMON_INVALID_PARAMS COMMON_ERROR_BASE +0x001 /*!< Provided Invalid params */
vijaynvr 0:bc9f26b5dadf 45 #define COMMON_INVALID_OUTPUT COMMON_ERROR_BASE +0x002 /*!< Provided Invalid output */
vijaynvr 0:bc9f26b5dadf 46 #define SYSTEM_ERROR_BASE 0x0200 /*!< Base number for all errors related to system function */
vijaynvr 0:bc9f26b5dadf 47
vijaynvr 0:bc9f26b5dadf 48 #define RANGE_ERROR_BASE 0x0300 /*!< Base number for all errors related to ranging function */
vijaynvr 0:bc9f26b5dadf 49
vijaynvr 0:bc9f26b5dadf 50 #define ALS_ERROR_BASE 0x0400 /*!< Base number for all errors related to als function */
vijaynvr 0:bc9f26b5dadf 51
vijaynvr 0:bc9f26b5dadf 52 #define DEBUG_SESSION_NOT_OPENE 2
vijaynvr 0:bc9f26b5dadf 53 #define DEBUG_ONLINE 0x10 /*!< Run time debugging. output via usb-serial port */
vijaynvr 0:bc9f26b5dadf 54 #define DEBUG_OFFLINE 0x20 /*!< Offline debugging. Store debug log in memory space */
vijaynvr 0:bc9f26b5dadf 55
vijaynvr 0:bc9f26b5dadf 56 /* Debugging api definition */
vijaynvr 0:bc9f26b5dadf 57 #define MINIMUM_LOG_LEVEL 0
vijaynvr 0:bc9f26b5dadf 58 #define NORMAL_LOG_LEVEL 1
vijaynvr 0:bc9f26b5dadf 59 #define VERBOSE_LOG_LEVEL 2
vijaynvr 0:bc9f26b5dadf 60 #define I2C_LOG_LEVEL 3
vijaynvr 0:bc9f26b5dadf 61
vijaynvr 0:bc9f26b5dadf 62
vijaynvr 0:bc9f26b5dadf 63 #ifdef DEBUG_ENABLE
vijaynvr 0:bc9f26b5dadf 64
vijaynvr 0:bc9f26b5dadf 65 extern char* pDebugBuffer;
vijaynvr 0:bc9f26b5dadf 66 extern uint32_t DebugLogSize;
vijaynvr 0:bc9f26b5dadf 67 extern bool_t DebugStarted;
vijaynvr 0:bc9f26b5dadf 68
vijaynvr 0:bc9f26b5dadf 69 /* Defines for external use */
vijaynvr 0:bc9f26b5dadf 70 #define SPRINTF(buf,fmt,args...) sprintf((char *)buf,fmt,##args)
vijaynvr 0:bc9f26b5dadf 71
vijaynvr 0:bc9f26b5dadf 72 #define LOG_FUNCTION_START(...) void* _pLogAllARgs_[]={ __VA_ARGS__ }; loggingFunctionStart(__func__, _pLogAllARgs_);
vijaynvr 0:bc9f26b5dadf 73 #define LOG_FUNCTION_END(returned) loggingFunctionEnd(__func__, returned, _pLogAllARgs_)
vijaynvr 0:bc9f26b5dadf 74
vijaynvr 0:bc9f26b5dadf 75
vijaynvr 0:bc9f26b5dadf 76 #define DEBUG_WRITE_IN_LOG(...) SPRINTF(pDebugBuffer,##__VA_ARGS__); loggingOutput(pDebugBuffer);
vijaynvr 0:bc9f26b5dadf 77 #define INTERNAL_DEBUG_LOG(...) if(DebugStarted){logDebugMessageStart(__func__);DEBUG_WRITE_IN_LOG(__VA_ARGS__);logDebugMessageEnd();}
vijaynvr 0:bc9f26b5dadf 78 #define INTERNAL_ERROR_LOG(...) logErrorMessageStart(__func__);DEBUG_WRITE_IN_LOG(__VA_ARGS__);logErrorMessageEnd();
vijaynvr 0:bc9f26b5dadf 79
vijaynvr 0:bc9f26b5dadf 80 #define DEBUG_LOG(...) INTERNAL_DEBUG_LOG(__VA_ARGS__);CUSTOMER_DEBUG_LOG(__VA_ARGS__)
vijaynvr 0:bc9f26b5dadf 81 #define SENSOR_ERROR_LOG(...) INTERNAL_ERROR_LOG(__VA_ARGS__);CUSTOMER_ERROR_LOG(__VA_ARGS__)
vijaynvr 0:bc9f26b5dadf 82
vijaynvr 0:bc9f26b5dadf 83 /* Help compiling in C++ */
vijaynvr 0:bc9f26b5dadf 84 #ifdef __cplusplus
vijaynvr 0:bc9f26b5dadf 85 extern "C"{
vijaynvr 0:bc9f26b5dadf 86 #endif /*__cplusplus*/
vijaynvr 0:bc9f26b5dadf 87
vijaynvr 0:bc9f26b5dadf 88
vijaynvr 0:bc9f26b5dadf 89 /*!
vijaynvr 0:bc9f26b5dadf 90 * \fn sensor_error loggingOpen()
vijaynvr 0:bc9f26b5dadf 91 * \brief Initialize debug sequence
vijaynvr 0:bc9f26b5dadf 92 *
vijaynvr 0:bc9f26b5dadf 93 * This function should be called at the beginning of the debugging session. It initializes everything that is necessary.
vijaynvr 0:bc9f26b5dadf 94 * This function allocates a big size buffer in order to store all logged data.
vijaynvr 0:bc9f26b5dadf 95 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 96 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 97 */
vijaynvr 0:bc9f26b5dadf 98 sensor_error loggingOpen();
vijaynvr 0:bc9f26b5dadf 99
vijaynvr 0:bc9f26b5dadf 100 /*!
vijaynvr 0:bc9f26b5dadf 101 * \fn sensor_error loggingClose()
vijaynvr 0:bc9f26b5dadf 102 * \brief Initialize debug sequence
vijaynvr 0:bc9f26b5dadf 103 *
vijaynvr 0:bc9f26b5dadf 104 * This function shall be called once logging functionalities are no more required.
vijaynvr 0:bc9f26b5dadf 105 * This function will free the memory allocated during the call to logingOpen function
vijaynvr 0:bc9f26b5dadf 106 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 107 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 108 */
vijaynvr 0:bc9f26b5dadf 109 sensor_error loggingClose();
vijaynvr 0:bc9f26b5dadf 110
vijaynvr 0:bc9f26b5dadf 111 /*!
vijaynvr 0:bc9f26b5dadf 112 * \fn sensor_error loggingSetMode()
vijaynvr 0:bc9f26b5dadf 113 * \brief Set up debug mode
vijaynvr 0:bc9f26b5dadf 114 *
vijaynvr 0:bc9f26b5dadf 115 * This function shall be called before start logging functions.
vijaynvr 0:bc9f26b5dadf 116 * This function will set the debug logging mode as realtime output or offline mode.
vijaynvr 0:bc9f26b5dadf 117 * \param[in] mode
vijaynvr 0:bc9f26b5dadf 118 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 119 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 120 */
vijaynvr 0:bc9f26b5dadf 121 sensor_error loggingSetMode(char mode);
vijaynvr 0:bc9f26b5dadf 122
vijaynvr 0:bc9f26b5dadf 123 /*!
vijaynvr 0:bc9f26b5dadf 124 * \fn sensor_error loggingSetBuffer()
vijaynvr 0:bc9f26b5dadf 125 * \brief Set up offline debug buffer
vijaynvr 0:bc9f26b5dadf 126 *
vijaynvr 0:bc9f26b5dadf 127 * This function shall be called to set up offline debug buffer.
vijaynvr 0:bc9f26b5dadf 128 * This function will use the buffer created from user application to store the logging data.
vijaynvr 0:bc9f26b5dadf 129 * \param[in] pBuf pointer of user buffer
vijaynvr 0:bc9f26b5dadf 130 * \param[in] size size of user buffer
vijaynvr 0:bc9f26b5dadf 131 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 132 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 133 */
vijaynvr 0:bc9f26b5dadf 134 sensor_error loggingSetBuffer(char *pBuf, uint32_t size);
vijaynvr 0:bc9f26b5dadf 135
vijaynvr 0:bc9f26b5dadf 136 /*!
vijaynvr 0:bc9f26b5dadf 137 * \fn sensor_error loggingStart(uint8_t DebugLevel)
vijaynvr 0:bc9f26b5dadf 138 * \brief Start logging all activities
vijaynvr 0:bc9f26b5dadf 139 *
vijaynvr 0:bc9f26b5dadf 140 * All device activity will be logged once this function is called.
vijaynvr 0:bc9f26b5dadf 141 * This function shall be called after loggingOpen().
vijaynvr 0:bc9f26b5dadf 142 * \param[in] DebugLevel
vijaynvr 0:bc9f26b5dadf 143 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 144 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 145 */
vijaynvr 0:bc9f26b5dadf 146 sensor_error loggingStart(uint8_t DebugLevel);
vijaynvr 0:bc9f26b5dadf 147
vijaynvr 0:bc9f26b5dadf 148 /*!
vijaynvr 0:bc9f26b5dadf 149 * \fn sensor_error loggingStop()
vijaynvr 0:bc9f26b5dadf 150 * \brief Stop logging all activities
vijaynvr 0:bc9f26b5dadf 151 *
vijaynvr 0:bc9f26b5dadf 152 * All device activity will stop to be logged once this function is called.
vijaynvr 0:bc9f26b5dadf 153 * This function shall be called after loggingStart().
vijaynvr 0:bc9f26b5dadf 154 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 155 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 156 */
vijaynvr 0:bc9f26b5dadf 157 sensor_error loggingStop();
vijaynvr 0:bc9f26b5dadf 158
vijaynvr 0:bc9f26b5dadf 159 /*!
vijaynvr 0:bc9f26b5dadf 160 * \fn sensor_error logDebugMessageStart(const char* pFunctionName)
vijaynvr 0:bc9f26b5dadf 161 * \brief Write start section to log debug message
vijaynvr 0:bc9f26b5dadf 162 * \param[in] pFunctionName
vijaynvr 0:bc9f26b5dadf 163 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 164 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 165 */
vijaynvr 0:bc9f26b5dadf 166 sensor_error logDebugMessageStart(const char* pFunctionName);
vijaynvr 0:bc9f26b5dadf 167
vijaynvr 0:bc9f26b5dadf 168 /*!
vijaynvr 0:bc9f26b5dadf 169 * \fn sensor_error logDebugMessageEnd()
vijaynvr 0:bc9f26b5dadf 170 * \brief Write end section to log debug message
vijaynvr 0:bc9f26b5dadf 171 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 172 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 173 */
vijaynvr 0:bc9f26b5dadf 174 sensor_error logDebugMessageEnd();
vijaynvr 0:bc9f26b5dadf 175
vijaynvr 0:bc9f26b5dadf 176 /*!
vijaynvr 0:bc9f26b5dadf 177 * \fn sensor_error logErrorMessageStart(const char* pFunctionName)
vijaynvr 0:bc9f26b5dadf 178 * \brief Write start section to log error message
vijaynvr 0:bc9f26b5dadf 179 * \param[in] pFunctionName
vijaynvr 0:bc9f26b5dadf 180 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 181 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 182 */
vijaynvr 0:bc9f26b5dadf 183 sensor_error logErrorMessageStart(const char* pFunctionName);
vijaynvr 0:bc9f26b5dadf 184
vijaynvr 0:bc9f26b5dadf 185 /*!
vijaynvr 0:bc9f26b5dadf 186 * \fn sensor_error logErrorMessageEnd()
vijaynvr 0:bc9f26b5dadf 187 * \brief Write end section to log error message
vijaynvr 0:bc9f26b5dadf 188 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 189 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 190 */
vijaynvr 0:bc9f26b5dadf 191 sensor_error logErrorMessageEnd();
vijaynvr 0:bc9f26b5dadf 192
vijaynvr 0:bc9f26b5dadf 193 /*!
vijaynvr 0:bc9f26b5dadf 194 * \fn sensor_error loggingFunctionStart(const char* FunctionName, void **pFuncArguments)
vijaynvr 0:bc9f26b5dadf 195 * \brief log start of an API function
vijaynvr 0:bc9f26b5dadf 196 * \param[in] FunctionName
vijaynvr 0:bc9f26b5dadf 197 * \param[in] pFuncArguments
vijaynvr 0:bc9f26b5dadf 198 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 199 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 200 */
vijaynvr 0:bc9f26b5dadf 201 sensor_error loggingFunctionStart(const char* pFunctionName, void **pFuncArguments);
vijaynvr 0:bc9f26b5dadf 202
vijaynvr 0:bc9f26b5dadf 203 /*!
vijaynvr 0:bc9f26b5dadf 204 * \fn sensor_error loggingFunctionEnd(const char* pFunctionName, sensor_error ReturnedValue, void **pFuncArguments)
vijaynvr 0:bc9f26b5dadf 205 * \brief log end of an API function
vijaynvr 0:bc9f26b5dadf 206 * \param[in] pFunctionName
vijaynvr 0:bc9f26b5dadf 207 * \param[in] ReturnedValue
vijaynvr 0:bc9f26b5dadf 208 * \param[in] pFuncArguments
vijaynvr 0:bc9f26b5dadf 209 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 210 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 211 */
vijaynvr 0:bc9f26b5dadf 212 sensor_error loggingFunctionEnd(const char* pFunctionName, sensor_error ReturnedValue, void **pFuncArguments);
vijaynvr 0:bc9f26b5dadf 213
vijaynvr 0:bc9f26b5dadf 214 /*!
vijaynvr 0:bc9f26b5dadf 215 * \fn sensor_error loggingOutput(char* pBuffer)
vijaynvr 0:bc9f26b5dadf 216 * \brief Write messge bugger to actual output
vijaynvr 0:bc9f26b5dadf 217 * \param[in] pBuffer
vijaynvr 0:bc9f26b5dadf 218 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 219 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 220 */
vijaynvr 0:bc9f26b5dadf 221 sensor_error loggingOutput(char* pBuffer);
vijaynvr 0:bc9f26b5dadf 222
vijaynvr 0:bc9f26b5dadf 223 /*!
vijaynvr 0:bc9f26b5dadf 224 * \fn sensor_error loggingOfflineOutput()
vijaynvr 0:bc9f26b5dadf 225 * \brief Write messge bugger from offline buffer to actual output
vijaynvr 0:bc9f26b5dadf 226 * \retval SENSOR_ERROR_NONE : Success
vijaynvr 0:bc9f26b5dadf 227 * \retval "Other Error Code" : Failure
vijaynvr 0:bc9f26b5dadf 228 */
vijaynvr 0:bc9f26b5dadf 229 sensor_error loggingOfflineOutput();
vijaynvr 0:bc9f26b5dadf 230
vijaynvr 0:bc9f26b5dadf 231 /* help compiling in C++ */
vijaynvr 0:bc9f26b5dadf 232 #ifdef __cplusplus
vijaynvr 0:bc9f26b5dadf 233 }
vijaynvr 0:bc9f26b5dadf 234 #endif /*__cplusplus*/
vijaynvr 0:bc9f26b5dadf 235
vijaynvr 0:bc9f26b5dadf 236
vijaynvr 0:bc9f26b5dadf 237 #else
vijaynvr 0:bc9f26b5dadf 238
vijaynvr 0:bc9f26b5dadf 239 #define SENSOR_ERROR_LOG(...) ;
vijaynvr 0:bc9f26b5dadf 240 #define DEBUG_LOG(...) ;
vijaynvr 0:bc9f26b5dadf 241 #define LOG_FUNCTION_START(...) ;
vijaynvr 0:bc9f26b5dadf 242 #define LOG_FUNCTION_END(...) ;
vijaynvr 0:bc9f26b5dadf 243 #define loggingOpen() SENSOR_ERROR_NONE
vijaynvr 0:bc9f26b5dadf 244 #define loggingClose() SENSOR_ERROR_NONE
vijaynvr 0:bc9f26b5dadf 245 #define loggingStart(...) SENSOR_ERROR_NONE
vijaynvr 0:bc9f26b5dadf 246 #define loggingStop() SENSOR_ERROR_NONE
vijaynvr 0:bc9f26b5dadf 247 #define loggingGetSize(...) SENSOR_ERROR_NONE
vijaynvr 0:bc9f26b5dadf 248 #define loggingReadBack(...) SENSOR_ERROR_NONE
vijaynvr 0:bc9f26b5dadf 249 #define loggingOutput(...) SENSOR_ERROR_NONE
vijaynvr 0:bc9f26b5dadf 250 #endif
vijaynvr 0:bc9f26b5dadf 251
vijaynvr 0:bc9f26b5dadf 252 #endif /* DEBUG */
vijaynvr 0:bc9f26b5dadf 253
vijaynvr 0:bc9f26b5dadf 254