Hardware Abstraction Layer for FreeRTOS
temp.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Author: Andreas Werner <kernel@andy89.org>
4  * Date: 2019
5  */
6 #ifndef TEMP_H_
7 #define TEMP_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 temp;
29 #ifdef CONFIG_TEMP_MULTI
30 
33 struct temp_ops {
34  struct temp *(*temp_init)(uint32_t index);
35  int32_t (*temp_deinit)(struct temp *temp);
36 
37  int32_t (*temp_get)(struct temp *temp, float *value, TickType_t waittime);
38  int32_t (*temp_getISR)(struct temp *temp, float *value);
39 };
40 #endif
41 
44 struct temp_generic {
49  bool init;
50 #ifdef CONFIG_INSTANCE_NAME
51 
54  const char *name;
55 #endif
56 #ifdef CONFIG_TEMP_THREAD_SAVE
57 
61 #endif
62 #ifdef CONFIG_TEMP_MULTI
63 
66  const struct temp_ops *ops;
67 #endif
68 };
69 
70 #ifndef CONFIG_TEMP_MULTI
71 
76 struct temp *temp_init(uint32_t index);
82 int32_t temp_deinit(struct temp *temp);
91 int32_t temp_get(struct temp *temp, float *value, TickType_t waittime);
98 int32_t temp_getISR(struct temp *temp, float *value);
99 #else
100 inline struct temp *temp_init(uint32_t index) {
102  struct temp_generic *a = (struct temp_generic *) HAL_GET_DEV(temp, index);
103  if (a == NULL) {
104  return NULL;
105  }
106  return a->ops->temp_init(index);
107 }
108 inline int32_t temp_deinit(struct temp *temp) {
109  struct temp_generic *a = (struct temp_generic *) temp;
110  return a->ops->temp_deinit(temp);
111 }
112 
113 inline int32_t temp_get(struct temp *temp, float *value, TickType_t waittime) {
114  struct temp_generic *a = (struct temp_generic *) temp;
115  return a->ops->temp_get(temp, value, waittime);
116 }
117 inline int32_t temp_getISR(struct temp *temp, float *value) {
118  struct temp_generic *a = (struct temp_generic *) temp;
119  return a->ops->temp_getISR(temp, value);
120 }
121 #endif
122 
123 #endif
124 
temp_generic
Definition: temp.h:44
OS_DEFINE_MUTEX_RECURSIVE
#define OS_DEFINE_MUTEX_RECURSIVE(name)
Definition: os.h:59
hal.h
temp_generic::init
bool init
Definition: temp.h:49
HAL_DEFINE_GLOBAL_ARRAY
#define HAL_DEFINE_GLOBAL_ARRAY(gns)
Definition: hal.h:149
HAL_GET_DEV
#define HAL_GET_DEV(gns, index)
Definition: hal.h:182
temp_deinit
int32_t temp_deinit(struct temp *temp)
temp_init
struct temp * temp_init(uint32_t index)
system.h
vec.h
temp_getISR
int32_t temp_getISR(struct temp *temp, float *value)
temp_get
int32_t temp_get(struct temp *temp, float *value, TickType_t waittime)