From 91e1037e97ff83bbab953c24fc51f14d6e29a02a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 8 Mar 2013 11:11:23 +0000 Subject: EQADC driver starts responding. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5382 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.c | 14 ++++++++++---- os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.h | 17 +++++++++-------- testhal/SPC563Mxx/ADC/.cproject | 6 +++++- testhal/SPC563Mxx/ADC/Makefile | 2 +- testhal/SPC563Mxx/ADC/main.c | 8 +++----- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.c b/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.c index 1de887ab7..96a527b61 100644 --- a/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.c +++ b/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.c @@ -619,10 +619,6 @@ void adc_lld_start(ADCDriver *adcp) { chDbgAssert((adcp->cfifo_channel != EDMA_ERROR) && (adcp->rfifo_channel != EDMA_ERROR), "adc_lld_start(), #2", "channel cannot be allocated"); - - /* HW triggers setup.*/ - SIU.ETISR.R = adcp->config->etisr; - SIU.ISEL3.R = adcp->config->isel3; } /** @@ -660,6 +656,7 @@ void adc_lld_stop(ADCDriver *adcp) { * @notapi */ void adc_lld_start_conversion(ADCDriver *adcp) { + uint32_t bitoff; chDbgAssert(adcp->grpp->num_iterations >= adcp->depth, "adc_lld_start_conversion(), #1", "too many elements"); @@ -699,6 +696,15 @@ void adc_lld_start_conversion(ADCDriver *adcp) { EDMA_TCD_MODE_DREQ | EDMA_TCD_MODE_INT_END | ((adcp->depth > 1) ? EDMA_TCD_MODE_INT_HALF: 0));/* mode.*/ + + /* HW triggers setup.*/ + bitoff = 20 + ((uint32_t)adcp->fifo * 2); + SIU.ETISR.R = (SIU.ETISR.R & ~(3U << bitoff)) | + (adcp->grpp->tsel << bitoff); + bitoff = (uint32_t)adcp->fifo * 5; + SIU.ISEL3.R = (SIU.ISEL3.R & ~(31U << bitoff)) | + (adcp->grpp->etsel << bitoff); + /* Starting DMA channels.*/ edmaChannelStart(adcp->rfifo_channel); edmaChannelStart(adcp->cfifo_channel); diff --git a/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.h b/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.h index 98bf63c12..7c04fa56a 100644 --- a/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.h +++ b/os/hal/platforms/SPC5xx/EQADC_v1/adc_lld.h @@ -553,6 +553,14 @@ typedef struct { * @brief Initialization value for CFCR register. */ uint16_t cfcr; + /** + * @brief SIU ETISR.TSEL value for this queue; + */ + uint8_t tsel; + /** + * @brief SIU ISEL3.ETSEL value for this queue; + */ + uint8_t etsel; /** * @brief Number of command iterations stored in @p commands. * @note The total number of array elements must be @p num_channels * @@ -574,14 +582,7 @@ typedef struct { * @note It could be empty on some architectures. */ typedef struct { - /** - * @brief ETISR register value for the session. - */ - uint32_t etisr; - /** - * @brief ISEL3 register value for the session. - */ - uint32_t isel3; + uint32_t dummy; } ADCConfig; /** diff --git a/testhal/SPC563Mxx/ADC/.cproject b/testhal/SPC563Mxx/ADC/.cproject index e53532a36..57b44e9a8 100644 --- a/testhal/SPC563Mxx/ADC/.cproject +++ b/testhal/SPC563Mxx/ADC/.cproject @@ -47,6 +47,10 @@ - + + + + + diff --git a/testhal/SPC563Mxx/ADC/Makefile b/testhal/SPC563Mxx/ADC/Makefile index 39c0bca1a..4a009578f 100644 --- a/testhal/SPC563Mxx/ADC/Makefile +++ b/testhal/SPC563Mxx/ADC/Makefile @@ -5,7 +5,7 @@ # Compiler options here. ifeq ($(USE_OPT),) - USE_OPT = -O1 -ggdb -fomit-frame-pointer -falign-functions=16 + USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 endif # C specific options here (added to USE_OPT). diff --git a/testhal/SPC563Mxx/ADC/main.c b/testhal/SPC563Mxx/ADC/main.c index e7e7f8fb3..076d506d7 100644 --- a/testhal/SPC563Mxx/ADC/main.c +++ b/testhal/SPC563Mxx/ADC/main.c @@ -27,8 +27,6 @@ //#define ADC_GRP2_NUM_CHANNELS 8 //#define ADC_GRP2_BUF_DEPTH 16 -static ADCConfig adccfg1 = {0, 0}; - static adcsample_t samples1[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH]; //static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH]; @@ -236,8 +234,8 @@ static const ADCConversionGroup adcgrpcfg1 = { ADC_GRP1_NUM_CHANNELS, NULL, adcerrorcallback, -// EQADC_CFCR_SSE | EQADC_CFCR_MODE_SWSS, EQADC_CFCR_MODE_SWCS, + 0, 0, /* ISEL, EISEL.*/ ADC_GRP1_BUF_DEPTH, adcgrpcfg1_commands }; @@ -298,9 +296,9 @@ int main(void) { chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); /* - * Activates the ADC1 driver and the temperature sensor. + * Activates the ADC1 driver (unit zero queue zero). */ - adcStart(&ADCD1, &adccfg1); + adcStart(&ADCD1, NULL); /* * Linear conversion. -- cgit v1.2.3