From d74117450cddb98188b5adde758725ca1e640459 Mon Sep 17 00:00:00 2001 From: Rob Purchase Date: Mon, 7 Apr 2008 22:48:19 +0000 Subject: Make the TCC780x ADC driver work again in the bootloader. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17031 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/tcc780x/adc-tcc780x.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'firmware/target/arm/tcc780x/adc-tcc780x.c') diff --git a/firmware/target/arm/tcc780x/adc-tcc780x.c b/firmware/target/arm/tcc780x/adc-tcc780x.c index 62bc53e6c1..8c438e2689 100644 --- a/firmware/target/arm/tcc780x/adc-tcc780x.c +++ b/firmware/target/arm/tcc780x/adc-tcc780x.c @@ -63,7 +63,7 @@ unsigned short adc_read(int channel) { #ifdef BOOTLOADER /* IRQs aren't enabled in the bootloader - just do the read directly */ - int i,num; + int i; uint32_t adc_status; PCLK_ADC |= PCK_EN; /* Enable ADC clock */ @@ -72,15 +72,15 @@ unsigned short adc_read(int channel) for (i = 0; i < 4; i++) ADCCON = i; - /* Wait for data to become stable */ - while ((ADCDATA & 0x1) == 0); - - do + /* Now read the values back */ + for (i=0; i < 4; i++) { + /* Wait for data to become stable */ + while ((ADCDATA & 0x1) == 0); + adc_status = ADCSTATUS; - num = (adc_status>>24) & 7; - if (num) adcdata[(adc_status >> 16) & 0x7] = adc_status & 0x3ff; - } while (num); + adcdata[(adc_status >> 16) & 0x7] = adc_status & 0x3ff; + } PCLK_ADC &= ~PCK_EN; /* Disable ADC clock */ #endif @@ -93,10 +93,11 @@ void adc_init(void) /* consider configuring PCK_ADC source here */ ADCCON = (1<<4); /* Enter standby mode */ - ADCCFG |= 0x0000000B; /* Single-mode, auto power-down, IRQ enable */ + ADCCFG |= 0x00000003; /* Single-mode, auto power-down */ #ifndef BOOTLOADER - IEN |= ADC_IRQ_MASK; /* Enable ADC IRQs */ + ADCCFG |= (1<<3); /* Request IRQ on ADC completion */ + IEN |= ADC_IRQ_MASK; /* Unmask ADC IRQs */ tick_add_task(adc_tick); -- cgit v1.2.3