• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef ADC_CORE_H
10 #define ADC_CORE_H
11 
12 #include "osal_spinlock.h"
13 #include "hdf_base.h"
14 #include "adc_if.h"
15 #include "platform_core.h"
16 
17 #ifdef __cplusplus
18 #if __cplusplus
19 extern "C" {
20 #endif
21 #endif /* __cplusplus */
22 
23 #define ADC_DEVICES_MAX 15
24 
25 struct AdcDevice;
26 struct AdcMethod;
27 struct AdcLockMethod;
28 
29 struct AdcDevice {
30     const struct AdcMethod *ops;
31     OsalSpinlock spin;
32     uint32_t devNum;
33     uint32_t chanNum;
34     const struct AdcLockMethod *lockOps;
35     void *priv;
36 };
37 
38 struct AdcMethod {
39     int32_t (*read)(struct AdcDevice *device, uint32_t channel, uint32_t *val);
40     int32_t (*start)(struct AdcDevice *device);
41     int32_t (*stop)(struct AdcDevice *device);
42 };
43 
44 struct AdcLockMethod {
45     int32_t (*lock)(struct AdcDevice *device);
46     void (*unlock)(struct AdcDevice *device);
47 };
48 
49 int32_t AdcDeviceAdd(struct AdcDevice *device);
50 
51 void AdcDeviceRemove(struct AdcDevice *device);
52 
53 struct AdcDevice *AdcDeviceGet(uint32_t number);
54 
55 void AdcDevicePut(struct AdcDevice *device);
56 
57 int32_t AdcDeviceRead(struct AdcDevice *device, uint32_t channel, uint32_t *val);
58 
59 int32_t AdcDeviceStart(struct AdcDevice *device);
60 
61 int32_t AdcDeviceStop(struct AdcDevice *device);
62 
63 #ifdef __cplusplus
64 #if __cplusplus
65 }
66 #endif
67 #endif /* __cplusplus */
68 
69 #endif /* ADC_CORE_H */
70