2011-12-16 04:30:46 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
#ifndef AP_ADC_ADS7844_H
|
|
|
|
#define AP_ADC_ADS7844_H
|
|
|
|
|
|
|
|
#define bit_set(p,m) ((p) |= ( 1<<m))
|
|
|
|
#define bit_clear(p,m) ((p) &= ~(1<<m))
|
|
|
|
|
|
|
|
// We use Serial Port 2 in SPI Mode
|
|
|
|
#define ADC_DATAOUT 51 // MOSI
|
|
|
|
#define ADC_DATAIN 50 // MISO
|
|
|
|
#define ADC_SPICLOCK 52 // SCK
|
|
|
|
#define ADC_CHIP_SELECT 33 // PC4 9 // PH6 Puerto:0x08 Bit mask : 0x40
|
|
|
|
|
|
|
|
// DO NOT CHANGE FROM 8!!
|
|
|
|
#define ADC_ACCEL_FILTER_SIZE 8
|
|
|
|
|
|
|
|
#include "AP_ADC.h"
|
2011-11-12 23:12:53 -04:00
|
|
|
#include "../AP_PeriodicProcess/AP_PeriodicProcess.h"
|
2011-12-16 04:30:46 -04:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
class AP_ADC_ADS7844 : public AP_ADC
|
|
|
|
{
|
2012-08-17 02:39:21 -03:00
|
|
|
public:
|
|
|
|
AP_ADC_ADS7844(); // Constructor
|
|
|
|
void Init( AP_PeriodicProcess * scheduler );
|
2011-12-16 04:30:46 -04:00
|
|
|
|
2012-08-17 02:39:21 -03:00
|
|
|
// Read 1 sensor value
|
|
|
|
float Ch(unsigned char ch_num);
|
2011-12-16 04:30:46 -04:00
|
|
|
|
2012-08-17 02:39:21 -03:00
|
|
|
// Read 6 sensors at once
|
|
|
|
uint32_t Ch6(const uint8_t *channel_numbers, float *result);
|
2012-03-03 03:31:09 -04:00
|
|
|
|
|
|
|
// check if Ch6 would block
|
2012-08-17 02:39:21 -03:00
|
|
|
bool new_data_available(const uint8_t *channel_numbers);
|
2012-03-03 03:31:09 -04:00
|
|
|
|
2012-08-30 04:50:03 -03:00
|
|
|
// Get minimum number of samples read from the sensors
|
|
|
|
uint16_t num_samples_available(const uint8_t *channel_numbers);
|
|
|
|
|
2012-08-17 02:39:21 -03:00
|
|
|
private:
|
|
|
|
static void read(uint32_t);
|
2011-12-16 04:30:46 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|