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