ver:init
x-nucleo-idb0xa1/bluenrg-hci/ble_gp_timer.h@0:4946262d6030, 2017-06-18 (annotated)
- Committer:
- iv123
- Date:
- Sun Jun 18 16:11:03 2017 +0000
- Revision:
- 0:4946262d6030
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
iv123 | 0:4946262d6030 | 1 | /******************** (C) COPYRIGHT 2012 STMicroelectronics ******************** |
iv123 | 0:4946262d6030 | 2 | * File Name : gp_timer.h |
iv123 | 0:4946262d6030 | 3 | * Author : AMS - HEA&RF BU |
iv123 | 0:4946262d6030 | 4 | * Version : V1.0.0 |
iv123 | 0:4946262d6030 | 5 | * Date : 19-July-2012 |
iv123 | 0:4946262d6030 | 6 | * Description : General purpose timer library. |
iv123 | 0:4946262d6030 | 7 | ******************************************************************************** |
iv123 | 0:4946262d6030 | 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
iv123 | 0:4946262d6030 | 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
iv123 | 0:4946262d6030 | 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
iv123 | 0:4946262d6030 | 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
iv123 | 0:4946262d6030 | 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
iv123 | 0:4946262d6030 | 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
iv123 | 0:4946262d6030 | 14 | *******************************************************************************/ |
iv123 | 0:4946262d6030 | 15 | |
iv123 | 0:4946262d6030 | 16 | #ifndef __GP_TIMER_H__ |
iv123 | 0:4946262d6030 | 17 | #define __GP_TIMER_H__ |
iv123 | 0:4946262d6030 | 18 | |
iv123 | 0:4946262d6030 | 19 | #include "ble_clock.h" |
iv123 | 0:4946262d6030 | 20 | #include "ble_status.h" |
iv123 | 0:4946262d6030 | 21 | #ifdef __DMA_LP__ |
iv123 | 0:4946262d6030 | 22 | #include "stm32xx_timerserver.h" |
iv123 | 0:4946262d6030 | 23 | #endif /* __DMA_LP__ */ |
iv123 | 0:4946262d6030 | 24 | |
iv123 | 0:4946262d6030 | 25 | /** |
iv123 | 0:4946262d6030 | 26 | * timer |
iv123 | 0:4946262d6030 | 27 | * |
iv123 | 0:4946262d6030 | 28 | * A structure that represents a timer. Use Timer_Set() to set the timer. |
iv123 | 0:4946262d6030 | 29 | * |
iv123 | 0:4946262d6030 | 30 | */ |
iv123 | 0:4946262d6030 | 31 | struct timer { |
iv123 | 0:4946262d6030 | 32 | |
iv123 | 0:4946262d6030 | 33 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
iv123 | 0:4946262d6030 | 34 | |
iv123 | 0:4946262d6030 | 35 | tClockTime start; |
iv123 | 0:4946262d6030 | 36 | tClockTime interval; |
iv123 | 0:4946262d6030 | 37 | |
iv123 | 0:4946262d6030 | 38 | #endif |
iv123 | 0:4946262d6030 | 39 | }; |
iv123 | 0:4946262d6030 | 40 | |
iv123 | 0:4946262d6030 | 41 | typedef void (* TIMER_HCI_TIMEOUT_NOTIFY_CALLBACK_TYPE)(void); |
iv123 | 0:4946262d6030 | 42 | |
iv123 | 0:4946262d6030 | 43 | /** |
iv123 | 0:4946262d6030 | 44 | * Timer_Set |
iv123 | 0:4946262d6030 | 45 | * |
iv123 | 0:4946262d6030 | 46 | * @param[in] t Pointer to a timer structure |
iv123 | 0:4946262d6030 | 47 | * @param[in] interval timeout value |
iv123 | 0:4946262d6030 | 48 | * |
iv123 | 0:4946262d6030 | 49 | * This function sets the timeout value of a timer. |
iv123 | 0:4946262d6030 | 50 | * |
iv123 | 0:4946262d6030 | 51 | */ |
iv123 | 0:4946262d6030 | 52 | void Timer_Set(struct timer *t, tClockTime interval); |
iv123 | 0:4946262d6030 | 53 | |
iv123 | 0:4946262d6030 | 54 | /** |
iv123 | 0:4946262d6030 | 55 | * Timer_Reset |
iv123 | 0:4946262d6030 | 56 | * |
iv123 | 0:4946262d6030 | 57 | * @param[in] t Pointer to a timer structure |
iv123 | 0:4946262d6030 | 58 | * |
iv123 | 0:4946262d6030 | 59 | * This function resets the timer with the same interval given |
iv123 | 0:4946262d6030 | 60 | * with Timer_Set, starting from the time it previously expired. |
iv123 | 0:4946262d6030 | 61 | * |
iv123 | 0:4946262d6030 | 62 | */ |
iv123 | 0:4946262d6030 | 63 | void Timer_Reset(struct timer *t); |
iv123 | 0:4946262d6030 | 64 | |
iv123 | 0:4946262d6030 | 65 | /** |
iv123 | 0:4946262d6030 | 66 | * Timer_Restart |
iv123 | 0:4946262d6030 | 67 | * |
iv123 | 0:4946262d6030 | 68 | * @param[in] t Pointer to a timer structure |
iv123 | 0:4946262d6030 | 69 | * |
iv123 | 0:4946262d6030 | 70 | * This function resets the timer with the same interval given |
iv123 | 0:4946262d6030 | 71 | * with Timer_Set, starting from the current time. |
iv123 | 0:4946262d6030 | 72 | * |
iv123 | 0:4946262d6030 | 73 | */ |
iv123 | 0:4946262d6030 | 74 | void Timer_Restart(struct timer *t); |
iv123 | 0:4946262d6030 | 75 | |
iv123 | 0:4946262d6030 | 76 | /** |
iv123 | 0:4946262d6030 | 77 | * Timer_Expired |
iv123 | 0:4946262d6030 | 78 | * |
iv123 | 0:4946262d6030 | 79 | * @param[in] t Pointer to a timer structure |
iv123 | 0:4946262d6030 | 80 | * |
iv123 | 0:4946262d6030 | 81 | * This function returns TRUE if timer is expired, FALSE otherwise. |
iv123 | 0:4946262d6030 | 82 | * |
iv123 | 0:4946262d6030 | 83 | */ |
iv123 | 0:4946262d6030 | 84 | int Timer_Expired(struct timer *t); |
iv123 | 0:4946262d6030 | 85 | |
iv123 | 0:4946262d6030 | 86 | /** |
iv123 | 0:4946262d6030 | 87 | * Timer_Expired |
iv123 | 0:4946262d6030 | 88 | * |
iv123 | 0:4946262d6030 | 89 | * @param[in] t Pointer to a timer structure |
iv123 | 0:4946262d6030 | 90 | * |
iv123 | 0:4946262d6030 | 91 | * This function returns the time needed for expiration. |
iv123 | 0:4946262d6030 | 92 | * |
iv123 | 0:4946262d6030 | 93 | * @return Time before timer's expiration. |
iv123 | 0:4946262d6030 | 94 | */ |
iv123 | 0:4946262d6030 | 95 | tClockTime Timer_Remaining(struct timer *t); |
iv123 | 0:4946262d6030 | 96 | |
iv123 | 0:4946262d6030 | 97 | #ifdef __DMA_LP__ |
iv123 | 0:4946262d6030 | 98 | tBleStatus Blue_NRG_HCI_Timer_Start(uint32_t expiryTime, |
iv123 | 0:4946262d6030 | 99 | TIMER_HCI_TIMEOUT_NOTIFY_CALLBACK_TYPE timercb, |
iv123 | 0:4946262d6030 | 100 | uint8_t *timerID); |
iv123 | 0:4946262d6030 | 101 | |
iv123 | 0:4946262d6030 | 102 | tBleStatus Blue_NRG_HCI_Timer_Stop(uint8_t timerID); |
iv123 | 0:4946262d6030 | 103 | #endif /* __DMA_LP__ */ |
iv123 | 0:4946262d6030 | 104 | |
iv123 | 0:4946262d6030 | 105 | #endif /* __GP_TIMER_H__ */ |