mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-19 12:53:30 +08:00
[adc] modify adc channel data type from rt_uint32_t to rt_int8_t
This commit is contained in:
parent
c8956357e4
commit
e9bbc2e349
@ -12,17 +12,18 @@
|
|||||||
|
|
||||||
#ifndef __ADC_H__
|
#ifndef __ADC_H__
|
||||||
#define __ADC_H__
|
#define __ADC_H__
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
|
||||||
#define RT_ADC_INTERN_CH_TEMPER ((rt_uint32_t)-1)
|
#define RT_ADC_INTERN_CH_TEMPER (-1)
|
||||||
#define RT_ADC_INTERN_CH_VREF ((rt_uint32_t)-2)
|
#define RT_ADC_INTERN_CH_VREF (-2)
|
||||||
#define RT_ADC_INTERN_CH_VBAT ((rt_uint32_t)-3)
|
#define RT_ADC_INTERN_CH_VBAT (-3)
|
||||||
|
|
||||||
struct rt_adc_device;
|
struct rt_adc_device;
|
||||||
struct rt_adc_ops
|
struct rt_adc_ops
|
||||||
{
|
{
|
||||||
rt_err_t (*enabled)(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
|
rt_err_t (*enabled)(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled);
|
||||||
rt_err_t (*convert)(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
|
rt_err_t (*convert)(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value);
|
||||||
rt_uint8_t (*get_resolution)(struct rt_adc_device *device);
|
rt_uint8_t (*get_resolution)(struct rt_adc_device *device);
|
||||||
rt_int16_t (*get_vref) (struct rt_adc_device *device);
|
rt_int16_t (*get_vref) (struct rt_adc_device *device);
|
||||||
};
|
};
|
||||||
@ -43,10 +44,9 @@ typedef enum
|
|||||||
} rt_adc_cmd_t;
|
} rt_adc_cmd_t;
|
||||||
|
|
||||||
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);
|
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);
|
||||||
|
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_int8_t channel);
|
||||||
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel);
|
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_int8_t channel);
|
||||||
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel);
|
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_int8_t channel);
|
||||||
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel);
|
rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_int8_t channel);
|
||||||
rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_uint32_t channel);
|
|
||||||
|
|
||||||
#endif /* __ADC_H__ */
|
#endif /* __ADC_H__ */
|
||||||
|
@ -115,7 +115,7 @@ rt_err_t rt_hw_adc_register(rt_adc_device_t device, const char *name, const stru
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel)
|
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_int8_t channel)
|
||||||
{
|
{
|
||||||
rt_uint32_t value;
|
rt_uint32_t value;
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel)
|
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_int8_t channel)
|
||||||
{
|
{
|
||||||
rt_err_t result = RT_EOK;
|
rt_err_t result = RT_EOK;
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel)
|
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_int8_t channel)
|
||||||
{
|
{
|
||||||
rt_err_t result = RT_EOK;
|
rt_err_t result = RT_EOK;
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_uint32_t channel)
|
rt_int16_t rt_adc_voltage(rt_adc_device_t dev, rt_int8_t channel)
|
||||||
{
|
{
|
||||||
rt_uint32_t value = 0;
|
rt_uint32_t value = 0;
|
||||||
rt_int16_t vref = 0, voltage = 0;
|
rt_int16_t vref = 0, voltage = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user