/*****************************************************************************
* File Name          : Systick_For_Timeout.c
* Author             : 
* Version            : V1.4.0.0
* Date               : 31/01/2011
* Description        : 
******************************************************************************/   


#include "Systick_For_Timeout.h"

// variables
volatile uint16_t  i_Timeout_Count ;

uint16_t get_Timeout_Count()
{
	return i_Timeout_Count;
}

void Timeout_CountDwn()
{
	if ( i_Timeout_Count > 0 )
	{
		i_Timeout_Count -- ;	
	}
}

uint8_t Systick_1ms_Init( void )
{
	// SysTick end of count event each 1ms with input clock equal to 9MHz (HCLK/8, default)
	//SysTick_SetReload( 9000 ) ;
	
	// Enable SysTick interrupt
	//SysTick_ITConfig( ENABLE ) ;
	

	return 1 ;
}

void Systick_Timeout_Start( uint16_t Count_times )
{
	i_Timeout_Count = Count_times ;

	// Clear SysTick Counter
	//SysTick_CounterCmd( SysTick_Counter_Clear ) ;

	// Enable the SysTick Counter
	//SysTick_CounterCmd( SysTick_Counter_Enable ) ;
}

void Systick_Timeout_Stop( void )
{
	// Disable SysTick Counter
	//SysTick_CounterCmd( SysTick_Counter_Disable ) ;
}

uint8_t TimeOut_Check( void )
{		
	if( i_Timeout_Count > 0 )
	{
		return  0 ; 
	}
	else
	{
		return  1 ;
	}
}
