|
用stm32f103rct6單片機(jī)寫的W5500為TCP 服務(wù)器與電腦之間的數(shù)據(jù)互發(fā),通過(guò)串口調(diào)試助手發(fā)一個(gè)數(shù)據(jù),網(wǎng)絡(luò)調(diào)試助手接收并顯示,通過(guò)網(wǎng)絡(luò)調(diào)試助手發(fā)數(shù)據(jù),串口調(diào)試助手接收并顯示
W69~J$S$EH}F5E_ED7816G7.png (147.66 KB, 下載次數(shù): 84)
下載附件
2019-5-9 10:42 上傳
單片機(jī)源程序如下:
- /**
- ******************************************************************************
- * @file main.c
- * @version V1.2
- * @brief 用3.5.0版本庫(kù)建的工程模板
- * @attention 內(nèi)網(wǎng)測(cè)試,請(qǐng)保證W5500的IP與測(cè)試PC機(jī)在同一網(wǎng)段內(nèi),且不沖突
- * 如果是用網(wǎng)線跟PC機(jī)直連,請(qǐng)?jiān)O(shè)置PC機(jī)本地連接地址IP為靜態(tài)IP
- *
- * @company 林哈哈
- * @information
- * @website
- * @forum
- * @qqGroup
- ******************************************************************************
- */
- /*W5500接STM32的 SPI1硬件接線定義*/
- // W5500_SCS ---> STM32_GPIOA4 /*W5500的片選管腳*/
- // W5500_SCLK ---> STM32_GPIOA5 /*W5500的時(shí)鐘管腳*/
- // W5500_MISO ---> STM32_GPIOA6 /*W5500的MISO管腳*/
- // W5500_MOSI ---> STM32_GPIOA7 /*W5500的MOSI管腳*/
- // W5500_RESET ---> STM32_GPIOC0 /*W5500的RESET管腳*/
- // W5500_INT ---> STM32_GPIOC1 /*W5500的INT管腳*/
- /*W5500接STM32的 SPI2硬件接線定義*/
- // W5500_SCS ---> STM32_GPIOB12 /*W5500的片選管腳*/
- // W5500_SCLK ---> STM32_GPIOB13 /*W5500的時(shí)鐘管腳*/
- // W5500_MISO ---> STM32_GPIOB14 /*W5500的MISO管腳*/
- // W5500_MOSI ---> STM32_GPIOB15 /*W5500的MOSI管腳*/
- // W5500_RESET ---> STM32_GPIOB9 /*W5500的RESET管腳*/
- // W5500_INT ---> STM32_GPIOC6 /*W5500的INT管腳*/
- #include <stdio.h>
- #include <string.h>
- #include "stm32f10x.h"
- #include "bsp_usart1.h"
- #include "bsp_i2c_ee.h"
- #include "bsp_i2c_gpio.h"
- #include "w5500.h"
- #include "W5500_conf.h"
- #include "socket.h"
- #include "utility.h"
- #include "tcp_demo.h"
- #include "bsp_TiMbase.h"
- #include "bsp_led.h"
- int main(void)
- {
- TIM3_Int_Init(999,71);
- USART1_Initialise(115200);
- systick_init(72); /*初始化Systick工作時(shí)鐘*/
- //// USART1_Config(); /*初始化串口通信:115200@8-n-1*/
- i2c_CfgGpio(); /*初始化eeprom*/
- //
- printf(" 林哈哈的實(shí)驗(yàn)!\r\n");
- printf(" 嘻嘻哈哈 V1.2 \r\n");
-
- gpio_for_w5500_config(); /*初始化MCU相關(guān)引腳*/
- reset_w5500(); /*硬復(fù)位W5500*/
- PHY_check(); /*檢查網(wǎng)線是否接入*/
- set_w5500_mac(); /*配置MAC地址*/
- set_w5500_ip(); /*配置IP地址*/
- socket_buf_init(txsize, rxsize); /*初始化8個(gè)Socket的發(fā)送接收緩存大小*/
-
- printf(" W5500為TCP 服務(wù)器,建立偵聽(tīng),等待PC作為TCP Client建立連接 \r\n");
- printf(" W5500監(jiān)聽(tīng)端口為: %d \r\n",local_port);
- printf(" 連接成功后,TCP Client發(fā)送數(shù)據(jù)給W5500,W5500將返回對(duì)應(yīng)數(shù)據(jù) \r\n");
-
- while(1) /*循環(huán)執(zhí)行的函數(shù)*/
- {
- do_tcp_server(); /*TCP_Server 數(shù)據(jù)回環(huán)測(cè)試程序*/
- jg();
- }
-
- }
復(fù)制代碼
所有資料51hei提供下載:
2.TCP Server - 互發(fā).7z
(234.5 KB, 下載次數(shù): 184)
2019-5-10 18:19 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|