vlx lib
i2c_log.cpp@0:bc9f26b5dadf, 2015-02-08 (annotated)
- Committer:
- vijaynvr
- Date:
- Sun Feb 08 14:26:51 2015 +0000
- Revision:
- 0:bc9f26b5dadf
working
Who changed what in which revision?
User | Revision | Line number | New 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 | #include "platform.h" |
vijaynvr | 0:bc9f26b5dadf | 25 | #include "utilities.h" |
vijaynvr | 0:bc9f26b5dadf | 26 | #ifndef __KERNEL__ |
vijaynvr | 0:bc9f26b5dadf | 27 | #include <stdio.h> |
vijaynvr | 0:bc9f26b5dadf | 28 | #else |
vijaynvr | 0:bc9f26b5dadf | 29 | #include <linux/kernel.h> |
vijaynvr | 0:bc9f26b5dadf | 30 | #include <linux/string.h> |
vijaynvr | 0:bc9f26b5dadf | 31 | #endif |
vijaynvr | 0:bc9f26b5dadf | 32 | static bool_t _i2c_log_started = FALSE; |
vijaynvr | 0:bc9f26b5dadf | 33 | |
vijaynvr | 0:bc9f26b5dadf | 34 | void i2c_log_start(void) |
vijaynvr | 0:bc9f26b5dadf | 35 | { |
vijaynvr | 0:bc9f26b5dadf | 36 | _i2c_log_started= TRUE; |
vijaynvr | 0:bc9f26b5dadf | 37 | } |
vijaynvr | 0:bc9f26b5dadf | 38 | |
vijaynvr | 0:bc9f26b5dadf | 39 | void i2c_log_end(void) |
vijaynvr | 0:bc9f26b5dadf | 40 | { |
vijaynvr | 0:bc9f26b5dadf | 41 | _i2c_log_started= FALSE; |
vijaynvr | 0:bc9f26b5dadf | 42 | } |
vijaynvr | 0:bc9f26b5dadf | 43 | |
vijaynvr | 0:bc9f26b5dadf | 44 | void i2c_log_outputReadByteMsg(uint8_t value, uint32_t regOffset) |
vijaynvr | 0:bc9f26b5dadf | 45 | { |
vijaynvr | 0:bc9f26b5dadf | 46 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 47 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 48 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 49 | { |
vijaynvr | 0:bc9f26b5dadf | 50 | sprintf(str, "Read reg : 0x%04X, Val : 0x%02X\n", regOffset, (uint32_t)value); |
vijaynvr | 0:bc9f26b5dadf | 51 | |
vijaynvr | 0:bc9f26b5dadf | 52 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 53 | } |
vijaynvr | 0:bc9f26b5dadf | 54 | } |
vijaynvr | 0:bc9f26b5dadf | 55 | |
vijaynvr | 0:bc9f26b5dadf | 56 | void i2c_log_outputReadWordMsg(uint16_t value, uint32_t regOffset) |
vijaynvr | 0:bc9f26b5dadf | 57 | { |
vijaynvr | 0:bc9f26b5dadf | 58 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 59 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 60 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 61 | { |
vijaynvr | 0:bc9f26b5dadf | 62 | sprintf(str, "Read reg : 0x%04X, Val : 0x%04X\n", regOffset, (uint32_t)value); |
vijaynvr | 0:bc9f26b5dadf | 63 | |
vijaynvr | 0:bc9f26b5dadf | 64 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 65 | } |
vijaynvr | 0:bc9f26b5dadf | 66 | } |
vijaynvr | 0:bc9f26b5dadf | 67 | |
vijaynvr | 0:bc9f26b5dadf | 68 | void i2c_log_outputReadIntMsg(uint32_t value, uint32_t regOffset) |
vijaynvr | 0:bc9f26b5dadf | 69 | { |
vijaynvr | 0:bc9f26b5dadf | 70 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 71 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 72 | |
vijaynvr | 0:bc9f26b5dadf | 73 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 74 | { |
vijaynvr | 0:bc9f26b5dadf | 75 | sprintf(str, "Read reg : 0x%04X, Val : 0x%08X\n", regOffset, (uint32_t)value); |
vijaynvr | 0:bc9f26b5dadf | 76 | |
vijaynvr | 0:bc9f26b5dadf | 77 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 78 | } |
vijaynvr | 0:bc9f26b5dadf | 79 | } |
vijaynvr | 0:bc9f26b5dadf | 80 | |
vijaynvr | 0:bc9f26b5dadf | 81 | void i2c_log_outputReadMsg(uint8_t *data, uint32_t regOffset, int32_t size) |
vijaynvr | 0:bc9f26b5dadf | 82 | { |
vijaynvr | 0:bc9f26b5dadf | 83 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 84 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 85 | char dataStr[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 86 | |
vijaynvr | 0:bc9f26b5dadf | 87 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 88 | { |
vijaynvr | 0:bc9f26b5dadf | 89 | array2HexCString(data, dataStr, size); |
vijaynvr | 0:bc9f26b5dadf | 90 | |
vijaynvr | 0:bc9f26b5dadf | 91 | sprintf(str, "Read reg : 0x%04X, Val : %s\n", regOffset, dataStr); |
vijaynvr | 0:bc9f26b5dadf | 92 | |
vijaynvr | 0:bc9f26b5dadf | 93 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 94 | } |
vijaynvr | 0:bc9f26b5dadf | 95 | } |
vijaynvr | 0:bc9f26b5dadf | 96 | |
vijaynvr | 0:bc9f26b5dadf | 97 | void i2c_log_outputWriteByteMsg(uint8_t data, uint32_t regOffset) |
vijaynvr | 0:bc9f26b5dadf | 98 | { |
vijaynvr | 0:bc9f26b5dadf | 99 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 100 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 101 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 102 | { |
vijaynvr | 0:bc9f26b5dadf | 103 | sprintf(str, "Write reg : 0x%04X, Val : 0x%02X\n", regOffset, (uint32_t)data); |
vijaynvr | 0:bc9f26b5dadf | 104 | |
vijaynvr | 0:bc9f26b5dadf | 105 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 106 | } |
vijaynvr | 0:bc9f26b5dadf | 107 | } |
vijaynvr | 0:bc9f26b5dadf | 108 | |
vijaynvr | 0:bc9f26b5dadf | 109 | void i2c_log_outputWriteWordMsg(uint16_t data, uint32_t regOffset) |
vijaynvr | 0:bc9f26b5dadf | 110 | { |
vijaynvr | 0:bc9f26b5dadf | 111 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 112 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 113 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 114 | { |
vijaynvr | 0:bc9f26b5dadf | 115 | |
vijaynvr | 0:bc9f26b5dadf | 116 | sprintf(str, "Write reg : 0x%04X, Val : 0x%04X\n", regOffset, (uint32_t)data); |
vijaynvr | 0:bc9f26b5dadf | 117 | |
vijaynvr | 0:bc9f26b5dadf | 118 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 119 | } |
vijaynvr | 0:bc9f26b5dadf | 120 | } |
vijaynvr | 0:bc9f26b5dadf | 121 | |
vijaynvr | 0:bc9f26b5dadf | 122 | void i2c_log_outputWriteIntMsg(uint32_t data, uint32_t regOffset) |
vijaynvr | 0:bc9f26b5dadf | 123 | { |
vijaynvr | 0:bc9f26b5dadf | 124 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 125 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 126 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 127 | { |
vijaynvr | 0:bc9f26b5dadf | 128 | sprintf(str, "Write reg : 0x%04X, Val : 0x%08X\n", regOffset, data); |
vijaynvr | 0:bc9f26b5dadf | 129 | |
vijaynvr | 0:bc9f26b5dadf | 130 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 131 | } |
vijaynvr | 0:bc9f26b5dadf | 132 | } |
vijaynvr | 0:bc9f26b5dadf | 133 | |
vijaynvr | 0:bc9f26b5dadf | 134 | void i2c_log_outputWriteMsg(uint8_t *data, uint32_t regOffset, int32_t size) |
vijaynvr | 0:bc9f26b5dadf | 135 | { |
vijaynvr | 0:bc9f26b5dadf | 136 | const int32_t cMaxStrSize = 255; |
vijaynvr | 0:bc9f26b5dadf | 137 | char str[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 138 | char dataStr[cMaxStrSize]; |
vijaynvr | 0:bc9f26b5dadf | 139 | if (_i2c_log_started) |
vijaynvr | 0:bc9f26b5dadf | 140 | { |
vijaynvr | 0:bc9f26b5dadf | 141 | array2HexCString(data, dataStr, size); |
vijaynvr | 0:bc9f26b5dadf | 142 | |
vijaynvr | 0:bc9f26b5dadf | 143 | sprintf(str, "Write reg : 0x%04X, Val : %s\n", regOffset, dataStr); |
vijaynvr | 0:bc9f26b5dadf | 144 | |
vijaynvr | 0:bc9f26b5dadf | 145 | debug2_print(str); |
vijaynvr | 0:bc9f26b5dadf | 146 | } |
vijaynvr | 0:bc9f26b5dadf | 147 | } |
vijaynvr | 0:bc9f26b5dadf | 148 |