• 大小: 11.67MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2024-03-14
  • 语言: 其他
  • 标签: stm32f4  w5300  

资源简介

stm32f4 驱动 w5300 固件库例程 接口使用8/16位数据总线 以太网

资源截图

代码片段和文件信息

#include “loopback.h“
#include “w5300_config.h“
#include “socket.h“
#include “w5300.h“

#include “usart.h“
#include 
#include 
#include 

//uint8 data_buff[1024] __at (0x20001000); // buffer for loopack data
uint8 data_buff[1024];
void   loopback_tcps(SOCKET s)
{
   uint16 len;
  // uint8 buffer[800];

   switch(getSn_SSR(s))                // check SOCKET status
   {                                   // ------------
      case SOCK_ESTABLISHED:           // ESTABLISHED?
         if(getSn_IR(s) & Sn_IR_CON)   // check Sn_IR_CON bit
         {
            printf(“%d : Connect OK 0x%04x 0x%04x\r\n“sgetSn_MR(0)getSn_MR(1));
            setSn_IR(sSn_IR_CON);     // clear Sn_IR_CON
         }
         if((len=getSn_RX_RSR(s)) > 0) // check the size of received data
         {
           len=recv(sdata_bufflen);     // recv
send(sdata_bufflen);  // send
memset(data_buff0len);  
         }
/* if(USART_RX_STA&0x8000)
{    
len=USART_RX_STA&0x3fff;//得到此次接收到的数据长度
USART_RX_STA=0;
memcpy(data_buffUSART_RX_BUFlen);
memset(USART_RX_BUF0len+1);
            send(sdata_bufflen);  // send
printf(“tx_buf=%s\r\n“data_buff);
memset(data_buff0len);
} */
      break;                                  
case SOCK_CLOSE_WAIT:               // PASSIVE CLOSED
        // disconnect(s);                // disconnect 
close(s);
      break;                              
case SOCK_CLOSED:                   // CLOSED                        // close the SOCKET
socket(sSn_MR_TCPlocal_portSn_MR_ND);   // open the SOCKET  
      break;                                   
case SOCK_INIT:                     // The SOCKET opened with TCP mode
listen(s);                       // listen to any connection request from “TCP CLIENT“
printf(“%d : LOOPBACK_TCPS(%d) Started.\r\n“slocal_port);
      break;
default:
      break;
   }
}

/**
 * “TCP CLIENT“ loopback program.
 */ 
void loopback_tcpc(SOCKET s)
{
   uint16 len;
   switch(getSn_SSR(s))                   // check SOCKET status
   {                                      // ------------
      case SOCK_ESTABLISHED:              // ESTABLISHED?
         if(getSn_IR(s) & Sn_IR_CON)      // check Sn_IR_CON bit
         {
            printf(“%d : Connect OK\r\n“s);
            setSn_IR(sSn_IR_CON);        // clear Sn_IR_CON
         }
         if((len=getSn_RX_RSR(s)) > 0)    // check the size of received data
         {
            len = recv(sdata_bufflen);        // recv
            send(sdata_bufflen);    // send
printf(“%s\r\n“data_buff);
memset(data_buff0len);
         }
      break;                                   
case SOCK_CLOSE_WAIT:                  // PASSIVE CLOSED
disconnect(s);                   // disconnect 
break;                           
case S

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     109142  2017-12-07 13:11  TCP_Server\CORE\core_cm4.h

----------- ---------  ---------- -----  ----

               109142                    1


评论

共有 条评论