* 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
*/
#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 */
ADC_CHER = BV(ch);
}
-
/**
* Start an ADC convertion.
*/
/* Clock ADC peripheral */
pmc_periphEnable(ADC_ID);
-
/* Reset adc controller */
ADC_CR = ADC_SWRST;
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. */
*
* SAM3 Analog to Digital Converter.
*
+ * $WIZ$
+ *
*/
#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.
#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.
* 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
*/
#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 */