summaryrefslogtreecommitdiff
path: root/components/drivers/misc
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/misc')
-rw-r--r--components/drivers/misc/adc.c2
-rw-r--r--components/drivers/misc/dac.c20
2 files changed, 14 insertions, 8 deletions
diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c
index ae324a16ec..9c87919793 100644
--- a/components/drivers/misc/adc.c
+++ b/components/drivers/misc/adc.c
@@ -58,7 +58,7 @@ static rt_err_t _adc_control(rt_device_t dev, int cmd, void *args)
if(resolution != 0)
{
*((rt_uint8_t*)args) = resolution;
- LOG_D("ADC resolution:%d", resolution);
+ LOG_D("resolution: %d bits", resolution);
result = RT_EOK;
}
}
diff --git a/components/drivers/misc/dac.c b/components/drivers/misc/dac.c
index 548a7bde99..ecbadfd502 100644
--- a/components/drivers/misc/dac.c
+++ b/components/drivers/misc/dac.c
@@ -40,21 +40,27 @@ static rt_size_t _dac_write(rt_device_t dev, rt_off_t pos, const void *buffer, r
static rt_err_t _dac_control(rt_device_t dev, int cmd, void *args)
{
- rt_err_t result = RT_EOK;
+ rt_err_t result = -RT_EINVAL;
rt_dac_device_t dac = (struct rt_dac_device *)dev;
- if (dac->ops->enabled == RT_NULL)
- {
- return -RT_ENOSYS;
- }
- if (cmd == RT_DAC_CMD_ENABLE)
+ if (cmd == RT_DAC_CMD_ENABLE && dac->ops->enabled)
{
result = dac->ops->enabled(dac, (rt_uint32_t)args);
}
- else if (cmd == RT_DAC_CMD_DISABLE)
+ else if (cmd == RT_DAC_CMD_DISABLE && dac->ops->enabled)
{
result = dac->ops->disabled(dac, (rt_uint32_t)args);
}
+ else if (cmd == RT_DAC_CMD_GET_RESOLUTION && dac->ops->get_resolution)
+ {
+ rt_uint8_t resolution = dac->ops->get_resolution(dac);
+ if(resolution != 0)
+ {
+ *((rt_uint8_t*)args) = resolution;
+ LOG_D("resolution: %d bits", resolution);
+ result = RT_EOK;
+ }
+ }
return result;
}