-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdma.h
53 lines (43 loc) · 1.09 KB
/
dma.h
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
#ifndef DMA_H
#define DMA_H
#include <stdlib.h>
#include <stdint.h>
#define DMA_BASE 0x20007000
#define DMA_OFFSET 0x100
#define DMA_CHANNELS 16
#define DMA_ENABLE_OFFSET 0xFF0
#define DMA_ENABLE_ALL ((1 << DMA_CHANNELS) - 1)
#define DMA_CS_ACTIVE 0x1
#define DMA_CS_RESET 0x80000000
#define DMA_TI_DEST_INC (1 << 4)
#define DMA_TI_SRC_INC (1 << 8)
typedef struct dma_register {
uint32_t cs;
uint32_t conblk_ad;
uint32_t ti;
uint32_t source_ad;
uint32_t dest_ad;
uint32_t txfr_len;
uint32_t stride;
uint32_t nextconbk;
uint32_t debug;
} dma_register_t;
typedef struct dma_conblk {
uint32_t ti;
uint32_t source_ad;
uint32_t dest_ad;
uint32_t txfr_len;
uint32_t stride;
uint32_t nextconbk;
uint32_t reserved1;
uint32_t reserved2;
} dma_conblk_t;
int dma_init(void);
int dma_check_usable(int ch);
int dma_check_active(int ch);
int dma_copy(void *dst, const void *sr, size_t lenc);
int dma_fill(void *dst, const void *sr, size_t lenc);
int dma_zero(void *dst, size_t lenc);
volatile dma_register_t *dma_reserve_channel(void);
void dma_free_channel(volatile dma_register_t *channel);
#endif