blob: 4e17b44be94ef78386538638038aad1e5e1b31f8 (
about) (
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
|
#ifndef GLOBAL_H
#define GLOBAL_H
#include <stdint.h>
// board type, raspi2
#define RASPI 2
// conditionally #define PERIF_BASE
#if RASPI == 4
#define PERIF_BASE 0xFE000000
#elif RASPI == 3 || RASPI == 2
#define PERIF_BASE 0x3F000000
#else // if RASPI == 1
#define PERIF_BASE 0x20000000
#endif
// GPIO_BASE is #define'd in terms of PERIF_BASE
// (as in sane kernels - like linux, not like in wiki.osdev codes...)
#define GPIO_BASE (PERIF_BASE + 0x200000)
inline static uint32_t rd32(uint32_t addr)
{
return *(uint32_t volatile*) addr;
}
inline static void wr32(uint32_t addr, uint32_t value)
{
*(uint32_t volatile*) addr = value;
}
#endif // GLOBAL_H
|