annotate 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
rev   line source
207
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
1 // This file blinks a LED on the STM32F4 discovery board.
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
2 package blink;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
3
228
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
4 type struct {
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
5 int MODER;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
6 int OTYPER;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
7 int OSPEEDR;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
8 int PUPDR;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
9 int IDR;
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
10 int ODR;
231
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
11 }* GPIO_Type;
228
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
12
231
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
13 type struct {
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
14 } RCC_Type;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
15
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
16
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
17 // Functions:
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
18 function void main()
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
19 {
231
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
20 var int APB1PERIPH_BASE;
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
21 APB1PERIPH_BASE = 0x40000000
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
22 //var int
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
23 var GPIO_Type GPIOD;
521567d17388 simplify blink.c3
Windel Bouwman
parents: 228
diff changeset
24 GPIOD = cast<GPIO_Type>(0x400000);
228
7f18ed9b6b7e Removal of emptystatement class
Windel Bouwman
parents: 221
diff changeset
25
219
1fa3e0050b49 Expanded ad hoc code generator
Windel Bouwman
parents: 212
diff changeset
26 var int* RCC_AHB1ENR;
221
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
27 RCC_AHB1ENR = cast<int*>(0x40003022);
220
3f6c30a5d234 Major change in expression parsing to enable pointers and structs
Windel Bouwman
parents: 219
diff changeset
28 *RCC_AHB1ENR = *RCC_AHB1ENR | 8943;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
29 /*
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
30 RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
31 RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
32
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
33 GPIOD->MODER = (1<<26);
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
34
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
35 NVIC->ISER[0] |= 1<< (TIM2_IRQn);
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
36
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
37 TIM2->PSC = 0xE000;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
38 TIM2->DIER |= TIM_DIER_UIE;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
39 TIM2->ARR = 0xE000;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
40 TIM2->CR1 |= TIM_CR1_ARPE | TIM_CR1_CEN;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
41 TIM2->EGR = 1;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
42
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
43 */
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
44 while(true) {}
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
45 }
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
46