drv_dma.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * File : drv_dma.h
  3. * This file is part of FH8620 BSP for RT-Thread distribution.
  4. *
  5. * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd.
  6. * All rights reserved
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * Visit http://www.fullhan.com to get contact with Fullhan.
  23. *
  24. * Change Logs:
  25. * Date Author Notes
  26. */
  27. #ifndef DMA_H_
  28. #define DMA_H_
  29. #include <rtthread.h>
  30. /****************************************************************************
  31. * #include section
  32. * add #include here if any
  33. ***************************************************************************/
  34. /****************************************************************************
  35. * #define section
  36. * add constant #define here if any
  37. ***************************************************************************/
  38. #define RT_DEVICE_CTRL_DMA_OPEN (1)
  39. #define RT_DEVICE_CTRL_DMA_CLOSE (2)
  40. #define RT_DEVICE_CTRL_DMA_REQUEST_CHANNEL (3)
  41. #define RT_DEVICE_CTRL_DMA_RELEASE_CHANNEL (4)
  42. #define RT_DEVICE_CTRL_DMA_SINGLE_TRANSFER (5)
  43. // cyclic add func below....
  44. #define RT_DEVICE_CTRL_DMA_CYCLIC_PREPARE (6)
  45. #define RT_DEVICE_CTRL_DMA_CYCLIC_START (7)
  46. #define RT_DEVICE_CTRL_DMA_CYCLIC_STOP (8)
  47. #define RT_DEVICE_CTRL_DMA_CYCLIC_FREE (9)
  48. #define RT_DEVICE_CTRL_DMA_PAUSE (10)
  49. #define RT_DEVICE_CTRL_DMA_RESUME (11)
  50. //#define RT_DEVICE_CTRL_ (3) /* get the left time before reboot(in
  51. //seconds) */
  52. //#define RT_DEVICE_CTRL_ (4) /* refresh watchdog */
  53. //#define RT_DEVICE_CTRL_ (5) /* start watchdog */
  54. //#define RT_DEVICE_CTRL_ (6) /* stop watchdog */
  55. /****************************************************************************
  56. * ADT section
  57. * add Abstract Data Type definition here
  58. ***************************************************************************/
  59. #define ADC_CMD_READ_RAW_DATA (0x22)
  60. #define ADC_CMD_DISABLE (0x44)
  61. /*dma cmd */
  62. typedef enum
  63. {
  64. DMA_CMD_ADD_DESCRIPTOR = 0,
  65. DMA_CMD_START,
  66. DMA_CMD_STOP,
  67. }RT_DMA_DMD;
  68. typedef void (*RT_DMA_NOTIFIER_F)(void);
  69. typedef struct rt_dma_descriptor_s
  70. {
  71. rt_uint32_t srcAddr; /* Source address */
  72. rt_uint32_t dstAddr; /* Destination address */
  73. struct dma_descriptor_s *next; /* Pointing to next descriptor */
  74. rt_uint32_t reportAddr; /* The physical address to store DMA hardware reporting status */
  75. rt_uint32_t dataLength; /* Transfer byte count , max value = 2^22 */
  76. rt_uint32_t descAttr; /* Descriptor 's attribute */
  77. }RT_DMA_DESCRIPTOR_S;
  78. typedef struct
  79. {
  80. rt_uint32_t channel;
  81. rt_uint32_t mode;
  82. RT_DMA_NOTIFIER_F intNotifier;
  83. }RT_DMA_OPEN_PARAM_S;
  84. typedef struct rt_dma_device
  85. {
  86. // the parent must be the fitst para..
  87. rt_uint32_t handle;
  88. struct rt_device parent;
  89. RT_DMA_OPEN_PARAM_S openParam;
  90. }rt_dma_device_s;
  91. /****************************************************************************
  92. * extern variable declaration section
  93. ***************************************************************************/
  94. /****************************************************************************
  95. * section
  96. * add function prototype here if any
  97. ***************************************************************************/
  98. void rt_gk_dma_init(void);
  99. /********************************End Of File********************************/
  100. #endif