From 0b7c0f050c5ad42a55fc3635d6ae44bda5bfe049 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 2 May 2015 12:57:07 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7937 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/STM32F4xx/DAC/halconf.h | 2 +- testhal/STM32/STM32F4xx/DAC/main.c | 22 ++++++++++++++++++++-- testhal/STM32/STM32F4xx/DAC/mcuconf.h | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/testhal/STM32/STM32F4xx/DAC/halconf.h b/testhal/STM32/STM32F4xx/DAC/halconf.h index a065d771d..28bd0e52d 100644 --- a/testhal/STM32/STM32F4xx/DAC/halconf.h +++ b/testhal/STM32/STM32F4xx/DAC/halconf.h @@ -69,7 +69,7 @@ * @brief Enables the GPT subsystem. */ #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -#define HAL_USE_GPT FALSE +#define HAL_USE_GPT TRUE #endif /** diff --git a/testhal/STM32/STM32F4xx/DAC/main.c b/testhal/STM32/STM32F4xx/DAC/main.c index 7371cbb2d..d35d42b83 100644 --- a/testhal/STM32/STM32F4xx/DAC/main.c +++ b/testhal/STM32/STM32F4xx/DAC/main.c @@ -90,6 +90,17 @@ static const DACConversionGroup daccfg1 = { trigger: DAC_TRG(0) }; + +/* + * GPT2 configuration. + */ +static const GPTConfig gpt6cfg1 = { + frequency: 1000000U, + callback: NULL, + cr2: TIM_CR2_MMS_1, /* MMS = 010 = TRGO on Update Event. */ + dier: 0U +}; + /* * Application entry point. */ @@ -106,16 +117,22 @@ int main(void) { chSysInit(); /* - * Starting DAC driver, setting up the output pin as analog as suggested + * Starting DAC1 driver, setting up the output pin as analog as suggested * by the Reference Manual. */ palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG); dacStart(&DACD1, NULL); /* - * Starting a continous conversion. + * Starting GPT6 driver, it is used for triggering the DAC. + */ + gptStart(&GPTD6, &gpt6cfg1); + + /* + * Starting a continuous conversion. */ dacStartConversion(&DACD1, &daccfg1, dac_buffer, DAC_BUFFER_SIZE); + gptStartContinuous(&GPTD6, 2U); /* * Normal main() thread activity, if the button is pressed then the I2s @@ -123,6 +140,7 @@ int main(void) { */ while (true) { if (palReadPad(GPIOA, GPIOA_BUTTON)) { + gptStopTimer(&GPTD6); dacStopConversion(&DACD1); } chThdSleepMilliseconds(500); diff --git a/testhal/STM32/STM32F4xx/DAC/mcuconf.h b/testhal/STM32/STM32F4xx/DAC/mcuconf.h index 419775ba1..a6bc10980 100644 --- a/testhal/STM32/STM32F4xx/DAC/mcuconf.h +++ b/testhal/STM32/STM32F4xx/DAC/mcuconf.h @@ -129,7 +129,7 @@ #define STM32_GPT_USE_TIM3 FALSE #define STM32_GPT_USE_TIM4 FALSE #define STM32_GPT_USE_TIM5 FALSE -#define STM32_GPT_USE_TIM6 FALSE +#define STM32_GPT_USE_TIM6 TRUE #define STM32_GPT_USE_TIM7 FALSE #define STM32_GPT_USE_TIM8 FALSE #define STM32_GPT_USE_TIM9 FALSE -- cgit v1.2.3