blob: 89c1e15392fcbeba76883554a2344a0be92badb0 (
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
|
#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_PUDR *((volatile unsigned int *)(PORT + 0x0060u))
#define PIO_WPMR *((volatile unsigned int *)(PORT + 0x00E4u))
#define PIO_WPKEY 0x50494Fu
#define PMC_PID 13
#define PMC_WPKEY 0x504D43u
#define PMC_WPMR *((volatile unsigned int *)(PORT + 0x400E06E4u))
#define PMC_PCER0 *((volatile unsigned int *)(PORT + 0x400E0610u))
#define GPIO_NUM 1
#define GPIO_MASK (1u << GPIO_NUM)
int main(void)
{
// enable peripheral clock
//PMC_WPMR = PMC_WPKEY << 8;
//PMC_PCER0 |= (1u << PMC_PID);
//PMC_WPMR = (PMC_WPKEY << 8) | 1u;
// enable port, set to output, disable pull-up
PIO_WPMR = PIO_WPKEY << 8;
PIO_PER |= GPIO_MASK;
PIO_OER |= GPIO_MASK;
PIO_PUDR |= GPIO_MASK;
PIO_WPMR = (PIO_WPKEY << 8) | 1u;
// set pin to logic 1
PIO_SODR |= GPIO_MASK;
for (;;)
;
return 0;
}
extern const unsigned int StackTop;
__attribute__ ((section(".vtor")))
const void* VectorTable[] = {
&StackTop, /* CPU will automatically *
* set stack its pointer *
* to this value */
main, /* -15: Reset_IRQn */
};
|