aboutsummaryrefslogtreecommitdiffstats
path: root/src/wiring/wiring_analog.c
diff options
context:
space:
mode:
authorPerry Hung <iperry@alum.mit.edu>2010-03-23 00:55:40 -0400
committerPerry Hung <iperry@alum.mit.edu>2010-03-23 01:25:00 -0400
commit3639ad2cf027da7425ebe76382842c006acec05a (patch)
tree65682fc68e0625c4ff41f7cdc169482ec6d77672 /src/wiring/wiring_analog.c
parent48be688f451e81d2a81c76a85dadf18093e672ab (diff)
downloadlibrambutan-3639ad2cf027da7425ebe76382842c006acec05a.tar.gz
librambutan-3639ad2cf027da7425ebe76382842c006acec05a.zip
Unified analog, digital, and timer pin mappings to implement the mapping
we discussed. There's no such thing as A0-A15 anymore. You should now be able to do something like: unsigned int val; pinMode(15, INPUT_ANALOG); val = analogRead(15);
Diffstat (limited to 'src/wiring/wiring_analog.c')
-rw-r--r--src/wiring/wiring_analog.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/wiring/wiring_analog.c b/src/wiring/wiring_analog.c
index 0426f85..d7d7150 100644
--- a/src/wiring/wiring_analog.c
+++ b/src/wiring/wiring_analog.c
@@ -25,27 +25,9 @@
#include "libmaple.h"
#include "wiring.h"
-#include "adc.h"
+#include "io.h"
-/* Indexed by pins A[0-15] */
-uint32_t PIN_TO_ADC[NR_ANALOG_PINS] = {
- 10, // A0/D14 ADC10
- 11, // A1/D15 ADC11
- 12, // A2/D16 ADC12
- 13, // A3/D17 ADC13
- 14, // A4/D18 ADC14
- 15, // A5/D19 ADC15
- 3, // A6/D0 ADC3
- 2, // A7/D1 ADC2
- 0, // A8/D2 ADC0
- 1, // A9/D3 ADC1
- 4, // A10/D10 ADC4
- 7, // A11/D11 ADC7
- 6, // A12/D12 ADC6
- 5, // A13/D13 ADC5
- 8, // A14/D26 ADC8
- 9, // A15/D11 ADC9
-};
+extern const PinMapping PIN_MAP[NR_MAPLE_PINS];
/* Assumes that the ADC has been initialized and
* that the pin is set to ANALOG_INPUT */
@@ -53,5 +35,5 @@ uint32_t analogRead(uint8_t pin) {
if (pin >= NR_ANALOG_PINS)
return 0;
- return adc_read(PIN_TO_ADC[pin]);
+ return adc_read(PIN_MAP[pin].adc);
}