亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? socket.c

?? MCS-51的一個Free小型操作系統,在KeilC中下編譯工作
?? C
?? 第 1 頁 / 共 4 頁
字號:
/*
********************************************************************************
* TERN, Inc.
* (c) Copyright 2005, http://www.tern.com
*
* MODIFIED BY RICHARD BARRY TO ADD SEMAPHORE FOR COMMUNICATION BETWEEN THE 
* WIZnet ISR AND THE HTTP TASK.
*
* - Derived based on development version provided by Wiznet.
*
* Filename : socket.h
* Programmer(s):
* Created : 2002/06/20
* Modified :
*  2002/09/27 : - Renaming
*			       INT_STATUS --> INT_REG
*			       STATUS(i) --> INT_STATUS(i)
*			       C_STATUS(i) --> SOCK_STATUS(i)
*  2003/11/06 : Ported for use with TERN controller.  Note all byte access is at even addresses
*  2005/10/8  : Modified constants for easier initialization.
*
* Description : Header file of W3100A for TERN embedded controller
********************************************************************************
*/
/*
###############################################################################
File Include Section
###############################################################################
*/
#include "i2chip_hw.h" 
#include "socket.h"
#include "types.h"
#include <string.h>
#include <stdio.h>

#include <FreeRTOS.h>
#include <semphr.h>
#include <portasm.h>


/*
###############################################################################
Local Variable Declaration Section
###############################################################################
*/
u_char I_STATUS[4];				// Store Interrupt Status according to channels
u_int Local_Port;				   // Designate Local Port
union un_l2cval	SEQ_NUM;		// Set initial sequence number

u_long SMASK[MAX_SOCK_NUM];   // Variable to store MASK of Tx in each channel,
                              // on setting dynamic memory size.
u_long RMASK[MAX_SOCK_NUM];   // Variable to store MASK of Rx in each channel,
                              // on setting dynamic memory size.
int SSIZE[MAX_SOCK_NUM];      // Maximun Tx memory size by each channel
int RSIZE[MAX_SOCK_NUM];      // Maximun Rx memory size by each channel

u_int SBUFBASEADDRESS[MAX_SOCK_NUM];   // Maximun Tx memory base address by each channel
u_int RBUFBASEADDRESS[MAX_SOCK_NUM];   // Maximun Rx memory base address by each channel

/*
###############################################################################
Function Implementation Section
###############################################################################
*/

/*
********************************************************************************
*               Interrupt handling function of the W3100A
*
* Description :
*   Stores the status information that each function waits for in the global variable I_STATUS
*   for transfer. I_STATUS stores the interrupt status value for each channel.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
********************************************************************************
*/

portBASE_TYPE prvProcessISR( void )
{
unsigned char status;
extern xSemaphoreHandle xTCPSemaphore;
portBASE_TYPE xSwitchRequired = pdFALSE;

#ifdef I2CHIP_WINDOW
u_int current_window = i2chip_get_window();
#endif

status = READ_VALUE(INT_REG);


if (status)
  {
  xSwitchRequired = pdTRUE;
  // channel 0 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x01)
    {
	 I_STATUS[0] = READ_VALUE(INT_STATUS(0));

//	 if (I_STATUS[0] & SESTABLISHED)
//    ISR_ESTABLISHED(0);
//	 if (I_STATUS[0] & SCLOSED)
//    ISR_CLOSED(0);

	 WRITE_VALUE(INT_REG, 0x01);
	 }

  // channel 1 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x02)
    {
	 I_STATUS[1] = READ_VALUE(INT_STATUS(1));

//	 if (I_STATUS[1] & SESTABLISHED)
//    ISR_ESTABLISHED(1);
//	 if (I_STATUS[1] & SCLOSED)
//    ISR_CLOSED(1);

	 WRITE_VALUE(INT_REG, 0x02);
	 }

  // channel 2 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x04)
    {
	 I_STATUS[2] = READ_VALUE(INT_STATUS(2));

//	 if (I_STATUS[2] & SESTABLISHED)
//    ISR_ESTABLISHED(2);
//	 if (I_STATUS[2] & SCLOSED)
//    ISR_CLOSED(2);

	 WRITE_VALUE(INT_REG, 0x04);
	 }

  // channel 3 interrupt(sysinit, sockinit, established, closed, timeout, send_ok, recv_ok)
  if (status & 0x08)
    {
	 I_STATUS[3] = READ_VALUE(INT_STATUS(3));

//	 if (I_STATUS[3] & SESTABLISHED) ISR_ESTABLISHED(3);
//	 if (I_STATUS[3] & SCLOSED) ISR_CLOSED(3);

	 WRITE_VALUE(INT_REG, 0x08);
	 }

  // channel 0 receive interrupt
  if (status & 0x10)
    {
//	 ISR_RX(0);
	 WRITE_VALUE(INT_REG, 0x10);
	 }

  // channel 1 receive interrupt
  if (status & 0x20)
    {
//	 ISR_RX(1);
	 WRITE_VALUE(INT_REG, 0x20);
	 }

  // channel 2 receive interrupt
  if (status & 0x40)
    {
//	 ISR_RX(2);
	 WRITE_VALUE(INT_REG, 0x40);
	 }

  // channel 3 receive interrupt
  if (status & 0x80)
    {
//	 ISR_RX(3);
	 WRITE_VALUE(INT_REG, 0x80);
	 }
  status = READ_VALUE(INT_REG);
  }

WRITE_VALUE(INT_REG, 0xFF);

#ifdef I2CHIP_WINDOW
i2chip_set_window(current_window);
#endif

	if( xSwitchRequired == pdTRUE )
    {
		xSwitchRequired = xSemaphoreGiveFromISR( xTCPSemaphore, pdFALSE );
    }

	return xSwitchRequired;
}

