2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
13 #include "PinNames.h" // mbed.h lib
22 // define how many bits of extra resolution required
23 // 2 bits means the 12bit ADC is 14 bits of resolution
30 void enable_pin(Pin
*pin
);
31 unsigned int read(Pin
*pin
);
34 void new_sample(int chan
, uint32_t value
);
35 // return the maximum ADC value, base is 12bits 4095.
37 int get_max_value() const { return 4095 << OVERSAMPLE
;}
39 int get_max_value() const { return 4095;}
43 PinName
_pin_to_pinname(Pin
*pin
);
46 static const int num_channels
= 6;
48 // we need 4^n sample to oversample and we get double that to filter out spikes
49 static const int num_samples
= powf(4, OVERSAMPLE
)*2;
51 static const int num_samples
= 8;
53 // buffers storing the last num_samples readings for each channel
54 uint16_t sample_buffers
[num_channels
][num_samples
];