Changed interval types from uint32_t to etl::timer::interval::type

This commit is contained in:
John Wellbelove 2026-10-29 08:53:29 +00:00
parent 51134bca50
commit f6eaaba713
4 changed files with 38 additions and 33 deletions

View File

@ -157,7 +157,7 @@ namespace etl
// Returns true if the tick was processed,
// false if not.
//*******************************************
bool tick(uint32_t count)
bool tick(etl::timer::interval::type count)
{
bool was_processed = false;
@ -286,7 +286,7 @@ namespace etl
//*******************************************
/// Sets a timer's interval.
//*******************************************
bool set_interval(etl::timer::node& timer_, uint32_t interval_) ETL_NOEXCEPT
bool set_interval(etl::timer::node& timer_, etl::timer::interval::type interval_) ETL_NOEXCEPT
{
bool result = false;
@ -389,9 +389,9 @@ namespace etl
/// Returns etl::timer::interval::No_Interval if there is no active
/// timer.
//*******************************************
uint32_t time_to_next() const ETL_NOEXCEPT
etl::timer::interval::type time_to_next() const ETL_NOEXCEPT
{
uint32_t delta = static_cast<uint32_t>(etl::timer::interval::No_Interval);
etl::timer::interval::type delta = static_cast<etl::timer::interval::type>(etl::timer::interval::No_Interval);
lock_policy.lock();

View File

@ -31,6 +31,7 @@ SOFTWARE.
#include "platform.h"
#include "atomic.h"
#include "limits.h"
#include <stdint.h>
@ -48,10 +49,10 @@ namespace etl
#endif
#endif
//***************************************************************************
/// Common definitions for the timer framework.
//***************************************************************************
namespace timer
//***************************************************************************
/// Common definitions for the timer framework.
//***************************************************************************
namespace timer
{
// Timer modes.
struct mode
@ -87,41 +88,45 @@ namespace etl
// Timer id.
struct id
{
typedef uint_least8_t type;
enum
{
NO_TIMER = 255, // Deprecated
No_Timer = 255
NO_TIMER = etl::integral_limits<type>::max, // Deprecated
No_Timer = etl::integral_limits<type>::max
};
typedef uint_least8_t type;
};
// Timer state.
struct state
{
typedef uint32_t type;
enum
{
INACTIVE = 0xFFFFFFFFUL, // Deprecated
Inactive = 0xFFFFFFFFUL
INACTIVE = etl::integral_limits<type>::max, // Deprecated
Inactive = etl::integral_limits<type>::max
};
};
// Timer time interval.
struct interval
{
typedef uint32_t type;
enum
{
No_Active_Interval = 0xFFFFFFFFUL, // Deprecated
No_Interval = 0xFFFFFFFFUL
No_Active_Interval = etl::integral_limits<type>::max, // Deprecated
No_Interval = etl::integral_limits<type>::max
};
typedef uint32_t type;
};
// Timer owner.
struct owner
{
static ETL_CONSTANT void* No_Owner = ETL_NULLPTR;
typedef void* type;
static ETL_CONSTANT type No_Owner = ETL_NULLPTR;
};
} // namespace timer
} // namespace etl

View File

@ -89,7 +89,7 @@ namespace etl
//*******************************************
/// Constructor.
//*******************************************
ETL_CONSTEXPR config(uint32_t interval_, etl::timer::mode::type mode_) ETL_NOEXCEPT
ETL_CONSTEXPR config(etl::timer::interval::type interval_, etl::timer::mode::type mode_) ETL_NOEXCEPT
: interval(interval_)
, mode(mode_)
, id(etl::timer::id::No_Timer)
@ -99,7 +99,7 @@ namespace etl
//*******************************************
/// Returns the interval of the timer.
//*******************************************
ETL_CONSTEXPR uint32_t get_interval() const ETL_NOEXCEPT
ETL_CONSTEXPR etl::timer::interval::type get_interval() const ETL_NOEXCEPT
{
return interval;
}
@ -132,9 +132,9 @@ namespace etl
private:
uint32_t interval; ///< The interval of the timer.
etl::timer::mode::type mode; ///< Whether the timer is repeating or single-shot.
etl::timer::id::type id; ///< The id of the timer.
etl::timer::interval::type interval; ///< The interval of the timer.
etl::timer::mode::type mode; ///< Whether the timer is repeating or single-shot.
etl::timer::id::type id; ///< The id of the timer.
};
} // namespace timer
} // namespace etl

View File

@ -134,7 +134,7 @@ namespace etl
//*******************************************
/// Returns the delta of the timer.
//*******************************************
ETL_CONSTEXPR uint32_t get_delta() const ETL_NOEXCEPT
ETL_CONSTEXPR etl::timer::interval::type get_delta() const ETL_NOEXCEPT
{
return delta;
}
@ -142,7 +142,7 @@ namespace etl
//*******************************************
/// Returns the interval of the timer.
//*******************************************
ETL_CONSTEXPR uint32_t get_interval() const ETL_NOEXCEPT
ETL_CONSTEXPR etl::timer::interval::type get_interval() const ETL_NOEXCEPT
{
return config.get_interval();
}
@ -192,7 +192,7 @@ namespace etl
//*******************************************
/// Sets the interval of the timer.
//*******************************************
void set_interval(uint32_t interval_) ETL_NOEXCEPT
void set_interval(etl::timer::interval::type interval_) ETL_NOEXCEPT
{
config.interval = interval_;
}
@ -284,12 +284,12 @@ namespace etl
node& operator=(const node&) ETL_DELETE;
node* registered_next; ///< The next timer in the registered timer list. unlinked() if the timer is not registered.
node* active_next; ///< The next timer in the active timer list. unlinked() if the timer is not active.
node* expired_next; ///< The next timer in the expired timer list. unlinked() if the timer is not expired.
void* owner; ///< The owner of the timer.
config config; ///< The configuration of the timer.
uint32_t delta; ///< The time remaining until the timer expires.
node* registered_next; ///< The next timer in the registered timer list. unlinked() if the timer is not registered.
node* active_next; ///< The next timer in the active timer list. unlinked() if the timer is not active.
node* expired_next; ///< The next timer in the expired timer list. unlinked() if the timer is not expired.
void* owner; ///< The owner of the timer.
config config; ///< The configuration of the timer.
etl::timer::interval::type delta; ///< The time remaining until the timer expires.
};
//***************************************************************************