1 | /* mbed Microcontroller Library
|
---|
2 | * Copyright (c) 2015 ARM Limited
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 | #include "hal/us_ticker_api.h"
|
---|
17 |
|
---|
18 | static ticker_event_queue_t events = { 0 };
|
---|
19 |
|
---|
20 | static ticker_irq_handler_type irq_handler = ticker_irq_handler;
|
---|
21 |
|
---|
22 | static const ticker_interface_t us_interface = {
|
---|
23 | .init = us_ticker_init,
|
---|
24 | .read = us_ticker_read,
|
---|
25 | .disable_interrupt = us_ticker_disable_interrupt,
|
---|
26 | .clear_interrupt = us_ticker_clear_interrupt,
|
---|
27 | .set_interrupt = us_ticker_set_interrupt,
|
---|
28 | .fire_interrupt = us_ticker_fire_interrupt,
|
---|
29 | .get_info = us_ticker_get_info,
|
---|
30 | .free = us_ticker_free,
|
---|
31 | };
|
---|
32 |
|
---|
33 | static const ticker_data_t us_data = {
|
---|
34 | .interface = &us_interface,
|
---|
35 | .queue = &events
|
---|
36 | };
|
---|
37 |
|
---|
38 | const ticker_data_t *get_us_ticker_data(void)
|
---|
39 | {
|
---|
40 | return &us_data;
|
---|
41 | }
|
---|
42 |
|
---|
43 | ticker_irq_handler_type set_us_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler)
|
---|
44 | {
|
---|
45 | ticker_irq_handler_type prev_irq_handler = irq_handler;
|
---|
46 |
|
---|
47 | irq_handler = ticker_irq_handler;
|
---|
48 |
|
---|
49 | return prev_irq_handler;
|
---|
50 | }
|
---|
51 |
|
---|
52 | void us_ticker_irq_handler(void)
|
---|
53 | {
|
---|
54 | if (irq_handler) {
|
---|
55 | irq_handler(&us_data);
|
---|
56 | }
|
---|
57 | }
|
---|