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;
|
212
|
11 //const TIM2_s *TIM2;// = (TIM2_s*)0x40004;
|
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;
|
204
|
20 if (divider > 100000)
|
|
21 {
|
|
22 divider = 0;
|
212
|
23 //GPIOD->ODR ^= (1 << 13);
|
204
|
24 }
|
|
25 }
|
|
26 }
|
|
27
|
|
28 function void main()
|
|
29 {
|
|
30 divider = 0;
|
|
31 /*
|
|
32 RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;
|
|
33 RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
|
|
34
|
|
35 GPIOD->MODER = (1<<26);
|
|
36
|
|
37 NVIC->ISER[0] |= 1<< (TIM2_IRQn);
|
|
38
|
|
39 TIM2->PSC = 0xE000;
|
|
40 TIM2->DIER |= TIM_DIER_UIE;
|
|
41 TIM2->ARR = 0xE000;
|
|
42 TIM2->CR1 |= TIM_CR1_ARPE | TIM_CR1_CEN;
|
|
43 TIM2->EGR = 1;
|
|
44
|
|
45 */
|
205
|
46 while(true) {}
|
204
|
47 }
|
|
48
|