Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ add_compile_definitions(
$<$<CONFIG:RelWithDebuInfo>:_DEBUG=0>
$<$<CONFIG:MinSizeRel>:NDEBUG>
$<$<CONFIG:MinSizeRel>:_DEBUG=0>
# Flags for features
_FEATURE_ON=1
_FEATURE_OFF=0
)

# Set compiler options
Expand Down
11 changes: 11 additions & 0 deletions configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/main/application/debug_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@

/* ---------------------------------------------------- INCLUDES ---------------------------------------------------- */

// Unconditionally include these so the compiler doesn't complain about an empty translation unit
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if defined( _FEATURE_ENABLE_DEBUG_PORT ) && _FEATURE_ENABLE_DEBUG_PORT

#include "application/buzzer.h"
#include "application/config.h"
#include "application/debug_port.h"
Expand Down Expand Up @@ -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 */
13 changes: 13 additions & 0 deletions src/main/application/debug_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ) */