亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码
標題:
STM32驅(qū)動w5500_dhcp+http TCP/IP網(wǎng)絡(luò)集成模塊的源碼
[打印本頁]
作者:
WinnerWinner
時間:
2018-3-25 14:31
標題:
STM32驅(qū)動w5500_dhcp+http TCP/IP網(wǎng)絡(luò)集成模塊的源碼
W5500 TCP/IP網(wǎng)絡(luò)集成模塊 STM32驅(qū)動
stm32_w5500_dhcp+http
單片機源程序如下:
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "usart.h"
#include "delay.h"
#include "spi.h"
#include "socket.h" // Just include one header for WIZCHIP
#include "Internet/DHCP/dhcp.h"
#include "httpServer.h"
#include "httpParser.h"
#include "httpUtil.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define SOCK_DHCP 0
#define MY_MAX_DHCP_RETRY 3
#define DATA_BUF_SIZE 2048
/* Private macro -------------------------------------------------------------*/
uint8_t gDATABUF[DATA_BUF_SIZE];
// Default Network Configuration
uint8_t http_tx_buf[2048];
uint8_t http_rx_buf[2048];
const uint8_t flash_buffer[2048];
uint8_t memsize[2][8] = {{2,2,2,2,2,2,2,2},{2,2,2,2,2,2,2,2}};
uint8_t socklist[] = {0,1,2,3,4,5,6 };
int g_time6=0;
extern char index_html[4096];
wiz_NetInfo gWIZNETINFO = { .mac = {0x00, 0x08, 0xdc,0x00, 0xab, 0xcd},
.ip = {192, 168, 1, 123},
.sn = {255,255,255,0},
.gw = {192, 168, 1, 1},
.dns = {0,0,0,0},
.dhcp = NETINFO_STATIC };
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
void platform_init(void); // initialize the dependent host peripheral
void my_ip_assign(void);
void network_init(void);
/************************************
* @ brief Call back for ip Conflict
************************************/
void my_ip_conflict(void)
{
printf("CONFLICT IP from DHCP\r\n");
//halt or reset or any...
while(1); // this example is halt.
}
/**
* @brief 串口打印輸出
* @param None
* @retval None
*/
int main(void)
{
uint8_t tmp;
uint8_t memsize[2][8] = { {2,2,2,2,2,2,2,2},{2,2,2,2,2,2,2,2}};
uint8_t my_dhcp_retry = 0;
//Host dependent peripheral initialized
platform_init();
// First of all, Should register SPI callback functions implemented by user for accessing WIZCHIP
/* Critical section callback */
reg_wizchip_cris_cbfunc(SPI_CrisEnter, SPI_CrisExit); //注冊臨界區(qū)函數(shù)
/* Chip selection call back */
#if _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_VDM_
reg_wizchip_cs_cbfunc(SPI_CS_Select, SPI_CS_Deselect);//注冊SPI片選信號函數(shù)
#elif _WIZCHIP_IO_MODE_ == _WIZCHIP_IO_MODE_SPI_FDM_
reg_wizchip_cs_cbfunc(SPI_CS_Select, SPI_CS_Deselect); // CS must be tried with LOW.
#else
#if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SIP_) != _WIZCHIP_IO_MODE_SIP_
#error "Unknown _WIZCHIP_IO_MODE_"
#else
reg_wizchip_cs_cbfunc(wizchip_select, wizchip_deselect);
#endif
#endif
/* SPI Read & Write callback function */
reg_wizchip_spi_cbfunc(SPI_ReadByte, SPI_WriteByte); //注冊讀寫函數(shù)
/* WIZCHIP SOCKET Buffer initialize */
if(ctlwizchip(CW_INIT_WIZCHIP,(void*)memsize) == -1){
printf("WIZCHIP Initialized fail.\r\n");
while(1);
}
/* PHY link status check */
do{
if(ctlwizchip(CW_GET_PHYLINK, (void*)&tmp) == -1){
printf("Unknown PHY Link stauts.\r\n");
}
}while(tmp == PHY_LINK_OFF);
/************************************************/
/* WIZnet W5500 Code Examples : */
/* Implemented using ioLibrary_BSD Socket APIs */
/************************************************/
/* >> DHCP Client */
/************************************************/
// must be set the default mac before DHCP started.
setSHAR(gWIZNETINFO.mac);
DHCP_init(SOCK_DHCP, gDATABUF);
// if you want defiffent action instead defalut ip assign,update, conflict,
// if cbfunc == 0, act as default.
reg_dhcp_cbfunc(my_ip_assign, my_ip_assign, my_ip_conflict);
httpServer_init(http_tx_buf,http_rx_buf,7,socklist);
sprintf(index_html,INDEX_HTML_C,"");
/* Main Loop */
while(1)
{
switch(DHCP_run())
{
case DHCP_IP_ASSIGN:
case DHCP_IP_CHANGED:
/* If this block empty, act with default_ip_assign & default_ip_update */
//
// This example calls my_ip_assign in the two case.
//
// Add to ...
//
break;
case DHCP_IP_LEASED:
//
// TO DO YOUR NETWORK APPs.
//
break;
case DHCP_FAILED:
/* ===== Example pseudo code ===== */
// The below code can be replaced your code or omitted.
// if omitted, retry to process DHCP
my_dhcp_retry++;
if(my_dhcp_retry > MY_MAX_DHCP_RETRY)
{
printf(">> DHCP %d Failed\r\n", my_dhcp_retry);
my_dhcp_retry = 0;
DHCP_stop(); // if restart, recall DHCP_init()
network_init(); // apply the default static network and print out netinfo to serial
}
break;
default:
break;
}
httpServer_run(0);
httpServer_run(1);
httpServer_run(2);
httpServer_run(3);
httpServer_run(4);
httpServer_run(5);
httpServer_run(6);
}
} // end of main()
/**
* @brief Loopback Test Example Code using ioLibrary_BSD
* @retval None
*/
void platform_init(void)
{
SystemInit();//系統(tǒng)時鐘初始化
USART_Configuration();//串口1初始化
//Config SPI
SPI_Configuration();
//延時初始化
delay_init();
}
/*******************************************************
* @ brief Call back for ip assing & ip update from DHCP
*******************************************************/
void my_ip_assign(void)
{
getIPfromDHCP(gWIZNETINFO.ip);
getGWfromDHCP(gWIZNETINFO.gw);
getSNfromDHCP(gWIZNETINFO.sn);
getDNSfromDHCP(gWIZNETINFO.dns);
gWIZNETINFO.dhcp = NETINFO_DHCP;
/* Network initialization */
network_init(); // apply from dhcp
printf("DHCP LEASED TIME : %d Sec.\r\n", getDHCPLeasetime());
}
/******************************************************************************
* @brief Network Init
* Intialize the network information to be used in WIZCHIP
*****************************************************************************/
void network_init(void)
{
uint8_t tmpstr[6] = {0};
wiz_NetInfo netinfo;
// Set Network information from netinfo structure
ctlnetwork(CN_SET_NETINFO, (void*)&gWIZNETINFO);
// Get Network information
ctlnetwork(CN_GET_NETINFO, (void*)&netinfo);
// Display Network Information
ctlwizchip(CW_GET_ID,(void*)tmpstr);
if(netinfo.dhcp == NETINFO_DHCP) printf("\r\n=== %s NET CONF : DHCP ===\r\n",(char*)tmpstr);
else printf("\r\n=== %s NET CONF : Static ===\r\n",(char*)tmpstr);
printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n",netinfo.mac[0],netinfo.mac[1],netinfo.mac[2],
netinfo.mac[3],netinfo.mac[4],netinfo.mac[5]);
printf("SIP: %d.%d.%d.%d\r\n", netinfo.ip[0],netinfo.ip[1],netinfo.ip[2],netinfo.ip[3]);
printf("GAR: %d.%d.%d.%d\r\n", netinfo.gw[0],netinfo.gw[1],netinfo.gw[2],netinfo.gw[3]);
printf("SUB: %d.%d.%d.%d\r\n", netinfo.sn[0],netinfo.sn[1],netinfo.sn[2],netinfo.sn[3]);
printf("DNS: %d.%d.%d.%d\r\n", netinfo.dns[0],netinfo.dns[1],netinfo.dns[2],netinfo.dns[3]);
printf("===========================\r\n");
}
/*********************************END OF FILE**********************************/
復(fù)制代碼
所有資料51hei提供下載:
stm32_w5500_dhcp+http.rar
(744.49 KB, 下載次數(shù): 404)
2018-3-26 03:00 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
1213213zzgg
時間:
2018-3-29 14:54
正好是我想找的,只有這里有,下來看看學(xué)習一下
作者:
dgxll
時間:
2019-7-16 09:43
還是下載不了
作者:
嘟嘟胖子
時間:
2019-7-16 10:20
沒幣,先留個標記,等有黑幣了再下吧!
作者:
sym_cool
時間:
2019-9-12 21:30
學(xué)習一下,不錯啊
作者:
shetx
時間:
2019-10-17 16:38
下載不了啥情況 樓主能發(fā)我下么 我最近正想搞這一塊
作者:
yqsqqq
時間:
2019-10-18 08:28
好東西
作者:
kyqhdf0583
時間:
2020-7-21 17:53
一直不知道怎么通過HTTP去接收數(shù)據(jù),感謝分享~
作者:
BossVee
時間:
2021-11-25 10:39
非常感謝樓主分享,也算是值得的。
作者:
dazhilao
時間:
2022-2-22 15:38
謝謝樓主,不過不是我想要的,樓主使用的代碼基本上來源于github上面,大家在github上搜索下w5500就用,我想要的是監(jiān)聽w5500拔插,發(fā)現(xiàn)重新連接上之后,重新運行dhcp獲取新ip地址。
作者:
dazhilao
時間:
2022-2-22 15:40
剛剛找到解決辦法了,CW_GET_PHYLINK就是獲取鏈路狀態(tài)。
歡迎光臨 (http://www.denmoz.com/bbs/)
Powered by Discuz! X3.1