mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-02 17:31:53 +00:00
Add debug serial
This commit is contained in:
parent
b8a0c3fd91
commit
f1596493f9
52
include/sta/debug_serial.hpp
Normal file
52
include/sta/debug_serial.hpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* @brief Debug output via UART.
|
||||||
|
*
|
||||||
|
* Define `STA_DEBUG_SERIAL_ENABLE` in `<sta/config.hpp>` to enable.
|
||||||
|
*
|
||||||
|
* Defining `DEBUG` will automatically enable the module.
|
||||||
|
* Defining `NDEBUG` will always force module to be disabled.
|
||||||
|
*
|
||||||
|
* Application must provide the sta::DebugSerial instance.
|
||||||
|
* 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
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
# ifdef STA_DEBUG_SERIAL_ENABLE
|
||||||
|
# undef STA_DEBUG_SERIAL_ENABLE
|
||||||
|
# endif // STA_DEBUG_SERIAL_ENABLE
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
Loading…
x
Reference in New Issue
Block a user