3月25日优化精简项目:
首先使用cude设置好所有lan8720的引脚定义,包括REST和PHYAD0,下面是需要小改动的部分
void LAN8720_RESET(void)
{
HAL_GPIO_WritePin(ETH_PHYAD0_GPIO_Port, ETH_PHYAD0_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(ETH_REST_GPIO_Port, ETH_REST_Pin, GPIO_PIN_RESET);
HAL_Delay(55);
HAL_GPIO_WritePin(ETH_REST_GPIO_Port, ETH_REST_Pin, GPIO_PIN_SET);
HAL_Delay(55);
}
3月26日 udp调试纪录
循环里直接加入udp_new(); udp_connect(); udp_bind(); udp_recv();
//UDP服务器发送数据
void udp_demo_senddata(struct udp_pcb *upcb)
{
struct pbuf *ptr;
ptr=pbuf_alloc(PBUF_TRANSPORT,strlen((char*)tcp_demo_sendbuf),PBUF_POOL); //申请内存
if(ptr)
{
pbuf_take(ptr,(char*)tcp_demo_sendbuf,strlen((char*)tcp_demo_sendbuf)); //将tcp_demo_sendbuf中的数据打包进pbuf结构中
udp_send(upcb,ptr); //udp发送数据
pbuf_free(ptr);//释放内存
}
}
7月14日 之前完成的上电后插网线DHCP获取,热插拔实现
if(HAL_GetTick()>time_check_eth)
{
time_check_eth=HAL_GetTick()+1000;
if(!netif_is_link_up(&gnetif))
{
HAL_ETH_ReadPHYRegister(&heth, PHY_BSR, &phyreg);
if(phyreg & PHY_LINKED_STATUS)
{
HAL_ETH_DeInit(&heth);
// HAL_ETH_Init(&heth);
MX_LWIP_ReInit();
}
}
else if(DHCP_OK==0&&gnetif.ip_addr.addr)
{
DHCP_OK=1;
UDP_START();
printf("\r\nSTM32 SYSTEM start!\r\n");
}
}
void MX_LWIP_ReInit(void)
{
/* Initilialize the LwIP stack without RTOS */
// lwip_init();
dhcp_stop(&gnetif);
/* IP addresses initialization with DHCP (IPv4) */
ipaddr.addr = 0;
netmask.addr = 0;
gw.addr = 0;
/* add the network interface (IPv4/IPv6) without RTOS */
netif_remove(&gnetif);
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input);
/* Registers the default network interface */
netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif))
{
/* When the netif is fully configured this function must be called */
netif_set_up(&gnetif);
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}
/* Start DHCP negotiation for a network interface (IPv4) */
dhcp_start(&gnetif);
}
上电等待网络连接超时太长(stm32f1xx_hal_eth.c)
#define ETH_TIMEOUT_LINKED_STATE 5000U
改为
#define ETH_TIMEOUT_LINKED_STATE 500U
7月15日 针对STM32F429 的MCO2无法输出问题
void EnablePLLI2S(void)
{
RCC_PLLI2SInitTypeDef RCC_PLLI2SInitStruct;
RCC_PLLI2SInitStruct.PLLI2SN = 50;
RCC_PLLI2SInitStruct.PLLI2SQ = 2;
RCC_PLLI2SInitStruct.PLLI2SR = 2;
if (HAL_RCCEx_EnablePLLI2S(&RCC_PLLI2SInitStruct) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}