Naze32 clone with Frysky receiver
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mbed_debug.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* mbed Microcontroller Library
  2. * Copyright (c) 2006-2013 ARM Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MBED_DEBUG_H
  17. #define MBED_DEBUG_H
  18. #include "device.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #if DEVICE_STDIO_MESSAGES
  23. #include <stdio.h>
  24. #include <stdarg.h>
  25. /** Output a debug message
  26. *
  27. * @param format printf-style format string, followed by variables
  28. */
  29. static inline void debug(const char *format, ...) {
  30. va_list args;
  31. va_start(args, format);
  32. vfprintf(stderr, format, args);
  33. va_end(args);
  34. }
  35. /** Conditionally output a debug message
  36. *
  37. * NOTE: If the condition is constant false (!= 1) and the compiler optimization
  38. * level is greater than 0, then the whole function will be compiled away.
  39. *
  40. * @param condition output only if condition is true (== 1)
  41. * @param format printf-style format string, followed by variables
  42. */
  43. static inline void debug_if(int condition, const char *format, ...) {
  44. if (condition == 1) {
  45. va_list args;
  46. va_start(args, format);
  47. vfprintf(stderr, format, args);
  48. va_end(args);
  49. }
  50. }
  51. #else
  52. static inline void debug(const char *format, ...) {}
  53. static inline void debug_if(int condition, const char *format, ...) {}
  54. #endif
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif