timecounter
1# This file was automatically generated by SWIG (https://www.swig.org). 2# Version 4.2.1 3# 4# Do not make changes to this file unless you know what you are doing - modify 5# the SWIG interface file instead. 6 7from sys import version_info as _swig_python_version_info 8from mock_rtems import _timecounter as _timecounter 9 10try: 11 import builtins as __builtin__ 12except ImportError: 13 import __builtin__ 14 15def _swig_repr(self): 16 try: 17 strthis = "proxy of " + self.this.__repr__() 18 except __builtin__.Exception: 19 strthis = "" 20 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) 21 22 23def _swig_setattr_nondynamic_instance_variable(set): 24 def set_instance_attr(self, name, value): 25 if name == "this": 26 set(self, name, value) 27 elif name == "thisown": 28 self.this.own(value) 29 elif hasattr(self, name) and isinstance(getattr(type(self), name), property): 30 set(self, name, value) 31 else: 32 raise AttributeError("You cannot add instance attributes to %s" % self) 33 return set_instance_attr 34 35 36def _swig_setattr_nondynamic_class_variable(set): 37 def set_class_attr(cls, name, value): 38 if hasattr(cls, name) and not isinstance(getattr(cls, name), property): 39 set(cls, name, value) 40 else: 41 raise AttributeError("You cannot add class attributes to %s" % cls) 42 return set_class_attr 43 44 45def _swig_add_metaclass(metaclass): 46 """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" 47 def wrapper(cls): 48 return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) 49 return wrapper 50 51 52class _SwigNonDynamicMeta(type): 53 """Meta class to enforce nondynamic attributes (no new attributes) for a class""" 54 __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) 55 56 57RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER = _timecounter.RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER 58r""" 59 Timecounter quality for the clock drivers. 60 61 Timecounter with higher quality value are used in favour of those with lower 62 quality value. 63 """ 64 65def rtems_timecounter_install(tc): 66 r""" 67 Below is an exemplary code snippet that shows the adjustable parameters and 68 the following call of the install routine. 69 70 .. code-block:: c++ 71 72 struct timecounter tc; 73 74 uint32_t get_timecount( struct timecounter *tc ) 75 { 76 return some_free_running_counter; 77 } 78 79 void install( void ) 80 { 81 tc.tc_get_timecount = get_timecount; 82 tc.tc_counter_mask = 0xffffffff; 83 tc.tc_frequency = 123456; 84 tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER; 85 rtems_timecounter_install( &tc ); 86 } 87 """ 88 return _timecounter.rtems_timecounter_install(tc) 89 90def rtems_timecounter_tick(): 91 92 return _timecounter.rtems_timecounter_tick() 93class rtems_timecounter_simple(object): 94 r"""Simple timecounter to support legacy clock drivers.""" 95 96 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 97 __repr__ = _swig_repr 98 tc = property(_timecounter.rtems_timecounter_simple_tc_get, _timecounter.rtems_timecounter_simple_tc_set, doc=r"""tc : struct timecounter""") 99 scaler = property(_timecounter.rtems_timecounter_simple_scaler_get, _timecounter.rtems_timecounter_simple_scaler_set, doc=r"""scaler : uint64_t""") 100 real_interval = property(_timecounter.rtems_timecounter_simple_real_interval_get, _timecounter.rtems_timecounter_simple_real_interval_set, doc=r"""real_interval : uint32_t""") 101 binary_interval = property(_timecounter.rtems_timecounter_simple_binary_interval_get, _timecounter.rtems_timecounter_simple_binary_interval_set, doc=r"""binary_interval : uint32_t""") 102 103 def __init__(self): 104 r"""__init__(rtems_timecounter_simple self) -> rtems_timecounter_simple""" 105 _timecounter.rtems_timecounter_simple_swiginit(self, _timecounter.new_rtems_timecounter_simple()) 106 __swig_destroy__ = _timecounter.delete_rtems_timecounter_simple 107 108# Register rtems_timecounter_simple in _timecounter: 109_timecounter.rtems_timecounter_simple_swigregister(rtems_timecounter_simple) 110 111def rtems_timecounter_simple_install(tc, counter_frequency_in_hz, counter_ticks_per_clock_tick, get_timecount): 112 r""" 113 Initializes and installs a simple timecounter. 114 115 A simple timecounter can be used if the hardware provides no free running 116 counter. A periodic hardware counter must be provided. The counter period 117 must be synchronous to the clock tick. The counter ticks per clock tick is 118 scaled up to the next power of two. 119 120 :type tc: :py:class:`rtems_timecounter_simple`, in 121 :param tc: Zero initialized simple timecounter. 122 :type counter_frequency_in_hz: uint32_t, in 123 :param counter_frequency_in_hz: The hardware counter frequency in Hz. 124 :type counter_ticks_per_clock_tick: uint32_t, in 125 :param counter_ticks_per_clock_tick: The hardware counter ticks per clock 126 tick. 127 :type get_timecount: timecounter_get_t, in 128 :param get_timecount: The method to get the current time count. 129 130 .. code-block:: c++ 131 132 #include <rtems/timecounter.h> 133 134 static rtems_timecounter_simple some_tc; 135 136 static uint32_t some_tc_get( rtems_timecounter_simple *tc ) 137 { 138 return some.value; 139 } 140 141 static bool some_tc_is_pending( rtems_timecounter_simple *tc ) 142 { 143 return some.is_pending; 144 } 145 146 static uint32_t some_tc_get_timecount( struct timecounter *tc ) 147 { 148 return rtems_timecounter_simple_downcounter_get( 149 tc, 150 some_tc_get, 151 some_tc_is_pending 152 ); 153 } 154 155 static void some_tc_tick( void ) 156 { 157 rtems_timecounter_simple_downcounter_tick( &some_tc, some_tc_get ); 158 } 159 160 void some_tc_init( void ) 161 { 162 uint64_t us_per_tick; 163 uint32_t counter_frequency_in_hz; 164 uint32_t counter_ticks_per_clock_tick; 165 166 us_per_tick = rtems_configuration_get_microseconds_per_tick(); 167 counter_frequency_in_hz = some_tc_get_frequency(); 168 counter_ticks_per_clock_tick = 169 (uint32_t) ( counter_frequency_in_hz * us_per_tick ) / 1000000; 170 171 some_tc_init_hardware( counter_ticks_per_clock_tick ); 172 some_tc_init_clock_tick_interrupt( some_tc_tick ); 173 174 rtems_timecounter_simple_install( 175 &some_tc, 176 counter_frequency_in_hz, 177 counter_ticks_per_clock_tick, 178 some_tc_get_timecount 179 ); 180 } 181 182 See also: rtems_timecounter_simple_downcounter_get(), 183 rtems_timecounter_simple_downcounter_tick(), 184 rtems_timecounter_simple_upcounter_get() and 185 rtems_timecounter_simple_upcounter_tick(). 186 """ 187 return _timecounter.rtems_timecounter_simple_install(tc, counter_frequency_in_hz, counter_ticks_per_clock_tick, get_timecount) 188 189def rtems_timecounter_simple_scale(tc, value): 190 r""" 191 Maps a simple timecounter value into its binary frequency domain. 192 193 :type tc: :py:class:`rtems_timecounter_simple`, in 194 :param tc: The simple timecounter. 195 :type value: uint32_t, in 196 :param value: The value of the simple timecounter. 197 198 :rtype: uint32_t 199 :return: The scaled value. 200 """ 201 return _timecounter.rtems_timecounter_simple_scale(tc, value) 202 203def rtems_timecounter_simple_downcounter_tick(tc, get, at_tick): 204 r""" 205 Performs a simple timecounter tick for downcounters. 206 207 :type tc: :py:class:`rtems_timecounter_simple`, in 208 :param tc: The simple timecounter. 209 :type get: rtems_timecounter_simple_get, in 210 :param get: The method to get the value of the simple timecounter. 211 :type at_tick: rtems_timecounter_simple_at_tick, in 212 :param at_tick: The method to perform work under timecounter lock 213 protection at this tick, e.g. clear a pending flag. 214 """ 215 return _timecounter.rtems_timecounter_simple_downcounter_tick(tc, get, at_tick) 216 217def rtems_timecounter_simple_upcounter_tick(tc, get, at_tick): 218 r""" 219 Performs a simple timecounter tick for upcounters. 220 221 :type tc: :py:class:`rtems_timecounter_simple`, in 222 :param tc: The simple timecounter. 223 :type get: rtems_timecounter_simple_get, in 224 :param get: The method to get the value of the simple timecounter. 225 :type at_tick: rtems_timecounter_simple_at_tick, in 226 :param at_tick: The method to perform work under timecounter lock 227 protection at this tick, e.g. clear a pending flag. 228 """ 229 return _timecounter.rtems_timecounter_simple_upcounter_tick(tc, get, at_tick) 230 231def rtems_timecounter_simple_downcounter_get(tc_base, get, is_pending): 232 r""" 233 Gets the simple timecounter value mapped to its binary frequency 234 domain for downcounters. 235 236 :param tc: The simple timecounter. 237 :type get: rtems_timecounter_simple_get, in 238 :param get: The method to get the value of the simple timecounter. 239 :type is_pending: rtems_timecounter_simple_is_pending, in 240 :param is_pending: The method which indicates if the interrupt of the 241 simple timecounter is pending. 242 """ 243 return _timecounter.rtems_timecounter_simple_downcounter_get(tc_base, get, is_pending) 244 245def rtems_timecounter_simple_upcounter_get(tc_base, get, is_pending): 246 r""" 247 Gets the simple timecounter value mapped to its binary frequency 248 domain for upcounters. 249 250 :param tc: The simple timecounter. 251 :type get: rtems_timecounter_simple_get, in 252 :param get: The method to get the value of the simple timecounter. 253 :type is_pending: rtems_timecounter_simple_is_pending, in 254 :param is_pending: The method which indicates if the interrupt of the 255 simple timecounter is pending. 256 """ 257 return _timecounter.rtems_timecounter_simple_upcounter_get(tc_base, get, is_pending)
Timecounter quality for the clock drivers.
Timecounter with higher quality value are used in favour of those with lower quality value.
66def rtems_timecounter_install(tc): 67 r""" 68 Below is an exemplary code snippet that shows the adjustable parameters and 69 the following call of the install routine. 70 71 .. code-block:: c++ 72 73 struct timecounter tc; 74 75 uint32_t get_timecount( struct timecounter *tc ) 76 { 77 return some_free_running_counter; 78 } 79 80 void install( void ) 81 { 82 tc.tc_get_timecount = get_timecount; 83 tc.tc_counter_mask = 0xffffffff; 84 tc.tc_frequency = 123456; 85 tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER; 86 rtems_timecounter_install( &tc ); 87 } 88 """ 89 return _timecounter.rtems_timecounter_install(tc)
Below is an exemplary code snippet that shows the adjustable parameters and the following call of the install routine.
struct timecounter tc;
uint32_t get_timecount( struct timecounter *tc )
{
return some_free_running_counter;
}
void install( void )
{
tc.tc_get_timecount = get_timecount;
tc.tc_counter_mask = 0xffffffff;
tc.tc_frequency = 123456;
tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
rtems_timecounter_install( &tc );
}
94class rtems_timecounter_simple(object): 95 r"""Simple timecounter to support legacy clock drivers.""" 96 97 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 98 __repr__ = _swig_repr 99 tc = property(_timecounter.rtems_timecounter_simple_tc_get, _timecounter.rtems_timecounter_simple_tc_set, doc=r"""tc : struct timecounter""") 100 scaler = property(_timecounter.rtems_timecounter_simple_scaler_get, _timecounter.rtems_timecounter_simple_scaler_set, doc=r"""scaler : uint64_t""") 101 real_interval = property(_timecounter.rtems_timecounter_simple_real_interval_get, _timecounter.rtems_timecounter_simple_real_interval_set, doc=r"""real_interval : uint32_t""") 102 binary_interval = property(_timecounter.rtems_timecounter_simple_binary_interval_get, _timecounter.rtems_timecounter_simple_binary_interval_set, doc=r"""binary_interval : uint32_t""") 103 104 def __init__(self): 105 r"""__init__(rtems_timecounter_simple self) -> rtems_timecounter_simple""" 106 _timecounter.rtems_timecounter_simple_swiginit(self, _timecounter.new_rtems_timecounter_simple()) 107 __swig_destroy__ = _timecounter.delete_rtems_timecounter_simple
Simple timecounter to support legacy clock drivers.
104 def __init__(self): 105 r"""__init__(rtems_timecounter_simple self) -> rtems_timecounter_simple""" 106 _timecounter.rtems_timecounter_simple_swiginit(self, _timecounter.new_rtems_timecounter_simple())
__init__(rtems_timecounter_simple self) -> rtems_timecounter_simple
97 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
The membership flag
112def rtems_timecounter_simple_install(tc, counter_frequency_in_hz, counter_ticks_per_clock_tick, get_timecount): 113 r""" 114 Initializes and installs a simple timecounter. 115 116 A simple timecounter can be used if the hardware provides no free running 117 counter. A periodic hardware counter must be provided. The counter period 118 must be synchronous to the clock tick. The counter ticks per clock tick is 119 scaled up to the next power of two. 120 121 :type tc: :py:class:`rtems_timecounter_simple`, in 122 :param tc: Zero initialized simple timecounter. 123 :type counter_frequency_in_hz: uint32_t, in 124 :param counter_frequency_in_hz: The hardware counter frequency in Hz. 125 :type counter_ticks_per_clock_tick: uint32_t, in 126 :param counter_ticks_per_clock_tick: The hardware counter ticks per clock 127 tick. 128 :type get_timecount: timecounter_get_t, in 129 :param get_timecount: The method to get the current time count. 130 131 .. code-block:: c++ 132 133 #include <rtems/timecounter.h> 134 135 static rtems_timecounter_simple some_tc; 136 137 static uint32_t some_tc_get( rtems_timecounter_simple *tc ) 138 { 139 return some.value; 140 } 141 142 static bool some_tc_is_pending( rtems_timecounter_simple *tc ) 143 { 144 return some.is_pending; 145 } 146 147 static uint32_t some_tc_get_timecount( struct timecounter *tc ) 148 { 149 return rtems_timecounter_simple_downcounter_get( 150 tc, 151 some_tc_get, 152 some_tc_is_pending 153 ); 154 } 155 156 static void some_tc_tick( void ) 157 { 158 rtems_timecounter_simple_downcounter_tick( &some_tc, some_tc_get ); 159 } 160 161 void some_tc_init( void ) 162 { 163 uint64_t us_per_tick; 164 uint32_t counter_frequency_in_hz; 165 uint32_t counter_ticks_per_clock_tick; 166 167 us_per_tick = rtems_configuration_get_microseconds_per_tick(); 168 counter_frequency_in_hz = some_tc_get_frequency(); 169 counter_ticks_per_clock_tick = 170 (uint32_t) ( counter_frequency_in_hz * us_per_tick ) / 1000000; 171 172 some_tc_init_hardware( counter_ticks_per_clock_tick ); 173 some_tc_init_clock_tick_interrupt( some_tc_tick ); 174 175 rtems_timecounter_simple_install( 176 &some_tc, 177 counter_frequency_in_hz, 178 counter_ticks_per_clock_tick, 179 some_tc_get_timecount 180 ); 181 } 182 183 See also: rtems_timecounter_simple_downcounter_get(), 184 rtems_timecounter_simple_downcounter_tick(), 185 rtems_timecounter_simple_upcounter_get() and 186 rtems_timecounter_simple_upcounter_tick(). 187 """ 188 return _timecounter.rtems_timecounter_simple_install(tc, counter_frequency_in_hz, counter_ticks_per_clock_tick, 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
- tc: Zero initialized simple timecounter.
- counter_frequency_in_hz: The hardware counter frequency in Hz.
- counter_ticks_per_clock_tick: The hardware counter ticks per clock tick.
- get_timecount: The method to get the current time count.
#include <rtems/timecounter.h>
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;
us_per_tick = rtems_configuration_get_microseconds_per_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 );
rtems_timecounter_simple_install(
&some_tc,
counter_frequency_in_hz,
counter_ticks_per_clock_tick,
some_tc_get_timecount
);
}
See also: rtems_timecounter_simple_downcounter_get(), rtems_timecounter_simple_downcounter_tick(), rtems_timecounter_simple_upcounter_get() and rtems_timecounter_simple_upcounter_tick().
190def rtems_timecounter_simple_scale(tc, value): 191 r""" 192 Maps a simple timecounter value into its binary frequency domain. 193 194 :type tc: :py:class:`rtems_timecounter_simple`, in 195 :param tc: The simple timecounter. 196 :type value: uint32_t, in 197 :param value: The value of the simple timecounter. 198 199 :rtype: uint32_t 200 :return: The scaled value. 201 """ 202 return _timecounter.rtems_timecounter_simple_scale(tc, value)
Maps a simple timecounter value into its binary frequency domain.
Parameters
- tc: The simple timecounter.
- value: The value of the simple timecounter.
Returns
The scaled value.
204def rtems_timecounter_simple_downcounter_tick(tc, get, at_tick): 205 r""" 206 Performs a simple timecounter tick for downcounters. 207 208 :type tc: :py:class:`rtems_timecounter_simple`, in 209 :param tc: The simple timecounter. 210 :type get: rtems_timecounter_simple_get, in 211 :param get: The method to get the value of the simple timecounter. 212 :type at_tick: rtems_timecounter_simple_at_tick, in 213 :param at_tick: The method to perform work under timecounter lock 214 protection at this tick, e.g. clear a pending flag. 215 """ 216 return _timecounter.rtems_timecounter_simple_downcounter_tick(tc, get, at_tick)
Performs a simple timecounter tick for downcounters.
Parameters
- tc: The simple timecounter.
- get: The method to get the value of the simple timecounter.
- at_tick: The method to perform work under timecounter lock protection at this tick, e.g. clear a pending flag.
218def rtems_timecounter_simple_upcounter_tick(tc, get, at_tick): 219 r""" 220 Performs a simple timecounter tick for upcounters. 221 222 :type tc: :py:class:`rtems_timecounter_simple`, in 223 :param tc: The simple timecounter. 224 :type get: rtems_timecounter_simple_get, in 225 :param get: The method to get the value of the simple timecounter. 226 :type at_tick: rtems_timecounter_simple_at_tick, in 227 :param at_tick: The method to perform work under timecounter lock 228 protection at this tick, e.g. clear a pending flag. 229 """ 230 return _timecounter.rtems_timecounter_simple_upcounter_tick(tc, get, at_tick)
Performs a simple timecounter tick for upcounters.
Parameters
- tc: The simple timecounter.
- get: The method to get the value of the simple timecounter.
- at_tick: The method to perform work under timecounter lock protection at this tick, e.g. clear a pending flag.
232def rtems_timecounter_simple_downcounter_get(tc_base, get, is_pending): 233 r""" 234 Gets the simple timecounter value mapped to its binary frequency 235 domain for downcounters. 236 237 :param tc: The simple timecounter. 238 :type get: rtems_timecounter_simple_get, in 239 :param get: The method to get the value of the simple timecounter. 240 :type is_pending: rtems_timecounter_simple_is_pending, in 241 :param is_pending: The method which indicates if the interrupt of the 242 simple timecounter is pending. 243 """ 244 return _timecounter.rtems_timecounter_simple_downcounter_get(tc_base, get, is_pending)
Gets the simple timecounter value mapped to its binary frequency domain for downcounters.
Parameters
- tc: The simple timecounter.
- get: The method to get the value of the simple timecounter.
- is_pending: The method which indicates if the interrupt of the simple timecounter is pending.
246def rtems_timecounter_simple_upcounter_get(tc_base, get, is_pending): 247 r""" 248 Gets the simple timecounter value mapped to its binary frequency 249 domain for upcounters. 250 251 :param tc: The simple timecounter. 252 :type get: rtems_timecounter_simple_get, in 253 :param get: The method to get the value of the simple timecounter. 254 :type is_pending: rtems_timecounter_simple_is_pending, in 255 :param is_pending: The method which indicates if the interrupt of the 256 simple timecounter is pending. 257 """ 258 return _timecounter.rtems_timecounter_simple_upcounter_get(tc_base, get, is_pending)
Gets the simple timecounter value mapped to its binary frequency domain for upcounters.
Parameters
- tc: The simple timecounter.
- get: The method to get the value of the simple timecounter.
- is_pending: The method which indicates if the interrupt of the simple timecounter is pending.