void far interrupt in4_isr_i2chip(void)
{
	if( prvProcessISR() == pdTRUE )
    {
		portEND_SWITCHING_ISR();
    }

    INT_EOI;
}

/*
****************************************************************************************************
*               Established connection interrupt handling function.
*
* Description :
*   Called upon connection establishment, and may be inserted in user code if needed by
*   the programmer.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
****************************************************************************************************
*/
/*
void ISR_ESTABLISHED(SOCKET s)
{
// TO ADD YOUR CODE
}
*/

/*
****************************************************************************************************
*               Closed connection interrupt handling function
*
* Description :
*   Called upon connection closure, and may be inserted in user code if needed by the programmer.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
****************************************************************************************************
*/
/*
void ISR_CLOSED(SOCKET s)
{
// TO ADD YOUR CODE
}
*/

/*
****************************************************************************************************
*               Received data interrupt handling function
*
* Description :
*   Called upon receiving data, and may be inserted in user code if needed by the programmer.
* Arguments   : None
* Returns     : None
* Note        : Internal Function
****************************************************************************************************
*/
/*
void ISR_RX(SOCKET s)
{
// TO ADD YOUR CODE
}
*/

/*
****************************************************************************************************
*              W3100A Initialization Function
*
* Description:  Reset of W3100A S/W and Registeration of i386 interrupt
* Arguments  : None.
* Returns    : None.
* Note       :
****************************************************************************************************
*/
void initW3100A(void)
{

// Install interrupt handler for i2Chip
INT_INIT(in4_isr_i2chip);


Local_Port = 1000;         // This default value will be set if you didn't designate it when you
                           // create a socket. If you don't designate port number and create a
                           // socket continuously, the port number will be assigned with
                           // incremented by one to Local_Port
SEQ_NUM.lVal = 4294967293ul;	// Sets the initial SEQ# to be used for TCP communication.
                           // (It should be ramdom value)
WRITE_VALUE(COMMAND(0), CSW_RESET);   // Software RESET
}

