BA
/
BaBoRo_test2
Backup 1
mbed-os/hal/lp_ticker_api.h@0:02dd72d1d465, 2018-04-24 (annotated)
- Committer:
- borlanic
- Date:
- Tue Apr 24 11:45:18 2018 +0000
- Revision:
- 0:02dd72d1d465
BaBoRo_test2 - backup 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borlanic | 0:02dd72d1d465 | 1 | |
borlanic | 0:02dd72d1d465 | 2 | /** \addtogroup hal */ |
borlanic | 0:02dd72d1d465 | 3 | /** @{*/ |
borlanic | 0:02dd72d1d465 | 4 | /* mbed Microcontroller Library |
borlanic | 0:02dd72d1d465 | 5 | * Copyright (c) 2015 ARM Limited |
borlanic | 0:02dd72d1d465 | 6 | * |
borlanic | 0:02dd72d1d465 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
borlanic | 0:02dd72d1d465 | 8 | * you may not use this file except in compliance with the License. |
borlanic | 0:02dd72d1d465 | 9 | * You may obtain a copy of the License at |
borlanic | 0:02dd72d1d465 | 10 | * |
borlanic | 0:02dd72d1d465 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
borlanic | 0:02dd72d1d465 | 12 | * |
borlanic | 0:02dd72d1d465 | 13 | * Unless required by applicable law or agreed to in writing, software |
borlanic | 0:02dd72d1d465 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
borlanic | 0:02dd72d1d465 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
borlanic | 0:02dd72d1d465 | 16 | * See the License for the specific language governing permissions and |
borlanic | 0:02dd72d1d465 | 17 | * limitations under the License. |
borlanic | 0:02dd72d1d465 | 18 | */ |
borlanic | 0:02dd72d1d465 | 19 | #ifndef MBED_LPTICKER_API_H |
borlanic | 0:02dd72d1d465 | 20 | #define MBED_LPTICKER_API_H |
borlanic | 0:02dd72d1d465 | 21 | |
borlanic | 0:02dd72d1d465 | 22 | #include "device.h" |
borlanic | 0:02dd72d1d465 | 23 | |
borlanic | 0:02dd72d1d465 | 24 | #if DEVICE_LOWPOWERTIMER |
borlanic | 0:02dd72d1d465 | 25 | |
borlanic | 0:02dd72d1d465 | 26 | #include "hal/ticker_api.h" |
borlanic | 0:02dd72d1d465 | 27 | |
borlanic | 0:02dd72d1d465 | 28 | #ifdef __cplusplus |
borlanic | 0:02dd72d1d465 | 29 | extern "C" { |
borlanic | 0:02dd72d1d465 | 30 | #endif |
borlanic | 0:02dd72d1d465 | 31 | |
borlanic | 0:02dd72d1d465 | 32 | /** |
borlanic | 0:02dd72d1d465 | 33 | * \defgroup hal_LpTicker Low Power Ticker Functions |
borlanic | 0:02dd72d1d465 | 34 | * @{ |
borlanic | 0:02dd72d1d465 | 35 | */ |
borlanic | 0:02dd72d1d465 | 36 | |
borlanic | 0:02dd72d1d465 | 37 | typedef void (*ticker_irq_handler_type)(const ticker_data_t *const); |
borlanic | 0:02dd72d1d465 | 38 | |
borlanic | 0:02dd72d1d465 | 39 | /** Set low power ticker IRQ handler |
borlanic | 0:02dd72d1d465 | 40 | * |
borlanic | 0:02dd72d1d465 | 41 | * @param ticker_irq_handler IRQ handler to be connected |
borlanic | 0:02dd72d1d465 | 42 | * |
borlanic | 0:02dd72d1d465 | 43 | * @return previous ticker IRQ handler |
borlanic | 0:02dd72d1d465 | 44 | * |
borlanic | 0:02dd72d1d465 | 45 | * @note by default IRQ handler is set to ticker_irq_handler() |
borlanic | 0:02dd72d1d465 | 46 | * @note this function is primarily for testing purposes and it's not required part of HAL implementation |
borlanic | 0:02dd72d1d465 | 47 | * |
borlanic | 0:02dd72d1d465 | 48 | */ |
borlanic | 0:02dd72d1d465 | 49 | ticker_irq_handler_type set_lp_ticker_irq_handler(ticker_irq_handler_type ticker_irq_handler); |
borlanic | 0:02dd72d1d465 | 50 | |
borlanic | 0:02dd72d1d465 | 51 | /** Get low power ticker's data |
borlanic | 0:02dd72d1d465 | 52 | * |
borlanic | 0:02dd72d1d465 | 53 | * @return The low power ticker data |
borlanic | 0:02dd72d1d465 | 54 | */ |
borlanic | 0:02dd72d1d465 | 55 | const ticker_data_t* get_lp_ticker_data(void); |
borlanic | 0:02dd72d1d465 | 56 | |
borlanic | 0:02dd72d1d465 | 57 | /** The wrapper for ticker_irq_handler, to pass lp ticker's data |
borlanic | 0:02dd72d1d465 | 58 | * |
borlanic | 0:02dd72d1d465 | 59 | */ |
borlanic | 0:02dd72d1d465 | 60 | void lp_ticker_irq_handler(void); |
borlanic | 0:02dd72d1d465 | 61 | |
borlanic | 0:02dd72d1d465 | 62 | /* HAL lp ticker */ |
borlanic | 0:02dd72d1d465 | 63 | |
borlanic | 0:02dd72d1d465 | 64 | /** Initialize the low power ticker |
borlanic | 0:02dd72d1d465 | 65 | * |
borlanic | 0:02dd72d1d465 | 66 | */ |
borlanic | 0:02dd72d1d465 | 67 | void lp_ticker_init(void); |
borlanic | 0:02dd72d1d465 | 68 | |
borlanic | 0:02dd72d1d465 | 69 | /** Read the current counter |
borlanic | 0:02dd72d1d465 | 70 | * |
borlanic | 0:02dd72d1d465 | 71 | * @return The current timer's counter value in microseconds |
borlanic | 0:02dd72d1d465 | 72 | */ |
borlanic | 0:02dd72d1d465 | 73 | uint32_t lp_ticker_read(void); |
borlanic | 0:02dd72d1d465 | 74 | |
borlanic | 0:02dd72d1d465 | 75 | /** Set interrupt for specified timestamp |
borlanic | 0:02dd72d1d465 | 76 | * |
borlanic | 0:02dd72d1d465 | 77 | * @param timestamp The time in microseconds to be set |
borlanic | 0:02dd72d1d465 | 78 | */ |
borlanic | 0:02dd72d1d465 | 79 | void lp_ticker_set_interrupt(timestamp_t timestamp); |
borlanic | 0:02dd72d1d465 | 80 | |
borlanic | 0:02dd72d1d465 | 81 | /** Disable low power ticker interrupt |
borlanic | 0:02dd72d1d465 | 82 | * |
borlanic | 0:02dd72d1d465 | 83 | */ |
borlanic | 0:02dd72d1d465 | 84 | void lp_ticker_disable_interrupt(void); |
borlanic | 0:02dd72d1d465 | 85 | |
borlanic | 0:02dd72d1d465 | 86 | /** Clear the low power ticker interrupt |
borlanic | 0:02dd72d1d465 | 87 | * |
borlanic | 0:02dd72d1d465 | 88 | */ |
borlanic | 0:02dd72d1d465 | 89 | void lp_ticker_clear_interrupt(void); |
borlanic | 0:02dd72d1d465 | 90 | |
borlanic | 0:02dd72d1d465 | 91 | /** Set pending interrupt that should be fired right away. |
borlanic | 0:02dd72d1d465 | 92 | * |
borlanic | 0:02dd72d1d465 | 93 | * The ticker should be initialized prior calling this function. |
borlanic | 0:02dd72d1d465 | 94 | */ |
borlanic | 0:02dd72d1d465 | 95 | void lp_ticker_fire_interrupt(void); |
borlanic | 0:02dd72d1d465 | 96 | |
borlanic | 0:02dd72d1d465 | 97 | /** Get frequency and counter bits of this ticker. |
borlanic | 0:02dd72d1d465 | 98 | * |
borlanic | 0:02dd72d1d465 | 99 | */ |
borlanic | 0:02dd72d1d465 | 100 | const ticker_info_t* lp_ticker_get_info(void); |
borlanic | 0:02dd72d1d465 | 101 | |
borlanic | 0:02dd72d1d465 | 102 | /**@}*/ |
borlanic | 0:02dd72d1d465 | 103 | |
borlanic | 0:02dd72d1d465 | 104 | #ifdef __cplusplus |
borlanic | 0:02dd72d1d465 | 105 | } |
borlanic | 0:02dd72d1d465 | 106 | #endif |
borlanic | 0:02dd72d1d465 | 107 | |
borlanic | 0:02dd72d1d465 | 108 | #endif |
borlanic | 0:02dd72d1d465 | 109 | |
borlanic | 0:02dd72d1d465 | 110 | #endif |
borlanic | 0:02dd72d1d465 | 111 | |
borlanic | 0:02dd72d1d465 | 112 | /** @}*/ |