Hardware Abstraction Layer for FreeRTOS
gyro_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 GYRO_PRV_
7 #define GYRO_PRV_
8 #ifndef GYRO_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 GYRO_ALREDY_INITED 1
17 int32_t gyro_generic_init(struct gyro *gyro);
18 #ifdef CONFIG_GYRO_THREAD_SAVE
19 # define gyro_lock(u, w, e) HAL_LOCK(u, w, e)
20 # define gyro_unlock(u, e) HAL_UNLOCK(u, e)
21 #else
22 # define gyro_lock(u, w, e)
23 # define gyro_unlock(u, e)
24 #endif
25 
26 #define GYRO_ADDDEV(ns, p) HAL_ADDDEV(gyro, ns, p)
28 #define GYRO_GET_DEV(index) HAL_GET_DEV(gyro, index)
29 #ifndef CONFIG_GYRO_MULTI
30 # define GYRO_OPS(ns)
31 # define GYRO_INIT_DEV(ns)
32 
33 # define GYRO_INIT(ns, index) struct gyro *gyro_init(uint32_t index)
34 # define GYRO_DEINIT(ns, a) int32_t gyro_deinit(struct gyro *a)
35 
36 # define GYRO_GET(ns, a, v, waittime) int32_t gyro_get(struct gyro *a, struct vector *v, TickType_t waittime)
37 # define GYRO_GET_ISR(ns, a, v) int32_t gyro_getISR(struct gyro *a, struct vector *v)
38 
39 #else
40 # define GYRO_OPS(ns) const struct gyro_ops ns##_gyro_ops = { \
41  .gyro_init = &ns##_gyro_init, \
42  .gyro_deinit = &ns##_gyro_deinit, \
43  .gyro_get = &ns##_gyro_get, \
44  .gyro_getISR = &ns##_gyro_getISR, \
45 }
46 # define GYRO_INIT_DEV(ns) .gen.ops = &ns##_gyro_ops,
47 
48 # define GYRO_INIT(ns, index) static struct gyro *ns##_gyro_init(uint32_t index)
49 # define GYRO_DEINIT(ns, a) static int32_t ns##_gyro_deinit(struct gyro *a)
50 
51 # define GYRO_GET(ns, a, v, waittime) static int32_t ns##_gyro_get(struct gyro *a, struct vector *v, TickType_t waittime)
52 # define GYRO_GET_ISR(ns, a, v) static int32_t ns##_gyro_getISR(struct gyro *a, struct vector *v)
53 
54 #endif
55 #endif
56 
gyro_generic_init
int32_t gyro_generic_init(struct gyro *gyro)
hal.h
HAL_DEFINE_GLOBAL_ARRAY
HAL_DEFINE_GLOBAL_ARRAY(gyro)