EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
em_timer.h
1/*
2 * Copyright (c) 2017, Nokia Solutions and Networks
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30#ifndef EM_TIMER_H_
31#define EM_TIMER_H_
32
33#include <odp_api.h>
34
35#include <event_machine.h>
36
37#include "em_timer_types.h"
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43#define TMR_DBG_PRINT(fmt, ...) \
44 EM_DBG(EM_DEBUG_PRINT_TIMER, "TMRDBG: %s(): " fmt, __func__, ## __VA_ARGS__)
45
46em_status_t timer_init(timer_storage_t *const tmrs);
47em_status_t timer_init_local(void);
48em_status_t timer_term_local(void);
49em_status_t timer_term(timer_storage_t *const tmrs);
50
51static inline int
52timer_clksrc_em2odp(em_timer_clksrc_t clksrc_em,
53 odp_timer_clk_src_t *clksrc_odp /* out */)
54{
55 switch (clksrc_em) {
56 case EM_TIMER_CLKSRC_0:
57 *clksrc_odp = ODP_CLOCK_SRC_0;
58 break;
59 case EM_TIMER_CLKSRC_1:
60 *clksrc_odp = ODP_CLOCK_SRC_1;
61 break;
62 case EM_TIMER_CLKSRC_2:
63 *clksrc_odp = ODP_CLOCK_SRC_2;
64 break;
65 case EM_TIMER_CLKSRC_3:
66 *clksrc_odp = ODP_CLOCK_SRC_3;
67 break;
68 case EM_TIMER_CLKSRC_4:
69 *clksrc_odp = ODP_CLOCK_SRC_4;
70 break;
71 case EM_TIMER_CLKSRC_5:
72 *clksrc_odp = ODP_CLOCK_SRC_5;
73 break;
74 default:
75 return -1;
76 }
77 return 0;
78}
79
80static inline int
81timer_clksrc_odp2em(odp_timer_clk_src_t clksrc_odp,
82 em_timer_clksrc_t *clksrc_em /* out */)
83{
84 switch (clksrc_odp) {
85 case ODP_CLOCK_SRC_0:
86 *clksrc_em = EM_TIMER_CLKSRC_0;
87 break;
88 case ODP_CLOCK_SRC_1:
89 *clksrc_em = EM_TIMER_CLKSRC_1;
90 break;
91 case ODP_CLOCK_SRC_2:
92 *clksrc_em = EM_TIMER_CLKSRC_2;
93 break;
94 case ODP_CLOCK_SRC_3:
95 *clksrc_em = EM_TIMER_CLKSRC_3;
96 break;
97 case ODP_CLOCK_SRC_4:
98 *clksrc_em = EM_TIMER_CLKSRC_4;
99 break;
100 case ODP_CLOCK_SRC_5:
101 *clksrc_em = EM_TIMER_CLKSRC_5;
102 break;
103 default:
104 return -1;
105 }
106 return 0;
107}
108
109#ifdef __cplusplus
110}
111#endif
112
113#endif /* EM_TIMER_H_ */
uint32_t em_status_t