MTK HTTP 프로 토 콜 의 시간 조작
nw_time.c
#include "nw_define.h"
#include "Vmsys.h"
NW_TIMER_DATA nw_timer;
#define NW_HTTP_TIMER_ID    125
#define NW_TIMER_SUPPORT_MAX   (16)
#define NW_TIMER_MAIN_LOOP	(100)
void nw_http_timer_loop(void);
void nw_http_main_timer_start()
{
	StartTimer(NW_HTTP_TIMER_ID, 100, nw_http_timer_loop);
}
void nw_http_main_timer_stop()
{
	StopTimer(NW_HTTP_TIMER_ID);
}
nw_uint32 nw_timer_get_interval()
{
	return NW_TIMER_MAIN_LOOP;  //100  
}
void nw_http_timer_loop(void)
{
	if (nw_timer.callback_func != NULL)
	{
		if (nw_timer.remain_time <= nw_timer_get_interval())
		{
			NW_TIMER_CALLBACK timer_func = nw_timer.callback_func;
			nw_timer.callback_func = NULL;
			timer_func(nw_timer.nw_timer_param_i,nw_timer.nw_timer_param_w);
		}
		else
		{
			nw_timer.remain_time -= nw_timer_get_interval();
		}
	}
}
nw_uint16 nw_http_timer_start(nw_int8 app_index, nw_uint32 delay, NW_TIMER_CALLBACK callback_func, NW_TIMER_TYPE type)
{
	if(nw_timer.used == 0)
	{
		nw_timer.timer_id =  1; 
		nw_timer.remain_time= delay;
		nw_timer.callback_func	= callback_func;
		nw_timer.soc_id= app_index;
		nw_timer.nw_timer_param_i	= (void*)nw_timer.soc_id;
		nw_timer.used = 1;
		nw_timer.type = type;
		nw_timer.nw_timer_param_w	= (void*)nw_timer.type;
		return (nw_timer.timer_id);
	}
	return 0;
}
nw_uint16 nw_http_get_timer_id_by_app_index(nw_int8 app_index , NW_TIMER_TYPE type)
{
	if((nw_timer.soc_id == app_index) && (nw_timer.type == type))
	{
		return (nw_timer.timer_id);
	}
	return 0;
}
nw_uint16 nw_http_timer_stop(nw_uint16 timer_id)
{
	if(timer_id == nw_timer.timer_id)
	{
		nw_timer.timer_id = 0; 
		nw_timer.remain_time= 0;
		nw_timer.callback_func	= 0;
		nw_timer.soc_id= 0;
	}
	return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
자바스크립트로 타이머 만들기JavaScript와 HTML만 사용하여 간단한 타이머를 만들어 보겠습니다. 먼저 인터페이스를 만들고 HTML만 사용하여 간단한 작업을 수행합니다. HTML 구조에서 시간 정보를 표시하기 위해 일부span가 생성되었...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.