comparison python/stm32f4/burn.c3 @ 251:6ed3d3a82a63

Added another c3 example. First import attempt
author Windel Bouwman
date Mon, 29 Jul 2013 20:23:13 +0200
parents ce6d390043a7
children 225f444019b1
comparison
equal deleted inserted replaced
250:f5fba5b554d7 251:6ed3d3a82a63
4 4
5 the board has 4 leds on PD12, PD13, PD14 and PD15 5 the board has 4 leds on PD12, PD13, PD14 and PD15
6 6
7 */ 7 */
8 8
9 package blink; 9 package burn;
10 10
11 type struct { 11 import stm32f4xx;
12 int MODER;
13 int OTYPER;
14 int OSPEEDR;
15 int PUPDR;
16 int IDR;
17 int ODR;
18 }* GPIO_Type;
19 12
20 type struct { 13 function void init()
21 int CR; 14 {
22 int PLLCFGR; 15 }
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 16
39
40 // Functions:
41 function void main() 17 function void main()
42 { 18 {
43 // Memory mapped control registers: 19 //init();
44 var GPIO_Type GPIOD;
45 GPIOD = cast<GPIO_Type>(0x40020C00);
46 var RCC_Type RCC; 20 var RCC_Type RCC;
47 RCC = cast<RCC_Type>(0x40023800); 21 RCC = cast<RCC_Type>(0x40023800);
48 22
49 // Enable the clock to port D: 23 // Enable the clock to port D:
50 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3); 24 RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3);
25 // Memory mapped control registers:
26 var GPIO_Type GPIOD;
27 GPIOD = cast<GPIO_Type>(0x40020C00);
51 28
52 var int pin; 29 var int pin;
53 pin = 15; 30 pin = 15;
54 // PD13 == output (01) 31 // PD13 == output (01)
55 GPIOD->MODER = (1 << (pin << 1)); 32 GPIOD->MODER = (1 << (pin << 1));