diff options
author | Denys Dmytriyenko <denis@denix.org> | 2009-03-17 14:32:59 -0400 |
---|---|---|
committer | Denys Dmytriyenko <denis@denix.org> | 2009-03-17 14:32:59 -0400 |
commit | 709c4d66e0b107ca606941b988bad717c0b45d9b (patch) | |
tree | 37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/i2c-tools/picodlp-control/DumpMem.c | |
parent | fa6cd5a3b993f16c27de4ff82b42684516d433ba (diff) |
rename packages/ to recipes/ per earlier agreement
See links below for more details:
http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326
http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816
Signed-off-by: Denys Dmytriyenko <denis@denix.org>
Acked-by: Mike Westerhof <mwester@dls.net>
Acked-by: Philip Balister <philip@balister.org>
Acked-by: Khem Raj <raj.khem@gmail.com>
Acked-by: Marcin Juszkiewicz <hrw@openembedded.org>
Acked-by: Koen Kooi <koen@openembedded.org>
Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/i2c-tools/picodlp-control/DumpMem.c')
-rw-r--r-- | recipes/i2c-tools/picodlp-control/DumpMem.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/recipes/i2c-tools/picodlp-control/DumpMem.c b/recipes/i2c-tools/picodlp-control/DumpMem.c new file mode 100644 index 0000000000..e13e94b0f8 --- /dev/null +++ b/recipes/i2c-tools/picodlp-control/DumpMem.c @@ -0,0 +1,93 @@ +/**************************************************************************** +* +* Copyright (c) 2006 Dave Hylands <dhylands@gmail.com> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Alternatively, this software may be distributed under the terms of BSD +* license. +* +* See README and COPYING for more details. +* +****************************************************************************/ +/** +* +* @file DumpMem.c +* +* @brief Memmory dump routine +* +****************************************************************************/ + +// ---- Include Files ------------------------------------------------------- + +#include <inttypes.h> +#include "DumpMem.h" +#include "Log.h" + +// ---- Public Variables ---------------------------------------------------- +// ---- Private Constants and Types ----------------------------------------- +// ---- Private Variables --------------------------------------------------- +// ---- Private Function Prototypes ----------------------------------------- +// ---- Functions ----------------------------------------------------------- + +/**************************************************************************/ +/** +* Dumps a page of output for debugging purposes. +*/ + +void DumpMem( const char *prefix, unsigned address, const void *inData, unsigned numBytes ) +{ + const uint8_t *data = (const uint8_t *)inData; + unsigned byteOffset; + + if ( numBytes == 0 ) + { + Log( "%s: No data\n", prefix ); + return; + } + +#define LINE_WIDTH 16 + + for ( byteOffset = 0; byteOffset < numBytes; byteOffset += LINE_WIDTH ) + { + unsigned i; + + Log( "%s: %04x: ", prefix, address + byteOffset ); + + for ( i = 0; i < LINE_WIDTH; i++ ) + { + if (( byteOffset + i ) < numBytes ) + { + Log( "%02.2X ", data[ byteOffset + i ] ); + } + else + { + Log( " " ); + } + } + for ( i = 0; i < LINE_WIDTH; i++ ) + { + if (( byteOffset + i ) < numBytes ) + { + unsigned char ch = data[ byteOffset + i ]; + if (( ch < ' ' ) || ( ch > '~' )) + { + Log( "." ); + } + else + { + Log( "%c", ch ); + } + } + else + { + break; + } + } + Log( "\n" ); + } + +} // DumpMem + |