ip地址显示在串口屏
This commit is contained in:
parent
d8d1a3bf69
commit
c5774f328e
|
@ -32,6 +32,8 @@
|
||||||
#include "tim.h"
|
#include "tim.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
#include "tcpserverc.h"
|
#include "tcpserverc.h"
|
||||||
|
#include "lwip.h"
|
||||||
|
#include "uart_lcd.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
@ -170,6 +172,7 @@ void start_tcp_task(void const *argument)
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
uart_lcd_draw_ipaddr();
|
||||||
osThreadTerminate(NULL);
|
osThreadTerminate(NULL);
|
||||||
}
|
}
|
||||||
/* USER CODE END start_tcp_task */
|
/* USER CODE END start_tcp_task */
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
/* USER CODE BEGIN Header */
|
/* USER CODE BEGIN Header */
|
||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* File Name : LWIP.c
|
* File Name : LWIP.c
|
||||||
* Description : This file provides initialization code for LWIP
|
* @file lwip.c
|
||||||
* middleWare.
|
* middleWare.
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
* @attention
|
||||||
*
|
*
|
||||||
* Copyright (c) 2024 STMicroelectronics.
|
* Copyright (c) 2024 STMicroelectronics.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
* in the root directory of this software component.
|
* in the root directory of this software component.
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "lwip.h"
|
#include "lwip.h"
|
||||||
#include "lwip/init.h"
|
#include "lwip/init.h"
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
#if defined ( __CC_ARM ) /* MDK ARM Compiler */
|
#if defined(__CC_ARM) /* MDK ARM Compiler */
|
||||||
#include "lwip/sio.h"
|
#include "lwip/sio.h"
|
||||||
#endif /* MDK ARM Compiler */
|
#endif /* MDK ARM Compiler */
|
||||||
#include "ethernetif.h"
|
#include "ethernetif.h"
|
||||||
|
@ -53,8 +53,8 @@ uint8_t GATEWAY_ADDRESS[4];
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LwIP initialization function
|
* LwIP initialization function
|
||||||
*/
|
*/
|
||||||
void MX_LWIP_Init(void)
|
void MX_LWIP_Init(void)
|
||||||
{
|
{
|
||||||
/* IP addresses initialization */
|
/* IP addresses initialization */
|
||||||
|
@ -71,15 +71,15 @@ void MX_LWIP_Init(void)
|
||||||
GATEWAY_ADDRESS[2] = 1;
|
GATEWAY_ADDRESS[2] = 1;
|
||||||
GATEWAY_ADDRESS[3] = 29;
|
GATEWAY_ADDRESS[3] = 29;
|
||||||
|
|
||||||
/* USER CODE BEGIN IP_ADDRESSES */
|
/* USER CODE BEGIN IP_ADDRESSES */
|
||||||
/* USER CODE END IP_ADDRESSES */
|
/* USER CODE END IP_ADDRESSES */
|
||||||
|
|
||||||
/* Initilialize the LwIP stack with RTOS */
|
/* Initilialize the LwIP stack with RTOS */
|
||||||
tcpip_init( NULL, NULL );
|
tcpip_init(NULL, NULL);
|
||||||
|
|
||||||
/* IP addresses initialization without DHCP (IPv4) */
|
/* IP addresses initialization without DHCP (IPv4) */
|
||||||
IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
|
IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
|
||||||
IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
|
IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1], NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
|
||||||
IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
|
IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
|
||||||
|
|
||||||
/* add the network interface (IPv4/IPv6) with RTOS */
|
/* add the network interface (IPv4/IPv6) with RTOS */
|
||||||
|
@ -103,14 +103,14 @@ void MX_LWIP_Init(void)
|
||||||
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
|
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
|
||||||
|
|
||||||
/* Create the Ethernet link handler thread */
|
/* Create the Ethernet link handler thread */
|
||||||
/* USER CODE BEGIN H7_OS_THREAD_DEF_CREATE_CMSIS_RTOS_V1 */
|
/* USER CODE BEGIN H7_OS_THREAD_DEF_CREATE_CMSIS_RTOS_V1 */
|
||||||
osThreadDef(EthLink, ethernet_link_thread, osPriorityBelowNormal, 0, configMINIMAL_STACK_SIZE *2);
|
osThreadDef(EthLink, ethernet_link_thread, osPriorityBelowNormal, 0, configMINIMAL_STACK_SIZE * 2);
|
||||||
osThreadCreate (osThread(EthLink), &gnetif);
|
osThreadCreate(osThread(EthLink), &gnetif);
|
||||||
/* USER CODE END H7_OS_THREAD_DEF_CREATE_CMSIS_RTOS_V1 */
|
/* USER CODE END H7_OS_THREAD_DEF_CREATE_CMSIS_RTOS_V1 */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
|
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_OBSOLETE_USER_CODE_SECTION_4
|
#ifdef USE_OBSOLETE_USER_CODE_SECTION_4
|
||||||
|
@ -121,25 +121,25 @@ void MX_LWIP_Init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Notify the User about the network interface config status
|
* @brief Notify the User about the network interface config status
|
||||||
* @param netif: the network interface
|
* @param netif: the network interface
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void ethernet_link_status_updated(struct netif *netif)
|
static void ethernet_link_status_updated(struct netif *netif)
|
||||||
{
|
{
|
||||||
if (netif_is_up(netif))
|
if (netif_is_up(netif))
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 5 */
|
/* USER CODE BEGIN 5 */
|
||||||
/* USER CODE END 5 */
|
/* USER CODE END 5 */
|
||||||
}
|
}
|
||||||
else /* netif is down */
|
else /* netif is down */
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 6 */
|
/* USER CODE BEGIN 6 */
|
||||||
/* USER CODE END 6 */
|
/* USER CODE END 6 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined ( __CC_ARM ) /* MDK ARM Compiler */
|
#if defined(__CC_ARM) /* MDK ARM Compiler */
|
||||||
/**
|
/**
|
||||||
* Opens a serial device for communication.
|
* Opens a serial device for communication.
|
||||||
*
|
*
|
||||||
|
@ -150,9 +150,9 @@ sio_fd_t sio_open(u8_t devnum)
|
||||||
{
|
{
|
||||||
sio_fd_t sd;
|
sio_fd_t sd;
|
||||||
|
|
||||||
/* USER CODE BEGIN 7 */
|
/* USER CODE BEGIN 7 */
|
||||||
sd = 0; // dummy code
|
sd = 0; // dummy code
|
||||||
/* USER CODE END 7 */
|
/* USER CODE END 7 */
|
||||||
|
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,8 @@ sio_fd_t sio_open(u8_t devnum)
|
||||||
*/
|
*/
|
||||||
void sio_send(u8_t c, sio_fd_t fd)
|
void sio_send(u8_t c, sio_fd_t fd)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 8 */
|
/* USER CODE BEGIN 8 */
|
||||||
/* USER CODE END 8 */
|
/* USER CODE END 8 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,9 +186,9 @@ u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len)
|
||||||
{
|
{
|
||||||
u32_t recved_bytes;
|
u32_t recved_bytes;
|
||||||
|
|
||||||
/* USER CODE BEGIN 9 */
|
/* USER CODE BEGIN 9 */
|
||||||
recved_bytes = 0; // dummy code
|
recved_bytes = 0; // dummy code
|
||||||
/* USER CODE END 9 */
|
/* USER CODE END 9 */
|
||||||
return recved_bytes;
|
return recved_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +205,9 @@ u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len)
|
||||||
{
|
{
|
||||||
u32_t recved_bytes;
|
u32_t recved_bytes;
|
||||||
|
|
||||||
/* USER CODE BEGIN 10 */
|
/* USER CODE BEGIN 10 */
|
||||||
recved_bytes = 0; // dummy code
|
recved_bytes = 0; // dummy code
|
||||||
/* USER CODE END 10 */
|
/* USER CODE END 10 */
|
||||||
return recved_bytes;
|
return recved_bytes;
|
||||||
}
|
}
|
||||||
#endif /* MDK ARM Compiler */
|
#endif /* MDK ARM Compiler */
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||||
<Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
<Name>-US -O2254 -SF1800 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
</TargetDriverDllRegistry>
|
</TargetDriverDllRegistry>
|
||||||
<Breakpoint/>
|
<Breakpoint/>
|
||||||
|
@ -230,7 +230,50 @@
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>state</ItemText>
|
<ItemText>state</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>16</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>IP_ADDRESS,0x0A</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>17</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>ipaddr,0x10</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>18</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>ip_addr_str,0x0A</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>19</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>gnetif</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>20</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>MACConf</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>21</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>heth</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>22</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>ip_addr</ItemText>
|
||||||
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
|
<MemoryWindow1>
|
||||||
|
<Mm>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<SubType>0</SubType>
|
||||||
|
<ItemText>\\semi_finished_product_testing\../LWIP/Target/ethernetif.c\heth.Init.MACAddr</ItemText>
|
||||||
|
<AccSizeX>0</AccSizeX>
|
||||||
|
</Mm>
|
||||||
|
</MemoryWindow1>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
<THDelay>0</THDelay>
|
<THDelay>0</THDelay>
|
||||||
</Tracepoint>
|
</Tracepoint>
|
||||||
|
@ -278,7 +321,7 @@
|
||||||
<EnableFlashSeq>0</EnableFlashSeq>
|
<EnableFlashSeq>0</EnableFlashSeq>
|
||||||
<EnableLog>0</EnableLog>
|
<EnableLog>0</EnableLog>
|
||||||
<Protocol>2</Protocol>
|
<Protocol>2</Protocol>
|
||||||
<DbgClock>10000000</DbgClock>
|
<DbgClock>1800000</DbgClock>
|
||||||
</DebugDescription>
|
</DebugDescription>
|
||||||
</TargetOption>
|
</TargetOption>
|
||||||
</Target>
|
</Target>
|
||||||
|
@ -1933,7 +1976,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>User/driver</GroupName>
|
<GroupName>User/driver</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
@ -1973,6 +2016,18 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>12</GroupNumber>
|
||||||
|
<FileNumber>134</FileNumber>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>..\User\driver\uart_lcd.c</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>uart_lcd.c</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -1983,7 +2038,7 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>13</GroupNumber>
|
<GroupNumber>13</GroupNumber>
|
||||||
<FileNumber>134</FileNumber>
|
<FileNumber>135</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -1995,7 +2050,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>13</GroupNumber>
|
<GroupNumber>13</GroupNumber>
|
||||||
<FileNumber>135</FileNumber>
|
<FileNumber>136</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
|
@ -1103,6 +1103,11 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\User\driver\ht1200m.c</FilePath>
|
<FilePath>..\User\driver\ht1200m.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>uart_lcd.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\User\driver\uart_lcd.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include "uart_lcd.h"
|
||||||
|
#include "usart.h"
|
||||||
|
#include "lwip.h"
|
||||||
|
|
||||||
|
extern ip4_addr_t ipaddr;
|
||||||
|
uint8_t ip_addr[24] = {0};
|
||||||
|
void uart_lcd_draw_ipaddr(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
ip_addr[0] = 0xEE;
|
||||||
|
ip_addr[1] = 0xB1;
|
||||||
|
ip_addr[2] = 0x10;
|
||||||
|
ip_addr[3] = 0x00;
|
||||||
|
ip_addr[4] = 0x00;
|
||||||
|
ip_addr[5] = 0x00;
|
||||||
|
ip_addr[6] = 0x03;
|
||||||
|
char *ip_addr_str = ipaddr_ntoa(&ipaddr);
|
||||||
|
MEMCPY(ip_addr + 7, (uint8_t *)ip_addr_str, strlen(ip_addr_str));
|
||||||
|
ip_addr[7 + strlen(ip_addr_str)] = 0xFF;
|
||||||
|
ip_addr[8 + strlen(ip_addr_str)] = 0xFC;
|
||||||
|
ip_addr[9 + strlen(ip_addr_str)] = 0xFF;
|
||||||
|
ip_addr[10 + strlen(ip_addr_str)] = 0xFF;
|
||||||
|
dma_usart_send(&huart4, ip_addr, ARRAY_LEN(ip_addr));
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef __UART_LCD_H__
|
||||||
|
#define __UART_LCD_H__
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
void uart_lcd_draw_ipaddr(void);
|
||||||
|
#endif
|
Loading…
Reference in New Issue