1.新增通道检查开关。
This commit is contained in:
@@ -63,6 +63,7 @@ static int mr_adc_close(struct mr_dev *dev)
|
||||
struct mr_adc *adc = (struct mr_adc *)dev;
|
||||
struct mr_adc_ops *ops = (struct mr_adc_ops *)dev->drv->ops;
|
||||
|
||||
#ifdef MR_USING_ADC_AUTO_DISABLE
|
||||
/* Disable all channels */
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
@@ -72,6 +73,7 @@ static int mr_adc_close(struct mr_dev *dev)
|
||||
MR_BIT_CLR(adc->channel, (1 << i));
|
||||
}
|
||||
}
|
||||
#endif /* MR_USING_ADC_AUTO_DISABLE */
|
||||
|
||||
return ops->configure(adc, MR_DISABLE);
|
||||
}
|
||||
@@ -83,11 +85,13 @@ static ssize_t mr_adc_read(struct mr_dev *dev, int off, void *buf, size_t size,
|
||||
uint32_t *rd_buf = (uint32_t *)buf;
|
||||
ssize_t rd_size;
|
||||
|
||||
#ifdef MR_USING_ADC_CHANNEL_CHECK
|
||||
/* Check if the channel is enabled */
|
||||
if (MR_BIT_IS_SET(adc->channel, (1 << off)) == MR_DISABLE)
|
||||
{
|
||||
return MR_EINVAL;
|
||||
}
|
||||
#endif /* MR_USING_ADC_CHANNEL_CHECK */
|
||||
|
||||
MR_BIT_CLR(size, sizeof(*rd_buf) - 1);
|
||||
for (rd_size = 0; rd_size < size; rd_size += sizeof(*rd_buf))
|
||||
|
||||
@@ -63,6 +63,7 @@ static int mr_dac_close(struct mr_dev *dev)
|
||||
struct mr_dac *dac = (struct mr_dac *)dev;
|
||||
struct mr_dac_ops *ops = (struct mr_dac_ops *)dev->drv->ops;
|
||||
|
||||
#ifdef MR_USING_DAC_AUTO_DISABLE
|
||||
/* Disable all channels */
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
@@ -72,6 +73,7 @@ static int mr_dac_close(struct mr_dev *dev)
|
||||
MR_BIT_CLR(dac->channel, (1 << i));
|
||||
}
|
||||
}
|
||||
#endif /* MR_USING_DAC_AUTO_DISABLE */
|
||||
|
||||
return ops->configure(dac, MR_DISABLE);
|
||||
}
|
||||
@@ -83,11 +85,13 @@ static ssize_t mr_dac_write(struct mr_dev *dev, int off, const void *buf, size_t
|
||||
uint32_t *wr_buf = (uint32_t *)buf;
|
||||
ssize_t wr_size;
|
||||
|
||||
#ifdef MR_USING_DAC_CHANNEL_CHECK
|
||||
/* Check if the channel is enabled */
|
||||
if (MR_BIT_IS_SET(dac->channel, (1 << off)) == MR_DISABLE)
|
||||
{
|
||||
return MR_EINVAL;
|
||||
}
|
||||
#endif /* MR_USING_DAC_CHANNEL_CHECK */
|
||||
|
||||
MR_BIT_CLR(size, sizeof(*wr_buf) - 1);
|
||||
for (wr_size = 0; wr_size < size; wr_size += sizeof(*wr_buf))
|
||||
|
||||
@@ -98,11 +98,13 @@ static ssize_t mr_pin_read(struct mr_dev *dev, int off, void *buf, size_t size,
|
||||
uint8_t *rd_buf = (uint8_t *)buf;
|
||||
ssize_t rd_size;
|
||||
|
||||
#ifdef MR_USING_PIN_CHECK
|
||||
/* Check offset is valid */
|
||||
if (off < 0)
|
||||
{
|
||||
return MR_EINVAL;
|
||||
}
|
||||
#endif /* MR_USING_PIN_CHECK */
|
||||
|
||||
for (rd_size = 0; rd_size < size; rd_size += sizeof(*rd_buf))
|
||||
{
|
||||
@@ -119,11 +121,13 @@ static ssize_t mr_pin_write(struct mr_dev *dev, int off, const void *buf, size_t
|
||||
uint8_t *wr_buf = (uint8_t *)buf;
|
||||
ssize_t wr_size;
|
||||
|
||||
#ifdef MR_USING_PIN_CHECK
|
||||
/* Check offset is valid */
|
||||
if (off < 0)
|
||||
{
|
||||
return MR_EINVAL;
|
||||
}
|
||||
#endif /* MR_USING_PIN_CHECK */
|
||||
|
||||
for (wr_size = 0; wr_size < size; wr_size += sizeof(*wr_buf))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user