HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
BasePeriodicTimer.h File Reference

Abstract base class for periodic timer implementations in the HardFOC system. More...

#include "HardwareTypes.h"
#include <cstdint>
#include <string_view>
Include dependency graph for BasePeriodicTimer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hf_timer_stats_t
 Timer statistics structure. More...
 
struct  hf_timer_statistics_t
 Timer operation statistics. More...
 
struct  hf_timer_diagnostics_t
 Timer diagnostic information. More...
 
class  BasePeriodicTimer
 Abstract base class for periodic timer operations. More...
 

Macros

#define HF_TIMESTAMP_US_T_DEFINED
 
#define HF_TIMER_ERR_LIST(X)
 HardFOC Timer error codes.
 
#define X(name, value, desc)   name = value,
 
#define X(NAME, VALUE, DESC)
 

Typedefs

using hf_timestamp_us_t = hf_u64_t
 
using hf_timer_callback_t = void (*)(void* user_data)
 Timer callback function type.
 

Enumerations

enum class  hf_timer_err_t : hf_i32_t {
  X , TIMER_SUCCESS = 0 , TIMER_ERR_FAILURE = 1 , TIMER_ERR_NOT_INITIALIZED = 2 ,
  TIMER_ERR_ALREADY_INITIALIZED = 3 , TIMER_ERR_INVALID_PARAMETER = 4 , TIMER_ERR_NULL_POINTER = 5 , TIMER_ERR_OUT_OF_MEMORY = 6 ,
  TIMER_ERR_ALREADY_RUNNING = 7 , TIMER_ERR_NOT_RUNNING = 8 , TIMER_ERR_INVALID_PERIOD = 9 , TIMER_ERR_RESOURCE_BUSY = 10 ,
  TIMER_ERR_HARDWARE_FAULT = 11 , TIMER_ERR_UNSUPPORTED_OPERATION = 12 , TIMER_ERR_UNKNOWN = 13
}
 

Functions

constexpr std::string_view HfTimerErrToString (hf_timer_err_t err) noexcept
 Convert timer error code to string view.
 

Detailed Description

Abstract base class for periodic timer implementations in the HardFOC system.

This header-only file defines the abstract base class for periodic timer functionality that provides a consistent API across different timer implementations. Concrete implementations for various platforms inherit from this class to provide high-precision periodic callbacks, interval timing, and timer management features.

Author
Nebiyu Tadesse
Date
2025
Note
This is a header-only abstract base class following the same pattern as BaseCan.
Users should program against this interface, not specific implementations.

Macro Definition Documentation

◆ HF_TIMER_ERR_LIST

#define HF_TIMER_ERR_LIST ( X)
Value:
/* Success codes */ \
X(TIMER_SUCCESS, 0, "Success") \
/* General errors */ \
X(TIMER_ERR_FAILURE, 1, "General failure") \
X(TIMER_ERR_NOT_INITIALIZED, 2, "Not initialized") \
X(TIMER_ERR_ALREADY_INITIALIZED, 3, "Already initialized") \
X(TIMER_ERR_INVALID_PARAMETER, 4, "Invalid parameter") \
X(TIMER_ERR_NULL_POINTER, 5, "Null pointer") \
X(TIMER_ERR_OUT_OF_MEMORY, 6, "Out of memory") \
/* Timer specific errors */ \
X(TIMER_ERR_ALREADY_RUNNING, 7, "Timer already running") \
X(TIMER_ERR_NOT_RUNNING, 8, "Timer not running") \
X(TIMER_ERR_INVALID_PERIOD, 9, "Invalid period") \
X(TIMER_ERR_RESOURCE_BUSY, 10, "Timer resource busy") \
X(TIMER_ERR_HARDWARE_FAULT, 11, "Timer hardware fault") \
X(TIMER_ERR_UNSUPPORTED_OPERATION, 12, "Unsupported operation") \
X(TIMER_ERR_UNKNOWN, 13, "Unknown error")
@ TIMER_ERR_ALREADY_INITIALIZED
@ TIMER_ERR_UNSUPPORTED_OPERATION
@ TIMER_ERR_INVALID_PARAMETER

HardFOC Timer error codes.

Comprehensive error enumeration for all timer operations in the system. This enumeration is used across all timer-related classes to provide consistent error reporting and handling.

◆ HF_TIMESTAMP_US_T_DEFINED

#define HF_TIMESTAMP_US_T_DEFINED

◆ X [1/2]

#define X ( name,
value,
desc )   name = value,

◆ X [2/2]

#define X ( NAME,
VALUE,
DESC )
Value:
case hf_timer_err_t::NAME: \
return DESC;

Typedef Documentation

◆ hf_timer_callback_t

using hf_timer_callback_t = void (*)(void* user_data)

Timer callback function type.

Parameters
user_dataUser-provided data passed to callback

◆ hf_timestamp_us_t

Enumeration Type Documentation

◆ hf_timer_err_t

enum class hf_timer_err_t : hf_i32_t
strong
Enumerator
TIMER_SUCCESS 
TIMER_ERR_FAILURE 
TIMER_ERR_NOT_INITIALIZED 
TIMER_ERR_ALREADY_INITIALIZED 
TIMER_ERR_INVALID_PARAMETER 
TIMER_ERR_NULL_POINTER 
TIMER_ERR_OUT_OF_MEMORY 
TIMER_ERR_ALREADY_RUNNING 
TIMER_ERR_NOT_RUNNING 
TIMER_ERR_INVALID_PERIOD 
TIMER_ERR_RESOURCE_BUSY 
TIMER_ERR_HARDWARE_FAULT 
TIMER_ERR_UNSUPPORTED_OPERATION 
TIMER_ERR_UNKNOWN 

Function Documentation

◆ HfTimerErrToString()

constexpr std::string_view HfTimerErrToString ( hf_timer_err_t err)
constexprnoexcept

Convert timer error code to string view.

Parameters
errThe error code to convert
Returns
String view of the error description