mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-21 19:51:50 +00:00
Introduce MG_ARCH_CUBE, autodetect everything
This commit is contained in:
1 parent
e07a8283ec
commit
75c11436ff
9 files changed
+186
-56
No files matched your search
+10
-5
@@ -3048,7 +3048,7 @@ long mg_json_get_long(struct mg_str json, const char *path, long dflt) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mg_log_level = MG_LL_INFO;
|
int mg_log_level = MG_LL_DEBUG;
|
||||||
static mg_pfn_t s_log_func = mg_pfn_stdout;
|
static mg_pfn_t s_log_func = mg_pfn_stdout;
|
||||||
static void *s_log_func_param = NULL;
|
static void *s_log_func_param = NULL;
|
||||||
|
|
||||||
@@ -19779,6 +19779,13 @@ bool mg_random(void *buf, size_t len) {
|
|||||||
#if MG_ARCH == MG_ARCH_ESP32
|
#if MG_ARCH == MG_ARCH_ESP32
|
||||||
while (len--) *p++ = (unsigned char) (esp_random() & 255);
|
while (len--) *p++ = (unsigned char) (esp_random() & 255);
|
||||||
success = true;
|
success = true;
|
||||||
|
#elif MG_ARCH == MG_ARCH_CUBE && defined(HAL_RNG_MODULE_ENABLED)
|
||||||
|
extern RNG_HandleTypeDef hrng;
|
||||||
|
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
|
||||||
|
uint32_t r = HAL_RNG_ReadLastRandomNumber(&hrng);
|
||||||
|
memcpy((char *) buf + n, &r, n + sizeof(r) > len ? len - n : sizeof(r));
|
||||||
|
}
|
||||||
|
success = true;
|
||||||
#elif MG_ARCH == MG_ARCH_PICOSDK
|
#elif MG_ARCH == MG_ARCH_PICOSDK
|
||||||
while (len--) *p++ = (unsigned char) (get_rand_32() & 255);
|
while (len--) *p++ = (unsigned char) (get_rand_32() & 255);
|
||||||
success = true;
|
success = true;
|
||||||
@@ -19909,6 +19916,8 @@ uint64_t mg_millis(void) {
|
|||||||
#elif MG_ARCH == MG_ARCH_ESP8266 || MG_ARCH == MG_ARCH_ESP32 || \
|
#elif MG_ARCH == MG_ARCH_ESP8266 || MG_ARCH == MG_ARCH_ESP32 || \
|
||||||
MG_ARCH == MG_ARCH_FREERTOS
|
MG_ARCH == MG_ARCH_FREERTOS
|
||||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||||
|
#elif MG_ARCH == MG_ARCH_CUBE
|
||||||
|
return (uint64_t) HAL_GetTick();
|
||||||
#elif MG_ARCH == MG_ARCH_THREADX
|
#elif MG_ARCH == MG_ARCH_THREADX
|
||||||
return tx_time_get() * (1000 /* MS per SEC */ / TX_TIMER_TICKS_PER_SECOND);
|
return tx_time_get() * (1000 /* MS per SEC */ / TX_TIMER_TICKS_PER_SECOND);
|
||||||
#elif MG_ARCH == MG_ARCH_TIRTOS
|
#elif MG_ARCH == MG_ARCH_TIRTOS
|
||||||
@@ -19942,10 +19951,6 @@ uint64_t mg_millis(void) {
|
|||||||
return ((uint64_t) ts.tv_sec * 1000 + (uint64_t) ts.tv_nsec / 1000000);
|
return ((uint64_t) ts.tv_sec * 1000 + (uint64_t) ts.tv_nsec / 1000000);
|
||||||
#elif defined(ARDUINO)
|
#elif defined(ARDUINO)
|
||||||
return (uint64_t) millis();
|
return (uint64_t) millis();
|
||||||
#elif defined(__STM32H5xx_HAL_H) || defined(__STM32H7xx_HAL_H) || \
|
|
||||||
defined(__STM32F7xx_HAL_H) || defined(__STM32F4xx_HAL_H) || \
|
|
||||||
defined(__STM32F2xx_HAL_H) || defined(__STM32F1xx_HAL_H)
|
|
||||||
return (uint64_t) HAL_GetTick(); // Using STM32 HAL
|
|
||||||
#else
|
#else
|
||||||
return (uint64_t) (time(NULL) * 1000);
|
return (uint64_t) (time(NULL) * 1000);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+82
@@ -80,6 +80,7 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if MG_ARCH == MG_ARCH_ARMCGT
|
#if MG_ARCH == MG_ARCH_ARMCGT
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -122,6 +123,85 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if MG_ARCH == MG_ARCH_CUBE
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
// Cube-generated header, includes ST Cube HAL
|
||||||
|
// NOTE: use angle brackets to prevent amalgamator ditching it
|
||||||
|
#include <main.h>
|
||||||
|
|
||||||
|
#ifndef MG_PATH_MAX
|
||||||
|
#define MG_PATH_MAX 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_ENABLE_DIRLIST
|
||||||
|
#define MG_ENABLE_DIRLIST 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_ENABLE_SOCKET
|
||||||
|
#define MG_ENABLE_SOCKET 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_ENABLE_TCPIP
|
||||||
|
#define MG_ENABLE_TCPIP 1 // Enable built-in TCP/IP stack
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MG_ENABLE_TCPIP && !defined(MG_ENABLE_DRIVER_STM32F) && !defined(MG_ENABLE_DRIVER_STM32H)
|
||||||
|
#if defined(STM32F1) || defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
|
||||||
|
#define MG_ENABLE_DRIVER_STM32F 1
|
||||||
|
#elif defined(STM32H5) || defined(STM32H7)
|
||||||
|
#define MG_ENABLE_DRIVER_STM32H 1
|
||||||
|
#else
|
||||||
|
#error Select a driver in mongoose_config.h
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(MG_OTA) && defined(STM32F1) || defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
|
||||||
|
#define MG_OTA MG_OTA_STM32F
|
||||||
|
#elif !defined(MG_OTA) && defined(STM32H5)
|
||||||
|
#define MG_OTA MG_OTA_STM32H5
|
||||||
|
#elif !defined(MG_OTA) && defined(STM32H7)
|
||||||
|
#define MG_OTA MG_OTA_STM32H7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STM32H5
|
||||||
|
#define HAL_ICACHE_IsEnabled() 0
|
||||||
|
#define HAL_ICACHE_Enable() (void) 0
|
||||||
|
#define HAL_ICACHE_Disable() (void) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_SET_MAC_ADDRESS
|
||||||
|
// Construct MAC address from UUID
|
||||||
|
#define MGUID ((uint32_t *) UID_BASE) // Unique 96-bit chip ID
|
||||||
|
#define MG_SET_MAC_ADDRESS(mac) \
|
||||||
|
do { \
|
||||||
|
int icache_enabled_ = HAL_ICACHE_IsEnabled(); \
|
||||||
|
if (icache_enabled_) HAL_ICACHE_Disable(); \
|
||||||
|
mac[0] = 42; \
|
||||||
|
mac[1] = ((MGUID[0] >> 0) & 255) ^ ((MGUID[2] >> 19) & 255); \
|
||||||
|
mac[2] = ((MGUID[0] >> 10) & 255) ^ ((MGUID[1] >> 10) & 255); \
|
||||||
|
mac[3] = (MGUID[0] >> 19) & 255; \
|
||||||
|
mac[4] = ((MGUID[1] >> 0) & 255) ^ ((MGUID[2] >> 10) & 255); \
|
||||||
|
mac[5] = ((MGUID[2] >> 0) & 255) ^ ((MGUID[1] >> 19) & 255); \
|
||||||
|
if (icache_enabled_) HAL_ICACHE_Enable(); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if MG_ARCH == MG_ARCH_ESP32
|
#if MG_ARCH == MG_ARCH_ESP32
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -3419,6 +3499,7 @@ struct mg_tcpip_driver_stm32f_data {
|
|||||||
mif_.driver_data = &driver_data_; \
|
mif_.driver_data = &driver_data_; \
|
||||||
MG_SET_MAC_ADDRESS(mif_.mac); \
|
MG_SET_MAC_ADDRESS(mif_.mac); \
|
||||||
mg_tcpip_init(mgr, &mif_); \
|
mg_tcpip_init(mgr, &mif_); \
|
||||||
|
NVIC_EnableIRQ(ETH_IRQn); \
|
||||||
MG_INFO(("Driver: stm32f, MAC: %M", mg_print_mac, mif_.mac)); \
|
MG_INFO(("Driver: stm32f, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -3479,6 +3560,7 @@ struct mg_tcpip_driver_stm32h_data {
|
|||||||
mif_.driver_data = &driver_data_; \
|
mif_.driver_data = &driver_data_; \
|
||||||
MG_SET_MAC_ADDRESS(mif_.mac); \
|
MG_SET_MAC_ADDRESS(mif_.mac); \
|
||||||
mg_tcpip_init(mgr, &mif_); \
|
mg_tcpip_init(mgr, &mif_); \
|
||||||
|
NVIC_EnableIRQ(ETH_IRQn); \
|
||||||
MG_INFO(("Driver: stm32h, MAC: %M", mg_print_mac, mif_.mac)); \
|
MG_INFO(("Driver: stm32h, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -38,15 +38,16 @@
|
|||||||
// http://esr.ibiblio.org/?p=5095
|
// http://esr.ibiblio.org/?p=5095
|
||||||
#define MG_BIG_ENDIAN (*(uint16_t *) "\0\xff" < 0x100)
|
#define MG_BIG_ENDIAN (*(uint16_t *) "\0\xff" < 0x100)
|
||||||
|
|
||||||
|
#include "arch_armgcc.h"
|
||||||
|
#include "arch_cube.h"
|
||||||
#include "arch_esp32.h"
|
#include "arch_esp32.h"
|
||||||
#include "arch_esp8266.h"
|
#include "arch_esp8266.h"
|
||||||
#include "arch_freertos.h"
|
#include "arch_freertos.h"
|
||||||
#include "arch_armgcc.h"
|
|
||||||
#include "arch_rtx.h"
|
#include "arch_rtx.h"
|
||||||
|
#include "arch_threadx.h"
|
||||||
#include "arch_unix.h"
|
#include "arch_unix.h"
|
||||||
#include "arch_win32.h"
|
#include "arch_win32.h"
|
||||||
#include "arch_zephyr.h"
|
#include "arch_zephyr.h"
|
||||||
#include "arch_threadx.h"
|
|
||||||
|
|
||||||
#include "net_ft.h"
|
#include "net_ft.h"
|
||||||
#include "net_lwip.h"
|
#include "net_lwip.h"
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if MG_ARCH == MG_ARCH_CUBE
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
// Cube-generated header, includes ST Cube HAL
|
||||||
|
// NOTE: use angle brackets to prevent amalgamator ditching it
|
||||||
|
#include <main.h>
|
||||||
|
|
||||||
|
#ifndef MG_PATH_MAX
|
||||||
|
#define MG_PATH_MAX 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_ENABLE_DIRLIST
|
||||||
|
#define MG_ENABLE_DIRLIST 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_ENABLE_SOCKET
|
||||||
|
#define MG_ENABLE_SOCKET 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_ENABLE_TCPIP
|
||||||
|
#define MG_ENABLE_TCPIP 1 // Enable built-in TCP/IP stack
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MG_ENABLE_TCPIP && !defined(MG_ENABLE_DRIVER_STM32F) && !defined(MG_ENABLE_DRIVER_STM32H)
|
||||||
|
#if defined(STM32F1) || defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
|
||||||
|
#define MG_ENABLE_DRIVER_STM32F 1
|
||||||
|
#elif defined(STM32H5) || defined(STM32H7)
|
||||||
|
#define MG_ENABLE_DRIVER_STM32H 1
|
||||||
|
#else
|
||||||
|
#error Select a driver in mongoose_config.h
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(MG_OTA) && defined(STM32F1) || defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
|
||||||
|
#define MG_OTA MG_OTA_STM32F
|
||||||
|
#elif !defined(MG_OTA) && defined(STM32H5)
|
||||||
|
#define MG_OTA MG_OTA_STM32H5
|
||||||
|
#elif !defined(MG_OTA) && defined(STM32H7)
|
||||||
|
#define MG_OTA MG_OTA_STM32H7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STM32H5
|
||||||
|
#define HAL_ICACHE_IsEnabled() 0
|
||||||
|
#define HAL_ICACHE_Enable() (void) 0
|
||||||
|
#define HAL_ICACHE_Disable() (void) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_SET_MAC_ADDRESS
|
||||||
|
// Construct MAC address from UUID
|
||||||
|
#define MGUID ((uint32_t *) UID_BASE) // Unique 96-bit chip ID
|
||||||
|
#define MG_SET_MAC_ADDRESS(mac) \
|
||||||
|
do { \
|
||||||
|
int icache_enabled_ = HAL_ICACHE_IsEnabled(); \
|
||||||
|
if (icache_enabled_) HAL_ICACHE_Disable(); \
|
||||||
|
mac[0] = 42; \
|
||||||
|
mac[1] = ((MGUID[0] >> 0) & 255) ^ ((MGUID[2] >> 19) & 255); \
|
||||||
|
mac[2] = ((MGUID[0] >> 10) & 255) ^ ((MGUID[1] >> 10) & 255); \
|
||||||
|
mac[3] = (MGUID[0] >> 19) & 255; \
|
||||||
|
mac[4] = ((MGUID[1] >> 0) & 255) ^ ((MGUID[2] >> 10) & 255); \
|
||||||
|
mac[5] = ((MGUID[2] >> 0) & 255) ^ ((MGUID[1] >> 19) & 255); \
|
||||||
|
if (icache_enabled_) HAL_ICACHE_Enable(); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -41,6 +41,7 @@ struct mg_tcpip_driver_stm32f_data {
|
|||||||
mif_.driver_data = &driver_data_; \
|
mif_.driver_data = &driver_data_; \
|
||||||
MG_SET_MAC_ADDRESS(mif_.mac); \
|
MG_SET_MAC_ADDRESS(mif_.mac); \
|
||||||
mg_tcpip_init(mgr, &mif_); \
|
mg_tcpip_init(mgr, &mif_); \
|
||||||
|
NVIC_EnableIRQ(ETH_IRQn); \
|
||||||
MG_INFO(("Driver: stm32f, MAC: %M", mg_print_mac, mif_.mac)); \
|
MG_INFO(("Driver: stm32f, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ struct mg_tcpip_driver_stm32h_data {
|
|||||||
mif_.driver_data = &driver_data_; \
|
mif_.driver_data = &driver_data_; \
|
||||||
MG_SET_MAC_ADDRESS(mif_.mac); \
|
MG_SET_MAC_ADDRESS(mif_.mac); \
|
||||||
mg_tcpip_init(mgr, &mif_); \
|
mg_tcpip_init(mgr, &mif_); \
|
||||||
|
NVIC_EnableIRQ(ETH_IRQn); \
|
||||||
MG_INFO(("Driver: stm32h, MAC: %M", mg_print_mac, mif_.mac)); \
|
MG_INFO(("Driver: stm32h, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "str.h"
|
#include "str.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
int mg_log_level = MG_LL_INFO;
|
int mg_log_level = MG_LL_DEBUG;
|
||||||
static mg_pfn_t s_log_func = mg_pfn_stdout;
|
static mg_pfn_t s_log_func = mg_pfn_stdout;
|
||||||
static void *s_log_func_param = NULL;
|
static void *s_log_func_param = NULL;
|
||||||
|
|
||||||
|
|||||||
+9
-4
@@ -17,6 +17,13 @@ bool mg_random(void *buf, size_t len) {
|
|||||||
#if MG_ARCH == MG_ARCH_ESP32
|
#if MG_ARCH == MG_ARCH_ESP32
|
||||||
while (len--) *p++ = (unsigned char) (esp_random() & 255);
|
while (len--) *p++ = (unsigned char) (esp_random() & 255);
|
||||||
success = true;
|
success = true;
|
||||||
|
#elif MG_ARCH == MG_ARCH_CUBE && defined(HAL_RNG_MODULE_ENABLED)
|
||||||
|
extern RNG_HandleTypeDef hrng;
|
||||||
|
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
|
||||||
|
uint32_t r = HAL_RNG_ReadLastRandomNumber(&hrng);
|
||||||
|
memcpy((char *) buf + n, &r, n + sizeof(r) > len ? len - n : sizeof(r));
|
||||||
|
}
|
||||||
|
success = true;
|
||||||
#elif MG_ARCH == MG_ARCH_PICOSDK
|
#elif MG_ARCH == MG_ARCH_PICOSDK
|
||||||
while (len--) *p++ = (unsigned char) (get_rand_32() & 255);
|
while (len--) *p++ = (unsigned char) (get_rand_32() & 255);
|
||||||
success = true;
|
success = true;
|
||||||
@@ -147,6 +154,8 @@ uint64_t mg_millis(void) {
|
|||||||
#elif MG_ARCH == MG_ARCH_ESP8266 || MG_ARCH == MG_ARCH_ESP32 || \
|
#elif MG_ARCH == MG_ARCH_ESP8266 || MG_ARCH == MG_ARCH_ESP32 || \
|
||||||
MG_ARCH == MG_ARCH_FREERTOS
|
MG_ARCH == MG_ARCH_FREERTOS
|
||||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||||
|
#elif MG_ARCH == MG_ARCH_CUBE
|
||||||
|
return (uint64_t) HAL_GetTick();
|
||||||
#elif MG_ARCH == MG_ARCH_THREADX
|
#elif MG_ARCH == MG_ARCH_THREADX
|
||||||
return tx_time_get() * (1000 /* MS per SEC */ / TX_TIMER_TICKS_PER_SECOND);
|
return tx_time_get() * (1000 /* MS per SEC */ / TX_TIMER_TICKS_PER_SECOND);
|
||||||
#elif MG_ARCH == MG_ARCH_TIRTOS
|
#elif MG_ARCH == MG_ARCH_TIRTOS
|
||||||
@@ -180,10 +189,6 @@ uint64_t mg_millis(void) {
|
|||||||
return ((uint64_t) ts.tv_sec * 1000 + (uint64_t) ts.tv_nsec / 1000000);
|
return ((uint64_t) ts.tv_sec * 1000 + (uint64_t) ts.tv_nsec / 1000000);
|
||||||
#elif defined(ARDUINO)
|
#elif defined(ARDUINO)
|
||||||
return (uint64_t) millis();
|
return (uint64_t) millis();
|
||||||
#elif defined(__STM32H5xx_HAL_H) || defined(__STM32H7xx_HAL_H) || \
|
|
||||||
defined(__STM32F7xx_HAL_H) || defined(__STM32F4xx_HAL_H) || \
|
|
||||||
defined(__STM32F2xx_HAL_H) || defined(__STM32F1xx_HAL_H)
|
|
||||||
return (uint64_t) HAL_GetTick(); // Using STM32 HAL
|
|
||||||
#else
|
#else
|
||||||
return (uint64_t) (time(NULL) * 1000);
|
return (uint64_t) (time(NULL) * 1000);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define MG_ARCH MG_ARCH_ARMGCC // Generic ARM GCC
|
|
||||||
#define MG_TLS MG_TLS_BUILTIN // MG_TLS_NONE, MG_TLS_MBED, MG_TLS_OPENSSL
|
|
||||||
#define MG_ENABLE_TCPIP 1 // Enable built-in TCP/IP stack
|
|
||||||
|
|
||||||
// #define MG_ENABLE_DRIVER_STM32F 1
|
|
||||||
// #define MG_ENABLE_DRIVER_STM32H 1
|
|
||||||
#error "Choose network driver in mongoose_config.h"
|
|
||||||
|
|
||||||
// OTA implementation
|
|
||||||
// #define MG_OTA_STM32F 1
|
|
||||||
// #define MG_OTA_STM32H5 1
|
|
||||||
// #define MG_OTA_STM32H7 1
|
|
||||||
|
|
||||||
// IP and MAC configuration
|
|
||||||
// ------------------------
|
|
||||||
// For static IP configuration, define MG_TCPIP_{IP,MASK,GW}
|
|
||||||
// By default, those are set to zero, meaning that DHCP is used
|
|
||||||
//
|
|
||||||
// #define MG_TCPIP_IP MG_IPV4(192, 168, 0, 10)
|
|
||||||
// #define MG_TCPIP_GW MG_IPV4(192, 168, 0, 1)
|
|
||||||
// #define MG_TCPIP_MASK MG_IPV4(255, 255, 255, 0)
|
|
||||||
//
|
|
||||||
// Construct MAC address from UUID
|
|
||||||
#include "main.h"
|
|
||||||
#define MGUID ((uint32_t *) UID_BASE) // Unique 96-bit chip ID
|
|
||||||
#define MG_SET_MAC_ADDRESS(mac) \
|
|
||||||
do { \
|
|
||||||
mac[0] = 2; \
|
|
||||||
mac[1] = MGUID[0] & 255; \
|
|
||||||
mac[2] = (MGUID[0] >> 10) & 255; \
|
|
||||||
mac[3] = (MGUID[0] >> 19) & 255; \
|
|
||||||
mac[4] = MGUID[1] & 255; \
|
|
||||||
mac[5] = MGUID[2] & 255; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
// #define MG_ENABLE_CUSTOM_CALLOC 1 // Let user define mg_calloc() and mg_free()
|
|
||||||
// #define MG_ENABLE_CUSTOM_RANDOM 1 // Let user define mg_random()
|
|
||||||
// #define MG_ENABLE_CUSTOM_MILLIS 1 // Let user define mg_millis()
|
|
||||||
|
|
||||||
// Driver options
|
|
||||||
// #define MG_DRIVER_MDC_CR 4 // RMII MDC clock divider, from 0 to 4
|
|
||||||
// #define MG_TCPIP_PHY_ADDR 0 // PHY address
|
|
||||||
Reference in new issue
Block a user