207
|
1 // This file blinks a LED on the STM32F4 discovery board.
|
|
2 package blink;
|
204
|
3
|
207
|
4 // import bla
|
|
5 //type struct TIM2_s {
|
|
6 // uint32_t SR;
|
|
7 //};
|
204
|
8
|
|
9 // Globals:
|
|
10 var int divider;
|
207
|
11 //const TIM2_s *TIM2;
|
204
|
12
|
|
13 // Functions:
|
|
14 function void tim2_handler()
|
|
15 {
|
207
|
16 // if (TIM2->SR & TIM_SR_UIF)
|
|
17 if (true)
|
204
|
18 {
|
207
|
19 divider = divider + 1;
|
|
20 /*
|
204
|
21 if (divider > 100000)
|
|
22 {
|
|
23 divider = 0;
|
|
24 GPIOD->ODR ^= (1 << 13);
|
|
25 }
|
207
|
26 */
|
204
|
27 }
|
|
28 }
|
|
29
|
|
30 function void main()
|
|
31 {
|
|
32 divider = 0;
|
|
33 /*
|
|
34 RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;
|
|
35 RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
|
|
36
|
|
37 GPIOD->MODER = (1<<26);
|
|
38
|
|
39 NVIC->ISER[0] |= 1<< (TIM2_IRQn);
|
|
40
|
|
41 TIM2->PSC = 0xE000;
|
|
42 TIM2->DIER |= TIM_DIER_UIE;
|
|
43 TIM2->ARR = 0xE000;
|
|
44 TIM2->CR1 |= TIM_CR1_ARPE | TIM_CR1_CEN;
|
|
45 TIM2->EGR = 1;
|
|
46
|
|
47 */
|
205
|
48 while(true) {}
|
204
|
49 }
|
|
50
|