FastAnalogIn
Fork of FastAnalogIn by
Diff: FastAnalogIn_LPC11UXX.cpp
- Revision:
- 11:14744c4ac884
- Parent:
- 10:afc3b84dbbd6
- Child:
- 12:46fbc645de4d
diff -r afc3b84dbbd6 -r 14744c4ac884 FastAnalogIn_LPC11UXX.cpp --- a/FastAnalogIn_LPC11UXX.cpp Tue Nov 04 17:53:25 2014 +0000 +++ b/FastAnalogIn_LPC11UXX.cpp Sun Mar 20 20:18:12 2016 +0000 @@ -1,4 +1,4 @@ -#ifdef TARGET_LPC11UXX +#if defined(TARGET_LPC11UXX) || defined (TARGET_LPC11XX) #include "FastAnalogIn.h" static inline int div_round_up(int x, int y) @@ -10,6 +10,7 @@ #define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60) #define MAX_ADC_CLK 4500000 +#ifdef TARGET_LPC11UXX static const PinMap PinMap_ADC[] = { {P0_11, ADC0_0, 0x02}, {P0_12, ADC0_1, 0x02}, @@ -21,6 +22,19 @@ {P0_23, ADC0_7, 0x01}, {NC , NC , 0 } }; +#else +static const PinMap PinMap_ADC[] = { + {P0_11, ADC0_0, 2}, + {P1_0 , ADC0_1, 2}, + {P1_1 , ADC0_2, 2}, + {P1_2 , ADC0_3, 2}, + // {P1_3 , ADC0_4, 2}, -- should be mapped to SWDIO only + {P1_4 , ADC0_5, 1}, + {P1_10, ADC0_6, 1}, + {P1_11, ADC0_7, 1}, + {NC , NC , 0} +}; +#endif static int channel_usage[8] = {0,0,0,0,0,0,0,0}; @@ -31,7 +45,13 @@ ADCnumber = (ADCName)pinmap_peripheral(pin, PinMap_ADC); if (ADCnumber == (uint32_t)NC) error("ADC pin mapping failed"); + + //Seriously software people, can't you guys never keep the namings the same? + #ifdef TARGET_LPC11UXX datareg = (uint32_t*) (&LPC_ADC->DR0 + ADCnumber); + #else + datareg = (uint32_t*) (&LPC_ADC->DR[ADCnumber]); + #endif // Power up ADC LPC_SYSCON->PDRUNCFG &= ~ (1 << 4);