Merge branch 'main' into arduino-support

This commit is contained in:
dario
2024-06-03 22:56:37 +02:00
22 changed files with 382 additions and 42 deletions

View File

@@ -3,9 +3,8 @@
* @brief Assertion handling.
*
* Configuration:
* * STA_ASSERT_FORCE: Ignore debug defines and always enable assertions
* * DEBUG: Enables assertions when defined
* * NDEBUG: Disables assertions when defined (overrides DEBUG)
* * STA_ASSERT_ENABLED: Enable assertions
* * STA_ASSERT_FORCE: Enable assertions. Still there for backwards compatibility.
*/
#ifndef STA_CORE_ASSERT_HPP
#define STA_CORE_ASSERT_HPP
@@ -24,18 +23,10 @@
#include <sta/config.hpp>
// Determine if module should be enabled
// Condition:
// STA_ASSERT_FORCE is defined
// or
// DEBUG is defined but not NDEBUG
// Keep STA_ASSERT_FORCE for backwards comapatibility.
#ifdef STA_ASSERT_FORCE
# define STA_ASSERT_ENABLED
#else // !STA_ASSERT_FORCE
# if defined(DEBUG) && !defined(NDEBUG)
# define STA_ASSERT_ENABLED
# endif // DEBUG && !NDEBUG
#endif // !STA_ASSERT_FORCE
# define STA_ASSERT_ENABLED
#endif // STA_ASSERT_FORCE
#if defined(STA_ASSERT_ENABLED) || defined(DOXYGEN)

View File

@@ -0,0 +1,47 @@
/*
* profile.hpp
*
* Created on: May 22, 2024
* Author: Dario
*/
#ifndef STA_DEBUGGING_PROFILING_HPP
#define STA_DEBUGGING_PROFILING_HPP
#include <sta/debug/debug.hpp>
#ifdef STA_PROFILING_ENABLED
#ifndef STA_DEBUGGING_ENABLED
# error "Debugging has to be enabled in order to use profiling."
#endif // STA_DEBUGGING_ENABLED
#ifndef STA_STM32_DELAY_US_TIM
# error "A microsecond timer has to be defined in order to use profiling."
#endif // STA_STM32_DELAY_US_TIM
namespace sta
{
class Profiler {
public:
Profiler(const char* name);
~Profiler();
private:
const char* name_;
uint32_t start_;
};
} // namespace sta
/**
*
*/
#define STA_TIME_IT(name) sta::Profiler profiler(name);
#else
#define STA_TIME_IT(name) ((void)0)
#endif // // STA_PROFILING_ENABLED
#endif // STA_DEBUGGING_PROFILING_HPP