annotate python/stm32f4/blink.c3 @ 242:c94965418684

Added tag burnchain for changeset ce6d390043a7
author Windel Bouwman
date Mon, 22 Jul 2013 22:56:51 +0200
parents e621e3ba78d2
children 6ed3d3a82a63
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
207
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
7 package blink;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
8
228
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
9 type struct {
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
10 int MODER;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
11 int OTYPER;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
12 int OSPEEDR;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
13 int PUPDR;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
14 int IDR;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
15 int ODR;
231
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
16 }* GPIO_Type;
228
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
17
231
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
18 type struct {
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
19 int CR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
20 int PLLCFGR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
21 int CFGR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
22 int CIR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
23 int AHB1RSTR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
24 int AHB2RSTR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
25 int AHB3RSTR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
26 int reserved0;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
27 int APB1RSTR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
28 int APB2RSTR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
29 int reserved1a, reserved1b;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
30 int AHB1ENR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
31 int AHB2ENR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
32 int AHB3ENR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
33 int reserved2;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
34 int APB1ENR, APB2ENR;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
35 }* RCC_Type;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
36
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
37
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
38 // Functions:
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
39 function void main()
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
40 {
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
41 // Memory mapped control registers:
231
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
42 var GPIO_Type GPIOD;
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
43 GPIOD = cast<GPIO_Type>(0x40020C00);
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
44 var RCC_Type RCC;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
45 RCC = cast<RCC_Type>(0x40023800);
228
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
46
232
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
47 // Enable the clock to port D:
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
48 RCC->AHB1ENR = RCC->AHB1ENR | 0x8;
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
49
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
50
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
51 // PD13 == output (01)
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
52 GPIOD->MODER = (1 << 26);
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
53 GPIOD->ODR = (1 << 13);
e621e3ba78d2 Added left shift instruction
Windel Bouwman
parents: 231
diff changeset
54
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
55 while(true) {}
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
56 }
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
57