/** * @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. */ #include // 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 #if defined(STA_DEBUG_SERIAL_ENABLED) || defined(DOXYGEN) #include 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