annotate examples/c3/blink.c3 @ 330:a79ac866732f

Added kernel recipe
author Windel Bouwman
date Fri, 07 Feb 2014 12:08:40 +0100
parents 158068af716c
children
rev   line source
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
1 /* This file blinks a LED on the STM32F4 discovery board.
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
2
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
3 the board has 4 leds on PD12, PD13, PD14 and PD15
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
4
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
5 */
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
6
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 271
diff changeset
7 module blink;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
8
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents: 232
diff changeset
9 import stm32f4xx;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
10
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
11 // Functions:
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
12 function void main()
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
13 {
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
14 // Memory mapped control registers:
231
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
15 var GPIO_Type GPIOD;
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
16 GPIOD = cast<GPIO_Type>(0x40020C00);
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
17 var RCC_Type RCC;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
18 RCC = cast<RCC_Type>(0x40023800);
228
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
19
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
20 // Enable the clock to port D:
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
21 RCC->AHB1ENR = RCC->AHB1ENR | 0x8;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
22
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
23
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
24 // PD13 == output (01)
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
25 GPIOD->MODER = (1 << 26);
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
26 GPIOD->ODR = (1 << 13);
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
27
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
28 while(true) {}
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
29 }
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
30