/*
****************************************************************************************************
*               W3100A initialization function
*
* Description :
*   Sets the Tx, Rx memory size by each channel, source MAC, source IP, gateway, and subnet mask
*   to be used by the W3100A to the designated values.
*   May be called when reflecting modified network information or Tx, Rx memory size on the W3100A
*   Include Ping Request for ARP update (In case that a device embedding W3100A is directly
*     connected to Router)
* Arguments  : sbufsize - Tx memory size (00 - 1KByte, 01- 2KBtye, 10 - 4KByte, 11 - 8KByte)
*                          bit 1-0 : Tx memory size of channel #0
*                          bit 3-2 : Tx memory size of channel #1
*                          bit 5-4 : Tx memory size of channel #2
*                          bit 7-6 : Tx memory size of channel #3
*              rbufsize - Rx memory size (00 - 1KByte, 01- 2KBtye, 10 - 4KByte, 11 - 8KByte)
*                          bit 1-0 : Rx memory size of channel #0
*                          bit 3-2 : Rx memory size of channel #1
*                          bit 5-4 : Rx memory size of channel #2
*                          bit 7-6 : Rx memory size of channel #3
* Returns    : None
* Note       : API Function
*              Maximum memory size for Tx, Rx in W3100A is 8KBytes,
*              In the range of 8KBytes, the memory size could be allocated dynamically by
*              each channel
*              Be attentive to sum of memory size shouldn't exceed 8Kbytes
*              and to data transmission and receiption from non-allocated channel may cause
*              some problems.
*              If 8KBytes memory already is assigned to centain channel, other 3 channels
*                couldn't be used, for there's no available memory.
*              If two 4KBytes memory are assigned to two each channels, other 2 channels couldn't
*                be used, for there's no available memory.
*              (Example of memory assignment)
*               sbufsize => 00000011, rbufsize => 00000011 :
*                 Assign 8KBytes for Tx and Rx to channel #0, Cannot use channel #1,#2,#3
*               sbufsize => 00001010, rbufsize => 00001010 :
*                 Assign 4KBytes for Tx and Rx to each channel #0,#1 respectively. Cannot use
*                 channel #2,#3
*               sbufsize => 01010101, rbufsize => 01010101 :
*                 Assign 2KBytes for Tx and Rx to each all channels respectively.
*               sbufsize => 00010110, rbufsize => 01010101 :
*                 Assign 4KBytes for Tx, 2KBytes for Rx to channel #0
*       s          2KBytes for Tx, 2KBytes for Rx to channel #1
*                 2KBytes for Tx, 2KBytes for Rx to channel #2
*                 2KBytes is available exclusively for Rx in channel #3. There's no memory for Tx.
****************************************************************************************************
*/
void sysinit(u_char sbufsize, u_char rbufsize)
{
char i;
int ssum,rsum;

ssum = 0;
rsum = 0;

// Set Tx memory size for each channel
WRITE_VALUE(TX_DMEM_SIZE, sbufsize);

// Set Rx memory size for each channel
WRITE_VALUE(RX_DMEM_SIZE, rbufsize);

// Set Base Address of Tx memory for channel #0
SBUFBASEADDRESS[0] = 0;

// Set Base Address of Rx memory for channel #0
RBUFBASEADDRESS[0] = 0;

// Set maximum memory size for Tx and Rx, mask, base address of memory by each channel
for(i = 0 ; i < MAX_SOCK_NUM; i++)
  {
  SSIZE[i] = 0;
  RSIZE[i] = 0;
  if(ssum < 8192)
	 {
	 switch((sbufsize >> i*2) & 0x03) // Set maximum Tx memory size
		{
		case 0:
		  SSIZE[i] = 1024;
		  SMASK[i] = 0x000003FF;
		  break;

		case 1:
		  SSIZE[i] = 2048;
		  SMASK[i] = 0x000007FF;
		  break;

		case 2:
		  SSIZE[i] = 4096;
		  SMASK[i] = 0x00000FFF;
		  break;

		case 3:
		  SSIZE[i] = 8192;
		  SMASK[i] = 0x00001FFF;
		  break;
		}
	 }
  if(rsum < 8192)
	 {
	 switch((rbufsize >> i*2) & 0x03)  // Set maximum Rx memory size
		{
		case 0:
		  RSIZE[i] = 1024;
		  RMASK[i] = 0x000003FF;
		  break;

		case 1:
		  RSIZE[i] = 2048;
		  RMASK[i] = 0x000007FF;
		  break;

		case 2:
		  RSIZE[i] = 4096;
		  RMASK[i] = 0x00000FFF;
		  break;

		case 3:
		  RSIZE[i] = 8192;
		  RMASK[i] = 0x00001FFF;
		  break;
		}
	 }
  ssum += SSIZE[i];
  rsum += RSIZE[i];

  // Set base address of Tx and Rx memory for channel #1,#2,#3
  if(i != 0)
    {
    SBUFBASEADDRESS[i] = ssum - SSIZE[i];
    RBUFBASEADDRESS[i] = rsum - RSIZE[i];
    }
  }

  WRITE_VALUE(COMMAND(0), CSYS_INIT);

while(!(I_STATUS[0] & SSYS_INIT_OK))
  I2CHIP_POLL_ISR(in4_isr_i2chip);

#ifdef __PING__
  {
  u_char xdata pingbuf[8];
  setIPprotocol(0, IPPROTO_ICMP);
  socket(0, SOCK_IPL_RAW, 3000,0);     // Create a socket for ARP update

  pingbuf[0] = 8;                      // ICMP TYPE
  pingbuf[1] = 0;                      // ICMP CODE
  pingbuf[2] = 0xf7;                   // CHECKSUM (already calculated)
  pingbuf[3] = 0xfd;
  pingbuf[4] = 0;                      // ID
  pingbuf[5] = 1;
  pingbuf[6] = 0;                      // SEQ #
  pingbuf[7] = 1;
  pingbuf[8] = 0;                      // Data 1 Byte

  sendto(0, pingbuf, 9, GATEWAY_PTR,3000);  // Ping Request
  close(0);
  printf("Route MAC Update Success");
  }
#endif
}

