task.c

来自「T-kernel Tcp/ip Protocol Stack Sample」· C语言 代码 · 共 63 行

C
63
字号
/*
 *  Copyright (C) 2004 MITSUBISHI ELECTRIC CORPORATION and
 *  RENESAS SOLUTIONS CORPORATION
 *  All rights reserved.
 *
 *  Sample Application program used for TCP/IP subsystem.
 */

#include <basic.h>
#include <tk/tkernel.h>

extern void *memset(void *, int, size_t);

/* mili seconds */
#define DELAY_TIME (1000)	/* mili-sec */


void
samp_cychdr(VP exinf)
{
	// tm_putstring("LED off.\n");
	return;
}

void
init_task(int stacd, void *exinf)
{
	ER ercd;
	INT i, cid;
	T_CCYC pk_ccyc;
	UINT intsts;

	tm_putstring("init_task() is executed.\n");

	/* create ans start cyclic handler */
	memset((char *)&pk_ccyc, 0, sizeof(T_CCYC));
	pk_ccyc.cycatr = TA_HLNG;
	pk_ccyc.cychdr = (FP)samp_cychdr;
	pk_ccyc.cyctim = (UINT)DELAY_TIME;
	cid = tk_cre_cyc(&pk_ccyc);
	if (cid < E_OK) goto error1;

	ercd = tk_sta_cyc(cid);
	if (ercd != E_OK) goto error1;

	ercd = tk_dly_tsk((DELAY_TIME)/2);
	if (ercd != E_OK) goto error1;

	for (i=1; ; i++) {
		DI(intsts);
		// tm_putstring("LED on.\n");
		EI(intsts);

		ercd = tk_dly_tsk(DELAY_TIME);
		if (ercd != E_OK) break;
	}

error1:
	tk_ext_tsk();
}

/* EOF */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?