Hardware Abstraction Layer for FreeRTOS
capture.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 CAPTURE_H_
7 #define CAPTURE_H_
8 #include <stdint.h>
9 #include <stdbool.h>
10 #include <system.h>
11 #include <hal.h>
27 struct capture;
28 #ifdef CONFIG_CAPTURE_MULTI
29 struct capture_ops {
30  struct capture *(*capture_init)(uint32_t index);
31  int32_t (*capture_deinit)(struct capture *capture);
32 
33  int32_t (*capture_setCallback)(struct capture *capture, bool (*callback)(struct capture *capture, uint32_t index, uint64_t time, void *data), void *data);
34 
35  int32_t (*capture_setPeriod)(struct capture *capture, uint64_t us);
36  uint64_t (*capture_getTime)(struct capture *capture);
37  uint64_t (*capture_getChannelTime)(struct capture *capture);
38 };
39 #endif
40 
48  bool init;
49 #ifdef CONFIG_INSTANCE_NAME
50 
53  const char *name;
54 #endif
55 #ifdef CONFIG_CAPTURE_MULTI
56 
59  const struct capture_ops *ops;
60 #endif
61 };
62 #ifndef CONFIG_CAPTURE_MULTI
63 
68 struct capture *capture_init(uint32_t index);
74 int32_t capture_deinit(struct capture *capture);
82 int32_t capture_setCallback(struct capture *capture, bool (*callback)(struct capture *capture, uint32_t index, uint64_t time, void *data), void *data);
89 int32_t capture_setPeriod(struct capture *capture, uint64_t us);
95 uint64_t capture_getTime(struct capture *capture);
101 uint64_t capture_getChannelTime(struct capture *capture);
102 #else
103 inline struct capture *capture_init(uint32_t index) {
104  HAL_DEFINE_GLOBAL_ARRAY(capture);
105  struct capture_generic *p = (struct capture_generic *) HAL_GET_DEV(capture, index);
106  return p->ops->capture_init(index);
107 }
108 inline int32_t capture_deinit(struct capture *capture) {
109  struct capture_generic *p = (struct capture_generic *) capture;
110  return p->ops->capture_deinit(capture);
111 }
112 
113 inline int32_t capture_setCallback(struct capture *capture, bool (*callback)(struct capture *capture, uint32_t index, uint64_t time, void *data), void *data) {
114  struct capture_generic *p = (struct capture_generic *) capture;
115  return p->ops->capture_setCallback(capture, callback, data);
116 }
117 
118 inline int32_t capture_setPeriod(struct capture *capture, uint64_t us) {
119  struct capture_generic *p = (struct capture_generic *) capture;
120  return p->ops->capture_setPeriod(capture, us);
121 }
122 
123 inline uint64_t capture_getTime(struct capture *capture) {
124  struct capture_generic *p = (struct capture_generic *) capture;
125  return p->ops->capture_getTime(capture);
126 
127 }
128 inline uint64_t capture_getChannelTime(struct capture *capture) {
129  struct capture_generic *p = (struct capture_generic *) capture;
130  return p->ops->capture_getChannelTime(capture);
131 }
132 #endif
133 
134 #endif
capture_init
struct capture * capture_init(uint32_t index)
hal.h
capture_generic::init
bool init
Definition: capture.h:48
HAL_DEFINE_GLOBAL_ARRAY
#define HAL_DEFINE_GLOBAL_ARRAY(gns)
Definition: hal.h:149
capture_deinit
int32_t capture_deinit(struct capture *capture)
HAL_GET_DEV
#define HAL_GET_DEV(gns, index)
Definition: hal.h:182
capture_generic
Definition: capture.h:43
capture_setPeriod
int32_t capture_setPeriod(struct capture *capture, uint64_t us)
system.h
capture_setCallback
int32_t capture_setCallback(struct capture *capture, bool(*callback)(struct capture *capture, uint32_t index, uint64_t time, void *data), void *data)
capture_getChannelTime
uint64_t capture_getChannelTime(struct capture *capture)
capture_getTime
uint64_t capture_getTime(struct capture *capture)