1 /** 2 ***************************************************************************** 3 * @file cmem7_tim.h 4 * 5 * @brief CMEM7 timer header file 6 * 7 * 8 * @version V1.0 9 * @date 3. September 2013 10 * 11 * @note 12 * 13 ***************************************************************************** 14 * @attention 15 * 16 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 17 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 18 * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 19 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 20 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 21 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 22 * 23 * <h2><center>© COPYRIGHT 2013 Capital-micro </center></h2> 24 ***************************************************************************** 25 */ 26 27 #ifndef __CMEM7_TIM_H 28 #define __CMEM7_TIM_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include "cmem7.h" 35 #include "cmem7_conf.h" 36 37 38 #define IS_TIM_ALL_PERIPH(PERIPH) (((PERIPH) == TIMER0) || \ 39 ((PERIPH) == TIMER1) || \ 40 ((PERIPH) == TIMER2) || \ 41 ((PERIPH) == TIMER3)) 42 43 /** 44 * @brief Timer initialization 45 * @note This function should be called at first before any other interfaces. 46 * @param[in] Timx Timer peripheral, which is timer0, timer1, timer2 or timer3 47 * @param[in] Ms overflow micro-seconds of the specific timer 48 * @retval None 49 */ 50 void TIM_Init(TIMER0_Type* Timx, uint16_t Ms); 51 52 /** 53 * @brief Enable or disable timer interrupt. 54 * @param[in] Timx Timer peripheral, which is timer0, timer1, timer2 or timer3 55 * @param[in] Enable The bit indicates if the specific interrupt is enable or not 56 * @retval None 57 */ 58 void TIM_EnableInt(TIMER0_Type* Timx, BOOL Enable); 59 60 /** 61 * @brief Check the specific interrupt is set or not 62 * @param[in] Timx Timer peripheral, which is timer0, timer1, timer2 or timer3 63 * @retval BOOL The bit indicates if the specific interrupt is set or not 64 */ 65 BOOL TIM_GetIntStatus(TIMER0_Type* Timx); 66 67 /** 68 * @brief Clear specific interrupts 69 * @param[in] Timx Timer peripheral, which is timer0, timer1, timer2 or timer3 70 * @retval None 71 */ 72 void TIM_ClearInt(TIMER0_Type* Timx); 73 74 /** 75 * @brief Enable or disable timer. 76 * @param[in] Timx Timer peripheral, which is timer0, timer1, timer2 or timer3 77 * @param[in] Enable The bit indicates if the specific timer is enable or not 78 * @retval None 79 */ 80 void TIM_Enable(TIMER0_Type* Timx, BOOL Enable); 81 82 /** 83 * @brief Check the specific timer is overflow or not 84 * @param[in] Timx Timer peripheral, which is timer0, timer1, timer2 or timer3 85 * @retval BOOL The bit indicates if the specific timer is overflow or not 86 */ 87 BOOL TIM_IsOverflow(TIMER0_Type* Timx); 88 89 /** 90 * @brief Get current counter of timer 91 * @param[in] Timx Timer peripheral, which is timer0, timer1, timer2 or timer3 92 * @retval uint32_t current counter 93 */ 94 uint32_t TIM_GetCounter(TIMER0_Type* Timx); 95 96 #ifdef __cplusplus 97 } 98 #endif 99 100 #endif /*__CMEM7_TIM_H */ 101 102