first draft

Dependencies:   LMiC SX1272Libx mbed

Fork of LoRaWAN-lmic-app by Semtech

Committer:
tmulrooney
Date:
Tue Feb 23 15:42:41 2016 +0000
Revision:
6:fc465060b63e
Parent:
1:60184eda0066
Child:
8:0137acc9a6cd
first draft

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mluis 1:60184eda0066 1 /*******************************************************************************
mluis 1:60184eda0066 2 * Copyright (c) 2014-2015 IBM Corporation.
mluis 1:60184eda0066 3 * All rights reserved. This program and the accompanying materials
mluis 1:60184eda0066 4 * are made available under the terms of the Eclipse Public License v1.0
mluis 1:60184eda0066 5 * which accompanies this distribution, and is available at
mluis 1:60184eda0066 6 * http://www.eclipse.org/legal/epl-v10.html
mluis 1:60184eda0066 7 *
mluis 1:60184eda0066 8 * Contributors:
mluis 1:60184eda0066 9 * IBM Zurich Research Lab - initial API, implementation and documentation
mluis 1:60184eda0066 10 * Semtech Apps Team - Adapted for MBED
mluis 1:60184eda0066 11 *******************************************************************************/
mluis 1:60184eda0066 12 #ifndef _debug_hpp_
mluis 1:60184eda0066 13 #define _debug_hpp_
tmulrooney 6:fc465060b63e 14 #include <stdarg.h>
tmulrooney 6:fc465060b63e 15 #include <stdio.h>
tmulrooney 6:fc465060b63e 16 #include "oslmic.h"
mluis 1:60184eda0066 17
mluis 1:60184eda0066 18 // intialize debug library
mluis 1:60184eda0066 19 void debug_init (void);
mluis 1:60184eda0066 20
mluis 1:60184eda0066 21 // set LED state
mluis 1:60184eda0066 22 void debug_led (u1_t val);
mluis 1:60184eda0066 23
mluis 1:60184eda0066 24 // write character to USART
mluis 1:60184eda0066 25 void debug_char (u1_t c);
mluis 1:60184eda0066 26
mluis 1:60184eda0066 27 // write byte as two hex digits to USART
mluis 1:60184eda0066 28 void debug_hex (u1_t b);
mluis 1:60184eda0066 29
mluis 1:60184eda0066 30 // write buffer as hex dump to USART
mluis 1:60184eda0066 31 void debug_buf (const u1_t* buf, u2_t len);
mluis 1:60184eda0066 32
mluis 1:60184eda0066 33 // write 32-bit integer as eight hex digits to USART
mluis 1:60184eda0066 34 void debug_uint (u4_t v);
mluis 1:60184eda0066 35
mluis 1:60184eda0066 36 // write nul-terminated string to USART
mluis 1:60184eda0066 37 void debug_str (const u1_t* str);
mluis 1:60184eda0066 38
mluis 1:60184eda0066 39 // write LMiC event name to USART
mluis 1:60184eda0066 40 void debug_event (int ev);
mluis 1:60184eda0066 41
mluis 1:60184eda0066 42 // write label and 32-bit value as hex to USART
mluis 1:60184eda0066 43 void debug_val (const u1_t* label, u4_t val);
mluis 1:60184eda0066 44
tmulrooney 6:fc465060b63e 45 //#define NDEBUG
tmulrooney 6:fc465060b63e 46 #ifndef NDEBUG
tmulrooney 6:fc465060b63e 47
tmulrooney 6:fc465060b63e 48 /** Output a debug message
tmulrooney 6:fc465060b63e 49 *
tmulrooney 6:fc465060b63e 50 * @param format printf-style format string, followed by variables
tmulrooney 6:fc465060b63e 51 */
tmulrooney 6:fc465060b63e 52 static inline void debug(const char *format, ...) {
tmulrooney 6:fc465060b63e 53 va_list args;
tmulrooney 6:fc465060b63e 54 va_start(args, format);
tmulrooney 6:fc465060b63e 55 vfprintf(stderr, format, args);
tmulrooney 6:fc465060b63e 56 va_end(args);
tmulrooney 6:fc465060b63e 57 }
tmulrooney 6:fc465060b63e 58
tmulrooney 6:fc465060b63e 59 #else
tmulrooney 6:fc465060b63e 60 static inline void debug(const char *format, ...) {}
tmulrooney 6:fc465060b63e 61 #endif
tmulrooney 6:fc465060b63e 62
mluis 1:60184eda0066 63 #endif // _debug_hpp_