CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_ADC/AP_ADC_ADS1115.h
Views: 1798
1
#pragma once
2
3
#include <inttypes.h>
4
#include <AP_HAL/AP_HAL.h>
5
#include <AP_HAL/I2CDevice.h>
6
7
struct adc_report_s
8
{
9
uint8_t id;
10
float data;
11
};
12
13
class AP_ADC_ADS1115
14
{
15
public:
16
AP_ADC_ADS1115();
17
~AP_ADC_ADS1115();
18
19
bool init();
20
size_t read(adc_report_s *report, size_t length) const;
21
22
uint8_t get_channels_number() const
23
{
24
return _channels_number;
25
}
26
27
private:
28
static const uint8_t _channels_number;
29
30
AP_HAL::OwnPtr<AP_HAL::I2CDevice> _dev;
31
32
uint16_t _gain;
33
int _channel_to_read;
34
adc_report_s *_samples;
35
36
void _update();
37
bool _start_conversion(uint8_t channel);
38
39
float _convert_register_data_to_mv(int16_t word) const;
40
};
41
42