sta-core/include/sta/debug_printf.hpp

49 lines
1.2 KiB
C++

#ifndef STA_CORE_DEBUG_PRINTF_HPP
#define STA_CORE_DEBUG_PRINTF_HPP
#include <sta/config.hpp>
// Determine if module should be enabled
// Condition 1: STA_DEBUG_PRINTF is defined
// Condition 2:
// STA_DEBUG_PRINTF_FORCE is defined
// or
// DEBUG is defined but not NDEBUG
#ifdef STA_DEBUG_PRINTF
# ifdef STA_DEBUG_PRINTF_FORCE
# define STA_DEBUG_SERIAL_ENABLED
# else // !STA_DEBUG_PRINTF_FORCE
# if defined(DEBUG) && !defined(NDEBUG)
# define STA_DEBUG_PRINTF_ENABLED
# endif // DEBUG && !NDEBUG
# endif // !STA_DEBUG_PRINTF_FORCE
#endif // STA_DEBUG_PRINTF
#if defined(STA_DEBUG_PRINTF_ENABLED) || defined(DOXYGEN)
#include <sta/printable.hpp>
/**
* @brief Print debug output.
*
* @param ... See @ref sta::PrintableUART::print
*
* @ingroup sta_core_debug
*/
# define STA_DEBUG_PRINT(...) sta::print(__VA_ARGS__)
/**
* @brief Print debug output followed by new-line to UART.
*
* @param ... See @ref sta::PrintableUART::println
*
* @ingroup sta_core_debug
*/
# define STA_DEBUG_PRINTLN(...) sta::println(__VA_ARGS__)
#else // !STA_DEBUG_PRINTF_ENABLED
# define STA_DEBUG_PRINT(...) ((void)0)
# define STA_DEBUG_PRINTLN(...) ((void)0)
#endif // !STA_DEBUG_PRINTF_ENABLED
#endif // STA_CORE_DEBUG_PRINTF_HPP