hw_dmaaltd_regs.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * @brief DMA master ROM API declarations and functions
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2014
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licensor disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __HW_DMA_REGS_H_
  32. #define __HW_DMA_REGS_H_
  33. /**
  34. * @brief DMA Controller shared registers structure
  35. */
  36. typedef struct { /*!< DMA shared registers structure */
  37. volatile uint32_t ENABLESET; /*!< DMA Channel Enable read and Set for all DMA channels */
  38. volatile uint32_t RESERVED0;
  39. volatile uint32_t ENABLECLR; /*!< DMA Channel Enable Clear for all DMA channels */
  40. volatile uint32_t RESERVED1;
  41. volatile uint32_t ACTIVE; /*!< DMA Channel Active status for all DMA channels */
  42. volatile uint32_t RESERVED2;
  43. volatile uint32_t BUSY; /*!< DMA Channel Busy status for all DMA channels */
  44. volatile uint32_t RESERVED3;
  45. volatile uint32_t ERRINT; /*!< DMA Error Interrupt status for all DMA channels */
  46. volatile uint32_t RESERVED4;
  47. volatile uint32_t INTENSET; /*!< DMA Interrupt Enable read and Set for all DMA channels */
  48. volatile uint32_t RESERVED5;
  49. volatile uint32_t INTENCLR; /*!< DMA Interrupt Enable Clear for all DMA channels */
  50. volatile uint32_t RESERVED6;
  51. volatile uint32_t INTA; /*!< DMA Interrupt A status for all DMA channels */
  52. volatile uint32_t RESERVED7;
  53. volatile uint32_t INTB; /*!< DMA Interrupt B status for all DMA channels */
  54. volatile uint32_t RESERVED8;
  55. volatile uint32_t SETVALID; /*!< DMA Set ValidPending control bits for all DMA channels */
  56. volatile uint32_t RESERVED9;
  57. volatile uint32_t SETTRIG; /*!< DMA Set Trigger control bits for all DMA channels */
  58. volatile uint32_t RESERVED10;
  59. volatile uint32_t ABORT; /*!< DMA Channel Abort control for all DMA channels */
  60. } LPC_DMA_COMMON_T;
  61. /**
  62. * @brief DMA Controller shared registers structure
  63. */
  64. typedef struct { /*!< DMA channel register structure */
  65. volatile uint32_t CFG; /*!< DMA Configuration register */
  66. volatile uint32_t CTLSTAT; /*!< DMA Control and status register */
  67. volatile uint32_t XFERCFG; /*!< DMA Transfer configuration register */
  68. volatile uint32_t RESERVED;
  69. } LPC_DMA_CHANNEL_T;
  70. /* On LPC540XX, Max DMA channel is 22 */
  71. #define MAX_DMA_CHANNEL (22)
  72. /**
  73. * @brief DMA Controller register block structure
  74. */
  75. typedef struct { /*!< DMA Structure */
  76. volatile uint32_t CTRL; /*!< DMA control register */
  77. volatile uint32_t INTSTAT; /*!< DMA Interrupt status register */
  78. volatile uint32_t SRAMBASE; /*!< DMA SRAM address of the channel configuration table */
  79. volatile uint32_t RESERVED2[5];
  80. LPC_DMA_COMMON_T DMACOMMON[1]; /*!< DMA shared channel (common) registers */
  81. volatile uint32_t RESERVED0[225];
  82. LPC_DMA_CHANNEL_T DMACH[MAX_DMA_CHANNEL]; /*!< DMA channel registers */
  83. } LPC_DMA_T;
  84. /* DMA interrupt status bits (common) */
  85. #define DMA_INTSTAT_ACTIVEINT 0x2 /*!< Summarizes whether any enabled interrupts are pending */
  86. #define DMA_INTSTAT_ACTIVEERRINT 0x4 /*!< Summarizes whether any error interrupts are pending */
  87. /* Support macro for DMA_CHDESC_T */
  88. #define DMA_ADDR(addr) ((uint32_t) (addr))
  89. /* Support definitions for setting the configuration of a DMA channel. You
  90. will need to get more information on these options from the User manual. */
  91. #define DMA_CFG_PERIPHREQEN (1 << 0) /*!< Enables Peripheral DMA requests */
  92. #define DMA_CFG_HWTRIGEN (1 << 1) /*!< Use hardware triggering via imput mux */
  93. #define DMA_CFG_TRIGPOL_LOW (0 << 4) /*!< Hardware trigger is active low or falling edge */
  94. #define DMA_CFG_TRIGPOL_HIGH (1 << 4) /*!< Hardware trigger is active high or rising edge */
  95. #define DMA_CFG_TRIGTYPE_EDGE (0 << 5) /*!< Hardware trigger is edge triggered */
  96. #define DMA_CFG_TRIGTYPE_LEVEL (1 << 5) /*!< Hardware trigger is level triggered */
  97. #define DMA_CFG_TRIGBURST_SNGL (0 << 6) /*!< Single transfer. Hardware trigger causes a single transfer */
  98. #define DMA_CFG_TRIGBURST_BURST (1 << 6) /*!< Burst transfer (see UM) */
  99. #define DMA_CFG_BURSTPOWER_1 (0 << 8) /*!< Set DMA burst size to 1 transfer */
  100. #define DMA_CFG_BURSTPOWER_2 (1 << 8) /*!< Set DMA burst size to 2 transfers */
  101. #define DMA_CFG_BURSTPOWER_4 (2 << 8) /*!< Set DMA burst size to 4 transfers */
  102. #define DMA_CFG_BURSTPOWER_8 (3 << 8) /*!< Set DMA burst size to 8 transfers */
  103. #define DMA_CFG_BURSTPOWER_16 (4 << 8) /*!< Set DMA burst size to 16 transfers */
  104. #define DMA_CFG_BURSTPOWER_32 (5 << 8) /*!< Set DMA burst size to 32 transfers */
  105. #define DMA_CFG_BURSTPOWER_64 (6 << 8) /*!< Set DMA burst size to 64 transfers */
  106. #define DMA_CFG_BURSTPOWER_128 (7 << 8) /*!< Set DMA burst size to 128 transfers */
  107. #define DMA_CFG_BURSTPOWER_256 (8 << 8) /*!< Set DMA burst size to 256 transfers */
  108. #define DMA_CFG_BURSTPOWER_512 (9 << 8) /*!< Set DMA burst size to 512 transfers */
  109. #define DMA_CFG_BURSTPOWER_1024 (10 << 8) /*!< Set DMA burst size to 1024 transfers */
  110. #define DMA_CFG_BURSTPOWER(n) ((n) << 8) /*!< Set DMA burst size to 2^n transfers, max n=10 */
  111. #define DMA_CFG_SRCBURSTWRAP (1 << 14) /*!< Source burst wrapping is enabled for this DMA channel */
  112. #define DMA_CFG_DSTBURSTWRAP (1 << 15) /*!< Destination burst wrapping is enabled for this DMA channel */
  113. #define DMA_CFG_CHPRIORITY(p) ((p) << 16) /*!< Sets DMA channel priority, min 0 (highest), max 3 (lowest) */
  114. /* DMA channel control and status register definitions */
  115. #define DMA_CTLSTAT_VALIDPENDING (1 << 0) /*!< Valid pending flag for this channel */
  116. #define DMA_CTLSTAT_TRIG (1 << 2) /*!< Trigger flag. Indicates that the trigger for this channel is currently set */
  117. /* DMA channel transfer configuration registers definitions */
  118. #define DMA_XFERCFG_CFGVALID (1 << 0) /*!< Configuration Valid flag */
  119. #define DMA_XFERCFG_RELOAD (1 << 1) /*!< Indicates whether the channels control structure will be reloaded when the current descriptor is exhausted */
  120. #define DMA_XFERCFG_SWTRIG (1 << 2) /*!< Software Trigger */
  121. #define DMA_XFERCFG_CLRTRIG (1 << 3) /*!< Clear Trigger */
  122. #define DMA_XFERCFG_SETINTA (1 << 4) /*!< Set Interrupt flag A for this channel to fire when descriptor is complete */
  123. #define DMA_XFERCFG_SETINTB (1 << 5) /*!< Set Interrupt flag B for this channel to fire when descriptor is complete */
  124. #define DMA_XFERCFG_WIDTH_8 (0 << 8) /*!< 8-bit transfers are performed */
  125. #define DMA_XFERCFG_WIDTH_16 (1 << 8) /*!< 16-bit transfers are performed */
  126. #define DMA_XFERCFG_WIDTH_32 (2 << 8) /*!< 32-bit transfers are performed */
  127. #define DMA_XFERCFG_SRCINC_0 (0 << 12) /*!< DMA source address is not incremented after a transfer */
  128. #define DMA_XFERCFG_SRCINC_1 (1 << 12) /*!< DMA source address is incremented by 1 (width) after a transfer */
  129. #define DMA_XFERCFG_SRCINC_2 (2 << 12) /*!< DMA source address is incremented by 2 (width) after a transfer */
  130. #define DMA_XFERCFG_SRCINC_4 (3 << 12) /*!< DMA source address is incremented by 4 (width) after a transfer */
  131. #define DMA_XFERCFG_DSTINC_0 (0 << 14) /*!< DMA destination address is not incremented after a transfer */
  132. #define DMA_XFERCFG_DSTINC_1 (1 << 14) /*!< DMA destination address is incremented by 1 (width) after a transfer */
  133. #define DMA_XFERCFG_DSTINC_2 (2 << 14) /*!< DMA destination address is incremented by 2 (width) after a transfer */
  134. #define DMA_XFERCFG_DSTINC_4 (3 << 14) /*!< DMA destination address is incremented by 4 (width) after a transfer */
  135. #define DMA_XFERCFG_XFERCOUNT(n) ((n - 1) << 16) /*!< DMA transfer count in 'transfers', between (0)1 and (1023)1024 */
  136. #endif /* __HW_DMA_REGS_H_ */