/*
 * ft_timer.c
 *
 *  Created on: 27-Sep-2022
 *      Author: Invcuser52
 */

#include "ft_timer.h"

uint32_t ft_timer_inc;
uint32_t ft_timer_set;
uint8_t ft_timer_flag;
uint8_t ft_timer_on;
uint32_t ft_timer_set_value_save;

typedef struct ft_timer_info
{
	uint16_t timer_inc;
	uint16_t set_timer_one_second_threshold;
	uint16_t set_timer_sus_resume;
	uint16_t set_timer_transmission;
	uint8_t tx_rx_timer_on;
	uint8_t sus_res_timer_on;
	uint16_t tx_rx_timer_inc;
	uint16_t sus_res_timer_inc;
}s_ft_timer_info;


s_ft_timer_info ft_tim_info;

void ft_update_timer__()
{
	if(ft_tim_info.timer_inc < ft_tim_info.set_timer_one_second_threshold)
	{
		ft_tim_info.timer_inc++;

	}
	else
	{
		ft_tim_info.timer_inc =0;
	}

}



void ft_update_timer()
{
	if(ft_timer_inc < ft_timer_set)
	{
		ft_timer_inc++;
	}
	else
	{
		ft_timer_flag = ft_timer_on;
	}

}


void ft_reset_timer()
{
	ft_timer_inc = 0;
	ft_timer_flag = 0;
}

/*
 * set timer in seconds
 * uint16_t set in seconds
 */
void ft_set_timer(uint16_t set)
{
	ft_timer_inc = 0;
	ft_timer_flag = 0;
	ft_timer_on = 1;

	/* assumed timer tick is incremented every 1 ms time */
	ft_timer_set = set * FT_TICK_TIME_IN_MS;
	ft_timer_set_value_save = set;
}



uint8_t ft_get_flag()
{
	return ft_timer_flag;
}


void ft_stop_timer()
{
	ft_timer_on = 0;
}


void ft_init_timer()
{
//	ft_tim_info.timer_inc = 0;
//	ft_tim_info.sus_res_timer_on =0;
//	ft_tim_info.tx_rx_timer_on =0;
}


uint16_t ft_get_previous_timer(void)
{
	return ft_timer_set_value_save;
}

