2011-09-18 00:49:00 -03:00
|
|
|
#ifndef AP_ADC_H
|
|
|
|
#define AP_ADC_H
|
|
|
|
|
2011-09-15 00:01:45 -03:00
|
|
|
#include <stdint.h>
|
2011-11-12 23:12:53 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <../AP_PeriodicProcess/AP_PeriodicProcess.h>
|
2011-09-15 00:01:45 -03:00
|
|
|
|
2011-09-18 00:49:00 -03:00
|
|
|
/*
|
|
|
|
AP_ADC.cpp - Analog Digital Converter Base Class for Ardupilot Mega
|
|
|
|
Code by James Goppert. DIYDrones.com
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
Methods:
|
|
|
|
Init() : Initialization of ADC. (interrupts etc)
|
|
|
|
Ch(ch_num) : Return the ADC channel value
|
2011-09-15 00:01:45 -03:00
|
|
|
Ch6(channel_numbers, result) : Return 6 ADC channel values
|
2011-09-18 00:49:00 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
class AP_ADC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AP_ADC() {}; // Constructor
|
2011-11-12 23:12:53 -04:00
|
|
|
virtual void Init(AP_PeriodicProcess * scheduler = NULL) = 0;
|
2011-09-15 00:01:45 -03:00
|
|
|
|
|
|
|
/* read one channel value */
|
2011-12-10 06:43:57 -04:00
|
|
|
virtual float Ch(uint8_t ch_num) = 0;
|
2011-09-15 00:01:45 -03:00
|
|
|
|
|
|
|
/* read 6 channels values as a set, used by IMU for 3 gyros
|
|
|
|
and 3 accelerometeres.
|
|
|
|
|
|
|
|
Pass in an array of 6 channel numbers and results are
|
|
|
|
returned in result[]
|
|
|
|
|
2011-09-15 05:45:51 -03:00
|
|
|
The function returns the amount of time (in microseconds)
|
|
|
|
since the last call to Ch6().
|
2011-12-16 05:08:37 -04:00
|
|
|
|
|
|
|
NOTE: You must enable the channels using enable_channel()
|
|
|
|
before use
|
2011-09-15 00:01:45 -03:00
|
|
|
*/
|
|
|
|
virtual uint32_t Ch6(const uint8_t *channel_numbers, uint16_t *result) = 0;
|
2011-09-15 05:45:51 -03:00
|
|
|
|
2011-12-16 05:08:37 -04:00
|
|
|
virtual void enable_channel(const uint8_t ch) = 0;
|
|
|
|
|
2011-09-15 00:01:45 -03:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2011-09-18 00:49:00 -03:00
|
|
|
#include "AP_ADC_ADS7844.h"
|
|
|
|
#include "AP_ADC_HIL.h"
|
|
|
|
|
|
|
|
#endif
|