mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
PR #2308 collaterals
This commit is contained in:
1 parent
5607c714ec
commit
dbeaeb0d6c
25 files changed
+92
-77
No files matched your search
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
#include "main.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|
||||||
uint64_t mg_millis(void) { // Let Mongoose use our uptime function
|
uint64_t mg_millis(void) { // Let Mongoose use our uptime function
|
||||||
return (uint64_t)HAL_GetTick(); // Return number of milliseconds since boot
|
return (uint64_t) HAL_GetTick(); // Return number of milliseconds since boot
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
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) {
|
static void timer_fn(void *arg) {
|
||||||
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED
|
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); // Blink On-board blue LED
|
||||||
struct mg_tcpip_if *ifp = arg; // And show
|
struct mg_tcpip_if *ifp = arg; // And show
|
||||||
const char *names[] = {"down", "up", "ready"}; // network stats
|
const char *names[] = {"down", "up", "req", "ready"}; // network stats
|
||||||
MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u",
|
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,
|
names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent,
|
||||||
ifp->ndrop, ifp->nerr));
|
ifp->ndrop, ifp->nerr));
|
||||||
@@ -33,9 +33,9 @@ static void timer_fn(void *arg) {
|
|||||||
extern void mx_init(void);
|
extern void mx_init(void);
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
||||||
// Initialise random number generator
|
// Initialise random number generator
|
||||||
// Initialise ethernet pins
|
// Initialise ethernet pins
|
||||||
MG_INFO(("Starting, CPU freq %g MHz", (double) SystemCoreClock / 1000000));
|
MG_INFO(("Starting, CPU freq %g MHz", (double) SystemCoreClock / 1000000));
|
||||||
|
|
||||||
struct mg_mgr mgr; // Initialise
|
struct mg_mgr mgr; // Initialise
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "net.h"
|
||||||
#include "ethernetif.h"
|
#include "ethernetif.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
extern RNG_HandleTypeDef hrng;
|
extern RNG_HandleTypeDef hrng;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -2,16 +2,17 @@
|
|||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
#include "main.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|
||||||
extern void xPortSysTickHandler(void);
|
extern void xPortSysTickHandler(void);
|
||||||
void SysTick_Handler (void) {
|
void SysTick_Handler(void) {
|
||||||
HAL_IncTick();
|
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)
|
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
|
||||||
xPortSysTickHandler();
|
xPortSysTickHandler();
|
||||||
}
|
}
|
||||||
@@ -26,8 +27,8 @@ void mg_random(void *buf, size_t len) { // Use on-board RNG
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void timer_fn(void *arg) {
|
static void timer_fn(void *arg) {
|
||||||
struct mg_tcpip_if *ifp = arg; // And show
|
struct mg_tcpip_if *ifp = arg; // And show
|
||||||
const char *names[] = {"down", "up", "ready"}; // network stats
|
const char *names[] = {"down", "up", "req", "ready"}; // network stats
|
||||||
MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u",
|
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,
|
names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent,
|
||||||
ifp->ndrop, ifp->nerr));
|
ifp->ndrop, ifp->nerr));
|
||||||
@@ -65,7 +66,7 @@ static void server(void *args) {
|
|||||||
|
|
||||||
static void blinker(void *args) {
|
static void blinker(void *args) {
|
||||||
for (;;) {
|
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));
|
vTaskDelay(pdMS_TO_TICKS(BLINK_PERIOD_MS));
|
||||||
}
|
}
|
||||||
(void) args;
|
(void) args;
|
||||||
@@ -74,9 +75,9 @@ static void blinker(void *args) {
|
|||||||
extern void mx_init(void);
|
extern void mx_init(void);
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
||||||
// Initialise random number generator
|
// Initialise random number generator
|
||||||
// Initialise ethernet pins
|
// Initialise ethernet pins
|
||||||
// Start tasks. NOTE: stack sizes are in 32-bit words
|
// Start tasks. NOTE: stack sizes are in 32-bit words
|
||||||
xTaskCreate(blinker, "blinker", 128, ":)", configMAX_PRIORITIES - 1, NULL);
|
xTaskCreate(blinker, "blinker", 128, ":)", configMAX_PRIORITIES - 1, NULL);
|
||||||
xTaskCreate(server, "server", 2048, 0, configMAX_PRIORITIES - 1, NULL);
|
xTaskCreate(server, "server", 2048, 0, configMAX_PRIORITIES - 1, NULL);
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
+1
-1
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "net.h"
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include "ethernetif.h"
|
#include "ethernetif.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
+14
-13
@@ -1,15 +1,14 @@
|
|||||||
// Copyright (c) 2023 Cesanta Software Limited
|
// Copyright (c) 2023 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
|
#include "cmsis_os2.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
#include "main.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "main.h"
|
|
||||||
#include "cmsis_os2.h"
|
|
||||||
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|
||||||
|
|
||||||
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
||||||
extern RNG_HandleTypeDef hrng;
|
extern RNG_HandleTypeDef hrng;
|
||||||
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
|
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) {
|
static void timer_fn(void *arg) {
|
||||||
struct mg_tcpip_if *ifp = arg; // And show
|
struct mg_tcpip_if *ifp = arg; // And show
|
||||||
const char *names[] = {"down", "up", "ready"}; // network stats
|
const char *names[] = {"down", "up", "req", "ready"}; // network stats
|
||||||
MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u",
|
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,
|
names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent,
|
||||||
ifp->ndrop, ifp->nerr));
|
ifp->ndrop, ifp->nerr));
|
||||||
@@ -59,7 +58,7 @@ static void server(void *args) {
|
|||||||
|
|
||||||
static void blinker(void *args) {
|
static void blinker(void *args) {
|
||||||
for (;;) {
|
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);
|
osDelay((osKernelGetTickFreq() * BLINK_PERIOD_MS) / 1000U);
|
||||||
}
|
}
|
||||||
(void) args;
|
(void) args;
|
||||||
@@ -68,16 +67,18 @@ static void blinker(void *args) {
|
|||||||
extern void mx_init(void);
|
extern void mx_init(void);
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
||||||
// Initialise random number generator
|
// Initialise random number generator
|
||||||
// Initialise ethernet pins
|
// Initialise ethernet pins
|
||||||
osKernelInitialize(); // Initialize CMSIS-RTOS
|
osKernelInitialize(); // Initialize CMSIS-RTOS
|
||||||
osThreadNew(blinker, NULL, NULL); // Create the blinker thread with a default stack size
|
osThreadNew(blinker, NULL,
|
||||||
|
NULL); // Create the blinker thread with a default stack size
|
||||||
const osThreadAttr_t server_attr = {
|
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);
|
osThreadNew(server, NULL, &server_attr);
|
||||||
osKernelStart(); // This blocks
|
osKernelStart(); // This blocks
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "net.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
// Copyright (c) 2023 Cesanta Software Limited
|
// Copyright (c) 2023 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
|
#include "cmsis_os.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
#include "main.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "main.h"
|
|
||||||
#include "cmsis_os.h"
|
|
||||||
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|
||||||
|
|
||||||
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
||||||
extern RNG_HandleTypeDef hrng;
|
extern RNG_HandleTypeDef hrng;
|
||||||
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
|
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) {
|
static void timer_fn(void *arg) {
|
||||||
struct mg_tcpip_if *ifp = arg; // And show
|
struct mg_tcpip_if *ifp = arg; // And show
|
||||||
const char *names[] = {"down", "up", "ready"}; // network stats
|
const char *names[] = {"down", "up", "req", "ready"}; // network stats
|
||||||
MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u",
|
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,
|
names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent,
|
||||||
ifp->ndrop, ifp->nerr));
|
ifp->ndrop, ifp->nerr));
|
||||||
@@ -59,23 +58,25 @@ static void server(const void *args) {
|
|||||||
|
|
||||||
static void blinker(const void *args) {
|
static void blinker(const void *args) {
|
||||||
for (;;) {
|
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(BLINK_PERIOD_MS); // CMSIS-RTOS v1 uses milliseconds
|
osDelay(BLINK_PERIOD_MS); // CMSIS-RTOS v1 uses milliseconds
|
||||||
}
|
}
|
||||||
(void) args;
|
(void) args;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void mx_init(void);
|
extern void mx_init(void);
|
||||||
osThreadDef(server, osPriorityNormal, 1, 8192); // Create the server thread with a stack size of 8KB
|
osThreadDef(server, osPriorityNormal, 1,
|
||||||
osThreadDef(blinker, osPriorityNormal, 1, 0); // Create the blinker thread with default stack size
|
8192); // Create the server thread with a stack size of 8KB
|
||||||
|
osThreadDef(blinker, osPriorityNormal, 1,
|
||||||
int main(void) { // this is not actually baremetal main() but the "main" thread
|
0); // Create the blinker thread with default stack size
|
||||||
osKernelInitialize(); // Stop kernel
|
|
||||||
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
int main(void) { // this is not actually baremetal main() but the "main" thread
|
||||||
// Initialise random number generator
|
osKernelInitialize(); // Stop kernel
|
||||||
// Initialise ethernet pins
|
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(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
|
osKernelStart(); // Start kernel again and exit main thread
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "net.h"
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include "ethernetif.h"
|
#include "ethernetif.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "net.h"
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Add your customization below this comment
|
#define MG_ENABLE_TCPIP 1
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
// Copyright (c) 2023 Cesanta Software Limited
|
// Copyright (c) 2023 Cesanta Software Limited
|
||||||
// All rights reserved
|
// All rights reserved
|
||||||
|
|
||||||
|
#include "cmsis_os2.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
#include "main.h"
|
||||||
#include "mongoose.h"
|
#include "mongoose.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "main.h"
|
|
||||||
#include "cmsis_os2.h"
|
|
||||||
|
|
||||||
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
#define BLINK_PERIOD_MS 1000 // LED blinking period in millis
|
||||||
|
|
||||||
|
|
||||||
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
void mg_random(void *buf, size_t len) { // Use on-board RNG
|
||||||
extern RNG_HandleTypeDef hrng;
|
extern RNG_HandleTypeDef hrng;
|
||||||
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
|
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) {
|
static void timer_fn(void *arg) {
|
||||||
struct mg_tcpip_if *ifp = arg; // And show
|
struct mg_tcpip_if *ifp = arg; // And show
|
||||||
const char *names[] = {"down", "up", "ready"}; // network stats
|
const char *names[] = {"down", "up", "req", "ready"}; // network stats
|
||||||
MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u",
|
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,
|
names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent,
|
||||||
ifp->ndrop, ifp->nerr));
|
ifp->ndrop, ifp->nerr));
|
||||||
@@ -59,7 +58,7 @@ static void server(void *args) {
|
|||||||
|
|
||||||
static void blinker(void *args) {
|
static void blinker(void *args) {
|
||||||
for (;;) {
|
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);
|
osDelay((osKernelGetTickFreq() * BLINK_PERIOD_MS) / 1000U);
|
||||||
}
|
}
|
||||||
(void) args;
|
(void) args;
|
||||||
@@ -68,16 +67,17 @@ static void blinker(void *args) {
|
|||||||
extern void mx_init(void);
|
extern void mx_init(void);
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
mx_init(); // Setup clock and all peripherals configured in CubeMX
|
||||||
// Initialise random number generator
|
// Initialise random number generator
|
||||||
// Initialise ethernet pins
|
// Initialise ethernet pins
|
||||||
osKernelInitialize(); // Initialize CMSIS-RTOS
|
osKernelInitialize(); // Initialize CMSIS-RTOS
|
||||||
osThreadNew(blinker, NULL, NULL); // Create the blinker thread with a default stack size
|
osThreadNew(blinker, NULL,
|
||||||
|
NULL); // Create the blinker thread with a default stack size
|
||||||
const osThreadAttr_t server_attr = {
|
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);
|
osThreadNew(server, NULL, &server_attr);
|
||||||
osKernelStart(); // This blocks
|
osKernelStart(); // This blocks
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.367201976" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.367201976" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1115116583" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1115116583" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
|
<listOptionValue builtIn="false" value="MG_ENABLE_DRIVER_STM32H=1"/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.560996286" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.560996286" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@@ -39,6 +41,8 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.656778761" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.656778761" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1784614787" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1784614787" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
|
<listOptionValue builtIn="false" value="MG_ENABLE_DRIVER_STM32H=1"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||||
<listOptionValue builtIn="false" value="STM32F746xx"/>
|
<listOptionValue builtIn="false" value="STM32F746xx"/>
|
||||||
</option>
|
</option>
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.367201976" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.367201976" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1115116583" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1115116583" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
|
<listOptionValue builtIn="false" value="MG_ENABLE_DRIVER_STM32H=1"/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.560996286" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.560996286" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@@ -39,6 +41,8 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.656778761" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.656778761" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1784614787" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1784614787" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
|
<listOptionValue builtIn="false" value="MG_ENABLE_DRIVER_STM32H=1"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="MEMP_NUM_NETCONN=10"/>
|
<listOptionValue builtIn="false" value="MEMP_NUM_NETCONN=10"/>
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||||
<listOptionValue builtIn="false" value="STM32F746xx"/>
|
<listOptionValue builtIn="false" value="STM32F746xx"/>
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.367201976" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.367201976" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1115116583" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1115116583" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
|
<listOptionValue builtIn="false" value="MG_ENABLE_DRIVER_STM32H=1"/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.560996286" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.560996286" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@@ -39,6 +41,8 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.656778761" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.656778761" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1784614787" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1784614787" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
|
<listOptionValue builtIn="false" value="MG_ENABLE_DRIVER_STM32H=1"/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||||
<listOptionValue builtIn="false" value="STM32F746xx"/>
|
<listOptionValue builtIn="false" value="STM32F746xx"/>
|
||||||
</option>
|
</option>
|
||||||
|
|||||||
Reference in new issue
Block a user