ip地址显示在串口屏

This commit is contained in:
王绪洁 2025-02-28 10:12:33 +08:00
parent d8d1a3bf69
commit c5774f328e
6 changed files with 144 additions and 51 deletions

View File

@ -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 */

View File

@ -2,7 +2,7 @@
/** /**
****************************************************************************** ******************************************************************************
* File Name : LWIP.c * File Name : LWIP.c
* Description : This file provides initialization code for LWIP * @file lwip.c
* middleWare. * middleWare.
****************************************************************************** ******************************************************************************
* @attention * @attention
@ -211,4 +211,3 @@ u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len)
return recved_bytes; return recved_bytes;
} }
#endif /* MDK ARM Compiler */ #endif /* MDK ARM Compiler */

View File

@ -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>

View File

@ -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>

24
User/driver/uart_lcd.c Normal file
View File

@ -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));
}

7
User/driver/uart_lcd.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef __UART_LCD_H__
#define __UART_LCD_H__
#include "main.h"
void uart_lcd_draw_ipaddr(void);
#endif