/*
{{copyright}}
*/

/*
{{version}}
*/

/*
{{license}}
*/

#pragma once

#include <STM32Headers.h>
#include <sdi_toolBox/dateTime/iTimer.h>

namespace sdi_uToolBox::dateTime
{
//--------------------------------------------------------------
/**
 * @brief STM32 timer implementation using HAL_GetTick().
 *
 * Implements ITimer for STM32 platforms, using HAL_GetTick() to
 * provide millisecond-precision timing since system startup.
 */
class Timer : public sdi_toolBox::dateTime::ITimer
{
  public:
  Timer();                                              // Default constructor
  ~Timer()                               = default;     // Default destructor
  Timer(const Timer &obj)                = default;     // Copy constructor
  Timer(Timer &&obj) noexcept            = default;     // Move constructor
  Timer &operator=(const Timer &obj)     = default;     // Copy assignment operator
  Timer &operator=(Timer &&obj) noexcept = default;     // Move assignment operator

  /**
   * @brief Returns the current time point using HAL_GetTick().
   * @return The current time point.
   */
  [[nodiscard]] TimePoint now() const override;
};
//--------------------------------------------------------------
/* Default constructor */
inline Timer::Timer()
{
  reset();
}
//--------------------------------------------------------------
/* Get the current timepoint */
inline Timer::TimePoint Timer::now() const
{
  const auto ms = HAL_GetTick();
  return TimePoint(Duration(ms));
}
//--------------------------------------------------------------
}     // namespace sdi_uToolBox::dateTime
