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

Added tag burnchain for changeset ce6d390043a7
author Windel Bouwman
date Mon, 22 Jul 2013 22:56:51 +0200
parents ce6d390043a7
children 6ed3d3a82a63
rev   line source
241
ce6d390043a7 Added reset and run at end of flashing
Windel Bouwman
parents: 237
diff changeset
1 /*
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
2
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
3 This file blinks a LED on the STM32F4 discovery board.
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
4
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
5 the board has 4 leds on PD12, PD13, PD14 and PD15
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
6
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
7 */
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
8
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
9 package blink;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
10
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
11 type struct {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
12 int MODER;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
13 int OTYPER;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
14 int OSPEEDR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
15 int PUPDR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
16 int IDR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
17 int ODR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
18 }* GPIO_Type;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
19
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
20 type struct {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
21 int CR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
22 int PLLCFGR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
23 int CFGR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
24 int CIR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
25 int AHB1RSTR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
26 int AHB2RSTR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
27 int AHB3RSTR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
28 int reserved0;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
29 int APB1RSTR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
30 int APB2RSTR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
31 int reserved1a, reserved1b;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
32 int AHB1ENR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
33 int AHB2ENR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
34 int AHB3ENR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
35 int reserved2;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
36 int APB1ENR, APB2ENR;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
37 }* RCC_Type;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
38
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
39
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
40 // Functions:
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
41 function void main()
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
42 {
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
43 // Memory mapped control registers:
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
44 var GPIO_Type GPIOD;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
45 GPIOD = cast<GPIO_Type>(0x40020C00);
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
46 var RCC_Type RCC;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
47 RCC = cast<RCC_Type>(0x40023800);
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
48
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
49 // Enable the clock to port D:
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
50 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3);
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
51
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
52 var int pin;
241
ce6d390043a7 Added reset and run at end of flashing
Windel Bouwman
parents: 237
diff changeset
53 pin = 15;
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
54 // PD13 == output (01)
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
55 GPIOD->MODER = (1 << (pin << 1));
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
56 GPIOD->ODR = (1 << pin);
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
57
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
58 while(true) {}
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
59 }
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
60