Hardware Abstraction Layer for FreeRTOS
example.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 EXAMPLE_H_
7 #define EXAMPLE_H_
8 #include <FreeRTOS.h>
9 #include <stdint.h>
10 #include <stdbool.h>
11 #include <system.h>
12 #include <semphr.h>
13 #include <hal.h>
49 struct example;
50 #ifdef CONFIG_EXAMPLE_MULTI
51 
54 struct example_ops {
60  struct example *(*example_init)(uint32_t index);
66  int32_t (*example_deinit)(struct example *example);
73  int32_t (*example_funcname)(struct example *example, uint32_t params);
74 };
75 #endif
76 
91  bool init;
92 #ifdef CONFIG_INSTANCE_NAME
93 
96  const char *name;
97 #endif
98 #ifdef CONFIG_EXAMPLE_THREAD_SAVE
99 
103 #endif
104 #ifdef CONFIG_EXAMPLE_MULTI
105 
108  const struct example_ops *ops;
109 #endif
110 };
111 #ifndef CONFIG_EXAMPLE_MULTI
112 
117 struct example *example_init(uint32_t index);
123 int32_t example_deinit(struct example *example);
130 int32_t example_funcname(struct example *example, uint32_t params);
131 #else
132 
137 inline struct example *example_init(uint32_t index) {
138  /*
139  * Define Global Array in local space
140  * Userspace din't need it
141  */
142  HAL_DEFINE_GLOBAL_ARRAY(example);
143  /*
144  * Get Dev from array if NULL dev not exists
145  */
146  struct example_generic *p = (struct example_generic *) HAL_GET_DEV(example, index);
147  if (p == NULL) {
148  return NULL;
149  }
150  return p->ops->example_init(index);
151 }
157 inline int32_t example_deinit(struct example *example) {
158  struct example_generic *p = (struct example_generic *) example;
159  return p->ops->example_deinit(example);
160 }
167 inline int32_t example_funcname(struct example *example, uint32_t params) {
168  struct example_generic *p = (struct example_generic *) example;
169  return p->ops->example_funcname(example, params);
170 }
171 #endif
172 
173 #endif
example_ops::example_deinit
int32_t(* example_deinit)(struct example *example)
Definition: example.h:66
hal.h
example_init
struct example * example_init(uint32_t index)
Definition: example.h:137
example_deinit
int32_t example_deinit(struct example *example)
Definition: example.h:157
HAL_DEFINE_GLOBAL_ARRAY
#define HAL_DEFINE_GLOBAL_ARRAY(gns)
Definition: hal.h:149
example_generic
Definition: example.h:86
example_ops
Definition: example.h:54
HAL_GET_DEV
#define HAL_GET_DEV(gns, index)
Definition: hal.h:182
example_ops::example_init
struct example *(* example_init)(uint32_t index)
Definition: example.h:60
example_generic::OS_DEFINE_MUTEX_RECURSIVE
OS_DEFINE_MUTEX_RECURSIVE(lock)
example_funcname
int32_t example_funcname(struct example *example, uint32_t params)
Definition: example.h:167
system.h
example_ops::example_funcname
int32_t(* example_funcname)(struct example *example, uint32_t params)
Definition: example.h:73
example_generic::ops
const struct example_ops * ops
Definition: example.h:108
example_generic::init
bool init
Definition: example.h:91