User | Revision | Line number | New contents of line |
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
1
|
/* mbed Microcontroller Library
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
2
|
* Copyright (c) 2006-2013 ARM Limited
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
3
|
*
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
5
|
* you may not use this file except in compliance with the License.
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
6
|
* You may obtain a copy of the License at
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
7
|
*
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
8
|
* http://www.apache.org/licenses/LICENSE-2.0
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
9
|
*
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
10
|
* Unless required by applicable law or agreed to in writing, software
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
11
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
12
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
13
|
* See the License for the specific language governing permissions and
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
14
|
* limitations under the License.
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
15
|
*/
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
16
|
#ifndef MBED_TIMEREVENT_H
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
17
|
#define MBED_TIMEREVENT_H
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
18
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
19
|
#include "hal/ticker_api.h"
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
20
|
#include "hal/us_ticker_api.h"
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
21
|
#include "platform/NonCopyable.h"
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
22
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
23
|
namespace mbed {
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
24
|
/** \addtogroup drivers */
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
25
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
26
|
/** Base abstraction for timer interrupts
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
27
|
*
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
28
|
* @note Synchronization level: Interrupt safe
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
29
|
* @ingroup drivers
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
30
|
*/
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
31
|
class TimerEvent : private NonCopyable<TimerEvent> {
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
32
|
public:
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
33
|
TimerEvent();
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
34
|
TimerEvent(const ticker_data_t *data);
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
35
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
36
|
/** The handler registered with the underlying timer interrupt
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
37
|
*
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
38
|
* @param id Timer Event ID
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
39
|
*/
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
40
|
static void irq(uint32_t id);
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
41
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
42
|
/** Destruction removes it...
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
43
|
*/
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
44
|
virtual ~TimerEvent();
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
45
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
46
|
protected:
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
47
|
// The handler called to service the timer event of the derived class
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
48
|
virtual void handler() = 0;
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
49
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
50
|
// insert relative timestamp in to linked list
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
51
|
void insert(timestamp_t timestamp);
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
52
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
53
|
// insert absolute timestamp into linked list
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
54
|
void insert_absolute(us_timestamp_t timestamp);
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
55
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
56
|
// remove from linked list, if in it
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
57
|
void remove();
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
58
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
59
|
ticker_event_t event;
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
60
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
61
|
const ticker_data_t *_ticker_data;
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
62
|
};
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
63
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
64
|
} // namespace mbed
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
65
|
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
66
|
#endif
|
abe5b02d-a2d4-4fe9-818e-c4e57c809ea4 |
0:bdf663c61a82
|
67
|
|