RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
adc.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2024 RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2018-05-07 aozima the first version
9 * 2018-11-16 Ernest Chen add finsh command and update adc function
10 * 2022-05-11 Stanley Lwin add finsh voltage conversion command
11 */
12
13#ifndef __ADC_H__
14#define __ADC_H__
15
16#include <rtthread.h>
62
63
68#define RT_ADC_INTERN_CH_TEMPER (-1)
69#define RT_ADC_INTERN_CH_VREF (-2)
70#define RT_ADC_INTERN_CH_VBAT (-3)
71
72struct rt_adc_device;
77{
79 rt_err_t (*convert)(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value);
81 rt_int16_t (*get_vref) (struct rt_adc_device *device);
82};
83
87{
89 const struct rt_adc_ops *ops;
90};
92
93typedef enum
94{
97 RT_ADC_CMD_GET_RESOLUTION = RT_DEVICE_CTRL_BASE(ADC) + 3, /* get the resolution in bits */
98 RT_ADC_CMD_GET_VREF = RT_DEVICE_CTRL_BASE(ADC) + 4, /* get reference voltage */
100
110rt_err_t rt_hw_adc_register(rt_adc_device_t adc,const char *name, const struct rt_adc_ops *ops, const void *user_data);
111
120
129
138
147
149
150#endif /* __ADC_H__ */
rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_int8_t channel)
get the adc resolution
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_int8_t channel)
enable the adc channel
rt_err_t rt_hw_adc_register(rt_adc_device_t adc, const char *name, const struct rt_adc_ops *ops, const void *user_data)
register the adc device
rt_adc_cmd_t
定义 adc.h:94
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_int8_t channel)
read the adc value
struct rt_adc_device * rt_adc_device_t
定义 adc.h:91
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_int8_t channel)
disable the adc channel
@ RT_ADC_CMD_GET_VREF
定义 adc.h:98
@ RT_ADC_CMD_DISABLE
定义 adc.h:96
@ RT_ADC_CMD_ENABLE
定义 adc.h:95
@ RT_ADC_CMD_GET_RESOLUTION
定义 adc.h:97
#define RT_DEVICE_CTRL_BASE(Type)
signed char rt_int8_t
int rt_bool_t
rt_base_t rt_err_t
unsigned char rt_uint8_t
unsigned int rt_uint32_t
signed short rt_int16_t
adc device
定义 adc.h:87
const struct rt_adc_ops * ops
定义 adc.h:89
struct rt_device parent
定义 adc.h:88
Configure the adc device
定义 adc.h:77
rt_uint8_t(* get_resolution)(struct rt_adc_device *device)
定义 adc.h:80
rt_err_t(* convert)(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value)
定义 adc.h:79
rt_int16_t(* get_vref)(struct rt_adc_device *device)
定义 adc.h:81
rt_err_t(* enabled)(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled)
定义 adc.h:78