-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL2_timer.cpp
More file actions
36 lines (28 loc) · 709 Bytes
/
L2_timer.cpp
File metadata and controls
36 lines (28 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
#include "mbed.h"
#include "L2_FSMevent.h"
#include "protocol_parameters.h"
//ARQ retransmission timer
static Timeout timer;
static uint8_t timerStatus = 0;
//timer event : ARQ timeout
void L2_timer_timeoutHandler(void)
{
timerStatus = 0;
L2_event_setEventFlag(L2_event_arqTimeout);
}
//timer related functions ---------------------------
void L2_timer_startTimer()
{
uint8_t waitTime = L2_ARQ_MINWAITTIME + rand()%(L2_ARQ_MAXWAITTIME-L2_ARQ_MINWAITTIME);
timer.attach(L2_timer_timeoutHandler, waitTime);
timerStatus = 1;
}
void L2_timer_stopTimer()
{
timer.detach();
timerStatus = 0;
}
uint8_t L2_timer_getTimerStatus()
{
return timerStatus;
}