hal_dma.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**************************************************************************************************
  2. Filename: hal_dma.c
  3. Revised: $Date: 2010-05-11 15:33:22 -0700 (Tue, 11 May 2010) $
  4. Revision: $Revision: 22450 $
  5. Description: This file contains the interface to the DMA.
  6. Copyright 2007-2010 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. /*********************************************************************
  34. * INCLUDES
  35. */
  36. #include "hal_types.h"
  37. #include "hal_defs.h"
  38. #include "hal_dma.h"
  39. #include "hal_mcu.h"
  40. #include "hal_uart.h"
  41. #if (defined HAL_IRGEN) && (HAL_IRGEN == TRUE)
  42. #include "hal_irgen.h"
  43. #endif
  44. #if (defined HAL_SPI) && (HAL_SPI == TRUE)
  45. #include "hal_spi.h"
  46. #endif
  47. #if ((defined HAL_DMA) && (HAL_DMA == TRUE))
  48. /*********************************************************************
  49. * MACROS
  50. */
  51. /*********************************************************************
  52. * CONSTANTS
  53. */
  54. /*********************************************************************
  55. * TYPEDEFS
  56. */
  57. /*********************************************************************
  58. * GLOBAL VARIABLES
  59. */
  60. halDMADesc_t dmaCh0;
  61. halDMADesc_t dmaCh1234[4];
  62. /*********************************************************************
  63. * GLOBAL FUNCTIONS
  64. */
  65. /*********************************************************************
  66. * LOCAL VARIABLES
  67. */
  68. /*********************************************************************
  69. * LOCAL FUNCTIONS
  70. */
  71. /******************************************************************************
  72. * @fn HalDMAInit
  73. *
  74. * @brief DMA Interrupt Service Routine
  75. *
  76. * @param None
  77. *
  78. * @return None
  79. *****************************************************************************/
  80. void HalDmaInit( void )
  81. {
  82. HAL_DMA_SET_ADDR_DESC0( &dmaCh0 );
  83. HAL_DMA_SET_ADDR_DESC1234( dmaCh1234 );
  84. DMAIE = 1;
  85. }
  86. /******************************************************************************
  87. * @fn HalDMAInit
  88. *
  89. * @brief DMA Interrupt Service Routine
  90. *
  91. * @param None
  92. *
  93. * @return None
  94. *****************************************************************************/
  95. HAL_ISR_FUNCTION( halDmaIsr, DMA_VECTOR )
  96. {
  97. HAL_ENTER_ISR();
  98. DMAIF = 0;
  99. if (ZNP_CFG1_UART == znpCfg1)
  100. {
  101. if (HAL_DMA_CHECK_IRQ(HAL_DMA_CH_TX))
  102. {
  103. extern void HalUARTIsrDMA(void);
  104. HalUARTIsrDMA();
  105. }
  106. }
  107. else
  108. {
  109. if ( HAL_DMA_CHECK_IRQ( HAL_DMA_CH_RX ) )
  110. {
  111. HAL_DMA_CLEAR_IRQ( HAL_DMA_CH_RX );
  112. HalSpiRxIsr();
  113. }
  114. if ( HAL_DMA_CHECK_IRQ( HAL_DMA_CH_TX ) )
  115. {
  116. HAL_DMA_CLEAR_IRQ( HAL_DMA_CH_TX );
  117. HalSpiTxIsr();
  118. }
  119. }
  120. HAL_EXIT_ISR();
  121. }
  122. #endif // #if ((defined HAL_DMA) && (HAL_DMA == TRUE))
  123. /******************************************************************************
  124. ******************************************************************************/