RTEMS
clock.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
11 /*
12  * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _RTEMS_CONFDEFS_CLOCK_H
37 #define _RTEMS_CONFDEFS_CLOCK_H
38 
39 #ifndef __CONFIGURATION_TEMPLATE_h
40 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
41 #endif
42 
43 #ifdef CONFIGURE_INIT
44 
46 
47 #if !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) \
48  && !defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER) \
49  && !defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER)
50  #error "You must define one of CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER, CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER, and CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER"
51 #endif
52 
53 #if ( defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) \
54  + defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER) + \
55  + defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER) ) > 1
56  #error "CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER, CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER, and CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER are mutually exclusive"
57 #endif
58 
59 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
60  #include <rtems/clockdrv.h>
61  #include <rtems/sysinit.h>
62 #endif
63 
64 #ifndef CONFIGURE_MICROSECONDS_PER_TICK
65  #define CONFIGURE_MICROSECONDS_PER_TICK 10000
66 #endif
67 
68 #if 1000000 % CONFIGURE_MICROSECONDS_PER_TICK != 0
69  #warning "The clock ticks per second is not an integer"
70 #endif
71 
72 #if CONFIGURE_MICROSECONDS_PER_TICK <= 0
73  #error "CONFIGURE_MICROSECONDS_PER_TICK must be positive"
74 #endif
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
81  RTEMS_SYSINIT_ITEM(
83  RTEMS_SYSINIT_DEVICE_DRIVERS,
84  RTEMS_SYSINIT_ORDER_THIRD
85  );
86 #endif
87 
88 const uint32_t _Watchdog_Microseconds_per_tick =
90 
91 const uint32_t _Watchdog_Nanoseconds_per_tick =
92  (uint32_t) 1000 * CONFIGURE_MICROSECONDS_PER_TICK;
93 
94 const uint32_t _Watchdog_Ticks_per_second =
96 
97 #if defined(CONFIGURE_TICKS_PER_TIMESLICE) \
98  && CONFIGURE_TICKS_PER_TIMESLICE != WATCHDOG_TICKS_PER_TIMESLICE_DEFAULT
99  const uint32_t _Watchdog_Ticks_per_timeslice =
101 #endif
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* CONFIGURE_INIT */
108 
109 #endif /* _RTEMS_CONFDEFS_CLOCK_H */
const uint32_t _Watchdog_Ticks_per_second
The watchdog ticks per second.
const uint32_t _Watchdog_Nanoseconds_per_tick
The watchdog nanoseconds per tick.
const uint32_t _Watchdog_Microseconds_per_tick
The watchdog microseconds per tick.
#define CONFIGURE_TICKS_PER_TIMESLICE
This configuration option is an integer define.
Definition: appl-config.h:2984
void _Clock_Initialize(void)
Initialize the clock driver.
Definition: clockimpl.h:204
Constants for the watchdog ticks.
Clock Driver API.
const uint32_t _Watchdog_Ticks_per_timeslice
The watchdog ticks per timeslice.
#define CONFIGURE_MICROSECONDS_PER_TICK
This configuration option is an integer define.
Definition: appl-config.h:2890