/*
 ******************************************************************************
 *
 * @file     sys_tim.h
 * @brief    system timer module
 *                 
 *
 * @version  1.0
 * @date     2023/05/12   09:59:40
 * @author   Alex Xu
 *
 * Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
 * All Rights Reserved
 *
 * History:
 * Revision          Date           Author            Desc
 * 1.0.0            2023/07/12      Alex          build this file
 ******************************************************************************
 */

#ifndef __sys_tim_H__
#define __sys_tim_H__

#include "define.h"

//#define FOSC 11059200L

#define T1MS 921
#define T100uS 91
#define T200uS 183
#define T300uS 275
#define T400uS 368 
#define T500uS 460 
#define T600uS 552 
#define T800uS 736 

#define T10MS 9215			//FOSC/12/100

#define	C_TIM0_Reload	(65535 - T1MS)	//1ms (65535 - N) * 1/FOSC = Time -> (65535 - N) * 1/11.0592M = 1ms -> 65535 - N = 11059.2 -> N = 65535 - 11059.2
//extern void Sys_Tim0_Init(void );

#if TIMER1_ENABLE

#ifdef BREATHING_LIGHT
#define	C_TIM1_Reload	(65535 - T100uS) //100us ÓÃÓÚºôÎüµÆ
#else	
//#define	C_TIM1_Reload	(65535 - T300uS) //300us

#define	C_TIM1_Reload	(65535 - T500uS) //500us
#define	C_TIM1_Reload1	(65535 - T500uS) //500us

#endif

extern	bit F_sys_tim1_tick;
extern void Sys_Tim1_Init(void );

#endif

extern	bit F_sys_tim0_tick;

extern  bit F_sys_tim_5ms;
	
extern  bit F_sys_tim_10ms;

extern  bit F_sys_tim_250ms;
extern  bit F_sys_tim_100ms;
extern  bit F_sys_tim_1s;

extern void Sys_Tim_Handler(void );
extern void Delay200ms(void);

#endif

