add prefix capability to swo_log

This commit is contained in:
Kilian Bracher 2025-04-11 14:03:13 +02:00
parent 9b32e69b6d
commit babea2e805
Signed by: k.bracher
SSH Key Fingerprint: SHA256:mXpyZkK7RDiJ7qeHCKJX108woM0cl5TrCvNBJASu6lM
5 changed files with 923 additions and 911 deletions

View File

@ -19,13 +19,15 @@
#define PRINT_TIMESTAMP false // if true, timestamp (from HAL_GetTick) is printed before each log message #define PRINT_TIMESTAMP false // if true, timestamp (from HAL_GetTick) is printed before each log message
#if !USE_MULTIPLE_CHANNELS #if !USE_MULTIPLE_CHANNELS
#define DEBUG_CHANNEL 0 // channel to output messages on #ifndef DEBUG_CHANNEL
#define USE_CHANNEL_MASK_VARIABLE true #define DEBUG_CHANNEL 0 // channel to output messages on
#endif
#define USE_CHANNEL_MASK_VARIABLE true
#endif #endif
#if USE_CHANNEL_MASK_VARIABLE #if USE_CHANNEL_MASK_VARIABLE
#define MASK_VARIABLE logging_mask // variable to store the channel mask, must be globally defined somewhere #define MASK_VARIABLE logging_mask // variable to store the channel mask, must be globally defined somewhere
extern volatile uint32_t MASK_VARIABLE; extern volatile uint32_t MASK_VARIABLE;
#endif #endif
enum log_level_t { enum log_level_t {
@ -130,6 +132,10 @@ static inline void debug_log(enum log_level_t level, const char *msg, ...) {
__swo_print(level, __time_buffer); __swo_print(level, __time_buffer);
} }
#ifdef SWO_LOG_PREFIX
__swo_print(level, SWO_LOG_PREFIX);
#endif
__swo_print(level, log_level_names[level]); __swo_print(level, log_level_names[level]);
__swo_print(level, __swo_buffer); __swo_print(level, __swo_buffer);

View File

@ -4,15 +4,16 @@
* Created on: 14.07.2022 * Created on: 14.07.2022
* Author: max * Author: max
*/ */
#include "ADBMS_Abstraction.h" #include "ADBMS_Abstraction.h"
#include "ADBMS_CMD_MAKROS.h" #include "ADBMS_CMD_MAKROS.h"
#include "ADBMS_LL_Driver.h" #include "ADBMS_LL_Driver.h"
#include "config_ADBMS6830.h" #include "config_ADBMS6830.h"
#include "swo_log.h"
#include <stddef.h> #include <stddef.h>
#include "NTC.h" #include "NTC.h"
#define SWO_LOG_PREFIX "[ADBMS] "
#include "swo_log.h"
static const char* const HAL_Statuses[] = {"HAL_OK", "HAL_ERROR", "HAL_BUSY", "HAL_TIMEOUT"}; static const char* const HAL_Statuses[] = {"HAL_OK", "HAL_ERROR", "HAL_BUSY", "HAL_TIMEOUT"};
#define CHECK_RETURN(x) \ #define CHECK_RETURN(x) \

View File

@ -10,10 +10,12 @@
#include "ADBMS_Driver.h" #include "ADBMS_Driver.h"
#include "config_ADBMS6830.h" #include "config_ADBMS6830.h"
#include "stm32h7xx_hal.h" #include "stm32h7xx_hal.h"
#include "swo_log.h"
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#define SWO_LOG_PREFIX "[ADBMS] "
#include "swo_log.h"
Cell_Module modules[N_BMS] = {}; Cell_Module modules[N_BMS] = {};
uint32_t balancedCells = 0; uint32_t balancedCells = 0;
bool balancingActive = false; bool balancingActive = false;

View File

@ -8,10 +8,12 @@
#include "ADBMS_LL_Driver.h" #include "ADBMS_LL_Driver.h"
#include "config_ADBMS6830.h" #include "config_ADBMS6830.h"
#include "stm32h7xx_hal.h" #include "stm32h7xx_hal.h"
#include "swo_log.h"
#include <stdint.h> #include <stdint.h>
#include <strings.h> #include <strings.h>
#define SWO_LOG_PREFIX "[ADBMS] "
#include "swo_log.h"
#define INITIAL_COMMAND_PEC 0x0010 #define INITIAL_COMMAND_PEC 0x0010
#define INITIAL_DATA_PEC 0x0010 #define INITIAL_DATA_PEC 0x0010

View File

@ -23,6 +23,7 @@
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "ADBMS_Driver.h" #include "ADBMS_Driver.h"
#include "config_ADBMS6830.h" #include "config_ADBMS6830.h"
#define SWO_LOG_PREFIX "[MAIN] "
#include "swo_log.h" #include "swo_log.h"
#include <string.h> #include <string.h>