232
|
1 /* This file blinks a LED on the STM32F4 discovery board.
|
|
2
|
|
3 the board has 4 leds on PD12, PD13, PD14 and PD15
|
|
4
|
|
5 */
|
|
6
|
207
|
7 package blink;
|
204
|
8
|
228
|
9 type struct {
|
|
10 int MODER;
|
|
11 int OTYPER;
|
|
12 int OSPEEDR;
|
|
13 int PUPDR;
|
|
14 int IDR;
|
|
15 int ODR;
|
231
|
16 }* GPIO_Type;
|
228
|
17
|
231
|
18 type struct {
|
232
|
19 int CR;
|
|
20 int PLLCFGR;
|
|
21 int CFGR;
|
|
22 int CIR;
|
|
23 int AHB1RSTR;
|
|
24 int AHB2RSTR;
|
|
25 int AHB3RSTR;
|
|
26 int reserved0;
|
|
27 int APB1RSTR;
|
|
28 int APB2RSTR;
|
|
29 int reserved1a, reserved1b;
|
|
30 int AHB1ENR;
|
|
31 int AHB2ENR;
|
|
32 int AHB3ENR;
|
|
33 int reserved2;
|
|
34 int APB1ENR, APB2ENR;
|
|
35 }* RCC_Type;
|
204
|
36
|
|
37
|
|
38 // Functions:
|
|
39 function void main()
|
|
40 {
|
232
|
41 // Memory mapped control registers:
|
231
|
42 var GPIO_Type GPIOD;
|
232
|
43 GPIOD = cast<GPIO_Type>(0x40020C00);
|
|
44 var RCC_Type RCC;
|
|
45 RCC = cast<RCC_Type>(0x40023800);
|
228
|
46
|
232
|
47 // Enable the clock to port D:
|
|
48 RCC->AHB1ENR = RCC->AHB1ENR | 0x8;
|
|
49
|
|
50
|
|
51 // PD13 == output (01)
|
|
52 GPIOD->MODER = (1 << 26);
|
|
53 GPIOD->ODR = (1 << 13);
|
|
54
|
205
|
55 while(true) {}
|
204
|
56 }
|
|
57
|