/*
****************************************************************************************************
*              Function to set subnet mask
*
* Description:
* Arguments  : addr--> Pointer that has the value to be set
* Returns    : None.
* Note       :
****************************************************************************************************
*/
void setsubmask(u_char * addr)
{
u_char i;
u_char far* sm_ptr = SUBNET_MASK_PTR;   // We can only convert to 'regular'
                                   // pointer if we're confident arithmetic
                                   // won't take us out of current window.

for (i = 0; i < 4; i++)
  {
  WRITE_VALUE(sm_ptr + SA_OFFSET(i), addr[i]);
  }
}

/*
****************************************************************************************************
*               Function to set gateway IP
*
* Description:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产免费| 成人综合激情网| 欧美久久久久中文字幕| 亚洲一区在线观看视频| 欧美性大战久久| 蜜臀精品一区二区三区在线观看 | 欧美日本乱大交xxxxx| 亚洲电影在线播放| 欧美日韩一区 二区 三区 久久精品| 亚洲国产成人高清精品| 欧美一区二区精美| 国产成人av自拍| 亚洲人成网站精品片在线观看 | 日日摸夜夜添夜夜添亚洲女人| 欧美日韩性生活| a4yy欧美一区二区三区| 欧美一区二区三区在线电影| 轻轻草成人在线| 久久久久久免费| 欧美综合久久久| 精品一区二区三区香蕉蜜桃| 国产欧美日韩中文久久| 91麻豆swag| 美女一区二区久久| 中文字幕一区二区三区在线播放 | 国产精品嫩草影院com| 91久久一区二区| 另类欧美日韩国产在线| 国产精品久久久久久久久快鸭 | 国产网站一区二区三区| 91小宝寻花一区二区三区| 一区二区三区精品| 日韩欧美成人午夜| 99精品久久只有精品| 青娱乐精品在线视频| 日韩美女视频一区二区| 6080午夜不卡| 不卡欧美aaaaa| 久久精品国产99| 亚洲综合清纯丝袜自拍| 欧美国产国产综合| 欧美一区二区三区播放老司机| 国产91色综合久久免费分享| 午夜久久电影网| 国产精品婷婷午夜在线观看| 日韩欧美一卡二卡| 一本久道久久综合中文字幕| 精品在线免费视频| 亚洲综合一二区| 国产精品毛片a∨一区二区三区| 91麻豆精品91久久久久久清纯| 高清shemale亚洲人妖| 日韩和欧美一区二区| 悠悠色在线精品| 国产精品乱码人人做人人爱| 精品三级在线看| 欧美日韩高清在线| 欧美系列日韩一区| 91免费看片在线观看| 国产一区二区看久久| 婷婷一区二区三区| 亚洲影院在线观看| 亚洲欧洲三级电影| 欧美国产禁国产网站cc| 久久香蕉国产线看观看99| 在线成人免费观看| 欧美日韩一区二区三区免费看| 99久久精品国产导航| 国产成人午夜精品影院观看视频| 免费高清在线视频一区·| 日韩电影免费在线观看网站| 亚洲成av人在线观看| 亚洲制服丝袜av| 亚洲一卡二卡三卡四卡无卡久久| 亚洲人成小说网站色在线| 日韩久久一区二区| 《视频一区视频二区| 国产精品无人区| 国产精品乱码久久久久久| 中文字幕一区二区三区在线不卡 | 91麻豆精品国产91久久久久 | 亚洲欧美另类图片小说| 亚洲欧美乱综合| 亚洲欧美激情一区二区| 亚洲综合免费观看高清完整版| 亚洲国产日韩精品| 免费看精品久久片| 国产精品自产自拍| 岛国精品在线播放| 色综合欧美在线| 欧美午夜片在线看| 欧美一级高清片在线观看| 欧美一区二区在线免费播放 | 欧美日韩在线播放三区四区| 欧美三级蜜桃2在线观看| 欧美精品高清视频| 欧美大度的电影原声| 欧美激情一区二区在线| 亚洲免费观看高清完整版在线 | 在线免费av一区| 欧美在线制服丝袜| 制服丝袜日韩国产| 26uuu亚洲综合色欧美| 亚洲国产精品t66y| 一区二区三区四区在线免费观看| 亚洲超碰精品一区二区| 麻豆91小视频| 北条麻妃国产九九精品视频| 欧美亚洲愉拍一区二区| 欧美成人aa大片| 国产精品麻豆网站| 日韩 欧美一区二区三区| 国产成人免费视频一区| 在线中文字幕一区| 精品少妇一区二区三区| 亚洲欧美另类在线| 精品亚洲成a人| 色婷婷综合久久| 亚洲精品一区二区三区四区高清 | 亚洲亚洲人成综合网络| 精品一区二区三区欧美| 91亚洲午夜精品久久久久久| 日韩一级免费观看| 综合激情成人伊人| 紧缚奴在线一区二区三区| 一本久道中文字幕精品亚洲嫩| 日韩精品一区在线| 亚洲一区中文日韩| 国产91丝袜在线18| 欧美精品1区2区3区| 欧美激情综合五月色丁香| 日本大胆欧美人术艺术动态 | 亚洲成a人片在线观看中文| 国产在线播精品第三| 欧美制服丝袜第一页| 国产精品亲子乱子伦xxxx裸| 日韩成人av影视| 日本高清不卡视频| 中文字幕一区二区三区视频| 激情五月婷婷综合| 欧美日本免费一区二区三区| 亚洲欧美自拍偷拍色图| 精品一区二区av| 欧美精品 国产精品| 一区二区三区在线免费| 东方欧美亚洲色图在线| 精品久久免费看| 日韩—二三区免费观看av| 欧美系列一区二区| 一区二区三区四区高清精品免费观看 | 国产精品久久久一本精品| 精品一区二区三区久久| 欧美三日本三级三级在线播放| 国产精品私房写真福利视频| 国内精品免费**视频| 日韩精品一区二区三区四区| 三级影片在线观看欧美日韩一区二区| 91浏览器入口在线观看| 国产精品二三区| 久久www免费人成看片高清| 91麻豆精品国产无毒不卡在线观看| 亚洲一区在线看| 欧美性一级生活| 亚洲一级在线观看| 欧美性生活一区| 国产精品国产自产拍高清av王其| 韩国成人福利片在线播放| 日韩视频免费观看高清完整版在线观看| 亚洲国产日日夜夜| 欧美日本在线播放| 日韩高清在线一区| 5566中文字幕一区二区电影| 午夜久久久久久久久久一区二区| 在线播放中文字幕一区| 香蕉加勒比综合久久| 欧美精品vⅰdeose4hd| 日韩福利电影在线观看| 欧美一级淫片007| 国精品**一区二区三区在线蜜桃| 欧美成人精品3d动漫h| 国产自产v一区二区三区c| 国产亚洲制服色| 99国产精品久久久久久久久久| 亚洲欧洲日韩综合一区二区| 欧美午夜电影网| 免费在线观看成人| 久久综合九色综合97婷婷| 成人午夜免费电影| 亚洲视频你懂的| 91精品国产一区二区人妖| 精品一区二区三区免费毛片爱| 久久青草国产手机看片福利盒子| 国产成人免费在线视频| 一区精品在线播放| 制服丝袜中文字幕一区| 国精产品一区一区三区mba桃花| 国产精品国产三级国产普通话三级 | 色综合久久久久久久| 亚洲777理论| 久久久不卡影院|