comparison python/stm32f4/blink.c3 @ 231:521567d17388

simplify blink.c3
author Windel Bouwman
date Sat, 13 Jul 2013 20:20:44 +0200
parents 7f18ed9b6b7e
children e621e3ba78d2
comparison
equal deleted inserted replaced
230:88a1e0baef65 231:521567d17388
1 // This file blinks a LED on the STM32F4 discovery board. 1 // This file blinks a LED on the STM32F4 discovery board.
2 package blink; 2 package blink;
3
4 // import bla
5 type struct {
6 // uint32_t SR;
7 } TIM_Type;
8 3
9 type struct { 4 type struct {
10 int MODER; 5 int MODER;
11 int OTYPER; 6 int OTYPER;
12 int OSPEEDR; 7 int OSPEEDR;
13 int PUPDR; 8 int PUPDR;
14 int IDR; 9 int IDR;
15 int ODR; 10 int ODR;
16 } GPIO_Type; 11 }* GPIO_Type;
17 12
18 const GPIO_Type* GPIOD = cast<GPIO_Type*>(0x400000); 13 type struct {
14 } RCC_Type;
19 15
20 function void delay(int count)
21 {
22 while (count > 0)
23 {
24 count = count - 1;
25 }
26 }
27
28 // Globals:
29 var int divider;
30 //const TIM2_s *TIM2;// = (TIM2_s*)0x40004;
31 16
32 // Functions: 17 // Functions:
33 function void tim2_handler()
34 {
35 // if (TIM2->SR & TIM_SR_UIF)
36 if (true)
37 {
38 divider = divider + 1;
39 if (divider == 100000)
40 {
41 divider = 0;
42 //GPIOD->ODR ^= (1 << 13);
43 }
44 }
45 }
46
47 function void main() 18 function void main()
48 { 19 {
49 divider = 0; 20 var int APB1PERIPH_BASE;
50 21 APB1PERIPH_BASE = 0x40000000
51 // delay(100); 22 //var int
23 var GPIO_Type GPIOD;
24 GPIOD = cast<GPIO_Type>(0x400000);
52 25
53 var int* RCC_AHB1ENR; 26 var int* RCC_AHB1ENR;
54 RCC_AHB1ENR = cast<int*>(0x40003022); 27 RCC_AHB1ENR = cast<int*>(0x40003022);
55 *RCC_AHB1ENR = *RCC_AHB1ENR | 8943; 28 *RCC_AHB1ENR = *RCC_AHB1ENR | 8943;
56 /* 29 /*