blob: 4d9b8d6b282d65ca663d79b91f4b991995423c88 (
plain)
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
|
#ifndef DMA_H
#define DMA_H
#include <stdint.h>
#if defined(STM32F3)
struct DMA_channel_reg_t {
volatile uint32_t CR;
volatile uint32_t NDTR;
volatile uint32_t PAR;
volatile uint32_t MAR;
uint32_t _reserved;
};
struct DMA_reg_t {
volatile uint32_t ISR;
volatile uint32_t IFCR;
DMA_channel_reg_t C[7];
};
class DMA_t {
public:
DMA_reg_t& reg;
DMA_t(uint32_t reg_addr) : reg(*(DMA_reg_t*)reg_addr) {}
};
static DMA_t DMA1(0x40020000);
static DMA_t DMA2(0x40020400);
#elif defined(STM32F4)
struct DMA_stream_reg_t {
volatile uint32_t CR;
volatile uint32_t NDTR;
volatile uint32_t PAR;
volatile uint32_t M0AR;
volatile uint32_t M1AR;
volatile uint32_t FCR;
};
struct DMA_reg_t {
volatile uint32_t LISR;
volatile uint32_t HISR;
volatile uint32_t LIFCR;
volatile uint32_t HIFCR;
DMA_stream_reg_t S[8];
};
class DMA_t {
public:
DMA_reg_t& reg;
DMA_t(uint32_t reg_addr) : reg(*(DMA_reg_t*)reg_addr) {}
};
static DMA_t DMA1(0x40026000);
static DMA_t DMA2(0x40026400);
#endif
#endif
|