return;
/* Set conversion channel bit */
- adc->ctrl = ((adc->ctrl & ~LPC_ADC_CHANNEL_MASK) | (0x01 << channel));
+ adc->ctrl = ((adc->ctrl & ~LPC_ADC_CHANNEL_MASK) | LPC_ADC_CHANNEL(channel));
if (use_int) {
/* Set interrupt Bit */
- adc->int_en = (0x01 << channel);
+ adc->int_en = LPC_ADC_CHANNEL(channel);
} else {
adc->int_en = 0;
}
/* Start burst conversions.
* channels is a bit mask of requested channels.
- * Use LPC_ADC_CHANNEL_0 .. 7
+ * Use LPC_ADC_CHANNEL(x) (x = 0 .. 7) for channels selection.
*/
void adc_start_burst_conversion(uint8_t channels)
{
/* ADC Control register bits */
/* LPC_ADC_CHANNEL_* are also used for interrupt register */
#define LPC_ADC_CHANNEL_MASK (0xFF << 0)
-#define LPC_ADC_CHANNEL_0 (0x01 << 0)
-#define LPC_ADC_CHANNEL_1 (0x01 << 1)
-#define LPC_ADC_CHANNEL_2 (0x01 << 2)
-#define LPC_ADC_CHANNEL_3 (0x01 << 3)
-#define LPC_ADC_CHANNEL_4 (0x01 << 4)
-#define LPC_ADC_CHANNEL_5 (0x01 << 5)
-#define LPC_ADC_CHANNEL_6 (0x01 << 6)
-#define LPC_ADC_CHANNEL_7 (0x01 << 7)
+#define LPC_ADC_CHANNEL(x) (0x01 << ((x) & 0x07))
#define LPC_ADC_BURST (0x01 << 16)
+/* For more readability when selecting a channel number */
+#define LPC_ADC_NUM(x) (x)
/* These are unused for LPC1224 */
#define LPC_ADC_10BITS (0x00 << 17)
#define LPC_ADC_9BITS (0x01 << 17)
/* Start burst conversions.
* channels is a bit mask of requested channels.
- * Use LPC_ADC_CHANNEL_0 .. 7
+ * Use LPC_ADC_CHANNEL(x) (x = 0 .. 7) for channels selection.
*/
void adc_start_burst_conversion(uint8_t channels);