diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 587a117..93ee0f2 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -32,6 +32,8 @@ #include "tim.h" #include "gpio.h" #include "tcpserverc.h" +#include "lwip.h" +#include "uart_lcd.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -170,6 +172,7 @@ void start_tcp_task(void const *argument) /* Infinite loop */ for (;;) { + uart_lcd_draw_ipaddr(); osThreadTerminate(NULL); } /* USER CODE END start_tcp_task */ diff --git a/LWIP/App/lwip.c b/LWIP/App/lwip.c index 06f2ae0..98d2beb 100644 --- a/LWIP/App/lwip.c +++ b/LWIP/App/lwip.c @@ -1,28 +1,28 @@ /* USER CODE BEGIN Header */ /** ****************************************************************************** - * File Name : LWIP.c - * Description : This file provides initialization code for LWIP - * middleWare. - ****************************************************************************** - * @attention - * - * Copyright (c) 2024 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ + * File Name : LWIP.c + * @file lwip.c + * middleWare. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "lwip.h" #include "lwip/init.h" #include "lwip/netif.h" -#if defined ( __CC_ARM ) /* MDK ARM Compiler */ +#if defined(__CC_ARM) /* MDK ARM Compiler */ #include "lwip/sio.h" #endif /* MDK ARM Compiler */ #include "ethernetif.h" @@ -53,8 +53,8 @@ uint8_t GATEWAY_ADDRESS[4]; /* USER CODE END 2 */ /** - * LwIP initialization function - */ + * LwIP initialization function + */ void MX_LWIP_Init(void) { /* IP addresses initialization */ @@ -71,15 +71,15 @@ void MX_LWIP_Init(void) GATEWAY_ADDRESS[2] = 1; GATEWAY_ADDRESS[3] = 29; -/* USER CODE BEGIN IP_ADDRESSES */ -/* USER CODE END IP_ADDRESSES */ + /* USER CODE BEGIN IP_ADDRESSES */ + /* USER CODE END IP_ADDRESSES */ /* Initilialize the LwIP stack with RTOS */ - tcpip_init( NULL, NULL ); + tcpip_init(NULL, NULL); /* IP addresses initialization without DHCP (IPv4) */ 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]); /* 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); /* Create the Ethernet link handler thread */ -/* USER CODE BEGIN H7_OS_THREAD_DEF_CREATE_CMSIS_RTOS_V1 */ - osThreadDef(EthLink, ethernet_link_thread, osPriorityBelowNormal, 0, configMINIMAL_STACK_SIZE *2); - osThreadCreate (osThread(EthLink), &gnetif); -/* USER CODE END 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); + osThreadCreate(osThread(EthLink), &gnetif); + /* 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 @@ -121,25 +121,25 @@ void MX_LWIP_Init(void) #endif /** - * @brief Notify the User about the network interface config status - * @param netif: the network interface - * @retval None - */ + * @brief Notify the User about the network interface config status + * @param netif: the network interface + * @retval None + */ static void ethernet_link_status_updated(struct netif *netif) { if (netif_is_up(netif)) { -/* USER CODE BEGIN 5 */ -/* USER CODE END 5 */ + /* USER CODE BEGIN 5 */ + /* USER CODE END 5 */ } else /* netif is down */ { -/* USER CODE BEGIN 6 */ -/* USER CODE END 6 */ + /* USER CODE BEGIN 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. * @@ -150,9 +150,9 @@ sio_fd_t sio_open(u8_t devnum) { sio_fd_t sd; -/* USER CODE BEGIN 7 */ + /* USER CODE BEGIN 7 */ sd = 0; // dummy code -/* USER CODE END 7 */ + /* USER CODE END 7 */ return sd; } @@ -167,8 +167,8 @@ sio_fd_t sio_open(u8_t devnum) */ void sio_send(u8_t c, sio_fd_t fd) { -/* USER CODE BEGIN 8 */ -/* USER CODE END 8 */ + /* USER CODE BEGIN 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; -/* USER CODE BEGIN 9 */ + /* USER CODE BEGIN 9 */ recved_bytes = 0; // dummy code -/* USER CODE END 9 */ + /* USER CODE END 9 */ 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; -/* USER CODE BEGIN 10 */ + /* USER CODE BEGIN 10 */ recved_bytes = 0; // dummy code -/* USER CODE END 10 */ + /* USER CODE END 10 */ return recved_bytes; } #endif /* MDK ARM Compiler */ - diff --git a/MDK-ARM/semi-finished_product_testing.uvoptx b/MDK-ARM/semi-finished_product_testing.uvoptx index 4f443c2..87c1654 100644 --- a/MDK-ARM/semi-finished_product_testing.uvoptx +++ b/MDK-ARM/semi-finished_product_testing.uvoptx @@ -145,7 +145,7 @@ 0 ST-LINKIII-KEIL_SWO - -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) + -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) @@ -230,7 +230,50 @@ 1 state + + 16 + 1 + IP_ADDRESS,0x0A + + + 17 + 1 + ipaddr,0x10 + + + 18 + 1 + ip_addr_str,0x0A + + + 19 + 1 + gnetif + + + 20 + 1 + MACConf + + + 21 + 1 + heth + + + 22 + 1 + ip_addr + + + + 1 + 0 + \\semi_finished_product_testing\../LWIP/Target/ethernetif.c\heth.Init.MACAddr + 0 + + 0 @@ -278,7 +321,7 @@ 0 0 2 - 10000000 + 1800000 @@ -1933,7 +1976,7 @@ User/driver - 0 + 1 0 0 0 @@ -1973,6 +2016,18 @@ 0 0 + + 12 + 134 + 1 + 0 + 0 + 0 + ..\User\driver\uart_lcd.c + uart_lcd.c + 0 + 0 + @@ -1983,7 +2038,7 @@ 0 13 - 134 + 135 1 0 0 @@ -1995,7 +2050,7 @@ 13 - 135 + 136 1 0 0 diff --git a/MDK-ARM/semi-finished_product_testing.uvprojx b/MDK-ARM/semi-finished_product_testing.uvprojx index f215648..6135aa2 100644 --- a/MDK-ARM/semi-finished_product_testing.uvprojx +++ b/MDK-ARM/semi-finished_product_testing.uvprojx @@ -1103,6 +1103,11 @@ 1 ..\User\driver\ht1200m.c + + uart_lcd.c + 1 + ..\User\driver\uart_lcd.c + diff --git a/User/driver/uart_lcd.c b/User/driver/uart_lcd.c new file mode 100644 index 0000000..ec3587c --- /dev/null +++ b/User/driver/uart_lcd.c @@ -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)); +} diff --git a/User/driver/uart_lcd.h b/User/driver/uart_lcd.h new file mode 100644 index 0000000..1f0fc7e --- /dev/null +++ b/User/driver/uart_lcd.h @@ -0,0 +1,7 @@ +#ifndef __UART_LCD_H__ +#define __UART_LCD_H__ + +#include "main.h" + +void uart_lcd_draw_ipaddr(void); +#endif