Hardware Abstraction Layer for FreeRTOS
accel_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 ACCEL_PRV_
7 #define ACCEL_PRV_
8 #ifndef ACCEL_PRV
9 # error "Never include this file out of a Accel 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 ACCEL_ALREDY_INITED 1
17 int32_t accel_generic_init(struct accel *accel);
18 #ifdef CONFIG_ACCEL_THREAD_SAVE
19 # define accel_lock(u, w, e) HAL_LOCK(u, w, e)
20 # define accel_unlock(u, e) HAL_UNLOCK(u, e)
21 #else
22 # define accel_lock(u, w, e)
23 # define accel_unlock(u, e)
24 #endif
25 
26 #define ACCEL_ADDDEV(ns, p) HAL_ADDDEV(accel, ns, p)
28 #define ACCEL_GET_DEV(index) HAL_GET_DEV(accel, index)
29 #ifndef CONFIG_ACCEL_MULTI
30 # define ACCEL_OPS(ns)
31 # define ACCEL_INIT_DEV(ns)
32 
33 # define ACCEL_INIT(ns, index) struct accel *accel_init(uint32_t index)
34 # define ACCEL_DEINIT(ns, a) int32_t accel_deinit(struct accel *a)
35 
36 # define ACCEL_GET(ns, a, v, waittime) int32_t accel_get(struct accel *a, struct vector *v, TickType_t waittime)
37 # define ACCEL_GET_ISR(ns, a, v) int32_t accel_getISR(struct accel *a, struct vector *v)
38 
39 #else
40 # define ACCEL_OPS(ns) const struct accel_ops ns##_accel_ops = { \
41  .accel_init = &ns##_accel_init, \
42  .accel_deinit = &ns##_accel_deinit, \
43  .accel_get = &ns##_accel_get, \
44  .accel_getISR = &ns##_accel_getISR, \
45 }
46 # define ACCEL_INIT_DEV(ns) .gen.ops = &ns##_accel_ops,
47 
48 # define ACCEL_INIT(ns, index) static struct accel *ns##_accel_init(uint32_t index)
49 # define ACCEL_DEINIT(ns, a) static int32_t ns##_accel_deinit(struct accel *a)
50 
51 # define ACCEL_GET(ns, a, v, waittime) static int32_t ns##_accel_get(struct accel *a, struct vector *v, TickType_t waittime)
52 # define ACCEL_GET_ISR(ns, a, v) static int32_t ns##_accel_getISR(struct accel *a, struct vector *v)
53 
54 #endif
55 #endif
56 
hal.h
accel_generic_init
int32_t accel_generic_init(struct accel *accel)
HAL_DEFINE_GLOBAL_ARRAY
HAL_DEFINE_GLOBAL_ARRAY(accel)