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