summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-19 18:04:25 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-19 18:04:25 +0000
commit56959ae057f6711bdd709758b798e64489e8af60 (patch)
tree773accb63916ecc53b27ea83f20e708e46b1e75c /nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c
parentd7ea71908198fbe6ed03df12eb3ce2b77a8945dc (diff)
downloadpx4-nuttx-56959ae057f6711bdd709758b798e64489e8af60.tar.gz
px4-nuttx-56959ae057f6711bdd709758b798e64489e8af60.tar.bz2
px4-nuttx-56959ae057f6711bdd709758b798e64489e8af60.zip
Fix error in STM32 DMA driver stream index calculation
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4405 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c
index 8dedde3ac..d92903104 100644
--- a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c
+++ b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32f40xxx_dma.c
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -427,6 +427,11 @@ void weak_function up_dmainitialize(void)
* Hmm.. I suppose this interface could be extended to make a non-blocking
* version. Feel free to do that if that is what you need.
*
+ * Input parameter:
+ * chan - Identifies the stream/channel resource. For the STM32 F4, this
+ * is a bit-encoded value as provided by the the DMAMAP_* definitions
+ * in chip/stm32f40xxx_dma.h
+ *
* Returned Value:
* Provided that 'stndx' is valid, this function ALWAYS returns a non-NULL,
* void* DMA channel handle. (If 'stndx' is invalid, the function will
@@ -439,12 +444,20 @@ void weak_function up_dmainitialize(void)
*
****************************************************************************/
-DMA_HANDLE stm32_dmachannel(int stndx)
+DMA_HANDLE stm32_dmachannel(unsigned int chan)
{
- struct stm32_dma_s *dmast = &g_dma[stndx];
+ struct stm32_dma_s *dmast;
+ int stndx;
+
+ /* Get the stream index from the bit-encoded channel value */
+ stndx = STM32_DMA_STREAM(chan);
DEBUGASSERT(stndx < DMA_NSTREAMS);
+ /* Then get the stream structure associated with the stream index */
+
+ dmast = &g_dma[stndx];
+
/* Get exclusive access to the DMA channel -- OR wait until the channel
* is available if it is currently being used by another driver
*/