Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

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