APM:Libraries
AP_ADC.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <AP_Common/AP_Common.h>
4 /*
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 /*
20  * AP_ADC.cpp - Analog Digital Converter Base Class for Ardupilot Mega
21  * Code by James Goppert. DIYDrones.com
22  *
23  * Methods:
24  * Init() : Initialization of ADC. (interrupts etc)
25  * Ch(ch_num) : Return the ADC channel value
26  * Ch6(channel_numbers, result) : Return 6 ADC channel values
27  */
28 
29 class AP_ADC
30 {
31 public:
32  AP_ADC() {
33  }; // Constructor
34  virtual void Init() = 0;
35 
36  /* read one channel value */
37  virtual float Ch(uint8_t ch_num) = 0;
38 
39  /* read 6 channels values as a set, used by IMU for 3 gyros
40  * and 3 accelerometeres.
41  *
42  * Pass in an array of 6 channel numbers and results are
43  * returned in result[]
44  *
45  * The function returns the amount of time (in microseconds)
46  * since the last call to Ch6().
47  */
48  virtual uint32_t Ch6(const uint8_t *channel_numbers, float *result) = 0;
49 
50  // check if Ch6() can return new data
51  virtual bool new_data_available(const uint8_t *channel_numbers) = 0;
52 
53  virtual uint16_t num_samples_available(const uint8_t *channel_numbers) = 0;
54 
55 private:
56 };
57 
58 #include "AP_ADC_ADS1115.h"
Definition: AP_ADC.h:29
AP_ADC()
Definition: AP_ADC.h:32
const char * result
Definition: Printf.cpp:16
virtual uint32_t Ch6(const uint8_t *channel_numbers, float *result)=0
Common definitions and utility routines for the ArduPilot libraries.
virtual float Ch(uint8_t ch_num)=0
virtual void Init()=0
virtual uint16_t num_samples_available(const uint8_t *channel_numbers)=0
virtual bool new_data_available(const uint8_t *channel_numbers)=0