1671198A-687F-44D1-8FC1-C0DA01C38199.png (608.38 KB, 下載次數: 61)
下載附件
2020-5-8 20:19 上傳
- /**
- ******************************************************************************
- * @file main.c
- * @author fire
- * @version V1.0
- * @brief 用3.5.0版本庫建的工程模板
- ******************************************************************************
- **@attention 內網測試,請保證W5500的IP與測試PC機在同一網段內,且不沖突;
- * @attention 如果是用網線跟PC機直連,請設置PC機本地連接地址IP為靜態IP;
- * @attention 網絡調試助手打開時的IP地址若是你本地連接地址,請自行設定;
- *
- * 使用本程序,先將w5500_conf.C 文件中的PC_IP,設定為PC機的IP地址,端口號可任意,默認為5000
- *
- ******************************************************************************
- */
- #include <stdio.h>
- #include <string.h>
- #include "stm32f10x.h"
- #include "bsp_spi_flash.h"
- #include "bsp_usart1.h"
- #include "bsp_i2c_ee.h"
- #include "bsp_i2c_gpio.h"
- #include "bsp_led.h"
- #include "bsp_dht11.h"
- #include "w5500.h"
- #include "W5500_conf.h"
- #include "socket.h"
- #include "utility.h"
- /*app函數頭文件*/
- #include "tcp_demo.h"
- uint8 buffer[2048];
- int main(void)
- {
- uint16 size=0;
- systick_init(72);/* 初始化Systick工作時鐘*/
- NVIC_Configuration();
- USART1_Config(); /*初始化串口通信:115200@8-n-1*/
- i2c_CfgGpio();/*初始化eeprom*/
- LED_GPIO_Config();
-
- printf(" 初始化W5500…… \r\n");
- gpio_for_w5500_config();/* 初始化MCU相關引腳*/
- // SPI_DMA_Config();
- reset_w5500();/*復位W5500*/
- printf(" W5500 Hardware initialized! \r\n");
-
- set_w5500_mac();/*配置W5500MAC地址*/
- if(use_define==1||use_eeprom==1)/*不DHCP獲取IP地址,就配置默認IP地址*/
- set_w5500_ip();/*配置W5500IP地址*/
- printf(" 電腦作為TCP客戶端連接W5500TCP服務器 \r\n");
- printf(" W5500服務器端口默認為: %d \r\n",W5500_tcp_server_port);
- printf(" 連接成功后,PC機發送數據給W5500,W5500將返回對應數據 \r\n");
- socket_buf_init(txsize, rxsize); /*初始化8個Socket的發送接收緩存大小*/
- printf(" 應用程序執行中……\r\n");
- while(1)//循環執行的函數
- {
- do_tcp_server();/*TCP_Server 數據回環測試程序*/
- }
- }
復制代碼
如圖,某寶提供的源代碼,分享給大家
DMA-W5500.rar
(384.08 KB, 下載次數: 125)
2020-5-8 20:19 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|