Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mbed-os/hal/mbed_us_ticker_api.c@0:6ad07c9019fd, 2018-05-30 (annotated)
- Committer:
- Bethory
- Date:
- Wed May 30 00:01:50 2018 +0000
- Revision:
- 0:6ad07c9019fd
Codigo de tales para todos los pasculaes
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Bethory | 0:6ad07c9019fd | 1 | /* mbed Microcontroller Library |
| Bethory | 0:6ad07c9019fd | 2 | * Copyright (c) 2015 ARM Limited |
| Bethory | 0:6ad07c9019fd | 3 | * |
| Bethory | 0:6ad07c9019fd | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| Bethory | 0:6ad07c9019fd | 5 | * you may not use this file except in compliance with the License. |
| Bethory | 0:6ad07c9019fd | 6 | * You may obtain a copy of the License at |
| Bethory | 0:6ad07c9019fd | 7 | * |
| Bethory | 0:6ad07c9019fd | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| Bethory | 0:6ad07c9019fd | 9 | * |
| Bethory | 0:6ad07c9019fd | 10 | * Unless required by applicable law or agreed to in writing, software |
| Bethory | 0:6ad07c9019fd | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| Bethory | 0:6ad07c9019fd | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| Bethory | 0:6ad07c9019fd | 13 | * See the License for the specific language governing permissions and |
| Bethory | 0:6ad07c9019fd | 14 | * limitations under the License. |
| Bethory | 0:6ad07c9019fd | 15 | */ |
| Bethory | 0:6ad07c9019fd | 16 | #include "hal/us_ticker_api.h" |
| Bethory | 0:6ad07c9019fd | 17 | |
| Bethory | 0:6ad07c9019fd | 18 | static ticker_event_queue_t events = { 0 }; |
| Bethory | 0:6ad07c9019fd | 19 | |
| Bethory | 0:6ad07c9019fd | 20 | static ticker_irq_handler_type irq_handler = ticker_irq_handler; |
| Bethory | 0:6ad07c9019fd | 21 | |
| Bethory | 0:6ad07c9019fd | 22 | static const ticker_interface_t us_interface = { |
| Bethory | 0:6ad07c9019fd | 23 | .init = us_ticker_init, |
| Bethory | 0:6ad07c9019fd | 24 | .read = us_ticker_read, |
| Bethory | 0:6ad07c9019fd | 25 | .disable_interrupt = us_ticker_disable_interrupt, |
| Bethory | 0:6ad07c9019fd | 26 | .clear_interrupt = us_ticker_clear_interrupt, |
| Bethory | 0:6ad07c9019fd | 27 | .set_interrupt = us_ticker_set_interrupt, |
| Bethory | 0:6ad07c9019fd | 28 | .fire_interrupt = us_ticker_fire_interrupt, |
| Bethory | 0:6ad07c9019fd | 29 | .get_info = us_ticker_get_info, |
| Bethory | 0:6ad07c9019fd | 30 | }; |
| Bethory | 0:6ad07c9019fd | 31 | |
| Bethory | 0:6ad07c9019fd | 32 | static const ticker_data_t us_data = { |
| Bethory | 0:6ad07c9019fd | 33 | .interface = &us_interface, |
| Bethory | 0:6ad07c9019fd | 34 | .queue = &events |
| Bethory | 0:6ad07c9019fd | 35 | }; |
| Bethory | 0:6ad07c9019fd | 36 | |
| Bethory | 0:6ad07c9019fd | 37 | const ticker_data_t* get_us_ticker_data(void) |
| Bethory | 0:6ad07c9019fd | 38 | { |
| Bethory | 0:6ad07c9019fd | 39 | return &us_data; |
| Bethory | 0:6ad07c9019fd | 40 | } |
| Bethory | 0:6ad07c9019fd | 41 | |
| Bethory | 0:6ad07c9019fd | 42 | ticker_irq_handler_type set_us_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler) |
| Bethory | 0:6ad07c9019fd | 43 | { |
| Bethory | 0:6ad07c9019fd | 44 | ticker_irq_handler_type prev_irq_handler = irq_handler; |
| Bethory | 0:6ad07c9019fd | 45 | |
| Bethory | 0:6ad07c9019fd | 46 | irq_handler = ticker_irq_handler; |
| Bethory | 0:6ad07c9019fd | 47 | |
| Bethory | 0:6ad07c9019fd | 48 | return prev_irq_handler; |
| Bethory | 0:6ad07c9019fd | 49 | } |
| Bethory | 0:6ad07c9019fd | 50 | |
| Bethory | 0:6ad07c9019fd | 51 | void us_ticker_irq_handler(void) |
| Bethory | 0:6ad07c9019fd | 52 | { |
| Bethory | 0:6ad07c9019fd | 53 | if (irq_handler) { |
| Bethory | 0:6ad07c9019fd | 54 | irq_handler(&us_data); |
| Bethory | 0:6ad07c9019fd | 55 | } |
| Bethory | 0:6ad07c9019fd | 56 | } |