Hardware Abstraction Layer for FreeRTOS
adc_prv.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 ADC_PRV_H_
7
#define ADC_PRV_H_
8
#ifndef ADC_PRV
9
# error "Never include this file out of a ADC 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 ADC_ALREDY_INITED 1
19
int32_t
adc_generic_init
(
struct
adc *adc);
20
#ifdef CONFIG_ADC_THREAD_SAVE
21
# define adc_lock(u, w, r) HAL_LOCK(u, w, r)
22
# define adc_unlock(u, r) HAL_UNLOCK(u, r)
23
#else
24
# define adc_lock(u, w, r)
25
# define adc_unlock(u, r)
26
#endif
27
#define ADC_ADDDEV(ns, p) HAL_ADDDEV(adc, ns, p)
28
HAL_DEFINE_GLOBAL_ARRAY
(adc);
29
#define ADC_GET_DEV(index) HAL_GET_DEV(adc, index)
30
#ifndef CONFIG_ADC_MULTI
31
# define ADC_OPS(ns)
32
# define ADC_INIT_DEV(ns)
33
#define ADC_INIT(ns, index, bits, hz) struct adc *adc_init(uint32_t index, uint8_t bits, uint32_t hz)
34
#define ADC_DEINIT(ns, a) int32_t adc_deinit(struct adc *a)
35
#define ADC_GET(ns, a, waittime) int32_t adc_get(struct adc *a, TickType_t waittime)
36
#define ADC_GET_ISR(ns, a) int32_t adc_getISR(struct adc *a)
37
#define ADC_SET_CALLBACK(ns, a, callback, data) int32_t adc_setCallback(struct adc *a, bool (*callback)(struct adc *adc, uint32_t channel, int32_t value, void *data), void *data)
38
#define ADC_START(ns, a) int32_t adc_start(struct adc *a)
39
#define ADC_STOP(ns, a) int32_t adc_stop(struct adc *a)
40
#else
41
# define ADC_OPS(ns) const struct adc_ops ns##_adc_ops = { \
42
.adc_init = &ns##_adc_init, \
43
.adc_deinit = &ns##_adc_deinit, \
44
.adc_get = &ns##_adc_get, \
45
.adc_getISR = &ns##_adc_getISR, \
46
.adc_setCallback = &ns##_adc_setCallback, \
47
.adc_start = &ns##_adc_start, \
48
.adc_stop = &ns##_adc_stop, \
49
}
50
# define ADC_INIT_DEV(ns) .gen.ops = &ns##_adc_ops,
51
52
#define ADC_INIT(ns, index, bits, hz) static struct adc *ns##_adc_init(uint32_t index, uint8_t bits, uint32_t hz)
53
#define ADC_DEINIT(ns, a) static int32_t ns##_adc_deinit(struct adc *a)
54
#define ADC_GET(ns, a, waittime) static int32_t ns##_adc_get(struct adc *a, TickType_t waittime)
55
#define ADC_GET_ISR(ns, a) static int32_t ns##_adc_getISR(struct adc *a)
56
#define ADC_SET_CALLBACK(ns, a, callback, data) static int32_t ns##_adc_setCallback(struct adc *a, bool (*callback)(struct adc *adc, uint32_t channel, int32_t value, void *data), void *data)
57
#define ADC_START(ns, a) static int32_t ns##_adc_start(struct adc *a)
58
#define ADC_STOP(ns, a) static int32_t ns##_adc_stop(struct adc *a)
59
#endif
60
#endif
hal.h
adc_generic_init
int32_t adc_generic_init(struct adc *adc)
HAL_DEFINE_GLOBAL_ARRAY
HAL_DEFINE_GLOBAL_ARRAY(adc)
driver
include
adc_prv.h
Generated on Tue Aug 17 2021 15:19:23 for Hardware Abstraction Layer for FreeRTOS by
1.8.20