blob: 63266ed0d7a6b23e52ca9c55c162080fe0911dea (
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
|
#define PIOA 0x400E0E00u
#define PIOB 0x400E1000u
#define PIOC 0x400E1200u
#define PIOD 0x400E1400u
#define PORT PIOC
#define PIO_PER *((volatile unsigned int *)(PORT + 0x0000u))
#define PIO_OER *((volatile unsigned int *)(PORT + 0x0010u))
#define PIO_SODR *((volatile unsigned int *)(PORT + 0x0030u))
#define PIO_ODSR *((volatile unsigned int *)(PORT + 0x0038u))
#define PIO_PUDR *((volatile unsigned int *)(PORT + 0x0060u))
#define PIO_WPMR *((volatile unsigned int *)(PORT + 0x00E4u))
#define WPKEY 0x50494Fu
#define GPIO_NUM 1
#define GPIO_MASK (1u << GPIO_NUM)
int main(void)
{
// todo: enable peripheral clock
PIO_WPMR = WPKEY << 8;
PIO_PER |= GPIO_MASK;
PIO_OER |= GPIO_MASK;
PIO_PUDR |= GPIO_MASK;
PIO_WPMR = (WPKEY << 8) | 1u;
PIO_SODR |= GPIO_MASK;
for (;;)
;
return 0;
}
|