mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/mq3: adapted to ADC driver changes
This commit is contained in:
parent
56c8e49fd2
commit
9bcfec9032
@ -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
|
||||
|
@ -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…
Reference in New Issue
Block a user