void adc_start_burst_conversion(uint8_t channels)
{
struct lpc_adc* adc = LPC_ADC;
+ uint32_t reg_val = 0;
- /* Set conversion channel bits */
- adc->ctrl = ((adc->ctrl & ~LPC_ADC_CHANNEL_MASK) | channels);
- adc->ctrl |= LPC_ADC_BURST;
+ /* Set conversion channel bits and burst mode */
+ reg_val = ((adc->ctrl & ~LPC_ADC_CHANNEL_MASK) | channels | LPC_ADC_BURST);
+ /* Clear single burst flag */
+ reg_val &= ~(LPC_ADC_SINGLE_BURST);
+
+ adc->ctrl = (reg_val & LPC_ADC_CTRL_MASK);
+}
+
+/* Start single burst conversions : triggers a single conversion for each of the
+ * selected channels.
+ * channels is a bit mask of requested channels.
+ * Use LPC_ADC_CHANNEL(x) (x = 0 .. 7) for channels selection.
+ */
+void adc_start_single_burst_conversion(uint8_t channels)
+{
+ struct lpc_adc* adc = LPC_ADC;
+ uint32_t reg_val = 0;
+
+ /* Set conversion channel bits and burst mode */
+ reg_val = ((adc->ctrl & ~LPC_ADC_CHANNEL_MASK) | channels);
+ reg_val |= (LPC_ADC_BURST | LPC_ADC_SINGLE_BURST);
+ adc->ctrl = (reg_val & LPC_ADC_CTRL_MASK);
}
+
/* Unsupported Yet */
/* This should be used to configure conversion start on falling or rising edges of
* some signals, or on timer for burst conversions.
#define LPC_ADC ((struct lpc_adc *) LPC_ADC_BASE)
/* ADC Control register bits */
+#define LPC_ADC_CTRL_MASK 0x0F01FFFF
/* LPC_ADC_CHANNEL_* are also used for interrupt register */
#define LPC_ADC_CHANNEL_MASK (0xFF << 0)
#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)
#define LPC_ADC_8BITS (0x02 << 17)
#define LPC_ADC_7BITS (0x03 << 17)
#define LPC_ADC_6BITS (0x04 << 17)
+#define LPC_ADC_5BITS (0x05 << 17)
+#define LPC_ADC_4BITS (0x06 << 17)
+#define LPC_ADC_3BITS (0x07 << 17)
+#define LPC_ADC_BITS_MASK (0x07 << 17)
+
+#define LPC_ADC_SINGLE_BURST (0x01 << 20)
+
#define LPC_ADC_START_CONV_NOW (0x01 << 24)
#define LPC_ADC_START_CONV_MASK (0x07 << 24)
#define LPC_ADC_OVERRUN (0x01 << 30)
#define LPC_ADC_CONV_DONE (0x01 << 31)
+/* For more readability when selecting a channel number */
+#define LPC_ADC_NUM(x) (x)
#endif /* LPC_REGS_H */
*/
void adc_start_burst_conversion(uint8_t channels);
+/* Start single burst conversions : triggers a single conversion for each of the
+ * selected channels.
+ * channels is a bit mask of requested channels.
+ * Use LPC_ADC_CHANNEL(x) (x = 0 .. 7) for channels selection.
+ */
+void adc_start_single_burst_conversion(uint8_t channels);
+
/* Unsupported Yet */
/* This should be used to configure conversion start on falling or rising edges of
* some signals, or on timer for burst conversions.