From 89960855da5480303b276a38faffb6d24439d602 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Fri, 28 Jul 2023 18:49:15 -0300 Subject: [PATCH] PR #2308 collaterals --- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-baremetal/main.c | 18 +++++----- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-freertos-lwip/main.c | 2 +- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-freertos-tcp/main.c | 2 +- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-freertos/main.c | 19 ++++++----- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../main.c | 2 +- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-freertos_cmsis2/main.c | 27 +++++++-------- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-rtx-mdk/main.c | 2 +- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-rtx/main.c | 33 ++++++++++--------- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-rtx5-lwip/main.c | 2 +- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-rtx5-mdk/main.c | 2 +- .../RTE/Network_Library/mongoose_custom.h | 2 +- .../nucleo-f746zg-keil-rtx5/main.c | 26 +++++++-------- .../nucleo-f746zg-cube-baremetal/.cproject | 4 +++ .../.cproject | 4 +++ .../nucleo-f746zg-cube-freertos/.cproject | 4 +++ 25 files changed, 92 insertions(+), 77 deletions(-) diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/RTE/Network_Library/mongoose_custom.h index a7fca3cd..c327c2cf 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/main.c index a34b938c..2c776132 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-baremetal/main.c @@ -2,14 +2,14 @@ // All rights reserved #include "hal.h" +#include "main.h" #include "mongoose.h" #include "net.h" -#include "main.h" #define BLINK_PERIOD_MS 1000 // LED blinking period in millis -uint64_t mg_millis(void) { // Let Mongoose use our uptime function - return (uint64_t)HAL_GetTick(); // Return number of milliseconds since boot +uint64_t mg_millis(void) { // Let Mongoose use our uptime function + return (uint64_t) HAL_GetTick(); // Return number of milliseconds since boot } void mg_random(void *buf, size_t len) { // Use on-board RNG @@ -22,9 +22,9 @@ void mg_random(void *buf, size_t len) { // Use on-board RNG } static void timer_fn(void *arg) { - HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED - struct mg_tcpip_if *ifp = arg; // And show - const char *names[] = {"down", "up", "ready"}; // network stats + HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED + struct mg_tcpip_if *ifp = arg; // And show + const char *names[] = {"down", "up", "req", "ready"}; // network stats MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u", names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent, ifp->ndrop, ifp->nerr)); @@ -33,9 +33,9 @@ static void timer_fn(void *arg) { extern void mx_init(void); int main(void) { - mx_init(); // Setup clock and all peripherals configured in CubeMX - // Initialise random number generator - // Initialise ethernet pins + mx_init(); // Setup clock and all peripherals configured in CubeMX + // Initialise random number generator + // Initialise ethernet pins MG_INFO(("Starting, CPU freq %g MHz", (double) SystemCoreClock / 1000000)); struct mg_mgr mgr; // Initialise diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/RTE/Network_Library/mongoose_custom.h index 8e245b97..7a038348 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/main.c index 26476dc6..89a4e842 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-lwip/main.c @@ -3,8 +3,8 @@ #include "hal.h" #include "mongoose.h" -#include "net.h" #include "main.h" +#include "net.h" #include "ethernetif.h" #include "lwip/dhcp.h" #include "lwip/netif.h" diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/RTE/Network_Library/mongoose_custom.h index 9c403a62..26a30a90 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/main.c index 86e8753d..4dc46eee 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos-tcp/main.c @@ -3,8 +3,8 @@ #include "hal.h" #include "mongoose.h" -#include "net.h" #include "main.h" +#include "net.h" extern RNG_HandleTypeDef hrng; diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/RTE/Network_Library/mongoose_custom.h index 580d5616..338cfb6c 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/main.c index 588a52ef..2cc5976a 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos/main.c @@ -2,16 +2,17 @@ // All rights reserved #include "hal.h" +#include "main.h" #include "mongoose.h" #include "net.h" -#include "main.h" #define BLINK_PERIOD_MS 1000 // LED blinking period in millis extern void xPortSysTickHandler(void); -void SysTick_Handler (void) { +void SysTick_Handler(void) { HAL_IncTick(); - // xPortSysTickHandler() must be called after vTaskStartScheduler() and mx_init() takes longer than 1ms + // xPortSysTickHandler() must be called after vTaskStartScheduler() and + // mx_init() takes longer than 1ms if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) xPortSysTickHandler(); } @@ -26,8 +27,8 @@ void mg_random(void *buf, size_t len) { // Use on-board RNG } static void timer_fn(void *arg) { - struct mg_tcpip_if *ifp = arg; // And show - const char *names[] = {"down", "up", "ready"}; // network stats + struct mg_tcpip_if *ifp = arg; // And show + const char *names[] = {"down", "up", "req", "ready"}; // network stats MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u", names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent, ifp->ndrop, ifp->nerr)); @@ -65,7 +66,7 @@ static void server(void *args) { static void blinker(void *args) { for (;;) { - HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED + HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED vTaskDelay(pdMS_TO_TICKS(BLINK_PERIOD_MS)); } (void) args; @@ -74,9 +75,9 @@ static void blinker(void *args) { extern void mx_init(void); int main(void) { - mx_init(); // Setup clock and all peripherals configured in CubeMX - // Initialise random number generator - // Initialise ethernet pins + mx_init(); // Setup clock and all peripherals configured in CubeMX + // Initialise random number generator + // Initialise ethernet pins // Start tasks. NOTE: stack sizes are in 32-bit words xTaskCreate(blinker, "blinker", 128, ":)", configMAX_PRIORITIES - 1, NULL); xTaskCreate(server, "server", 2048, 0, configMAX_PRIORITIES - 1, NULL); diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/RTE/Network_Library/mongoose_custom.h index 02f259c5..2cdb2a6a 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/main.c index df3d80ba..0db16573 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2-lwip/main.c @@ -3,8 +3,8 @@ #include "hal.h" #include "mongoose.h" -#include "net.h" #include "main.h" +#include "net.h" #include "cmsis_os2.h" #include "ethernetif.h" #include "lwip/dhcp.h" diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/RTE/Network_Library/mongoose_custom.h index a0726b9f..31bf8378 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/main.c index b68262f3..b88c2d76 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-freertos_cmsis2/main.c @@ -1,15 +1,14 @@ // Copyright (c) 2023 Cesanta Software Limited // All rights reserved +#include "cmsis_os2.h" #include "hal.h" +#include "main.h" #include "mongoose.h" #include "net.h" -#include "main.h" -#include "cmsis_os2.h" #define BLINK_PERIOD_MS 1000 // LED blinking period in millis - void mg_random(void *buf, size_t len) { // Use on-board RNG extern RNG_HandleTypeDef hrng; for (size_t n = 0; n < len; n += sizeof(uint32_t)) { @@ -20,8 +19,8 @@ void mg_random(void *buf, size_t len) { // Use on-board RNG } static void timer_fn(void *arg) { - struct mg_tcpip_if *ifp = arg; // And show - const char *names[] = {"down", "up", "ready"}; // network stats + struct mg_tcpip_if *ifp = arg; // And show + const char *names[] = {"down", "up", "req", "ready"}; // network stats MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u", names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent, ifp->ndrop, ifp->nerr)); @@ -59,7 +58,7 @@ static void server(void *args) { static void blinker(void *args) { for (;;) { - HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED + HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED osDelay((osKernelGetTickFreq() * BLINK_PERIOD_MS) / 1000U); } (void) args; @@ -68,16 +67,18 @@ static void blinker(void *args) { extern void mx_init(void); int main(void) { - mx_init(); // Setup clock and all peripherals configured in CubeMX - // Initialise random number generator - // Initialise ethernet pins - osKernelInitialize(); // Initialize CMSIS-RTOS - osThreadNew(blinker, NULL, NULL); // Create the blinker thread with a default stack size + mx_init(); // Setup clock and all peripherals configured in CubeMX + // Initialise random number generator + // Initialise ethernet pins + osKernelInitialize(); // Initialize CMSIS-RTOS + osThreadNew(blinker, NULL, + NULL); // Create the blinker thread with a default stack size const osThreadAttr_t server_attr = { - .stack_size = 8192 // Create the server thread with a stack size of 8KB bytes + .stack_size = + 8192 // Create the server thread with a stack size of 8KB bytes }; osThreadNew(server, NULL, &server_attr); - osKernelStart(); // This blocks + osKernelStart(); // This blocks return 0; } diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/RTE/Network_Library/mongoose_custom.h index 63bb3f74..03916762 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/main.c index 1155cb80..3bd039ab 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx-mdk/main.c @@ -3,8 +3,8 @@ #include "hal.h" #include "mongoose.h" -#include "net.h" #include "main.h" +#include "net.h" #include "cmsis_os.h" #define BLINK_PERIOD_MS 1000 // LED blinking period in millis diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/RTE/Network_Library/mongoose_custom.h index bea94279..2290857e 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/main.c index 232deccc..965df31a 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx/main.c @@ -1,15 +1,14 @@ // Copyright (c) 2023 Cesanta Software Limited // All rights reserved +#include "cmsis_os.h" #include "hal.h" +#include "main.h" #include "mongoose.h" #include "net.h" -#include "main.h" -#include "cmsis_os.h" #define BLINK_PERIOD_MS 1000 // LED blinking period in millis - void mg_random(void *buf, size_t len) { // Use on-board RNG extern RNG_HandleTypeDef hrng; for (size_t n = 0; n < len; n += sizeof(uint32_t)) { @@ -20,8 +19,8 @@ void mg_random(void *buf, size_t len) { // Use on-board RNG } static void timer_fn(void *arg) { - struct mg_tcpip_if *ifp = arg; // And show - const char *names[] = {"down", "up", "ready"}; // network stats + struct mg_tcpip_if *ifp = arg; // And show + const char *names[] = {"down", "up", "req", "ready"}; // network stats MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u", names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent, ifp->ndrop, ifp->nerr)); @@ -59,23 +58,25 @@ static void server(const void *args) { static void blinker(const void *args) { for (;;) { - HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED - osDelay(BLINK_PERIOD_MS); // CMSIS-RTOS v1 uses milliseconds + HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED + osDelay(BLINK_PERIOD_MS); // CMSIS-RTOS v1 uses milliseconds } (void) args; } extern void mx_init(void); -osThreadDef(server, osPriorityNormal, 1, 8192); // Create the server thread with a stack size of 8KB -osThreadDef(blinker, osPriorityNormal, 1, 0); // Create the blinker thread with default stack size - -int main(void) { // this is not actually baremetal main() but the "main" thread - osKernelInitialize(); // Stop kernel - mx_init(); // Setup clock and all peripherals configured in CubeMX - // Initialise random number generator - // Initialise ethernet pins +osThreadDef(server, osPriorityNormal, 1, + 8192); // Create the server thread with a stack size of 8KB +osThreadDef(blinker, osPriorityNormal, 1, + 0); // Create the blinker thread with default stack size + +int main(void) { // this is not actually baremetal main() but the "main" thread + osKernelInitialize(); // Stop kernel + mx_init(); // Setup clock and all peripherals configured in CubeMX + // Initialise random number generator + // Initialise ethernet pins osThreadCreate(osThread(blinker), NULL); // Create the blinker thread - osThreadCreate(osThread(server), NULL); // Create the server thread + osThreadCreate(osThread(server), NULL); // Create the server thread osKernelStart(); // Start kernel again and exit main thread return 0; } diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/RTE/Network_Library/mongoose_custom.h index 02f259c5..2cdb2a6a 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/main.c index 863e304b..1fc92177 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-lwip/main.c @@ -3,8 +3,8 @@ #include "hal.h" #include "mongoose.h" -#include "net.h" #include "main.h" +#include "net.h" #include "cmsis_os2.h" #include "ethernetif.h" #include "lwip/dhcp.h" diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/RTE/Network_Library/mongoose_custom.h index 7406a9cd..9eb9d3a1 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/main.c index 772c0d7f..9e823569 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5-mdk/main.c @@ -3,8 +3,8 @@ #include "hal.h" #include "mongoose.h" -#include "net.h" #include "main.h" +#include "net.h" #include "cmsis_os2.h" #define BLINK_PERIOD_MS 1000 // LED blinking period in millis diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/RTE/Network_Library/mongoose_custom.h b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/RTE/Network_Library/mongoose_custom.h index f8209f6b..c8b7496f 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/RTE/Network_Library/mongoose_custom.h +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/RTE/Network_Library/mongoose_custom.h @@ -74,4 +74,4 @@ #endif -// Add your customization below this comment +#define MG_ENABLE_TCPIP 1 diff --git a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/main.c b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/main.c index 80f47138..095ae14d 100644 --- a/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/main.c +++ b/extra/cmsis-pack/Boards/ST/NUCLEO-F746ZG/nucleo-f746zg-keil-rtx5/main.c @@ -1,15 +1,14 @@ // Copyright (c) 2023 Cesanta Software Limited // All rights reserved +#include "cmsis_os2.h" #include "hal.h" +#include "main.h" #include "mongoose.h" #include "net.h" -#include "main.h" -#include "cmsis_os2.h" #define BLINK_PERIOD_MS 1000 // LED blinking period in millis - void mg_random(void *buf, size_t len) { // Use on-board RNG extern RNG_HandleTypeDef hrng; for (size_t n = 0; n < len; n += sizeof(uint32_t)) { @@ -20,8 +19,8 @@ void mg_random(void *buf, size_t len) { // Use on-board RNG } static void timer_fn(void *arg) { - struct mg_tcpip_if *ifp = arg; // And show - const char *names[] = {"down", "up", "ready"}; // network stats + struct mg_tcpip_if *ifp = arg; // And show + const char *names[] = {"down", "up", "req", "ready"}; // network stats MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u", names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent, ifp->ndrop, ifp->nerr)); @@ -59,7 +58,7 @@ static void server(void *args) { static void blinker(void *args) { for (;;) { - HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED + HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED osDelay((osKernelGetTickFreq() * BLINK_PERIOD_MS) / 1000U); } (void) args; @@ -68,16 +67,17 @@ static void blinker(void *args) { extern void mx_init(void); int main(void) { - mx_init(); // Setup clock and all peripherals configured in CubeMX - // Initialise random number generator - // Initialise ethernet pins - osKernelInitialize(); // Initialize CMSIS-RTOS - osThreadNew(blinker, NULL, NULL); // Create the blinker thread with a default stack size + mx_init(); // Setup clock and all peripherals configured in CubeMX + // Initialise random number generator + // Initialise ethernet pins + osKernelInitialize(); // Initialize CMSIS-RTOS + osThreadNew(blinker, NULL, + NULL); // Create the blinker thread with a default stack size const osThreadAttr_t server_attr = { - .stack_size = 8192 // Create the server thread with a stack size of 8KB + .stack_size = 8192 // Create the server thread with a stack size of 8KB }; osThreadNew(server, NULL, &server_attr); - osKernelStart(); // This blocks + osKernelStart(); // This blocks return 0; } diff --git a/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-baremetal/.cproject b/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-baremetal/.cproject index 9633b646..eeb69f56 100644 --- a/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-baremetal/.cproject +++ b/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-baremetal/.cproject @@ -31,6 +31,8 @@ @@ -39,6 +41,8 @@ diff --git a/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-freertos-lwip/.cproject b/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-freertos-lwip/.cproject index 1b9ae556..c890cd76 100644 --- a/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-freertos-lwip/.cproject +++ b/extra/stm_exp_pack/Examples/nucleo-f746zg-cube-freertos-lwip/.cproject @@ -31,6 +31,8 @@ @@ -39,6 +41,8 @@