annotate python/stm32f4/burn.c3 @ 237:81752b0f85a5

Added burn led test program
author Windel Bouwman
date Wed, 17 Jul 2013 22:31:54 +0200
parents
children ce6d390043a7
rev   line source
237
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
1 /*
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;
81752b0f85a5 Added burn led test program
Windel Bouwman
parents:
diff changeset
53 pin = 13;
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