コード例 #1
0
int spwr_table_write(int dd,UW index, UW data)
{
	ER er;
	int asize, data0;

	data0 = index;
	er = tk_swri_dev(dd, DN_TBLIDX, &data0, sizeof(data0), &asize);
	if (er != E_OK) return er;

	data0 = data;
	er = tk_swri_dev(dd, DN_TBLDAT, &data0, sizeof(data0), &asize);
	return er;
}
コード例 #2
0
ファイル: spw_if.c プロジェクト: lzgjxh/SpaceWireRMAPLibrary
int spw_connect(int dd)
{
	ER er;
	UW data, div;
	int asize;
	int n;

	printf("connecting ...\n");

	data = ((UW)txclk_div << 8) & 0x00003f00;
	data |= 0x00000001;
	er = tk_swri_dev(dd, DN_LINKC, &data, sizeof(data), &asize);

	for (n = 0; n < 100; n ++) {

		slp_tsk(50);
		er = tk_srea_dev(dd, DN_LINKS, &data, sizeof(data), &asize);
		if (er == E_PAR) printf("spw_connect : E_PAR");
		printf("status = 0x%08x\n", data);

		if ((data & 0x0000001c) == 0x0000001c) {
			printf("connected.\n");
			return 0;
		}
		slp_tsk(100);
	}
	return 1;
}
コード例 #3
0
/** reset port
 */
