From 28d50790f29b2514e4d922d292375e77fcd34d45 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 24 Oct 2013 15:39:56 -0600 Subject: [PATCH] SAMA5D3x-EK: Add support for app/examples/adc --- ChangeLog | 3 +++ arch/arm/src/sama5/Kconfig | 27 +++++++++++++++------------ arch/arm/src/sama5/sam_adc.c | 21 +++++++++++---------- arch/arm/src/sama5/sam_adc.h | 7 +++++-- configs/sama5d3x-ek/src/Makefile | 4 ++++ 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9646fc40dd..2e1c0b8303 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5877,3 +5877,6 @@ * configs/freedom-kl25z/src/Makefile: Only build kl_wifi.c if CONFIG_WL_CC3000 is selected. From Alan Carvalho de Assis (2013-10-24). + * configs/sama5d3x-ek/src/sam_adc.c: Integrate support for the + apps/examples/adc into the SAMA5D3x-EK configuration (2013-10-24). + diff --git a/arch/arm/src/sama5/Kconfig b/arch/arm/src/sama5/Kconfig index 6da94442be..fb7d0378dd 100644 --- a/arch/arm/src/sama5/Kconfig +++ b/arch/arm/src/sama5/Kconfig @@ -1671,6 +1671,7 @@ if SAMA5_ADC_HAVE_CHAN config SAMA5_ADC_DMA bool "DMA Support" default n + depends on SAMA5_DMAC1 ---help--- Enable DMA transfers of converted data. This option is only useful if you have numerous DMA channels enabled. The end result @@ -1703,7 +1704,7 @@ menu "Channel gain" config SAMA5_ADC_GAIN0 int "Channel 0 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN0 range 0 3 ---help--- @@ -1714,7 +1715,7 @@ config SAMA5_ADC_GAIN0 config SAMA5_ADC_GAIN1 int "Channel 1 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN1 range 0 3 ---help--- @@ -1725,7 +1726,7 @@ config SAMA5_ADC_GAIN1 config SAMA5_ADC_GAIN2 int "Channel 2 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN2 range 0 3 ---help--- @@ -1736,7 +1737,7 @@ config SAMA5_ADC_GAIN2 config SAMA5_ADC_GAIN3 int "Channel 3 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN3 range 0 3 ---help--- @@ -1747,7 +1748,7 @@ config SAMA5_ADC_GAIN3 config SAMA5_ADC_GAIN4 int "Channel 4 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN4 range 0 3 ---help--- @@ -1758,7 +1759,7 @@ config SAMA5_ADC_GAIN4 config SAMA5_ADC_GAIN5 int "Channel 5 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN5 range 0 3 ---help--- @@ -1769,7 +1770,7 @@ config SAMA5_ADC_GAIN5 config SAMA5_ADC_GAIN6 int "Channel 6 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN6 range 0 3 ---help--- @@ -1780,7 +1781,7 @@ config SAMA5_ADC_GAIN6 config SAMA5_ADC_GAIN7 int "Channel 7 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN7 range 0 3 ---help--- @@ -1791,7 +1792,7 @@ config SAMA5_ADC_GAIN7 config SAMA5_ADC_GAIN8 int "Channel 8 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN8 range 0 3 ---help--- @@ -1802,7 +1803,7 @@ config SAMA5_ADC_GAIN8 config SAMA5_ADC_GAIN9 int "Channel 9 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN9 range 0 3 ---help--- @@ -1813,7 +1814,7 @@ config SAMA5_ADC_GAIN9 config SAMA5_ADC_GAIN10 int "Channel 10 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN10 range 0 3 ---help--- @@ -1824,7 +1825,7 @@ config SAMA5_ADC_GAIN10 config SAMA5_ADC_GAIN11 int "Channel 11 gain" - default 0 + default 1 depends on SAMA5_ADC_CHAN11 range 0 3 ---help--- @@ -2028,6 +2029,7 @@ if !SAMA5_ADC_ANARCH config SAMA5_ADC_GAIN int "Analog gain" + default 1 depends on SAMA5_ADC_CHAN0 range 0 3 ---help--- @@ -2263,6 +2265,7 @@ menu "Touchscreen configuration" config SAMA5_TSD bool "Touchscreen support" default n + depends on !SAMA5_ADC_HAVE_CHAN || EXPERIMENTAL select INPUT ---help--- Configure the ADC to support a touchscreen diff --git a/arch/arm/src/sama5/sam_adc.c b/arch/arm/src/sama5/sam_adc.c index 916752a4b5..3530b2e129 100644 --- a/arch/arm/src/sama5/sam_adc.c +++ b/arch/arm/src/sama5/sam_adc.c @@ -482,11 +482,7 @@ static struct sam_adc_s g_adcpriv; #ifdef SAMA5_ADC_HAVE_CHANNELS /* ADC device instance */ -static struct adc_dev_s g_adcdev = -{ - .ad_ops = &g_adcops, - .ad_priv = &g_adcpriv, -}; +static struct adc_dev_s g_adcdev; #endif /**************************************************************************** @@ -1432,9 +1428,9 @@ static void sam_adc_offset(struct sam_adc_s *priv) static void sam_adc_gain(struct sam_adc_s *priv) { +#ifdef CONFIG_SAMA5_ADC_ANARCH uint32_t regval; -#ifdef CONFIG_SAMA5_ADC_ANARCH /* Set the gain for each enabled channel */ regval = 0; @@ -1724,7 +1720,7 @@ static void sam_adc_channels(struct sam_adc_s *priv) ****************************************************************************/ /**************************************************************************** - * Name: sam_adcinitialize + * Name: sam_adc_initialize * * Description: * Initialize the adc @@ -1734,7 +1730,7 @@ static void sam_adc_channels(struct sam_adc_s *priv) * ****************************************************************************/ -struct sam_adc_s *sam_adc_initialize(void) +struct adc_dev_s *sam_adc_initialize(void) { struct sam_adc_s *priv = &g_adcpriv; uint32_t regval; @@ -1793,7 +1789,12 @@ struct sam_adc_s *sam_adc_initialize(void) sam_configpio(PIO_ADC_TRG); #endif - /* Initialize the ADC device data structure */ + /* Initialize the public ADC device data structure */ + + g_adcdev.ad_ops = &g_adcops; + g_adcdev.ad_priv = &priv; + + /* Initialize the private ADC device data structure */ sem_init(&priv->exclsem, 0, 1); priv->dev = &g_adcdev; @@ -1872,7 +1873,7 @@ struct sam_adc_s *sam_adc_initialize(void) /* Return a pointer to the device structure */ - return priv; + return &g_adcdev; } /**************************************************************************** diff --git a/arch/arm/src/sama5/sam_adc.h b/arch/arm/src/sama5/sam_adc.h index 089da16ea9..f8ba29f157 100644 --- a/arch/arm/src/sama5/sam_adc.h +++ b/arch/arm/src/sama5/sam_adc.h @@ -41,6 +41,9 @@ ****************************************************************************/ #include + +#include + #include "chip/sam_adc.h" #ifdef CONFIG_SAMA5_ADC @@ -120,8 +123,7 @@ extern "C" * ****************************************************************************/ -struct sam_adc_s; -FAR struct sam_adc_s *sam_adc_initialize(void); +FAR struct adc_dev_s *sam_adc_initialize(void); /**************************************************************************** * Interfaces exported from the ADC to the touchscreen driver @@ -135,6 +137,7 @@ FAR struct sam_adc_s *sam_adc_initialize(void); * ****************************************************************************/ +struct sam_adc_s; void sam_adc_lock(FAR struct sam_adc_s *priv); /**************************************************************************** diff --git a/configs/sama5d3x-ek/src/Makefile b/configs/sama5d3x-ek/src/Makefile index 37fce7939a..53d37be295 100644 --- a/configs/sama5d3x-ek/src/Makefile +++ b/configs/sama5d3x-ek/src/Makefile @@ -106,6 +106,10 @@ ifeq ($(CONFIG_NSH_ARCHINIT),y) CSRCS += sam_nsh.c endif +ifeq ($(CONFIG_ADC),y) +CSRCS += sam_adc.c +endif + ifeq ($(CONFIG_USBMSC),y) CSRCS += sam_usbmsc.c endif