Vijayaraghavan Narayanan / VLX6180X_API
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers i2c_log.cpp Source File

i2c_log.cpp

00001 /*******************************************************************************
00002 ################################################################################
00003 #                             (C) STMicroelectronics 2014
00004 #
00005 # This program is free software; you can redistribute it and/or modify it under
00006 # the terms of the GNU General Public License version 2 and only version 2 as
00007 # published by the Free Software Foundation.
00008 #
00009 # This program is distributed in the hope that it will be useful, but WITHOUT
00010 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00012 # details.
00013 #
00014 # You should have received a copy of the GNU General Public License along with
00015 # this program; if not, write to the Free Software Foundation, Inc.,
00016 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 #
00018 #------------------------------------------------------------------------------
00019 #                             Imaging Division
00020 ################################################################################
00021 ********************************************************************************/
00022 
00023 
00024 #include "platform.h"
00025 #include "utilities.h"
00026 #ifndef __KERNEL__
00027 #include <stdio.h>
00028 #else
00029 #include <linux/kernel.h>
00030 #include <linux/string.h>
00031 #endif
00032 static bool_t _i2c_log_started = FALSE;
00033 
00034 void i2c_log_start(void)
00035 {
00036     _i2c_log_started= TRUE;
00037 }
00038 
00039 void i2c_log_end(void)
00040 {
00041     _i2c_log_started= FALSE;
00042 }
00043 
00044 void i2c_log_outputReadByteMsg(uint8_t value, uint32_t regOffset)
00045 {
00046     const int32_t cMaxStrSize = 255;
00047     char str[cMaxStrSize];
00048     if (_i2c_log_started)
00049     {
00050         sprintf(str, "Read reg : 0x%04X, Val : 0x%02X\n", regOffset, (uint32_t)value);
00051 
00052         debug2_print(str);
00053     }
00054 }
00055 
00056 void i2c_log_outputReadWordMsg(uint16_t value, uint32_t regOffset)
00057 {
00058     const int32_t cMaxStrSize = 255;
00059     char str[cMaxStrSize];
00060     if (_i2c_log_started)
00061     {
00062         sprintf(str, "Read reg : 0x%04X, Val : 0x%04X\n", regOffset, (uint32_t)value);
00063 
00064         debug2_print(str);
00065     }
00066 }
00067 
00068 void i2c_log_outputReadIntMsg(uint32_t value, uint32_t regOffset)
00069 {
00070     const int32_t cMaxStrSize = 255;
00071     char str[cMaxStrSize];
00072     
00073     if (_i2c_log_started)
00074     {
00075         sprintf(str, "Read reg : 0x%04X, Val : 0x%08X\n", regOffset, (uint32_t)value);
00076 
00077         debug2_print(str);
00078     }
00079 }
00080 
00081 void i2c_log_outputReadMsg(uint8_t *data, uint32_t regOffset, int32_t size)
00082 {
00083     const int32_t cMaxStrSize = 255;
00084     char str[cMaxStrSize];
00085     char dataStr[cMaxStrSize];
00086 
00087     if (_i2c_log_started)
00088     {
00089         array2HexCString(data, dataStr, size);
00090 
00091         sprintf(str, "Read reg : 0x%04X, Val : %s\n", regOffset, dataStr);
00092 
00093         debug2_print(str);
00094     }
00095 }
00096 
00097 void i2c_log_outputWriteByteMsg(uint8_t data, uint32_t regOffset)
00098 {
00099     const int32_t cMaxStrSize = 255;
00100     char str[cMaxStrSize];
00101     if (_i2c_log_started)
00102     {
00103         sprintf(str, "Write reg : 0x%04X, Val : 0x%02X\n", regOffset, (uint32_t)data);
00104 
00105         debug2_print(str);
00106     }
00107 }
00108 
00109 void i2c_log_outputWriteWordMsg(uint16_t data, uint32_t regOffset)
00110 {
00111     const int32_t cMaxStrSize = 255;
00112     char str[cMaxStrSize];
00113     if (_i2c_log_started)
00114     {
00115 
00116         sprintf(str, "Write reg : 0x%04X, Val : 0x%04X\n", regOffset, (uint32_t)data);
00117 
00118         debug2_print(str);
00119     }
00120 }
00121 
00122 void i2c_log_outputWriteIntMsg(uint32_t data, uint32_t regOffset)
00123 {
00124     const int32_t cMaxStrSize = 255;
00125     char str[cMaxStrSize];
00126     if (_i2c_log_started)
00127     {
00128         sprintf(str, "Write reg : 0x%04X, Val : 0x%08X\n", regOffset, data);
00129 
00130         debug2_print(str);
00131     }
00132 }
00133 
00134 void i2c_log_outputWriteMsg(uint8_t *data, uint32_t regOffset, int32_t size)
00135 {
00136     const int32_t cMaxStrSize = 255;
00137     char str[cMaxStrSize];
00138     char dataStr[cMaxStrSize];
00139     if (_i2c_log_started)
00140     {
00141         array2HexCString(data, dataStr, size);
00142 
00143         sprintf(str, "Write reg : 0x%04X, Val : %s\n", regOffset, dataStr);
00144 
00145         debug2_print(str);
00146     }
00147 }
00148