You need to use a different event mask (EVT_TIMER) if you want to capture them as different events. The tricky thing is that you need to be careful about which you use because it may trigger other actions. These events are defined in svc.h
(Note that the mask is a long
and a long
is defined as being 32 bits, so you really don't have anything left after all the standard events are used).
The good news is that set_timer
returns an ID (that's what timer1
and timer2
are in your code). You can then use the SVC_TICKS
API to determine which timer has expired. I wrote a wrapper called "timeRemains" to help me with that.
//First, define "timeRemains"
char timeRemains(long* timer)
{
return SVC_TICKS(0, timer);
}
//Here's what your code may look like:
if(!timeRemains(&timer1))
{
//timer1 has expired. Do whatever you wanted to do when that happens.
//NOTE: you don't know the state of timer2--it may also have expired,
// so you will need to deal with that
}
if(!timeRemains(&timer2))
{
//timer2 has expired. Do whatever you wanted to do when that happens.
//NOTE: even though we are PRETTY sure that timer1 has not yet expired,
// you can't just forget about it. If you are going to exit this polling loop,
// be sure to clear it first.
}