disabled reading analog inputs with burst mode (for now at least)
diff --git a/gyro_board/src/usb/analog.c b/gyro_board/src/usb/analog.c
index b2ab48f..8dcaf26 100644
--- a/gyro_board/src/usb/analog.c
+++ b/gyro_board/src/usb/analog.c
@@ -2,19 +2,32 @@
#include "LPC17xx.h"
+#define USE_BURST 0
+
void analog_init(void) {
SC->PCONP |= PCONP_PCAD;
- // Enable AD0.0, AD0.1, AD0.2, AD0.3
+ // Enable AD0.0, AD0.1, AD0.2, and AD0.3.
PINCON->PINSEL1 &= ~(3 << 14 | 3 << 16 | 3 << 18 | 3 << 20);
PINCON->PINSEL1 |= 1 << 14 | 1 << 16 | 1 << 18 | 1 << 20;
+
+#if USE_BURST
ADC->ADCR = (1 << 0 | 1 << 1 | 1 << 2 | 1 << 3) /* enable all 4 */ |
7 << 8 /* 100MHz / 8 = 12.5MHz */ |
1 << 16 /* enable burst mode */ |
1 << 21 /* turn on ADC */;
+#else
+ ADC->ADCR = 7 << 8 /* 100MHz / 8 = 12.5MHz */ |
+ 1 << 21 /* turn on ADC */;
+#endif
}
uint16_t analog(int channel) {
+#if !USE_BURST
+ // Set the channel number to the one we want.
+ ADC->ADCR = (ADC->ADCR & ~0xFF) | (1 << channel);
+ ADC->ADCR |= 1 << 24; // start conversion
+#endif
uint32_t value;
do {
switch (channel) {