Hardware Abstraction Layer for FreeRTOS
dac_prv.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Author: David Brandt <david@wakka.de>
4  * Date: 2021
5  */
6 #ifndef DAC_PRV_H_
7 #define DAC_PRV_H_
8 #ifndef DAC_PRV
9 # error "Never include this file outside of a DAC driver"
10 #endif
11 #include <stdbool.h>
12 #include <stdint.h>
13 #include <FreeRTOS.h>
14 #include <semphr.h>
15 #include <stdbool.h>
16 #include <stdint.h>
17 #include <hal.h>
18 #define DAC_ALREDY_INITED 1
19 int32_t dac_generic_init(struct dac *dac);
20 #ifdef CONFIG_DAC_THREAD_SAVE
21 # define dac_lock(u, w, r) HAL_LOCK(u, w, r)
22 # define dac_unlock(u, r) HAL_UNLOCK(u, r)
23 #else
24 # define dac_lock(u, w, r)
25 # define dac_unlock(u, r)
26 #endif
27 #define DAC_ADDDEV(ns, p) HAL_ADDDEV(dac, ns, p)
29 #define DAC_GET_DEV(index) HAL_GET_DEV(dac, index)
30 #ifndef CONFIG_DAC_MULTI
31 # define DAC_OPS(ns)
32 # define DAC_INIT_DEV(ns)
33 #define DAC_INIT(ns, index, bits) struct dac *dac_init(uint32_t index, uint8_t bits)
34 #define DAC_DEINIT(ns, a) int32_t dac_deinit(struct dac *a)
35 #define DAC_SET(ns, a, d, waittime) int32_t dac_set(struct dac *a, uint32_t d, TickType_t waittime)
36 #define DAC_SET_ISR(ns, a, d) int32_t dac_setISR(struct dac *a, uint32_t d)
37 #else
38 # define DAC_OPS(ns) const struct dac_ops ns##_dac_ops = { \
39  .dac_init = &ns##_dac_init, \
40  .dac_deinit = &ns##_dac_deinit, \
41  .dac_set = &ns##_dac_set, \
42  .dac_setISR = &ns##_dac_setISR, \
43 }
44 # define DAC_INIT_DEV(ns) .gen.ops = &ns##_dac_ops,
45 
46 #define DAC_INIT(ns, index, bits) static struct dac *ns##_dac_init(uint32_t index, uint8_t bits)
47 #define DAC_DEINIT(ns, a) static int32_t ns##_dac_deinit(struct dac *a)
48 #define DAC_SET(ns, a, d, waittime) static int32_t ns##_dac_set(struct dac *a, uint32_t d, TickType_t waittime)
49 #define DAC_SET_ISR(ns, a, d) static int32_t ns##_dac_setISR(struct dac *a, uint32_t d)
50 #endif
51 #endif
HAL_DEFINE_GLOBAL_ARRAY
HAL_DEFINE_GLOBAL_ARRAY(dac)
hal.h
dac_generic_init
int32_t dac_generic_init(struct dac *dac)