comparison 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
comparison
equal deleted inserted replaced
236:8786811a5a59 237:81752b0f85a5
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 blink;
10
11 type struct {
12 int MODER;
13 int OTYPER;
14 int OSPEEDR;
15 int PUPDR;
16 int IDR;
17 int ODR;
18 }* GPIO_Type;
19
20 type struct {
21 int CR;
22 int PLLCFGR;
23 int CFGR;
24 int CIR;
25 int AHB1RSTR;
26 int AHB2RSTR;
27 int AHB3RSTR;
28 int reserved0;
29 int APB1RSTR;
30 int APB2RSTR;
31 int reserved1a, reserved1b;
32 int AHB1ENR;
33 int AHB2ENR;
34 int AHB3ENR;
35 int reserved2;
36 int APB1ENR, APB2ENR;
37 }* RCC_Type;
38
39
40 // Functions:
41 function void main()
42 {
43 // Memory mapped control registers:
44 var GPIO_Type GPIOD;
45 GPIOD = cast<GPIO_Type>(0x40020C00);
46 var RCC_Type RCC;
47 RCC = cast<RCC_Type>(0x40023800);
48
49 // Enable the clock to port D:
50 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3);
51
52 var int pin;
53 pin = 13;
54 // PD13 == output (01)
55 GPIOD->MODER = (1 << (pin << 1));
56 GPIOD->ODR = (1 << pin);
57
58 while(true) {}
59 }
60