|
|
|
@ -1,26 +1,24 @@
@@ -1,26 +1,24 @@
|
|
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- |
|
|
|
|
/* |
|
|
|
|
Example of APM_ADC library. |
|
|
|
|
Code by Jordi Muñoz and Jose Julio. DIYDrones.com |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
Example of APM_ADC library. |
|
|
|
|
Code by Jordi Muñoz and Jose Julio. DIYDrones.com |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <FastSerial.h> |
|
|
|
|
#include <Arduino_Mega_ISR_Registry.h> |
|
|
|
|
#include <AP_PeriodicProcess.h> |
|
|
|
|
#include <AP_ADC.h> // ArduPilot Mega ADC Library |
|
|
|
|
|
|
|
|
|
#include <AP_ADC.h> // ArduPilot Mega ADC Library |
|
|
|
|
|
|
|
|
|
FastSerialPort0(Serial); // FTDI/console |
|
|
|
|
|
|
|
|
|
Arduino_Mega_ISR_Registry isr_registry; |
|
|
|
|
AP_PeriodicProcess adc_scheduler; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long timer; |
|
|
|
|
AP_ADC_ADS7844 adc; |
|
|
|
|
|
|
|
|
|
static const uint8_t channel_map[6] = { 1, 2, 0, 4, 5, 6}; |
|
|
|
|
|
|
|
|
|
void setup() |
|
|
|
|
AP_ADC_ADS7844 adc; |
|
|
|
|
|
|
|
|
|
void setup() |
|
|
|
|
{ |
|
|
|
|
Serial.begin(115200, 128, 128); |
|
|
|
|
Serial.println("ArduPilot Mega ADC library test"); |
|
|
|
@ -32,12 +30,9 @@ void setup()
@@ -32,12 +30,9 @@ void setup()
|
|
|
|
|
adc.Init(&adc_scheduler); // APM ADC initialization |
|
|
|
|
delay(1000); |
|
|
|
|
timer = millis(); |
|
|
|
|
|
|
|
|
|
for (uint8_t ch=0; ch<6; ch++) { |
|
|
|
|
adc.enable_channel(channel_map[ch]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const uint8_t channel_map[6] = { 1, 2, 0, 4, 5, 6}; |
|
|
|
|
float v; |
|
|
|
|
uint32_t last_usec = 0; |
|
|
|
|
|
|
|
|
|