drivers/mq3: adapted to ADC driver changes

This commit is contained in:
Hauke Petersen 2016-03-11 19:24:20 +01:00
parent 56c8e49fd2
commit 9bcfec9032
2 changed files with 6 additions and 9 deletions

View File

@ -33,8 +33,7 @@ extern "C" {
* @brief device descriptor for a MQ-3 sensor * @brief device descriptor for a MQ-3 sensor
*/ */
typedef struct { typedef struct {
adc_t adc_dev; /**< the used ADC device */ adc_t adc_line; /**< the used ADC line */
int adc_chan; /**< used channel of the ADC */
} mq3_t; } mq3_t;
/** /**
@ -47,12 +46,11 @@ typedef struct {
* *
* @param[out] dev device descriptor of an MQ-3 sensor * @param[out] dev device descriptor of an MQ-3 sensor
* @param[in] adc the ADC device the sensor is connected to * @param[in] adc the ADC device the sensor is connected to
* @param[in] channel the channel of the ADC device used
* *
* @return 0 on success * @return 0 on success
* @return -1 on error * @return -1 on error
*/ */
int mq3_init(mq3_t *dev, adc_t adc, int channel); int mq3_init(mq3_t *dev, adc_t adc_line);
/** /**
* @brief Read the RAW sensor value, can be between 0 and MQ3_MAX_RAW_VALUE * @brief Read the RAW sensor value, can be between 0 and MQ3_MAX_RAW_VALUE

View File

@ -24,16 +24,15 @@
#define MIN (100U) /* TODO: calibrate to useful value */ #define MIN (100U) /* TODO: calibrate to useful value */
#define FACTOR (2.33f) /* TODO: calibrate to useful value */ #define FACTOR (2.33f) /* TODO: calibrate to useful value */
int mq3_init(mq3_t *dev, adc_t adc, int channel) int mq3_init(mq3_t *dev, adc_t adc_line)
{ {
dev->adc_dev = adc; dev->adc_line = adc_line;
dev->adc_chan = channel; return adc_init(dev->adc_line);
return adc_init(dev->adc_dev, PRECISION);
} }
int mq3_read_raw(mq3_t *dev) int mq3_read_raw(mq3_t *dev)
{ {
return adc_sample(dev->adc_dev, dev->adc_chan); return adc_sample(dev->adc_line, PRECISION);
} }
int mq3_read(mq3_t *dev) int mq3_read(mq3_t *dev)