262
|
1 /*
|
|
2
|
|
3 This file blinks a LED on the STM32F4 discovery board.
|
|
4
|
|
5 the board has 4 leds on PD12, PD13, PD14 and PD15
|
|
6
|
|
7 */
|
|
8
|
|
9 package burn2;
|
|
10
|
|
11 import stm32f4xx;
|
|
12
|
|
13 function void init()
|
|
14 {
|
|
15 var RCC_Type RCC;
|
|
16 RCC = cast<RCC_Type>(0x40023800);
|
|
17
|
|
18 // Enable the clock to port D:
|
|
19 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3);
|
|
20 // Memory mapped control registers:
|
|
21 var GPIO_Type GPIOD;
|
|
22 GPIOD = cast<GPIO_Type>(0x40020C00);
|
|
23
|
|
24 var int pin;
|
|
25 pin = 15;
|
|
26 // PD13 == output (01)
|
279
|
27 GPIOD->MODER = (1 << (pin << 1));
|
262
|
28 GPIOD->ODR = (1 << pin);
|
|
29 }
|
|
30
|
|
31
|
|
32 function void main()
|
|
33 {
|
|
34 init();
|
|
35
|
|
36 var int a;
|
|
37 a = 0
|
|
38 while (a < 1000)
|
|
39 {
|
|
40 a = a + 1;
|
|
41 }
|
|
42
|
|
43 while(true) {}
|
|
44 }
|
|
45
|