-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblink.c
42 lines (33 loc) · 792 Bytes
/
blink.c
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
/*
*
* Physical address from SAMD21E18A datasheet
*
* */
#define GPIO_BASE 0x41004400
#define PORTDIRSET 0x41004408
#define PORTOUT 0x41004410
#define PORTCLR 0x41004414
#define LED_GPIO_BIT 10
/** GPIO Register set */
volatile unsigned int* gpio;
/** Simple loop variable */
volatile unsigned int tim;
/** Main function - we'll never return from here */
void kernel_main() {
/* Set output direction for LED pin*/
gpio = (unsigned int*)PORTDIRSET;
*gpio |= (1 << LED_GPIO_BIT);
/* Never exit */
while (1) {
for (tim = 0; tim < 5000; tim++)
;
/* Clear LED output pin*/
gpio = (unsigned int*)PORTCLR;
*gpio = (1 << LED_GPIO_BIT);
for (tim = 0; tim < 5000; tim++)
;
/* Set LED output pin*/
gpio = (unsigned int*)PORTOUT;
*gpio = (1 << LED_GPIO_BIT);
}
}