Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
da251ade
Commit
da251ade
authored
11 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
SAMA5 ADC: If DMA is enabled, then you should be able to configuration larger DMA transfers
parent
13ec431d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arch/arm/src/sama5/Kconfig
+26
-0
26 additions, 0 deletions
arch/arm/src/sama5/Kconfig
arch/arm/src/sama5/sam_adc.c
+19
-6
19 additions, 6 deletions
arch/arm/src/sama5/sam_adc.c
with
45 additions
and
6 deletions
arch/arm/src/sama5/Kconfig
+
26
−
0
View file @
da251ade
...
...
@@ -1678,6 +1678,32 @@ config SAMA5_ADC_DMA
is that there will be one DMA interrupt per conversion sequence vs.
one interrupt per conversion.
config SAMA5_ADC_DMASAMPLES
int "Number of DMA samples"
default 2
depends on SAMA5_ADC_DMA
---help---
If DMA is enabled, then this will specify the number of sample to
collect before the DMA completes. This is actually the number of
triggers; the number of collected samples will be this value times
the number of channels that are enabled. You should also enable the
sequencer if you are DMAing multiple channels.
A value of "1" would DMA one set of samples. That is not advised.
In that case the processing and data transfer overhead would be
greater than if DMA were disabled. A value of 2 or more should be
selected.
The DMA logic uses ping-pong buffers, so the total buffering
requirement will be
2 Buffers * Number_of_ADC_Channels * SAMA5_ADC_DMASAMPLES * sizeof(uint32_t)
So, for example, if you had 8 ADC channels and 8 triggers per DMA
transfer, then the total DMA buffering requirment would be:
2 * 8 * 8 * 4 = 512 bytes.
config SAMA5_ADC_AUTOCALIB
bool "ADC auto-calibration"
default n
...
...
This diff is collapsed.
Click to expand it.
arch/arm/src/sama5/sam_adc.c
+
19
−
6
View file @
da251ade
...
...
@@ -357,6 +357,19 @@
# undef SAMA5_ADC_UNUSED
#endif
/* Number of DMA samples to collect */
#if !defined(CONFIG_SAMA5_ADC_DMA)
# undef CONFIG_SAMA5_ADC_DMASAMPLES
# define CONFIG_SAMA5_ADC_DMASAMPLES 1
#elif !defined(CONFIG_SAMA5_ADC_DMASAMPLES)
# error CONFIG_SAMA5_ADC_DMASAMPLES must be defined
#elif CONFIG_SAMA5_ADC_DMASAMPLES < 2
# warning Values of ONFIG_SAMA5_ADC_DMASAMPLES < 2 are inefficient
#endif
#define SAMA5_ADC_SAMPLES (CONFIG_SAMA5_ADC_DMASAMPLES * SAMA5_NCHANNELS)
/* Clocking */
#if BOARD_MCK_FREQUENCY <= SAM_ADC_MAXPERCLK
...
...
@@ -405,8 +418,8 @@ struct sam_adc_s
/* DMA sample data buffer */
#ifdef CONFIG_SAMA5_ADC_DMA
uint32_t
evenbuf
[
SAMA5_
NCHANNEL
S
];
uint32_t
oddbuf
[
SAMA5_
NCHANNEL
S
];
uint32_t
evenbuf
[
SAMA5_
ADC_SAMPLE
S
];
uint32_t
oddbuf
[
SAMA5_
ADC_SAMPLE
S
];
#endif
#endif
/* SAMA5_ADC_HAVE_CHANNELS */
...
...
@@ -617,11 +630,11 @@ static void sam_adc_dmadone(void *arg)
*/
cp15_invalidate_dcache
((
uintptr_t
)
buffer
,
(
uintptr_t
)
buffer
+
SAMA5_
NCHANNEL
S
*
sizeof
(
uint32_t
));
(
uintptr_t
)
buffer
+
SAMA5_
ADC_SAMPLE
S
*
sizeof
(
uint32_t
));
/* Process each sample */
for
(
i
=
0
;
i
<
SAMA5_
NCHANNEL
S
;
i
++
,
buffer
++
)
for
(
i
=
0
;
i
<
SAMA5_
ADC_SAMPLE
S
;
i
++
,
buffer
++
)
{
/* Get the sample and the channel number */
...
...
@@ -684,7 +697,7 @@ static void sam_adc_dmacallback(DMA_HANDLE handle, void *arg, int result)
sam_adc_dmasetup
(
priv
->
dma
,
priv
->
odd
?
(
void
*
)
priv
->
oddbuf
:
(
void
*
)
priv
->
evenbuf
,
SAMA5_
NCHANNEL
S
*
sizeof
(
uint32_t
));
SAMA5_
ADC_SAMPLE
S
*
sizeof
(
uint32_t
));
}
#endif
...
...
@@ -1008,7 +1021,7 @@ static int sam_adc_setup(struct adc_dev_s *dev)
priv
->
ready
=
true
;
priv
->
enabled
=
false
;
sam_adc_dmasetup
(
priv
,
(
void
*
)
priv
->
evenbuf
,
SAMA5_
NCHANNEL
S
);
sam_adc_dmasetup
(
priv
,
(
void
*
)
priv
->
evenbuf
,
SAMA5_
ADC_SAMPLE
S
);
#else
/* Enable end-of-conversion interrupts for all enabled channels. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment