RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches
Debug Driver

Overview

Usage & Initialization

This module provides functions to configure and control debug level, logging and assertion.

Note
Efinity IDE Will create userDef.h automatically when user create a new project or import a project that doesn't have userDef.h unless user's project already its own userDef.h

This is the template of Debug User Configuration in userDef.h:

// --- DEBUG_MODE ---
// 0 = Asserts OFF, Logs removed
// 1 = Asserts ON, Logs filtered
#define DEBUG_MODE 0
// --- ACTIVE_DEBUG_MOD --- This is the list of available module to debug
// DBG_MOD_SYS // Enable Log for RISCV Extension
// DBG_MOD_IRQ // Enable Log for IRQ, mtrap
// DBG_MOD_FAULT // Enable Log for System Fault
// DBG_MOD_UART // Enable Log for UART Driver
// DBG_MOD_I2C // Enable Log for I2C Driver
// DBG_MOD_SPI // Enable Log for SPI Driver
// DBG_MOD_SPI_FLASH // Enable Log for SPI FLASH Driver
// DBG_MOD_RTC // Enable Log for RTC Driver
// DBG_MOD_CAM // Enable Log for CAM Driver
// DBG_MOD_SENSOR // Enable Log for Sensor (temp sensor)
// DBG_MOD_MAIN // Enable Log for main.c
// DBG_MOD_ALL // Enable all Logs
#define ACTIVE_DEBUG_MOD DBG_MOD_ALL
// --- ACTIVE_MIN_LVL ---
// DBG_LVL_ALL 0 // Show Info, Warn, Error
// DBG_LVL_WARN 1 // Show Warn, Error
// DBG_LVL_ERR 2 // Show Error only
// DBG_LVL_NONE 3 // Silence
#define ACTIVE_MIN_LVL DBG_LVL_ALL

To use the logging function in the code, refer to Debug API Functions.

Example: Logging

The following shows how to enable and use the logging macros. For the full API reference, see Debug API Functions.

Step 1 — Configure debug settings in userDef.h

#define DEBUG_MODE 1
#define ACTIVE_DEBUG_MOD DBG_MOD_ALL
#define ACTIVE_MIN_LVL DBG_LVL_ALL

Step 2 — Use logging macros in main.c

With the configuration above, all log levels will print to the console.

#include "debug.h"
LOG_INFO(DBG_MOD_MAIN, "This is an info log.");
LOG_WARN(DBG_MOD_MAIN, "This is a warning log.");
LOG_ERR(DBG_MOD_MAIN, "This is an error log.");
Debug, logging, and assertion API.
#define LOG_WARN(mod, fmt,...)
Log a warning message (yellow).
Definition debug.h:245
#define LOG_INFO(mod, fmt,...)
Log an informational message (green).
Definition debug.h:233
#define LOG_ERR(mod, fmt,...)
Log an error message (red).
Definition debug.h:257
#define DBG_MOD_MAIN
Main application.
Definition debug.h:147

Topics

 ANSI Colors
 ANSI escape codes for colored terminal output.
 Debug API Functions
 Logging macros and runtime assertion.
 Debug Levels
 Minimum log severity filter.
 Debug Modules
 Bitmasks to enable logging per peripheral or subsystem.