-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathTimer.cpp
More file actions
44 lines (37 loc) · 709 Bytes
/
Timer.cpp
File metadata and controls
44 lines (37 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Arduino.h"
#define LED1_Pin PA0
#define LED2_Pin PA1
void Timer1_Callback()
{
Serial.println("Timer 1 Interrupt!");
togglePin(LED1_Pin);
}
void Timer2_Callback()
{
Serial.println("Timer 2 Interrupt!");
togglePin(LED2_Pin);
}
void setup()
{
Serial.begin(115200);
pinMode(LED1_Pin, OUTPUT);
pinMode(LED2_Pin, OUTPUT);
Timer_SetInterrupt(TIM1, 1000000/*@1000ms*/, Timer1_Callback);
Timer_SetInterrupt(TIM2, 100000 /*@100ms*/ , Timer2_Callback);
TIM_Cmd(TIM1, ENABLE);
TIM_Cmd(TIM2, ENABLE);
}
void loop()
{
}
/**
* @brief Main Function
* @param None
* @retval None
*/
int main(void)
{
Delay_Init();
setup();
for(;;)loop();
}