Libraries and Example of mbed parallel bus using I2C port expanders

Dependencies:   HDSP253X mbed PCF8574_Bus

Committer:
wim
Date:
Wed Aug 31 19:45:31 2011 +0000
Revision:
0:2467aed99127
First Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:2467aed99127 1 /** \file
wim 0:2467aed99127 2 Debugging helpers header file
wim 0:2467aed99127 3 */
wim 0:2467aed99127 4
wim 0:2467aed99127 5 /**
wim 0:2467aed99127 6 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
wim 0:2467aed99127 7
wim 0:2467aed99127 8 Permission is hereby granted, free of charge, to any person obtaining a copy
wim 0:2467aed99127 9 of this software and associated documentation files (the "Software"), to deal
wim 0:2467aed99127 10 in the Software without restriction, including without limitation the rights
wim 0:2467aed99127 11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
wim 0:2467aed99127 12 copies of the Software, and to permit persons to whom the Software is
wim 0:2467aed99127 13 furnished to do so, subject to the following conditions:
wim 0:2467aed99127 14
wim 0:2467aed99127 15 The above copyright notice and this permission notice shall be included in
wim 0:2467aed99127 16 all copies or substantial portions of the Software.
wim 0:2467aed99127 17
wim 0:2467aed99127 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
wim 0:2467aed99127 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
wim 0:2467aed99127 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
wim 0:2467aed99127 21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
wim 0:2467aed99127 22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wim 0:2467aed99127 23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
wim 0:2467aed99127 24 THE SOFTWARE.
wim 0:2467aed99127 25 */
wim 0:2467aed99127 26
wim 0:2467aed99127 27 #ifndef DBG_H
wim 0:2467aed99127 28 #define DBG_H
wim 0:2467aed99127 29
wim 0:2467aed99127 30 /*!
wim 0:2467aed99127 31 Define to enable debugging in one file
wim 0:2467aed99127 32 #define __DEBUG
wim 0:2467aed99127 33 */
wim 0:2467aed99127 34
wim 0:2467aed99127 35 #ifdef __DEBUG
wim 0:2467aed99127 36
wim 0:2467aed99127 37 #ifndef __DEBUGSTREAM
wim 0:2467aed99127 38 #define __DEBUGSTREAM
wim 0:2467aed99127 39
wim 0:2467aed99127 40 class DebugStream {
wim 0:2467aed99127 41 public:
wim 0:2467aed99127 42 static void debug(const char* format, ...);
wim 0:2467aed99127 43 static void release();
wim 0:2467aed99127 44 static void breakPoint(const char* file, int line);
wim 0:2467aed99127 45 private:
wim 0:2467aed99127 46
wim 0:2467aed99127 47 };
wim 0:2467aed99127 48
wim 0:2467aed99127 49 #undef DBG
wim 0:2467aed99127 50 #undef DBGL
wim 0:2467aed99127 51 #undef DBG_END
wim 0:2467aed99127 52 #undef BREAK
wim 0:2467aed99127 53
wim 0:2467aed99127 54 //Debug output (if enabled), same syntax as printf, with heading info
wim 0:2467aed99127 55 //#define DBG(...) do{ DebugStream::debug("[%s:%s@%d] ", __FILE__, __FUNCTION__, __LINE__); DebugStream::debug(__VA_ARGS__); } while(0);
wim 0:2467aed99127 56 #define DBG(...) do{ DebugStream::debug("[%s @%d] ", __FUNCTION__, __LINE__); DebugStream::debug(__VA_ARGS__); } while(0);
wim 0:2467aed99127 57
wim 0:2467aed99127 58 //Debug output (if enabled), same syntax as printf, no heading info
wim 0:2467aed99127 59 #define DBGL(...) do{ DebugStream::debug(__VA_ARGS__); } while(0);
wim 0:2467aed99127 60 #define DBG_END DebugStream::release
wim 0:2467aed99127 61
wim 0:2467aed99127 62 //Breakpoint using serial debug interface (if debug enabled)
wim 0:2467aed99127 63 #define BREAK() DebugStream::breakPoint(__FILE__, __LINE__)
wim 0:2467aed99127 64 #endif
wim 0:2467aed99127 65
wim 0:2467aed99127 66 #else
wim 0:2467aed99127 67 #undef DBG
wim 0:2467aed99127 68 #undef DBGL
wim 0:2467aed99127 69 #undef DBG_END
wim 0:2467aed99127 70 #undef BREAK
wim 0:2467aed99127 71
wim 0:2467aed99127 72 #define DBG(...)
wim 0:2467aed99127 73 #define DBGL(...)
wim 0:2467aed99127 74 #define DBG_END()
wim 0:2467aed99127 75 #define BREAK()
wim 0:2467aed99127 76 #endif
wim 0:2467aed99127 77
wim 0:2467aed99127 78 #endif