first draft

Dependencies:   LMiC SX1272Libx mbed

Fork of LoRaWAN-lmic-app by Semtech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.h Source File

debug.h

00001 /*******************************************************************************
00002  * Copyright (c) 2014-2015 IBM Corporation.
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the Eclipse Public License v1.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.eclipse.org/legal/epl-v10.html
00007  *
00008  * Contributors:
00009  *    IBM Zurich Research Lab - initial API, implementation and documentation
00010  *    Semtech Apps Team       - Adapted for MBED
00011  *******************************************************************************/
00012 #ifndef _debug_hpp_
00013 #define _debug_hpp_
00014 #include <stdarg.h>
00015 #include <stdio.h>
00016 #include "oslmic.h"
00017 
00018 // intialize debug library
00019 void debug_init (void);
00020 
00021 // set LED state
00022 void debug_led (u1_t val);
00023 
00024 // write character to USART
00025 void debug_char (u1_t c);
00026 
00027 // write byte as two hex digits to USART
00028 void debug_hex (u1_t b);
00029 
00030 // write buffer as hex dump to USART
00031 void debug_buf (const u1_t* buf, u2_t len);
00032 
00033 // write 32-bit integer as eight hex digits to USART
00034 void debug_uint (u4_t v);
00035 
00036 // write nul-terminated string to USART
00037 void debug_str (const u1_t* str);
00038 
00039 // write LMiC event name to USART
00040 void debug_event (int ev);
00041 
00042 // write label and 32-bit value as hex to USART
00043 void debug_val (const u1_t* label, u4_t val);
00044 
00045 #define NDEBUG
00046 #ifndef NDEBUG
00047 
00048 /** Output a debug message
00049  * 
00050  * @param format printf-style format string, followed by variables
00051  */
00052 static inline void debug(const char *format, ...) {
00053     va_list args;
00054     va_start(args, format);
00055     vfprintf(stderr, format, args);
00056     va_end(args);
00057 }
00058 
00059 #else
00060 static inline void debug(const char *format, ...) {}
00061 #endif
00062 
00063 #endif // _debug_hpp_