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