hello world
Fork of lmic_MOTE_L152RC by
debug.h@11:671d85a0f15b, 2016-02-09 (annotated)
- Committer:
- tmulrooney
- Date:
- Tue Feb 09 00:28:59 2016 +0000
- Revision:
- 11:671d85a0f15b
- Parent:
- 0:f2716e543d97
hello world
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudmuck | 0:f2716e543d97 | 1 | /******************************************************************************* |
dudmuck | 0:f2716e543d97 | 2 | * Copyright (c) 2014-2015 IBM Corporation. |
dudmuck | 0:f2716e543d97 | 3 | * All rights reserved. This program and the accompanying materials |
dudmuck | 0:f2716e543d97 | 4 | * are made available under the terms of the Eclipse Public License v1.0 |
dudmuck | 0:f2716e543d97 | 5 | * which accompanies this distribution, and is available at |
dudmuck | 0:f2716e543d97 | 6 | * http://www.eclipse.org/legal/epl-v10.html |
dudmuck | 0:f2716e543d97 | 7 | * |
dudmuck | 0:f2716e543d97 | 8 | * Contributors: |
dudmuck | 0:f2716e543d97 | 9 | * IBM Zurich Research Lab - initial API, implementation and documentation |
dudmuck | 0:f2716e543d97 | 10 | *******************************************************************************/ |
dudmuck | 0:f2716e543d97 | 11 | |
dudmuck | 0:f2716e543d97 | 12 | #include <stdarg.h> |
dudmuck | 0:f2716e543d97 | 13 | #include <stdio.h> |
dudmuck | 0:f2716e543d97 | 14 | |
dudmuck | 0:f2716e543d97 | 15 | /** Output a debug message |
dudmuck | 0:f2716e543d97 | 16 | * |
dudmuck | 0:f2716e543d97 | 17 | * @param format printf-style format string, followed by variables |
dudmuck | 0:f2716e543d97 | 18 | */ |
dudmuck | 0:f2716e543d97 | 19 | static inline void debug(const char *format, ...) { |
dudmuck | 0:f2716e543d97 | 20 | va_list args; |
dudmuck | 0:f2716e543d97 | 21 | va_start(args, format); |
dudmuck | 0:f2716e543d97 | 22 | vfprintf(stderr, format, args); |
dudmuck | 0:f2716e543d97 | 23 | va_end(args); |
dudmuck | 0:f2716e543d97 | 24 | } |
dudmuck | 0:f2716e543d97 | 25 | |
tmulrooney | 11:671d85a0f15b | 26 | #define NDEBUG |
tmulrooney | 11:671d85a0f15b | 27 | #ifndef NDEBUG |
tmulrooney | 11:671d85a0f15b | 28 | |
tmulrooney | 11:671d85a0f15b | 29 | /** Output a debug message |
tmulrooney | 11:671d85a0f15b | 30 | * |
tmulrooney | 11:671d85a0f15b | 31 | * @param format printf-style format string, followed by variables |
tmulrooney | 11:671d85a0f15b | 32 | */ |
tmulrooney | 11:671d85a0f15b | 33 | static inline void debugSW(const char *format, ...) { |
tmulrooney | 11:671d85a0f15b | 34 | va_list args; |
tmulrooney | 11:671d85a0f15b | 35 | va_start(args, format); |
tmulrooney | 11:671d85a0f15b | 36 | vfprintf(stderr, format, args); |
tmulrooney | 11:671d85a0f15b | 37 | va_end(args); |
tmulrooney | 11:671d85a0f15b | 38 | } |
tmulrooney | 11:671d85a0f15b | 39 | |
tmulrooney | 11:671d85a0f15b | 40 | #else |
tmulrooney | 11:671d85a0f15b | 41 | static inline void debugSW(const char *format, ...) {} |
tmulrooney | 11:671d85a0f15b | 42 | #endif |
tmulrooney | 11:671d85a0f15b | 43 | |
dudmuck | 0:f2716e543d97 | 44 | // intialize debug library |
dudmuck | 0:f2716e543d97 | 45 | void debug_init (void); |
dudmuck | 0:f2716e543d97 | 46 | |
dudmuck | 0:f2716e543d97 | 47 | // set LED state |
dudmuck | 0:f2716e543d97 | 48 | void debug_led (u1_t val); |
dudmuck | 0:f2716e543d97 | 49 | |
dudmuck | 0:f2716e543d97 | 50 | // write character to USART |
dudmuck | 0:f2716e543d97 | 51 | void debug_char (u1_t c); |
dudmuck | 0:f2716e543d97 | 52 | |
dudmuck | 0:f2716e543d97 | 53 | // write byte as two hex digits to USART |
dudmuck | 0:f2716e543d97 | 54 | void debug_hex (u1_t b); |
dudmuck | 0:f2716e543d97 | 55 | |
dudmuck | 0:f2716e543d97 | 56 | // write buffer as hex dump to USART |
dudmuck | 0:f2716e543d97 | 57 | void debug_buf (const u1_t* buf, u2_t len); |
dudmuck | 0:f2716e543d97 | 58 | |
dudmuck | 0:f2716e543d97 | 59 | // write 32-bit integer as eight hex digits to USART |
dudmuck | 0:f2716e543d97 | 60 | void debug_uint (u4_t v); |
dudmuck | 0:f2716e543d97 | 61 | |
dudmuck | 0:f2716e543d97 | 62 | // write nul-terminated string to USART |
dudmuck | 0:f2716e543d97 | 63 | void debug_str (const char* str); |
dudmuck | 0:f2716e543d97 | 64 | |
dudmuck | 0:f2716e543d97 | 65 | // write LMiC event name to USART |
dudmuck | 0:f2716e543d97 | 66 | void debug_event (int ev); |
dudmuck | 0:f2716e543d97 | 67 | |
dudmuck | 0:f2716e543d97 | 68 | // write label and 32-bit value as hex to USART |
dudmuck | 0:f2716e543d97 | 69 | void debug_val (const char* label, u4_t val); |
dudmuck | 0:f2716e543d97 | 70 | |
dudmuck | 0:f2716e543d97 | 71 | void debug_done(void); |