mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-12 01:25:59 +00:00
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
/**
|
|
* @brief Debug output via UART.
|
|
*
|
|
* Configuration:
|
|
* STA_DEBUG_SERIAL_ENABLE: Enable module
|
|
* STA_DEBUG_SERIAL_DISABLE: Forces module off when defined
|
|
* DEBUG: Automatically enables module when defined
|
|
* NDEBUG: Forces module off when defined
|
|
*
|
|
* The `sta::DebugSerial` instance must be provided.
|
|
* NOTE: Include this header before the definition because
|
|
* the default internal linkage of const namespace variables
|
|
* will cause undefined reference errors otherwise.
|
|
*/
|
|
#ifndef STA_DEBUG_SERIAL_HPP
|
|
#define STA_DEBUG_SERIAL_HPP
|
|
|
|
#include <sta/config.hpp>
|
|
|
|
#ifdef DEBUG
|
|
# ifndef STA_DEBUG_SERIAL_ENABLE
|
|
# define STA_DEBUG_SERIAL_ENABLE
|
|
# endif // !STA_DEBUG_SERIAL_ENABLE
|
|
#endif // DEBUG
|
|
|
|
#if defined(NDEBUG) || defined(STA_DEBUG_SERIAL_DISABLE)
|
|
# ifdef STA_DEBUG_SERIAL_ENABLE
|
|
# undef STA_DEBUG_SERIAL_ENABLE
|
|
# endif // STA_DEBUG_SERIAL_ENABLE
|
|
#endif // NDEBUG || STA_DEBUG_SERIAL_DISABLE
|
|
|
|
|
|
#ifdef STA_DEBUG_SERIAL_ENABLE
|
|
|
|
#include <sta/uart.hpp>
|
|
|
|
|
|
namespace sta
|
|
{
|
|
extern UART * const DebugSerial;
|
|
} // namespace sta
|
|
|
|
|
|
# define STA_DEBUG_PRINT(...) sta::DebugSerial->print(__VA_ARGS__)
|
|
# define STA_DEBUG_PRINTLN(...) sta::DebugSerial->println(__VA_ARGS__)
|
|
# define STA_DEBUG_WRITE(b, s) sta::DebugSerial->write(b, s)
|
|
#else // !STA_DEBUG_SERIAL_ENABLE
|
|
# define STA_DEBUG_PRINT(...) ((void)0)
|
|
# define STA_DEBUG_PRINTLN(...) ((void)0)
|
|
# define STA_DEBUG_WRITE(b, s) ((void)0)
|
|
#endif // !STA_DEBUG_SERIAL_ENABLE
|
|
|
|
#endif // STA_DEBUG_SERIAL_HPP
|