int spwr_reset_link(int dd,int portnum){
	ER er;
	UW data;
	int asize;

	if(portnum<1 || 6<portnum){
		return E_PAR;
	}

	int address;
	switch(portnum){
	case 1: address=DN_SPW1CSR;break;
	case 2: address=DN_SPW2CSR;break;
	case 3: address=DN_SPW3CSR;break;
	case 4: address=DN_SPW4CSR;break;
	case 5: address=DN_SPW5CSR;break;
	case 6: address=DN_SPW6CSR;break;
	default: return E_PAR;break;
	}

	er = tk_srea_dev(dd, address, &data, sizeof(data), &asize);
	if (asize != 4) {
		return E_IO;
	}
	data = data & 0x00ffffff;
	data = data | SPW_LINKRESET;


	er = tk_swri_dev(dd, address, &data, sizeof(data), &asize);
	if (asize != 4) {
		er = E_IO;
	}

	return er;
}
コード例 #4
0
int spwr_open(int portnum)
{
	ER er;
	UW data;
	int asize;
	int dd;
	if(portnum==4){
		dd = tk_opn_dev((UB*)"spwa", TD_UPDATE);
	}else if(portnum==5){
		dd = tk_opn_dev((UB*)"spwb", TD_UPDATE);
	}else if(portnum==6){
		dd = tk_opn_dev((UB*)"spwc", TD_UPDATE);
	}else{
		printf("open error : invalid port number\n");
		return -1;
	}

	if (dd < 0) {
		printf("open error (er=0x%8x)\n", dd);
		return dd;
	}

	/* Enable Timecode output to Port 1,2,3
	*/
	data=0x0000000e; //enable timecode output to port 1,2,3
	er = tk_swri_dev(dd, DN_TCODEEN, &data, sizeof(data), &asize);

	er = tk_srea_dev(dd, DN_SIGN, &data, sizeof(data), &asize);
	if (er == E_PAR) printf("E_PAR");
	else {
		printf("fpga ver. = 0x%04x\n", (unsigned short)(0x0000ffff & data));
	}

	return dd;
}
コード例 #5
0
ファイル: led.c プロジェクト: imasahiro/konoha-jit-deprecated
METHOD System_led(Ctx *ctx, knh_sfp_t *sfp)
{
    int v = p_int(sfp[1]);
    int ddl, asize;
    ddl = tk_opn_dev("led_test",TD_UPDATE);
    tk_swri_dev(ddl, DN_LEMode, &v, sizeof(v), &asize);
    KNH_RETURN_void(ctx, sfp);
}
コード例 #6
0
ファイル: led.c プロジェクト: imasahiro/konoha-jit-deprecated
METHOD System_segLed(Ctx *ctx, knh_sfp_t *sfp)
{
    int x = p_int(sfp[1]);
    int dd, asize;
    dd = tk_opn_dev("led", TD_UPDATE);
    tk_swri_dev(dd, DN_LEDEC, &x, sizeof(x), &asize);
    KNH_RETURN_void(ctx, sfp);
}
コード例 #7
0
ファイル: spw_if.c プロジェクト: lzgjxh/SpaceWireRMAPLibrary
int spw_send_timecode(int dd,unsigned char flag_and_timecode){
	ER er;
	UW data;
	int asize;

	data=0x00000000+flag_and_timecode;
	er = tk_swri_dev(dd, DN_TIMIN, &data, sizeof(data), &asize);
	return er;
}
コード例 #8
0
int spwr_send_timecode(int dd,unsigned char flag_and_timecode){
	ER er;
	unsigned int data;
	int asize;
	int dd;

	data=0x00000000+flag_and_timecode;
	er = tk_swri_dev(dd, DN_TCOUT, &data, sizeof(data), &asize);

	return er;
}
コード例 #9
0
ファイル: spw_if.c プロジェクト: lzgjxh/SpaceWireRMAPLibrary
int spw_set_read_timeout(int dd,UW time_out){
	ER er;
	UW data;
	int asize;

	data = time_out;
	er = tk_swri_dev(dd, DN_RXTMO, &data, sizeof(data), &asize);
	if (asize != 4) {
		printf("spw_set_read_timeout() size error asize=%d\n",asize);
		return E_IO;
	}
	return er;
}
コード例 #10
0
UW spwr_table_read(int dd,UW index)
{
	ER er;
	int asize, data0;

	data0 = index;
	er = tk_swri_dev(dd, DN_TBLIDX, &data0, sizeof(data0), &asize);
	if (er != E_OK) return 0xffffffff;

	er = tk_srea_dev(dd, DN_TBLDAT, &data0, sizeof(data0), &asize);
	if (er != E_OK) return 0xffffffff;
	return data0;
}
コード例 #11
0
int spwr_set_write_timeout(int dd,UW time_out)
{
	ER er;
	UW data;
	int asize;

	data = time_out;
	er = tk_swri_dev(dd, DN_TXTMO, &data, sizeof(data), &asize);
	if (asize != 4) {
		return E_IO;
	}
	return er;
}
コード例 #12
0
ファイル: spw_if.c プロジェクト: lzgjxh/SpaceWireRMAPLibrary
int spw_write(int dd,UW *buf, UW size)
{
	//printf("spw_write invoked\n");
	ER er;
	int asize;

	/*
	 * check link here ?
	 */

	er = tk_swri_dev(dd, 0, buf, size, &asize);
	if (size == asize) {
		return 0;
	} else {
		return 1;
	}
}
コード例 #13
0
int spwr_set_link3_txspeed(int dd,spwr_txclk_div txclk_div)
{
	ER er;
	UW data;
	int asize;

	er = tk_srea_dev(dd, DN_SPW3CSR, &data, sizeof(data), &asize);
	if (asize != 4) {
		return E_IO;
	}
	data = data | (((UW)txclk_div << 24) & 0x3f000000);
	er = tk_swri_dev(dd, DN_SPW3CSR, &data, sizeof(data), &asize);
	if (asize != 4) {
		return E_IO;
	}
	return er;
}
コード例 #14
0
int spwr_write(int dd,UW *buf, UW size)
{
	ER er;
	int asize;

	/*
	 * check link here ?
	 */

//	printf("spwr_write start\n");

	er = tk_swri_dev(dd, 0, buf, size, &asize);

//	printf("spwr_write done\n");

	if (size == asize) {
		return 0;
	} else {
		return 1;
	}
}
コード例 #15
0
ファイル: command.c プロジェクト: Ninals-GitHub/TRON
/*
	Get from / Set to RTC
*/
LOCAL	void	rtc_get_set(SYSTIM *stm, BOOL set)
{
	ID		dd;
	W		asz;
	ER		er;
	DATE_TIM	dt;
	struct tm	ctm;
	struct tzinfo	tz;

	/* open RTC (CLOCK) driver */
	dd = tk_opn_dev("CLOCK", (set == TRUE) ? TD_WRITE : TD_READ);
	if (dd < E_OK) {
		P("Can't open CLOCK device [%#x]\n", dd);
		goto exit0;
	}

	/* Note: The RTC is set to UTC rather than local time. because UTC
	   is not affected by time zone and daylight saving time. */

	if (set == TRUE) {	/* set date to RTC */

		/* convert system time to UTC date/time */
		dt_gmtime_ms(stm, &ctm);

		/* set local date/time to RTC */
		dt.d_year = ctm.tm_year;
		dt.d_month = ctm.tm_mon + 1;
		dt.d_day = ctm.tm_mday;
		dt.d_hour = ctm.tm_hour;
		dt.d_min = ctm.tm_min;
		dt.d_sec = ctm.tm_sec;
		dt.d_wday = ctm.tm_wday;
		er = tk_swri_dev(dd, DN_CKDATETIME, &dt, sizeof(dt), &asz);
		if (er < E_OK) {
			P("Can't set CLOCK [%#x]\n", er);
			goto exit1;
		}
	} else {		/* get date from RTC */

		/* get timezone of "UTC+0" */
		memset(&tz, 0, sizeof(tz));
		er = dt_tzset(&tz, "UTC+0");
		if (er < E_OK ) {
			P("dt_tzset(UTC+0) ERR [%#x]\n", er);
			goto exit1;
		}

		/* get UTC date/time from RTC */
		er = tk_srea_dev(dd, DN_CKDATETIME, &dt, sizeof(dt), &asz);
		if (er < E_OK) {
			P("Can't get CLOCK [%#x]\n", er);
			goto exit1;
		}

		/* convert to system time */
		ctm.tm_year = dt.d_year;
		ctm.tm_mon = dt.d_month - 1;
		ctm.tm_mday = dt.d_day;
		ctm.tm_hour = dt.d_hour;
		ctm.tm_min = dt.d_min;
		ctm.tm_sec = dt.d_sec;
		ctm.tm_wday = dt.d_wday;
		ctm.tm_usec = 0;
		ctm.tm_wday = -1;
		ctm.tm_isdst = 0;
		ctm.tm_yday = 0;
		dt_mktime_ms(&ctm, &tz, stm);
	}
exit1:
	tk_cls_dev(dd, 0);
exit0:
	return;
}