VSF Documented
vsf_adc128d818.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __HAL_ADC128D818_ADC_H__
19#define __HAL_ADC128D818_ADC_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_ADC == ENABLED && VSF_HAL_USE_ADC128D818_ADC == ENABLED
26
27/*\note Refer to template/README.md for usage cases.
28 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
29 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
30 * For emulated drivers, **** No reimplementation ****.
31 */
32
33/*\note Includes CAN ONLY be put here. */
34/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
35
36// IPCore
37#if defined(__VSF_HAL_ADC128D818_ADC_CLASS_IMPLEMENT)
38# define __VSF_CLASS_IMPLEMENT__
39#elif defined(__VSF_HAL_ADC128D818_ADC_CLASS_INHERIT__)
40# define __VSF_CLASS_INHERIT__
41#endif
42
43#include "utilities/ooc_class.h"
44// IPCore end
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/*============================ MACROS ========================================*/
51
52#if VSF_HAL_USE_I2C != ENABLED
53# error ADC128D818 uses I2C, please enable VSF_HAL_USE_I2C
54#endif
55
56/*\note VSF_ADC128D818_ADC_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
57 * while VSF_HW_ADC_CFG_MULTI_CLASS should be in adc.c.
58 */
59
60// IPCore
61#ifndef VSF_ADC128D818_ADC_CFG_MULTI_CLASS
62# define VSF_ADC128D818_ADC_CFG_MULTI_CLASS VSF_ADC_CFG_MULTI_CLASS
63#endif
64// IPCore end
65
66/*============================ MACROFIED FUNCTIONS ===========================*/
67
68#if VSF_ADC128D818_ADC_CFG_MULTI_CLASS == ENABLED
69# define __VSF_ADC128D818_ADC_HALOP .vsf_adc.op = &vsf_adc128d818_adc_op,
70#else
71# define __VSF_ADC128D818_ADC_HALOP
72#endif
73
74#define __VSF_ADC128D818_ADC_INIT(__I2C, __I2C_ADDR) \
75 __VSF_ADC128D818_ADC_HALOP \
76 .i2c = (__I2C), \
77 .i2c_addr = (__I2C_ADDR),
78#define VSF_ADC128D818_ADC_INIT(__I2C, __I2C_ADDR) \
79 __VSF_ADC128D818_ADC_INIT((__I2C), (__I2C_ADDR))
80
81#define __describe_adc128d818_adc(__name, __i2c, __i2c_addr) \
82 vsf_adc128d818_adc_t __name = { \
83 __VSF_ADC128D818_ADC_INIT((__i2c), (__i2c_addr)) \
84 };
85
86#define describe_adc128d818_adc(__name, __i2c, __i2c_addr) \
87 __describe_adc128d818_adc(__name, (__i2c), (__i2c_addr))
88
89/*============================ TYPES =========================================*/
90
91// IPCore
93 public_member(
95 vsf_adc_t vsf_adc;
96#endif
97 // TODO: support INT
98 vsf_i2c_t *i2c;
99 uint8_t i2c_addr;
100 )
101
102/*\note You can add more member in vsf_adc128d818_adc_t instance.
103 * For members accessible from child, put in protected_member.
104 * Else, put in private_member.
105 */
106
107 protected_member(
110 uint16_t *result_buffer;
111 uint32_t total_count;
112 uint8_t is_continuous_mode : 1;
113 uint8_t is_inited : 1;
114 uint8_t is_busy : 1;
115 uint8_t rx_byte_len : 2;
116 uint8_t configured_channel_mask;
117 uint8_t channel_seq_map[8];
118 uint8_t cur_channel_mask;
119 uint8_t cur_channel;
120 struct {
121 uint8_t cur_reg;
122 union {
123 uint8_t data_buffer[2];
125 };
128};
129// IPCore end
130
131/*============================ INCLUDES ======================================*/
132
133#define VSF_ADC_CFG_DEC_PREFIX vsf_adc128d818
134#define VSF_ADC_CFG_DEC_UPCASE_PREFIX VSF_ADC128D818
135#define VSF_ADC_CFG_DEC_EXTERN_OP ENABLED
137
138#ifdef __cplusplus
139}
140#endif
141
142// IPCore
143#undef __VSF_HAL_ADC128D818_ADC_CLASS_IMPLEMENT
144#undef __VSF_HAL_ADC128D818_ADC_CLASS_INHERIT__
145// IPCore end
146
147#endif // VSF_HAL_USE_ADC
148#endif // __HAL_ADC128D818_ADC_H__
149/* EOF */
#define ENABLED
Definition __type.h:28
Definition vsf_adc128d818.h:92
struct ieee80211_ext_chansw_ie data
Definition ieee80211.h:80
#define vsf_class(__name)
Definition ooc_class.h:48
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_adc.h:223
Definition vsf_template_adc.h:267
Definition vsf_template_i2c.h:334
vsf_adc_isr_t isr
Definition adc.h:83
#define VSF_ADC128D818_ADC_CFG_MULTI_CLASS
Definition vsf_adc128d818.h:62
struct vk_romfs_header_t VSF_CAL_PACKED
vsf_adc_irq_mask_t
Definition vsf_template_adc.h:199