annotate python/c3/examples/burn2.c3 @ 271:cf7d5fb7d9c8

Reorganization
author Windel Bouwman
date Tue, 20 Aug 2013 18:56:02 +0200
parents python/stm32f4/burn2.c3@5ec7580976d9
children 2ccd57b1d78c
rev   line source
262
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
1 /*
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
2
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
3 This file blinks a LED on the STM32F4 discovery board.
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
4
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
5 the board has 4 leds on PD12, PD13, PD14 and PD15
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
6
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
7 */
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
8
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
9 package burn2;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
10
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
11 import stm32f4xx;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
12
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
13 function void init()
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
14 {
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
15 var RCC_Type RCC;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
16 RCC = cast<RCC_Type>(0x40023800);
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
17
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
18 // Enable the clock to port D:
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
19 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3);
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
20 // Memory mapped control registers:
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
21 var GPIO_Type GPIOD;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
22 GPIOD = cast<GPIO_Type>(0x40020C00);
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
23
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
24 var int pin;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
25 pin = 15;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
26 // PD13 == output (01)
268
5ec7580976d9 Op naar tree-IR
Windel Bouwman
parents: 262
diff changeset
27 GPIOD->MODER = (1 << (pin * 2));
262
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
28 GPIOD->ODR = (1 << pin);
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
29 }
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
30
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
31
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
32 function void main()
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
33 {
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
34 init();
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
35
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
36 var int a;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
37 a = 0
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
38 while (a < 1000)
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
39 {
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
40 a = a + 1;
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
41 }
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
42
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
43 while(true) {}
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
44 }
ed14e077124c Added conditional branch instructions
Windel Bouwman
parents:
diff changeset
45