예제 #1
0
파일: socket.c 프로젝트: ATMEGA17/tinkerit
uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len)
{
	uint8 status=0;
// uint8 isr=0;
	uint16 ret=0;
	
#ifdef __DEF_IINCHIP_DBG__
	printf("igmpsend()\r\n");
#endif
	if (len > IINCHIP_TxMAX) ret = IINCHIP_TxMAX; // check size not to exceed MAX size.
	else ret = len;

	if (ret == 0) 
	{
		;
#ifdef __DEF_IINCHIP_DBG__
	printf("%d Fail[%d]\r\n",len);
#endif
	}
	else
	{
		// copy data
		send_data_processing(s, (uint8 *)buf, ret);
		
/* +2008.01 bj */ 
#ifdef __DEF_IINCHIP_INT__
		while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) 
#else
		while ( (wiz_read_byte(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) 
#endif
		{
			status = wiz_read_byte(Sn_SR(s));
#ifdef __DEF_IINCHIP_INT__
			if (getISR(s) & Sn_IR_TIMEOUT)
#else
			if (wiz_read_byte(Sn_IR(s)) & Sn_IR_TIMEOUT)
#endif
			{
#ifdef __DEF_IINCHIP_DBG__
				printf("igmpsend fail.\r\n");
#endif
				/* in case of igmp, if send fails, then socket closed */
				/* if you want change, remove this code. */
				close(s);
				/* ----- */
				
				return 0;
			}
		}

/* +2008.01 bj */ 
#ifdef __DEF_IINCHIP_INT__
		putISR(s, getISR(s) & (~Sn_IR_SEND_OK));
#else
		wiz_write_byte(Sn_IR(s), Sn_IR_SEND_OK);
#endif
	}
	return ret;
}
예제 #2
0
void PMAPI PM_installAltBreakHandler(PM_breakHandler bh)
{
    static int  ctrlCFlag,ctrlBFlag;

    _PM_ctrlCPtr = (uchar*)&ctrlCFlag;
    _PM_ctrlBPtr = (uchar*)&ctrlBFlag;
    getISR(0x1B, &_PM_prevBreak, &prevRealBreak);
    getISR(0x23, &_PM_prevCtrlC, &prevRealCtrlC);
    _PM_breakHandler = bh;
    setISR(0x1B, _PM_breakISR);
    setISR(0x23, _PM_ctrlCISR);
}
예제 #3
0
void PMAPI PM_installAltCriticalHandler(PM_criticalHandler ch)
{
    static short    critBuf[2];

    _PM_critPtr = (uchar*)critBuf;
    getISR(0x24, &_PM_prevCritical, &prevRealCritical);
    _PM_critHandler = ch;
    setISR(0x24, _PM_criticalISR);
}
예제 #4
0
ibool PMAPI PM_setRealTimeClockHandler(PM_intHandler th,int frequency)
{
    /* Save the old CMOS real time clock values */
    _PM_oldCMOSRegA = _PM_readCMOS(0x0A);
    _PM_oldCMOSRegB = _PM_readCMOS(0x0B);

    /* Set the real time clock interrupt handler */
    getISR(0x70, &_PM_prevRTC, &_PM_prevRealRTC);
    _PM_rtcHandler = th;
    setISR(0x70, _PM_rtcISR);

    /* Program the real time clock default frequency */
    PM_setRealTimeClockFrequency(frequency);

    /* Unmask IRQ8 in the PIC2 */
    _PM_oldRTCPIC2 = PM_inpb(0xA1);
    PM_outpb(0xA1,_PM_oldRTCPIC2 & 0xFE);
    return true;
}
예제 #5
0
파일: socket.c 프로젝트: Wiznet/W7200
/**
@brief	This function get the interrupt vector.
@return 	interrupt vector.
*/
uint8 GetInterrupt(SOCKET s)
{
    return getISR(s);
}
예제 #6
0
void PMAPI PM_setKey15Handler(PM_key15Handler kh)
{
    getISR(0x15, &_PM_prevKey15, &_PM_prevRealKey15);
    _PM_key15Handler = kh;
    setISR(0x15, _PM_key15ISR);
}
예제 #7
0
void PMAPI PM_setKeyHandler(PM_intHandler kh)
{
    getISR(0x9, &_PM_prevKey, &_PM_prevRealKey);
    _PM_keyHandler = kh;
    setISR(0x9, _PM_keyISR);
}
예제 #8
0
void PMAPI PM_setTimerHandler(PM_intHandler th)
{
    getISR(0x8, &_PM_prevTimer, &_PM_prevRealTimer);
    _PM_timerHandler = th;
    setISR(0x8, _PM_timerISR);
}
예제 #9
0
파일: socket.c 프로젝트: ATMEGA17/tinkerit
/**
@brief	This function is an application I/F function which is used to send the data for other then TCP mode. 
		Unlike TCP transmission, The peer's destination address and the port is needed.
		
@return	This function return send data size for success else -1.
*/ 
uint16 sendto(
	SOCKET s,		/**< socket index */
	const uint8 * buf,	/**< a pointer to the data */
	uint16 len,			/**< the data size to send */
	uint8 * addr,		/**< the peer's Destination IP address */
	uint16 port		/**< the peer's destination port number */
	)
{
	uint16 ret=0;
	
	if (len > IINCHIP_TxMAX) ret = IINCHIP_TxMAX; // check size not to exceed MAX size.
	else ret = len;

	if
		(
			((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) ||
			((port == 0x00)) ||(ret == 0)
		) 
	{
		/* +2008.01 [bj] : added return value */
		ret = 0;
	}
	else
	{
		wiz_write_buf(Sn_DIPR0(s),addr,4);
		wiz_write_word(Sn_DPORT0(s),port);
		send_data_processing(s, (uint8 *)buf, ret);
		
/* +2008.01 bj */ 
#ifdef __DEF_IINCHIP_INT__
		while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) 
#else
		while ( (wiz_read_byte(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) 
#endif
		{
#ifdef __DEF_IINCHIP_INT__
			if (getISR(s) & Sn_IR_TIMEOUT)
#else
			if (wiz_read_byte(Sn_IR(s)) & Sn_IR_TIMEOUT)
#endif
			{
#ifdef __DEF_IINCHIP_DBG__
				printf("send fail.\r\n");
#endif
/* +2008.01 [bj]: clear interrupt */
#ifdef __DEF_IINCHIP_INT__
				putISR(s, getISR(s) & ~(Sn_IR_SEND_OK | Sn_IR_TIMEOUT));	 /* clear SEND_OK & TIMEOUT */
#else
				wiz_write_byte(Sn_IR(s), (Sn_IR_SEND_OK | Sn_IR_TIMEOUT)); /* clear SEND_OK & TIMEOUT */
#endif
			return 0;
			}
		}

/* +2008.01 bj */ 
#ifdef __DEF_IINCHIP_INT__
		putISR(s, getISR(s) & (~Sn_IR_SEND_OK));
#else
		wiz_write_byte(Sn_IR(s), Sn_IR_SEND_OK);
#endif

	}
	return ret;
}
예제 #10
0
파일: socket.c 프로젝트: ATMEGA17/tinkerit
/**
@brief	This function used to send the data in TCP mode
@return	1 for success else 0.
*/ 
uint16 send(
	SOCKET s,		/**< the socket index */
	const uint8 * buf,	/**< a pointer to data */
	uint16 len		/**< the data size to be send */
	)
{
	uint8 status=0;
	uint16 ret=0;
	uint16 freesize=0;
#ifdef __DEF_IINCHIP_DBG__
	printf("send()\r\n");
#endif

	if (len > IINCHIP_TxMAX) ret = IINCHIP_TxMAX; // check size not to exceed MAX size.
	else ret = len;

	// if freebuf is available, start.
	do 
	{
		freesize = getSn_TX_FSR(s);
		status = wiz_read_byte(Sn_SR(s));
		if ((status != SOCK_ESTABLISHED) && (status != SOCK_CLOSE_WAIT))
		{
			ret = 0; 
			break;
		}
#ifdef __DEF_IINCHIP_DBG__
		printf("socket %d freesize(%d) empty or error\r\n", s, freesize);
#endif
	} while (freesize < ret);

		// copy data
	send_data_processing(s, (uint8 *)buf, ret);

	/* ------- */

/* +2008.01 bj */ 
#ifdef __DEF_IINCHIP_INT__
	while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) 
#else
	while ( (wiz_read_byte(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) 
#endif
	{
		/* m2008.01 [bj] : reduce code */
		if ( wiz_read_byte(Sn_SR(s)) == SOCK_CLOSED )
		{
#ifdef __DEF_IINCHIP_DBG__
			printf("SOCK_CLOSED.\r\n");
#endif
			close(s);
			return 0;
		}
	}
/* +2008.01 bj */ 
#ifdef __DEF_IINCHIP_INT__
	putISR(s, getISR(s) & (~Sn_IR_SEND_OK));
#else
	wiz_write_byte(Sn_IR(s), Sn_IR_SEND_OK);
#endif
	return ret;
}