stm32_dma.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef _DEV_STM32_DMA_H
  2. #define _DEV_STM32_DMA_H
  3. /*
  4. * Copyright (C) 2010 by Ulrich Prinz (uprinz2@netscape.net)
  5. * Copyright (C) 2010 by Nikolaj Zamotaev. All rights reserved.
  6. * Copyright (C) 2012-2013 Uwe Bonnes(bon@elektron.ikp.physik.tu-darmstadt.de)
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  25. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. *
  36. */
  37. /*
  38. * \verbatim
  39. * $Id$
  40. * \endverbatim
  41. */
  42. #include <cfg/arch.h>
  43. #include <arch/cm3/stm/stm32_irqreg.h>
  44. #if defined(MCU_STM32F0) || defined(MCU_STM32F1) || \
  45. defined(MCU_STM32L1) || defined(MCU_STM32F3)
  46. #include <arch/cm3/stm/stm32f1_dma.h>
  47. #elif defined(MCU_STM32F2)||defined(MCU_STM32F4)
  48. #include <arch/cm3/stm/stm32f2_dma.h>
  49. #else
  50. #warning "STM32 family has no implemented DMA"
  51. #endif
  52. /*!
  53. * \brief STM32 DMA Status and Interrupt Flags.
  54. */
  55. #define DMA_TEIF 0x8 /*< Channel x Transfer Error Flag */
  56. #define DMA_HTIF 0x4 /*< Channel x Half Transfer Complete Flag */
  57. #define DMA_TCIF 0x2 /*< Channel x Transfer Complete Flag */
  58. #define DMA_GIF 0x1 /*< Channel x Global Interrupt Flag */
  59. #define DMA_FLAGMASK 0xF
  60. #define DMA_IRQMASK 0x1
  61. /*
  62. * DMA Handles and Interrupt Entry Points
  63. */
  64. extern void Dma1IrqEntry(void *arg);
  65. #ifdef STM_HAS_DMA2
  66. extern void Dma2IrqEntry(void *arg);
  67. #endif
  68. /*
  69. * DMA Control Functions
  70. */
  71. void DMA_Setup( uint8_t ch, void* dst, void* src, uint16_t length, uint32_t flags);
  72. void DMA_Enable(uint8_t ch);
  73. void DMA_Disable(uint8_t ch);
  74. void DMA_Init(void);
  75. void DMA_IrqMask( uint8_t ch, uint32_t mask, uint8_t ena);
  76. void DMA_ClearFlag( uint8_t ch, uint32_t flags);
  77. uint32_t DMA_GetFlag( uint8_t ch);
  78. #endif