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
45
46
47
48
49
50
51
52
53
| #include "adl_global.h"
#include "adl_irq.h"
#include "adl_tcu.h"
const u16 wm_apmCustomStackSize = 1024 * 3;
s32 TCUHandle;
s32 IRQHandle;
adl_tcuTimerSettings_t Config;
adl_tcuTimerDuration_t timerDurationConfig;
bool MyTCUHandler (adl_irqID_e Source, adl_irqNotificationLevel_e NotoficationLevel, adl_irqEventData_t * Data) {
if (Source == ADL_IRQ_ID_TIMER) {
TRACE (( 1, "Timer event"));
adl_atSendResponse(ADL_AT_UNS, "Timer Event");
}
return TRUE;
}
void myFunction1(void) {
timerDurationConfig.DurationUnit = ADL_TCU_TIMER_UNIT_MS;
timerDurationConfig.DurationValue = 5;
Config.Duration = timerDurationConfig;
Config.Periodic = TRUE;
adl_irqCapabilities_t Caps;
adl_irqConfig_t IrqConfig;
adl_irqGetCapabilities(&Caps);
//Set configuration
IrqConfig.PriorityLevel = Caps.PriorityLevelsCount-1;
IrqConfig.Enable = TRUE;
IrqConfig.Options = ADL_IRQ_OPTION_AUTO_READ;
IRQHandle = adl_irqSubscribeExt(MyTCUHandler, ADL_IRQ_NOTIFY_LOW_LEVEL, &IrqConfig);
TCUHandle = adl_tcuSubscribe(ADL_TCU_ACCURATE_TIMER, IRQHandle, 0, &Config, NULL);
adl_tcuStart(TCUHandle);
}
void myFunction2() {
ascii tekst[30] = { 0 };
adl_tcuTimerDuration_t RemainingTimer;
adl_tcuStop(TCUHandle, &RemainingTimer);
adl_tcuUnsubscribe(TCUHandle);
wm_sprintf(tekst, "\r\n Remaining time: %d\r\n",
RemainingTimer.DurationValue);
adl_atSendResponse(ADL_AT_UNS, tekst);
}
void adl_main(adl_InitType_e InitType) {
TRACE (( 1, "Embedded Application : Main" ));
myFunction1();
} |