Browse Source

drivers/mq3: adapted to ADC driver changes

pr/gpio
Hauke Petersen 7 years ago
parent
commit
9bcfec9032
  1. 6
      drivers/include/mq3.h
  2. 9
      drivers/mq3/mq3.c

6
drivers/include/mq3.h

@ -33,8 +33,7 @@ extern "C" {
* @brief device descriptor for a MQ-3 sensor
*/
typedef struct {
adc_t adc_dev; /**< the used ADC device */
int adc_chan; /**< used channel of the ADC */
adc_t adc_line; /**< the used ADC line */
} mq3_t;
/**
@ -47,12 +46,11 @@ typedef struct {
*
* @param[out] dev device descriptor of an MQ-3 sensor
* @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 -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

9
drivers/mq3/mq3.c

@ -24,16 +24,15 @@
#define MIN (100U) /* 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_chan = channel;
return adc_init(dev->adc_dev, PRECISION);
dev->adc_line = adc_line;
return adc_init(dev->adc_line);
}
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)

Loading…
Cancel
Save