/* ****************************************************************************** * * @file sys_tim.c * @brief Timer module * * * @version 1.0 * @date 2022/09/05 15:00:40 * @author Alex Xu * * Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd. * All Rights Reserved * * History: * Revision Date Author Desc * 1.0.0 2022/09/05 Alex build this file ******************************************************************************/ /*_____ I N C L U D E S ____________________________________________________*/ #include "sys_tim.h" #include "vox_module.h" #include "system.h" #include "charger_module.h" #include "led.h" #include "gpio_comm.h" /******************************************************************************\ Macro definitions \******************************************************************************/ /******************************************************************************\ Variables definitions \******************************************************************************/ uint8_t cnt_sys_tim_10ms = 0; uint8_t cnt_sys_tim_250ms = 0; uint8_t cnt_sys_tim_100ms = 0; uint8_t cnt_sys_tim_1s = 0; bit F_sys_tim_10ms = 0; bit F_sys_tim_250ms = 0; bit F_sys_tim_100ms = 0; bit F_sys_tim_1s = 0; uint8_t F_sys_tim0_tick = 0; uint8_t cnt_sys_tim0_5ms = 0; bit BES_Puls_Start = 0; //开启BES Reset脉冲信号 #if TIMER1_ENABLE bit F_sys_tim1_tick = 0; #endif /******************************************************************************\ Functions definitions \******************************************************************************/ /* ******************************************************************************* * void Sys_Tim_Handler(void ) * * Description : Timer Handle * * Arguments : NONE * Returns : NONE * Notes : NONE * ******************************************************************************* */ void Sys_Tim_Handler(void) { if(F_sys_tim0_tick == 0) return; F_sys_tim0_tick = 0; //system tick #if 1 //---------------10ms---------------------------------------- cnt_sys_tim_10ms++; if(cnt_sys_tim_10ms >= 10) { cnt_sys_tim_10ms = 0; F_sys_tim_10ms = 1; } #endif //---------------100ms---------------------------------------- cnt_sys_tim_100ms++; if(cnt_sys_tim_100ms >= 100) { cnt_sys_tim_100ms = 0; F_sys_tim_100ms = 1; } //------------------------------------------------- cnt_sys_tim_250ms++; if(cnt_sys_tim_250ms>=250) { cnt_sys_tim_250ms = 0; F_sys_tim_250ms = 1; //-----------------250ms------------------------- cnt_sys_tim_1s++; if(cnt_sys_tim_1s >= 4) { cnt_sys_tim_1s = 0; F_sys_tim_1s = 1; } } } /* ******************************************************************************* * void Delay10ms(void) //@11.0592MHz * * Description : 10ms软定时函数 * * Arguments : NONE * Returns : NONE * Notes : NONE * ******************************************************************************* */ #if 0 void Delay15ms(void) //@11.0592MHz { unsigned char i, j; i = 36; j = 140; do { while (--j); } while (--i); } #endif /** * @brief This function handles sys_tim Handler. * @param None * @retval None * 1ms */ #define PATTERN_HIGH_CNT 160 //高电平时间 #define PATTERN_LOW_CNT 2 //低电平时间 #define PATTERN_TIM 162 //8s + 100ms void tim0_Interrupt(void) interrupt Interrupt_Vector_TF0 //interrupt address is 0x000B { //1ms TH0 += C_TIM0_Reload >> 8; TL0 += C_TIM0_Reload & 0xFF; F_sys_tim0_tick = 1; #if VOX_TX_PATTERN Gpio_Comm(Pattern_TX_Data); #endif } /* ******************************************************************************* * void Sys_Tim0_Init(void) * * Description : TImer0 Mode1 16bit timer Initialization * * Arguments : NONE * Returns : NONE * Notes : NONE * ******************************************************************************* */ #if 0 void Sys_Tim0_Init(void) { TMOD &= 0xF0; TMOD |= 0x01; //mode 1, 16bit timer TH0 = C_TIM0_Reload >> 8; TL0 = C_TIM0_Reload & 0xFF; ET0 = 1; //enable time0 interrupt TR0 = 1; //time0 run } #endif #if TIMER1_ENABLE /** * @brief This function handles sys_tim Handler. * @param None * @retval None * 1ms */ void tim1_Interrupt(void) interrupt Interrupt_Vector_TF1//interrupt address is 0x000B { //1ms TF1 = 0; TH1 += C_TIM1_Reload >> 8; TL1 += C_TIM1_Reload & 0xFF; #ifdef LED_DISPLAY #ifdef BREATHING_LIGHT /*todo*/ LED_Breathing_Light(); #endif #endif F_sys_tim1_tick = 1; } /* ******************************************************************************* * void Sys_Tim1_Init(void) * * Description : TImer1 Mode1 16bit timer Initialization * * Arguments : NONE * Returns : NONE * Notes : NONE * ******************************************************************************* */ #if 0 void Sys_Tim1_Init(void) { TMOD &= 0x0F; TMOD |= 0x10; //mode 1, 16bit timer TH1 = C_TIM1_Reload >> 8; TL1 = C_TIM1_Reload & 0xFF; ET1 = 1; //enable time1 interrupt TR1 = 1; //time1 run } #endif #endif