mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-13 01:55:59 +00:00
106 lines
2.4 KiB
C++
106 lines
2.4 KiB
C++
/**
|
|
* @file
|
|
* @brief Debug output via UART.
|
|
*
|
|
* Configuration:
|
|
* STA_DEBUG_SERIAL_UART: UART interface for output
|
|
* STA_DEBUG_SERIAL_FORCE: Ignore debug defines and always enable output
|
|
* DEBUG: Enables output when defined
|
|
* NDEBUG: Disables output when defined (overrides DEBUG)
|
|
*/
|
|
#ifndef STA_CORE_DEBUG_SERIAL_HPP
|
|
#define STA_CORE_DEBUG_SERIAL_HPP
|
|
|
|
/**
|
|
* @defgroup staCoreDebug Debug Serial
|
|
* @ingroup staCore
|
|
* @brief Debug serial output.
|
|
*/
|
|
|
|
#ifdef DOXYGEN
|
|
/**
|
|
* @def STA_DEBUG_SERIAL_UART
|
|
* @brief UART interface for debug output.
|
|
*
|
|
* @ingroup staCoreBuildConfig
|
|
*/
|
|
# define STA_DEBUG_SERIAL_UART
|
|
|
|
/**
|
|
* @def STA_DEBUG_SERIAL_FORCE
|
|
* @brief Force enable module.
|
|
*
|
|
* Enables debug output even if NDEBUG is defined
|
|
* or DEBUG is not defined.
|
|
*
|
|
* @ingroup staCoreBuildConfig
|
|
*/
|
|
# define STA_DEBUG_SERIAL_FORCE
|
|
#endif // DOXYGEN
|
|
|
|
|
|
#include <sta/config.hpp>
|
|
|
|
// Determine if module should be enabled
|
|
// Condition 1: STA_DEBUG_SERIAL_UART is defined
|
|
// Condition 2:
|
|
// STA_DEBUG_SERIAL_FORCE is defined
|
|
// or
|
|
// DEBUG is defined but not NDEBUG
|
|
#ifdef STA_DEBUG_SERIAL_UART
|
|
# ifdef STA_DEBUG_SERIAL_FORCE
|
|
# define STA_DEBUG_SERIAL_ENABLED
|
|
# else // !STA_DEBUG_SERIAL_FORCE
|
|
# if defined(DEBUG) && !defined(NDEBUG)
|
|
# define STA_DEBUG_SERIAL_ENABLED
|
|
# endif // DEBUG && !NDEBUG
|
|
# endif // !STA_DEBUG_SERIAL_FORCE
|
|
#endif // STA_DEBUG_SERIAL_UART
|
|
|
|
|
|
// Show enabled module in doxygen output
|
|
#ifdef DOXYGEN
|
|
# define STA_DEBUG_SERIAL_ENABLED
|
|
#endif // DOXYGEN
|
|
|
|
|
|
#ifdef STA_DEBUG_SERIAL_ENABLED
|
|
|
|
#include <sta/printable_uart.hpp>
|
|
|
|
|
|
namespace sta
|
|
{
|
|
/**
|
|
* @brief %UART print object for debug serial output.
|
|
*
|
|
* @ingroup staCoreDebug
|
|
*/
|
|
extern PrintableUART DebugSerial;
|
|
} // namespace sta
|
|
|
|
|
|
/**
|
|
* @brief Print debug output to UART.
|
|
*
|
|
* @param ... See @ref sta::PrintableUART::print
|
|
*
|
|
* @ingroup staCoreDebug
|
|
*/
|
|
# define STA_DEBUG_PRINT(...) sta::DebugSerial.print(__VA_ARGS__)
|
|
/**
|
|
* @brief Print debug output followed by new-line to UART.
|
|
*
|
|
* @param ... See @ref sta::PrintableUART::println
|
|
*
|
|
* @ingroup staCoreDebug
|
|
*/
|
|
# define STA_DEBUG_PRINTLN(...) sta::DebugSerial.println(__VA_ARGS__)
|
|
#else // !STA_DEBUG_SERIAL_ENABLED
|
|
# define STA_DEBUG_PRINT(...) ((void)0)
|
|
# define STA_DEBUG_PRINTLN(...) ((void)0)
|
|
#endif // !STA_DEBUG_SERIAL_ENABLED
|
|
|
|
|
|
#endif // STA_CORE_DEBUG_SERIAL_HPP
|