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/>.
10 #include "libs/nuts_bolts.h"
11 #include "libs/Module.h"
12 #include "libs/Kernel.h"
14 #include "libs/ADC/adc.h"
17 // This is an interface to the mbed.org ADC library you can find in libs/ADC/adc.h
18 // TODO : Having the same name is confusing, should change that
21 this->adc
= new ADC(1000, 1);
24 // Enables ADC on a given pin
25 void Adc::enable_pin(Pin
* pin
){
26 PinName pin_name
= this->_pin_to_pinname(pin
);
28 this->adc
->setup(pin_name
,1);
29 this->adc
->interrupt_state(pin_name
,1);
32 // Read the last value ( burst mode ) on a given pin
33 unsigned int Adc::read(Pin
* pin
){
34 return this->adc
->read(this->_pin_to_pinname(pin
));
37 // Convert a smoothie Pin into a mBed Pin
38 PinName
Adc::_pin_to_pinname(Pin
* pin
){
39 if( pin
->port
== LPC_GPIO0
&& pin
->pin
== 23 ){
41 }else if( pin
->port
== LPC_GPIO0
&& pin
->pin
== 24 ){
43 }else if( pin
->port
== LPC_GPIO0
&& pin
->pin
== 25 ){
45 }else if( pin
->port
== LPC_GPIO0
&& pin
->pin
== 26 ){
47 }else if( pin
->port
== LPC_GPIO1
&& pin
->pin
== 30 ){
49 }else if( pin
->port
== LPC_GPIO1
&& pin
->pin
== 31 ){