Hardware Abstraction Layer for FreeRTOS
gyro.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_H_
7
#define GYRO_H_
8
#include <stdint.h>
9
#include <stdbool.h>
10
#include <
system.h
>
11
#include <FreeRTOS.h>
12
#include <semphr.h>
13
#include <
hal.h
>
14
#include <
vec.h
>
28
struct
gyro;
29
#ifdef CONFIG_GYRO_MULTI
30
33
struct
gyro_ops {
34
struct
gyro *(*gyro_init)(uint32_t index);
35
int32_t (*
gyro_deinit
)(
struct
gyro *gyro);
36
37
int32_t (*
gyro_get
)(
struct
gyro *gyro,
struct
vector
*
vector
, TickType_t waittime);
38
int32_t (*
gyro_getISR
)(
struct
gyro *gyro,
struct
vector
*
vector
);
39
};
40
#endif
41
44
struct
gyro_generic
{
49
bool
init
;
50
#ifdef CONFIG_INSTANCE_NAME
51
54
const
char
*name;
55
#endif
56
#ifdef CONFIG_GYRO_THREAD_SAVE
57
60
OS_DEFINE_MUTEX_RECURSIVE
(lock);
61
#endif
62
#ifdef CONFIG_GYRO_MULTI
63
66
const
struct
gyro_ops *ops;
67
#endif
68
};
69
70
#ifndef CONFIG_GYRO_MULTI
71
76
struct
gyro *
gyro_init
(uint32_t index);
82
int32_t
gyro_deinit
(
struct
gyro *gyro);
90
int32_t
gyro_get
(
struct
gyro *gyro,
struct
vector
*
vector
, TickType_t waittime);
97
int32_t
gyro_getISR
(
struct
gyro *gyro,
struct
vector
*
vector
);
98
#else
99
inline
struct
gyro *
gyro_init
(uint32_t index) {
100
HAL_DEFINE_GLOBAL_ARRAY
(gyro);
101
struct
gyro_generic
*a = (
struct
gyro_generic
*)
HAL_GET_DEV
(gyro, index);
102
if
(a == NULL) {
103
return
NULL;
104
}
105
return
a->ops->gyro_init(index);
106
}
107
inline
int32_t
gyro_deinit
(
struct
gyro *gyro) {
108
struct
gyro_generic
*a = (
struct
gyro_generic
*) gyro;
109
return
a->ops->gyro_deinit(gyro);
110
}
111
112
inline
int32_t
gyro_get
(
struct
gyro *gyro,
struct
vector
*
vector
, TickType_t waittime) {
113
struct
gyro_generic
*a = (
struct
gyro_generic
*) gyro;
114
return
a->ops->gyro_get(gyro,
vector
, waittime);
115
}
116
inline
int32_t
gyro_getISR
(
struct
gyro *gyro,
struct
vector
*
vector
) {
117
struct
gyro_generic
*a = (
struct
gyro_generic
*) gyro;
118
return
a->ops->gyro_getISR(gyro,
vector
);
119
}
120
#endif
121
122
#endif
gyro_generic::init
bool init
Definition:
gyro.h:49
gyro_deinit
int32_t gyro_deinit(struct gyro *gyro)
OS_DEFINE_MUTEX_RECURSIVE
#define OS_DEFINE_MUTEX_RECURSIVE(name)
Definition:
os.h:59
hal.h
gyro_getISR
int32_t gyro_getISR(struct gyro *gyro, struct vector *vector)
gyro_get
int32_t gyro_get(struct gyro *gyro, struct vector *vector, TickType_t waittime)
HAL_DEFINE_GLOBAL_ARRAY
#define HAL_DEFINE_GLOBAL_ARRAY(gns)
Definition:
hal.h:149
vector
Definition:
vec.h:12
HAL_GET_DEV
#define HAL_GET_DEV(gns, index)
Definition:
hal.h:182
system.h
vec.h
gyro_generic
Definition:
gyro.h:44
gyro_init
struct gyro * gyro_init(uint32_t index)
driver
include
gyro.h
Generated on Tue Aug 17 2021 15:19:23 for Hardware Abstraction Layer for FreeRTOS by
1.8.20