1.2.5.2 Using The Library

When the Debug System Service is initialized, it sets the global system error level to the specified level. This level determines the threshold at which debug and error messages are sent to the console. This allows different debug and error reporting verbosity depending on the needs of the developer.

The Debug System Service also provides APIs to dynamically set the error level during program execution. This allows the developer to increase or decrease debug verbosity to specific areas of interest within the program.

Example Application to Send different messages on UART Console

SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "***This is Info message on UART console***\n\r");

SYS_DEBUG_MESSAGE(SYS_ERROR_DEBUG, "***This is Debug message on UART console***\n\r");

SYS_DEBUG_PRINT(SYS_ERROR_INFO,  "***This is %s on UART console***\n\r", "Info Print");

SYS_DEBUG_PRINT(SYS_ERROR_ERROR, "***This is %s on UART console***\n\r", "Error Print");

/* Change the error level to only print the debug messages with error value set to SYS_ERROR_ERROR or lower */
SYS_DEBUG_ErrorLevelSet(SYS_ERROR_ERROR);

/* The below message should not get printed as "SYS_ERROR_DEBUG" is higher than "SYS_ERROR_ERROR" */
SYS_DEBUG_MESSAGE(SYS_ERROR_DEBUG, "\n\rThis message should not be printed!");

/* Set the error level back to SYS_ERROR_DEBUG */
SYS_DEBUG_ErrorLevelSet(SYS_ERROR_DEBUG);