annotate python/stm32f4/blink.c3 @ 220:3f6c30a5d234

Major change in expression parsing to enable pointers and structs
author Windel Bouwman
date Sat, 06 Jul 2013 21:32:20 +0200
parents 1fa3e0050b49
children 848c4b15fd0b
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
207
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
4 // import bla
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
5 //type struct TIM2_s {
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
6 // uint32_t SR;
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
7 //};
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
8
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
9 // Globals:
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
10 var int divider;
212
62386bcee1ba Added parser combinator lib
Windel Bouwman
parents: 207
diff changeset
11 //const TIM2_s *TIM2;// = (TIM2_s*)0x40004;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
12
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
13 // Functions:
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
14 function void tim2_handler()
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
15 {
207
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
16 // if (TIM2->SR & TIM_SR_UIF)
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
17 if (true)
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
18 {
207
8b2f20aae086 cleaning of files
Windel Bouwman
parents: 205
diff changeset
19 divider = divider + 1;
219
1fa3e0050b49 Expanded ad hoc code generator
Windel Bouwman
parents: 212
diff changeset
20 if (divider == 100000)
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
21 {
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
22 divider = 0;
212
62386bcee1ba Added parser combinator lib
Windel Bouwman
parents: 207
diff changeset
23 //GPIOD->ODR ^= (1 << 13);
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
24 }
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
25 }
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
26 }
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
27
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
28 function void main()
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 divider = 0;
219
1fa3e0050b49 Expanded ad hoc code generator
Windel Bouwman
parents: 212
diff changeset
31
1fa3e0050b49 Expanded ad hoc code generator
Windel Bouwman
parents: 212
diff changeset
32 var int* RCC_AHB1ENR;
1fa3e0050b49 Expanded ad hoc code generator
Windel Bouwman
parents: 212
diff changeset
33 RCC_AHB1ENR = 0x40003022;
220
3f6c30a5d234 Major change in expression parsing to enable pointers and structs
Windel Bouwman
parents: 219
diff changeset
34 *RCC_AHB1ENR = *RCC_AHB1ENR | 8943;
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
35 /*
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
36 RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
37 RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
38
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
39 GPIOD->MODER = (1<<26);
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
40
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
41 NVIC->ISER[0] |= 1<< (TIM2_IRQn);
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 TIM2->PSC = 0xE000;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
44 TIM2->DIER |= TIM_DIER_UIE;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
45 TIM2->ARR = 0xE000;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
46 TIM2->CR1 |= TIM_CR1_ARPE | TIM_CR1_CEN;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
47 TIM2->EGR = 1;
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
48
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
49 */
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
50 while(true) {}
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
51 }
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents:
diff changeset
52