Fix error in STM32 DMA driver stream index calculation

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4405 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-02-19 18:04:25 +00:00
parent a7d27685a4
commit 12fd26bd67
3 changed files with 32 additions and 7 deletions

View File

@ -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

View File

@ -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];

View File

@ -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
*/