diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index d0dca1b..6e7e359 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -12,6 +12,9 @@ "F_CPU=8000000", "_DEBUG=1", "_BUILD_TYPE=\"Debug\"", + "_FEATURE_ON=1", + "_FEATURE_OFF=0", + "_FEATURE_ENABLE_DEBUG_PORT=_FEATURE_ON", "_CONFIG_DFLT_WPM=200", "_CONFIG_DFLT_WPM_ELEMENT_SCALE=1.0f", "_CONFIG_DFLT_BUZZER_ENABLED=true", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a39f20..6b5858c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,9 @@ add_compile_definitions( $<$:_DEBUG=0> $<$:NDEBUG> $<$:_DEBUG=0> + # Flags for features + _FEATURE_ON=1 + _FEATURE_OFF=0 ) # Set compiler options diff --git a/configuration.cmake b/configuration.cmake index bc68f58..d779ae8 100644 --- a/configuration.cmake +++ b/configuration.cmake @@ -7,6 +7,17 @@ # @cpyrt © 2025 by Chris Vig. Licensed under the GNU General Public License v3 (GPLv3). # +# -- Feature Enablement -- + +# Define values +set(FEATURE_ENABLE_DEBUG_PORT _FEATURE_ON + CACHE STRING "Set to _FEATURE_ON to enable the debug port.") + +# Set compile definitions +add_compile_definitions( + _FEATURE_ENABLE_DEBUG_PORT=${FEATURE_ENABLE_DEBUG_PORT} +) + # -- Configuration Defaults -- # Define values diff --git a/src/main/application/debug_port.c b/src/main/application/debug_port.c index acee42a..6fdfbf2 100644 --- a/src/main/application/debug_port.c +++ b/src/main/application/debug_port.c @@ -9,11 +9,14 @@ /* ---------------------------------------------------- INCLUDES ---------------------------------------------------- */ +// Unconditionally include these so the compiler doesn't complain about an empty translation unit #include #include #include #include +#if defined( _FEATURE_ENABLE_DEBUG_PORT ) && _FEATURE_ENABLE_DEBUG_PORT + #include "application/buzzer.h" #include "application/config.h" #include "application/debug_port.h" @@ -928,3 +931,5 @@ static void print_invalid_command( char const * const command ) debug_port_print( "\"" NEWLINE_STR ); } /* print_invalid_command() */ + +#endif /* defined( _FEATURE_ENABLE_DEBUG_PORT ) && _FEATURE_ENABLE_DEBUG_PORT */ diff --git a/src/main/application/debug_port.h b/src/main/application/debug_port.h index 2376add..6812275 100644 --- a/src/main/application/debug_port.h +++ b/src/main/application/debug_port.h @@ -27,6 +27,8 @@ /* ---------------------------------------------- PROCEDURE PROTOTYPES ---------------------------------------------- */ +#if defined( _FEATURE_ENABLE_DEBUG_PORT ) && _FEATURE_ENABLE_DEBUG_PORT + /** * @fn debug_port_init( void ) * @brief Initializes the debug port. @@ -58,4 +60,15 @@ void debug_port_tick( tick_t tick ); */ void debug_port_usart_rx( void ); +#else + +// Define dummy macros if debug port is disabled +#define debug_port_init() +#define debug_port_print( _str ) ( false ) +#define debug_port_printf( _fmt, ... ) ( false ) +#define debug_port_tick( _tick ) +#define debug_port_usart_rx() + +#endif /* defined( _FEATURE_ENABLE_DEBUG_PORT ) && _FEATURE_ENABLE_DEBUG_PORT */ + #endif /* !defined( APPLICATION_DEBUG_PORT_H ) */