From: asterix Date: Mon, 21 Mar 2011 18:37:06 +0000 (+0000) Subject: Add flag to configure the adc with wizard. X-Git-Tag: 2.7.0~178 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=f7b9f562693460fca28061c13a40e2a363cf00f7;p=bertos.git Add flag to configure the adc with wizard. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4788 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cfg/cfg_adc.h b/bertos/cfg/cfg_adc.h index df2587be..62a65734 100644 --- a/bertos/cfg/cfg_adc.h +++ b/bertos/cfg/cfg_adc.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate + * library without restriction. Specifically, if other files instantiateboards/sam3x-ek/examples/display/main.c * templates or use macros or inline functions from this file, or you compile * this file and link it with other files to produce an executable, this * file does not by itself cause the resulting executable to be covered by @@ -109,4 +109,41 @@ */ #define CONFIG_ADC_STROBE 0 + +/** + * Start up timer[s] = startup value / ADCClock [Hz] + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "sam3_adc_sut" + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_SUT ADC_SUT512 + +/** + * Analog Settling Time[s] = settling value / ADCClock[Hz] + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "sam3_adc_stt" + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_STTLING ADC_AST17 + +/** + * Tracking Time[s] = (TRACKTIM + 1) / ADCClock[Hz] + * + * $WIZ$ type = "int" + * $WIZ$ min = 0 + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_TRACKTIM 0 + +/** + * Transfer Period[s] = (TRANSFER * 2 + 3) ADCClock[Hz] + * + * $WIZ$ type = "int" + * $WIZ$ min = 0 + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_TRANSFER 1 + #endif /* CFG_ADC_H */ diff --git a/bertos/cpu/cortex-m3/drv/adc_sam3.c b/bertos/cpu/cortex-m3/drv/adc_sam3.c index e1e43a97..512e978d 100644 --- a/bertos/cpu/cortex-m3/drv/adc_sam3.c +++ b/bertos/cpu/cortex-m3/drv/adc_sam3.c @@ -95,7 +95,6 @@ void adc_hw_select_ch(uint8_t ch) ADC_CHER = BV(ch); } - /** * Start an ADC convertion. */ @@ -120,7 +119,6 @@ void adc_hw_init(void) /* Clock ADC peripheral */ pmc_periphEnable(ADC_ID); - /* Reset adc controller */ ADC_CR = ADC_SWRST; @@ -144,13 +142,13 @@ void adc_hw_init(void) LOG_INFO("Computed ADC_CLOCK %ld\n", ADC_CLOCK); ADC_MR |= ((ADC_PRESCALER << ADC_PRESCALER_SHIFT) & ADC_PRESCALER_MASK); LOG_INFO("prescaler[%ld]\n", ADC_PRESCALER); - ADC_MR |= ((ADC_SUT512 << ADC_STARTUP_SHIFT) & ADC_STARTUP_MASK); + ADC_MR |= ((CONFIG_ADC_SUT << ADC_STARTUP_SHIFT) & ADC_STARTUP_MASK); LOG_INFO("starup[%d]\n", ADC_SUT512); - ADC_MR |= ((ADC_AST17 << ADC_SETTLING_SHIFT) & ADC_SETTLING_MASK); + ADC_MR |= ((CONFIG_ADC_STTLING << ADC_SETTLING_SHIFT) & ADC_SETTLING_MASK); LOG_INFO("sttime[%d]\n", ADC_AST17); - ADC_MR |= ((0 << ADC_TRACKTIM_SHIFT) & ADC_TRACKTIM_MASK); + ADC_MR |= ((CONFIG_ADC_TRACKTIM << ADC_TRACKTIM_SHIFT) & ADC_TRACKTIM_MASK); LOG_INFO("tracking[%d]\n", 0); - ADC_MR |= ((1 << ADC_TRANSFER_SHIFT) & ADC_TRANSFER_MASK); + ADC_MR |= ((CONFIG_ADC_TRANSFER << ADC_TRANSFER_SHIFT) & ADC_TRANSFER_MASK); LOG_INFO("tranfer[%d]\n", 1); /* Register and enable irq for adc. */ diff --git a/bertos/cpu/cortex-m3/io/sam3_adc.h b/bertos/cpu/cortex-m3/io/sam3_adc.h index 9a506b0a..47fcaed4 100644 --- a/bertos/cpu/cortex-m3/io/sam3_adc.h +++ b/bertos/cpu/cortex-m3/io/sam3_adc.h @@ -34,6 +34,8 @@ * * SAM3 Analog to Digital Converter. * + * $WIZ$ + * */ @@ -84,6 +86,11 @@ #define ADC_STARTUP_MASK 0x000F0000 ///< Start up timer mask. #define ADC_STARTUP_SHIFT 16 ///< Start up timer shift. +/** + * Start up timer. + * $WIZ$ sam3_adc_sut = "ADC_SUT0","ADC_SUT8","ADC_SUT16","ADC_SUT24","ADC_SUT64","DC_SUT80","ADC_SUT96","ADC_SUT112","ADC_SUT512","ADC_SUT576","ADC_SUT640","ADC_SUT704","ADC_SUT768","ADC_SUT832","ADC_SUT896","ADC_SUT960" + * \{ + */ #define ADC_SUT0 0 ///< 0 period of ADCClock. #define ADC_SUT8 1 ///< 8 period of ADCClock. #define ADC_SUT16 2 ///< 16 period of ADCClock. @@ -100,9 +107,11 @@ #define ADC_SUT832 13 ///< 832 period of ADCClock. #define ADC_SUT896 14 ///< 896 period of ADCClock. #define ADC_SUT960 15 ///< 896 period of ADCClock. +/** \} */ /** - * Analog Settling Time + * Analog Settling Time. + * $WIZ$ sam3_adc_stt = "ADC_AST3", "ADC_AST5", "ADC_AST9", "ADC_AST17" */ #define ADC_SETTLING_MASK 0x00300000 ///< Analog Settling Time mask. #define ADC_SETTLING_SHIFT 20 ///< Analog Settling Time shift. diff --git a/boards/sam3x-ek/examples/display/cfg/cfg_adc.h b/boards/sam3x-ek/examples/display/cfg/cfg_adc.h index df2587be..62a65734 100644 --- a/boards/sam3x-ek/examples/display/cfg/cfg_adc.h +++ b/boards/sam3x-ek/examples/display/cfg/cfg_adc.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate + * library without restriction. Specifically, if other files instantiateboards/sam3x-ek/examples/display/main.c * templates or use macros or inline functions from this file, or you compile * this file and link it with other files to produce an executable, this * file does not by itself cause the resulting executable to be covered by @@ -109,4 +109,41 @@ */ #define CONFIG_ADC_STROBE 0 + +/** + * Start up timer[s] = startup value / ADCClock [Hz] + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "sam3_adc_sut" + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_SUT ADC_SUT512 + +/** + * Analog Settling Time[s] = settling value / ADCClock[Hz] + * + * $WIZ$ type = "enum" + * $WIZ$ value_list = "sam3_adc_stt" + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_STTLING ADC_AST17 + +/** + * Tracking Time[s] = (TRACKTIM + 1) / ADCClock[Hz] + * + * $WIZ$ type = "int" + * $WIZ$ min = 0 + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_TRACKTIM 0 + +/** + * Transfer Period[s] = (TRANSFER * 2 + 3) ADCClock[Hz] + * + * $WIZ$ type = "int" + * $WIZ$ min = 0 + * $WIZ$ supports = "sam3" + */ +#define CONFIG_ADC_TRANSFER 1 + #endif /* CFG_ADC_H */