示例#1
0
void RJ45_2_Init(void)
{
	u8 i;
	RJ45_2_GPIO_Init();
	RJ45_2_Reset();
	//设置MAC ADDRESS
	RJ45_2_Write_Buf(SHAR0,RJ45_2_MAC,6);
	//设置Subnet Mask ADDRESS
	RJ45_2_Write_Buf(SUBR0,RJ45_2_SubNet,4);
	//设置GateWay ADDRESS
	RJ45_2_Write_Buf(GAR0,RJ45_2_GateWay,4);
	//设置Local IP ADDRESS
	RJ45_2_Write_Buf(SIPR0,RJ45_2_IP,4);

	//设置重新发送时间以及重发次数
	WriteTem[0]=RTR_Time/256;
	WriteTem[1]=RTR_Time%256;
	RJ45_2_Write_Buf(RTR0,WriteTem,2);
	RJ45_2_Write_Register(WIZ_RCR,RCR_Num);
	//设置各Socket发送、接收最大数据包
	for(i=0;i<8;i++)
	{
		RJ45_2_Write_Register(Sn_TXMEM_SIZE(i),W5200_Tx_Size[i]);
		RJ45_2_Write_Register(Sn_RXMEM_SIZE(i),W5200_Rx_Size[i]);
	}
}
示例#2
0
文件: socket.c 项目: Wiznet/W7200
/**
@brief  This function set the transmit & receive buffer size as per the channels
*/
void wizMemInit( uint8 * tx_size, uint8 * rx_size  )
{
    int16 i;
    int16 ssum,rsum;

#ifdef __DEF_IINCHIP_DBG__
    printf("sysinit()\r\n");
#endif

    ssum = 0;
    rsum = 0;

    SBUFBASEADDRESS[0] = (uint16)(__DEF_IINCHIP_MAP_TXBUF__);   /* Set base address of Tx memory for channel #0 */
    RBUFBASEADDRESS[0] = (uint16)(__DEF_IINCHIP_MAP_RXBUF__);   /* Set base address of Rx memory for channel #0 */

    for (i = 0 ; i < MAX_SOCK_NUM; i++)	// Set the size, masking and base address of Tx & Rx memory by each channel
    {
        IINCHIP_WRITE((Sn_TXMEM_SIZE(i)),tx_size[i]);
        IINCHIP_WRITE((Sn_RXMEM_SIZE(i)),rx_size[i]);

#ifdef __DEF_IINCHIP_DBG__
        printf("Sn_TXMEM_SIZE = %d\r\n",IINCHIP_READ(Sn_TXMEM_SIZE(i)));
        printf("Sn_RXMEM_SIZE = %d\r\n",IINCHIP_READ(Sn_RXMEM_SIZE(i)));
#endif

        SSIZE[i] = (int16)(0);
        RSIZE[i] = (int16)(0);

        if (ssum <= 16384)
        {
            switch( tx_size[i] )
            {
            case 1:
                SSIZE[i] = (int16)(1024);
                SMASK[i] = (uint16)(0x03FF);
                break;
            case 2:
                SSIZE[i] = (int16)(2048);
                SMASK[i] = (uint16)(0x07FF);
                break;
            case 4:
                SSIZE[i] = (int16)(4096);
                SMASK[i] = (uint16)(0x0FFF);
                break;
            case 8:
                SSIZE[i] = (int16)(8192);
                SMASK[i] = (uint16)(0x1FFF);
                break;
            case 16:
                SSIZE[i] = (int16)(16384);
                SMASK[i] = (uint16)(0x3FFF);
                break;
            }
        }

        if (rsum <= 16384)
        {
            switch( rx_size[i] )
            {
            case 1:
                RSIZE[i] = (int16)(1024);
                RMASK[i] = (uint16)(0x03FF);
                break;
            case 2:
                RSIZE[i] = (int16)(2048);
                RMASK[i] = (uint16)(0x07FF);
                break;
            case 4:
                RSIZE[i] = (int16)(4096);
                RMASK[i] = (uint16)(0x0FFF);
                break;
            case 8:
                RSIZE[i] = (int16)(8192);
                RMASK[i] = (uint16)(0x1FFF);
                break;
            case 16:
                RSIZE[i] = (int16)(16384);
                RMASK[i] = (uint16)(0x3FFF);
                break;
            }
        }
        ssum += SSIZE[i];
        rsum += RSIZE[i];

        if (i != 0)			// Sets base address of Tx and Rx memory for channel #1,#2,#3
        {
            SBUFBASEADDRESS[i] = SBUFBASEADDRESS[i-1] + SSIZE[i-1];
            RBUFBASEADDRESS[i] = RBUFBASEADDRESS[i-1] + RSIZE[i-1];
        }
#ifdef __DEF_IINCHIP_DBG__
        printf("ch = %d\r\n",i);
        printf("SBUFBASEADDRESS = %d\r\n",(uint16)SBUFBASEADDRESS[i]);
        printf("RBUFBASEADDRESS = %d\r\n",(uint16)RBUFBASEADDRESS[i]);
        printf("SSIZE = %d\r\n",SSIZE[i]);
        printf("RSIZE = %d\r\n",RSIZE[i]);
#endif
    }
}
示例#3
0
文件: w5500.c 项目: 12019/tiaozhanbei
/**
@brief  This function set the transmit & receive buffer size as per the channels is used
Note for TMSR and RMSR bits are as follows\n
bit 1-0 : memory size of channel #0 \n
bit 3-2 : memory size of channel #1 \n
bit 5-4 : memory size of channel #2 \n
bit 7-6 : memory size of channel #3 \n
bit 9-8 : memory size of channel #4 \n
bit 11-10 : memory size of channel #5 \n
bit 12-12 : memory size of channel #6 \n
bit 15-14 : memory size of channel #7 \n
Maximum memory size for Tx, Rx in the W5500 is 16K Bytes,\n
In the range of 16KBytes, the memory size could be allocated dynamically by each channel.\n
Be attentive to sum of memory size shouldn't exceed 8Kbytes\n
and to data transmission and receiption from non-allocated channel may cause some problems.\n
If the 16KBytes memory is already  assigned to centain channel, \n
other 3 channels couldn't be used, for there's no available memory.\n
If two 4KBytes memory are assigned to two each channels, \n
other 2 channels couldn't be used, for there's no available memory.\n
*/
void sysinit( uint8 * tx_size, uint8 * rx_size  )
{
  int16 i;
  int16 ssum,rsum;
#ifdef __DEF_IINCHIP_DBG__
  printf("sysinit()\r\n");
#endif
  ssum = 0;
  rsum = 0;

  for (i = 0 ; i < MAX_SOCK_NUM; i++)       // Set the size, masking and base address of Tx & Rx memory by each channel
  {
          IINCHIP_WRITE( (Sn_TXMEM_SIZE(i)), tx_size[i]);
          IINCHIP_WRITE( (Sn_RXMEM_SIZE(i)), rx_size[i]);
          
#ifdef __DEF_IINCHIP_DBG__
         printf("tx_size[%d]: %d, Sn_TXMEM_SIZE = %d\r\n",i, tx_size[i], IINCHIP_READ(Sn_TXMEM_SIZE(i)));
         printf("rx_size[%d]: %d, Sn_RXMEM_SIZE = %d\r\n",i, rx_size[i], IINCHIP_READ(Sn_RXMEM_SIZE(i)));
#endif
    SSIZE[i] = (int16)(0);
    RSIZE[i] = (int16)(0);


    if (ssum <= 16384)
    {
         switch( tx_size[i] )
      {
      case 1:
        SSIZE[i] = (int16)(1024);
        break;
      case 2:
        SSIZE[i] = (int16)(2048);
        break;
      case 4:
        SSIZE[i] = (int16)(4096);
        break;
      case 8:
        SSIZE[i] = (int16)(8192);
        break;
      case 16:
        SSIZE[i] = (int16)(16384);
      break;
      default :
        RSIZE[i] = (int16)(2048);
        break;
      }
    }

   if (rsum <= 16384)
    {
         switch( rx_size[i] )
      {
      case 1:
        RSIZE[i] = (int16)(1024);
        break;
      case 2:
        RSIZE[i] = (int16)(2048);
        break;
      case 4:
        RSIZE[i] = (int16)(4096);
        break;
      case 8:
        RSIZE[i] = (int16)(8192);
        break;
      case 16:
        RSIZE[i] = (int16)(16384);
        break;
      default :
        RSIZE[i] = (int16)(2048);
        break;
      }
    }
    ssum += SSIZE[i];
    rsum += RSIZE[i];

  }
}