summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm
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
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')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_dma.h11
-rw-r--r--nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c9
-rw-r--r--nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c19
3 files changed, 32 insertions, 7 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_dma.h b/nuttx/arch/arm/src/stm32/stm32_dma.h
index 717c5ae1d..3e0afd7da 100644
--- a/nuttx/arch/arm/src/stm32/stm32_dma.h
+++ b/nuttx/arch/arm/src/stm32/stm32_dma.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/stm32/stm32_dma.h
*
- * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -126,6 +126,13 @@ extern "C" {
* 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 F1, this is simply the channel number as provided by
+ * the DMACHAN_* definitions in chip/stm32f10xxx_dma.h.
+ * 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 'chan' is valid, this function ALWAYS returns a non-NULL,
* void* DMA channel handle. (If 'chan' is invalid, the function will
@@ -138,7 +145,7 @@ extern "C" {
*
****************************************************************************/
-EXTERN DMA_HANDLE stm32_dmachannel(int chan);
+EXTERN DMA_HANDLE stm32_dmachannel(unsigned int chan);
/****************************************************************************
* Name: stm32_dmafree
diff --git a/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c
index eaa719e41..5094536c1 100644
--- a/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c
+++ b/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32f10xxx_dma.c
*
- * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -385,6 +385,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:
+ * chndx - Identifies the stream/channel resource. For the STM32 F1, this
+ * is simply the channel number as provided by the DMACHAN_* definitions
+ * in chip/stm32f10xxx_dma.h.
+ *
* Returned Value:
* Provided that 'chndx' is valid, this function ALWAYS returns a non-NULL,
* void* DMA channel handle. (If 'chndx' is invalid, the function will
@@ -397,7 +402,7 @@ void weak_function up_dmainitialize(void)
*
****************************************************************************/
-DMA_HANDLE stm32_dmachannel(int chndx)
+DMA_HANDLE stm32_dmachannel(unsigned int chndx)
{
struct stm32_dma_s *dmach = &g_dma[chndx];
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
*/