RTC auf true
hal/mbed_lp_ticker_api.c@0:38ceb79fef03, 2018-11-28 (annotated)
- Committer:
- kevman
- Date:
- Wed Nov 28 15:10:15 2018 +0000
- Revision:
- 0:38ceb79fef03
RTC modified
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevman | 0:38ceb79fef03 | 1 | /* mbed Microcontroller Library |
kevman | 0:38ceb79fef03 | 2 | * Copyright (c) 2015 ARM Limited |
kevman | 0:38ceb79fef03 | 3 | * |
kevman | 0:38ceb79fef03 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kevman | 0:38ceb79fef03 | 5 | * you may not use this file except in compliance with the License. |
kevman | 0:38ceb79fef03 | 6 | * You may obtain a copy of the License at |
kevman | 0:38ceb79fef03 | 7 | * |
kevman | 0:38ceb79fef03 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kevman | 0:38ceb79fef03 | 9 | * |
kevman | 0:38ceb79fef03 | 10 | * Unless required by applicable law or agreed to in writing, software |
kevman | 0:38ceb79fef03 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kevman | 0:38ceb79fef03 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kevman | 0:38ceb79fef03 | 13 | * See the License for the specific language governing permissions and |
kevman | 0:38ceb79fef03 | 14 | * limitations under the License. |
kevman | 0:38ceb79fef03 | 15 | */ |
kevman | 0:38ceb79fef03 | 16 | #include "hal/lp_ticker_api.h" |
kevman | 0:38ceb79fef03 | 17 | #include "hal/mbed_lp_ticker_wrapper.h" |
kevman | 0:38ceb79fef03 | 18 | |
kevman | 0:38ceb79fef03 | 19 | #if DEVICE_LPTICKER |
kevman | 0:38ceb79fef03 | 20 | |
kevman | 0:38ceb79fef03 | 21 | static ticker_event_queue_t events = { 0 }; |
kevman | 0:38ceb79fef03 | 22 | |
kevman | 0:38ceb79fef03 | 23 | static ticker_irq_handler_type irq_handler = ticker_irq_handler; |
kevman | 0:38ceb79fef03 | 24 | |
kevman | 0:38ceb79fef03 | 25 | static const ticker_interface_t lp_interface = { |
kevman | 0:38ceb79fef03 | 26 | .init = lp_ticker_init, |
kevman | 0:38ceb79fef03 | 27 | .read = lp_ticker_read, |
kevman | 0:38ceb79fef03 | 28 | .disable_interrupt = lp_ticker_disable_interrupt, |
kevman | 0:38ceb79fef03 | 29 | .clear_interrupt = lp_ticker_clear_interrupt, |
kevman | 0:38ceb79fef03 | 30 | .set_interrupt = lp_ticker_set_interrupt, |
kevman | 0:38ceb79fef03 | 31 | .fire_interrupt = lp_ticker_fire_interrupt, |
kevman | 0:38ceb79fef03 | 32 | .get_info = lp_ticker_get_info, |
kevman | 0:38ceb79fef03 | 33 | .free = lp_ticker_free, |
kevman | 0:38ceb79fef03 | 34 | }; |
kevman | 0:38ceb79fef03 | 35 | |
kevman | 0:38ceb79fef03 | 36 | static const ticker_data_t lp_data = { |
kevman | 0:38ceb79fef03 | 37 | .interface = &lp_interface, |
kevman | 0:38ceb79fef03 | 38 | .queue = &events, |
kevman | 0:38ceb79fef03 | 39 | }; |
kevman | 0:38ceb79fef03 | 40 | |
kevman | 0:38ceb79fef03 | 41 | const ticker_data_t *get_lp_ticker_data(void) |
kevman | 0:38ceb79fef03 | 42 | { |
kevman | 0:38ceb79fef03 | 43 | #if LPTICKER_DELAY_TICKS > 0 |
kevman | 0:38ceb79fef03 | 44 | return get_lp_ticker_wrapper_data(&lp_data); |
kevman | 0:38ceb79fef03 | 45 | #else |
kevman | 0:38ceb79fef03 | 46 | return &lp_data; |
kevman | 0:38ceb79fef03 | 47 | #endif |
kevman | 0:38ceb79fef03 | 48 | } |
kevman | 0:38ceb79fef03 | 49 | |
kevman | 0:38ceb79fef03 | 50 | ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler) |
kevman | 0:38ceb79fef03 | 51 | { |
kevman | 0:38ceb79fef03 | 52 | ticker_irq_handler_type prev_irq_handler = irq_handler; |
kevman | 0:38ceb79fef03 | 53 | |
kevman | 0:38ceb79fef03 | 54 | irq_handler = ticker_irq_handler; |
kevman | 0:38ceb79fef03 | 55 | |
kevman | 0:38ceb79fef03 | 56 | return prev_irq_handler; |
kevman | 0:38ceb79fef03 | 57 | } |
kevman | 0:38ceb79fef03 | 58 | |
kevman | 0:38ceb79fef03 | 59 | void lp_ticker_irq_handler(void) |
kevman | 0:38ceb79fef03 | 60 | { |
kevman | 0:38ceb79fef03 | 61 | #if LPTICKER_DELAY_TICKS > 0 |
kevman | 0:38ceb79fef03 | 62 | lp_ticker_wrapper_irq_handler(irq_handler); |
kevman | 0:38ceb79fef03 | 63 | #else |
kevman | 0:38ceb79fef03 | 64 | if (irq_handler) { |
kevman | 0:38ceb79fef03 | 65 | irq_handler(&lp_data); |
kevman | 0:38ceb79fef03 | 66 | } |
kevman | 0:38ceb79fef03 | 67 | #endif |
kevman | 0:38ceb79fef03 | 68 | } |
kevman | 0:38ceb79fef03 | 69 | |
kevman | 0:38ceb79fef03 | 70 | #endif |