Hardware Abstraction Layer for FreeRTOS
counter_prv.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Author: Andreas Werner <kernel@andy89.org>
4  * Date: 2016
5  */
6 #ifndef COUNTER_PRV_
7 #define COUNTER_PRV_
8 #ifndef COUNTER_PRV
9 # error "Never include this file out of a COUNTER driver"
10 #endif
11 #include <FreeRTOS.h>
12 #include <semphr.h>
13 #include <stdint.h>
14 #include <stdbool.h>
15 #include <hal.h>
16 #define COUNTER_ALREDY_INITED 1
17 int32_t counter_genericInit(struct counter *counter);
18 #define COUNTER_ADDDEV(ns, p) HAL_ADDDEV(counter, ns, p)
20 #define COUNTER_GET_DEV(index) HAL_GET_DEV(counter, index)
21 #ifndef CONFIG_COUNTER_MULTI
22 # define COUNTER_OPS(ns)
23 # define COUNTER_INIT_DEV(ns)
24 # define COUNTER_INIT(ns, index, mode) struct counter *counter_init(uint32_t index, enum counter_mode mode)
25 # define COUNTER_DEINIT(ns, p) int32_t counter_deinit(struct counter *p)
26 
27 # define COUNTER_GET_VALUE(ns, p) int64_t counter_getValue(struct counter *p)
28 # define COUNTER_RESET(ns, p) int32_t counter_reset(struct counter *p)
29 #else
30 # define COUNTER_OPS(ns) const struct counter_ops ns##_counter_ops = { \
31  .counter_init = &ns##_counter_init,\
32  .counter_deinit = &ns##_counter_deinit,\
33  .counter_getValue = &ns##_counter_getValue,\
34  .counter_reset = &ns##_counter_reset,\
35 }
36 # define COUNTER_INIT_DEV(ns) .gen.ops = &ns##_counter_ops,
37 
38 # define COUNTER_INIT(ns, index, mode) static struct counter *ns##_counter_init(uint32_t index, enum counter_mode mode)
39 # define COUNTER_DEINIT(ns, p) static int32_t ns##_counter_deinit(struct counter *p)
40 # define COUNTER_GET_VALUE(ns, p) static int64_t ns##_counter_getValue(struct counter *p)
41 # define COUNTER_RESET(ns, p) static int32_t ns##_counter_reset(struct counter *p)
42 #endif
43 #endif
44 
hal.h
HAL_DEFINE_GLOBAL_ARRAY
HAL_DEFINE_GLOBAL_ARRAY(counter)
counter_genericInit
int32_t counter_genericInit(struct counter *counter)