RTEMS 6.1-rc5
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Typedefs | Functions
Timecounter Support

The timecounter support provides directives to implement clock device drivers. More...

Files

file  timecounter.h
 This header file provides the Timecounter Support API.
 
file  tcsimpleinstall.c
 This source file contains the implementation of rtems_timecounter_simple_install().
 

Data Structures

struct  rtems_timecounter_simple
 Simple timecounter to support legacy clock drivers. More...
 

Macros

#define RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER   100
 Timecounter quality for the clock drivers.
 

Typedefs

typedef void rtems_timecounter_simple_at_tick(rtems_timecounter_simple *tc)
 At tick handling done under protection of the timecounter lock.
 
typedef uint32_t rtems_timecounter_simple_get(rtems_timecounter_simple *tc)
 Returns the current value of a simple timecounter.
 
typedef bool rtems_timecounter_simple_is_pending(rtems_timecounter_simple *tc)
 Returns true if the interrupt of a simple timecounter is pending, and false otherwise.
 

Functions

void rtems_timecounter_simple_install (rtems_timecounter_simple *tc, uint32_t counter_frequency_in_hz, uint32_t counter_ticks_per_clock_tick, timecounter_get_t *get_timecount)
 Initializes and installs a simple timecounter.
 

Detailed Description

The timecounter support provides directives to implement clock device drivers.

Macro Definition Documentation

◆ RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER

#define RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER   100

Timecounter quality for the clock drivers.

Timecounter with higher quality value are used in favour of those with lower quality value.

Function Documentation

◆ rtems_timecounter_simple_install()

void rtems_timecounter_simple_install ( rtems_timecounter_simple tc,
uint32_t  counter_frequency_in_hz,
uint32_t  counter_ticks_per_clock_tick,
timecounter_get_t *  get_timecount 
)

Initializes and installs a simple timecounter.

A simple timecounter can be used if the hardware provides no free running counter. A periodic hardware counter must be provided. The counter period must be synchronous to the clock tick. The counter ticks per clock tick is scaled up to the next power of two.

Parameters
[in]tcZero initialized simple timecounter.
[in]counter_frequency_in_hzThe hardware counter frequency in Hz.
[in]counter_ticks_per_clock_tickThe hardware counter ticks per clock tick.
[in]get_timecountThe method to get the current time count.
static rtems_timecounter_simple some_tc;
static uint32_t some_tc_get( rtems_timecounter_simple *tc )
{
return some.value;
}
static bool some_tc_is_pending( rtems_timecounter_simple *tc )
{
return some.is_pending;
}
static uint32_t some_tc_get_timecount( struct timecounter *tc )
{
return rtems_timecounter_simple_downcounter_get(
tc,
some_tc_get,
some_tc_is_pending
);
}
static void some_tc_tick( void )
{
rtems_timecounter_simple_downcounter_tick( &some_tc, some_tc_get );
}
void some_tc_init( void )
{
uint64_t us_per_tick;
uint32_t counter_frequency_in_hz;
uint32_t counter_ticks_per_clock_tick;
counter_frequency_in_hz = some_tc_get_frequency();
counter_ticks_per_clock_tick =
(uint32_t) ( counter_frequency_in_hz * us_per_tick ) / 1000000;
some_tc_init_hardware( counter_ticks_per_clock_tick );
some_tc_init_clock_tick_interrupt( some_tc_tick );
&some_tc,
counter_frequency_in_hz,
counter_ticks_per_clock_tick,
some_tc_get_timecount
);
}
void rtems_timecounter_simple_install(rtems_timecounter_simple *tc, uint32_t counter_frequency_in_hz, uint32_t counter_ticks_per_clock_tick, timecounter_get_t *get_timecount)
Initializes and installs a simple timecounter.
Definition: tcsimpleinstall.c:43
#define rtems_configuration_get_microseconds_per_tick()
Gets the number of microseconds per clock tick configured for this application.
Definition: config.h:527
Simple timecounter to support legacy clock drivers.
Definition: timecounter.h:107
Definition: timetc.h:58
This header file provides the Timecounter Support API.
See also
rtems_timecounter_simple_downcounter_get(), rtems_timecounter_simple_downcounter_tick(), rtems_timecounter_simple_upcounter_get() and rtems_timecounter_simple_upcounter_tick().