Skip to content

Commit fa84191

Browse files
committed
assorted nit picks
1 parent 75c1143 commit fa84191

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

mongoose.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,19 @@ extern "C" {
168168
#endif
169169
#endif
170170

171+
#ifndef MG_TLS
172+
#define MG_TLS MG_TLS_BUILTIN
173+
#endif
174+
171175
#if !defined(MG_OTA) && defined(STM32F1) || defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
172176
#define MG_OTA MG_OTA_STM32F
173177
#elif !defined(MG_OTA) && defined(STM32H5)
174178
#define MG_OTA MG_OTA_STM32H5
175179
#elif !defined(MG_OTA) && defined(STM32H7)
176180
#define MG_OTA MG_OTA_STM32H7
177181
#endif
182+
// use HAL-defined execute-in-ram section
183+
#define MG_IRAM __attribute__((section(".RamFunc")))
178184

179185
#ifndef STM32H5
180186
#define HAL_ICACHE_IsEnabled() 0
@@ -3486,6 +3492,12 @@ struct mg_tcpip_driver_stm32f_data {
34863492
#define MG_DRIVER_MDC_CR 4
34873493
#endif
34883494

3495+
#if MG_ARCH == MG_ARCH_CUBE
3496+
#define MG_NEIRQ NVIC_EnableIRQ(ETH_IRQn)
3497+
#else
3498+
#define MG_NEIRQ
3499+
#endif
3500+
34893501
#define MG_TCPIP_DRIVER_INIT(mgr) \
34903502
do { \
34913503
static struct mg_tcpip_driver_stm32f_data driver_data_; \
@@ -3498,8 +3510,8 @@ struct mg_tcpip_driver_stm32f_data {
34983510
mif_.driver = &mg_tcpip_driver_stm32f; \
34993511
mif_.driver_data = &driver_data_; \
35003512
MG_SET_MAC_ADDRESS(mif_.mac); \
3513+
MG_NEIRQ; \
35013514
mg_tcpip_init(mgr, &mif_); \
3502-
NVIC_EnableIRQ(ETH_IRQn); \
35033515
MG_INFO(("Driver: stm32f, MAC: %M", mg_print_mac, mif_.mac)); \
35043516
} while (0)
35053517

@@ -3546,6 +3558,12 @@ struct mg_tcpip_driver_stm32h_data {
35463558
#define MG_DRIVER_MDC_CR 4
35473559
#endif
35483560

3561+
#if MG_ENABLE_DRIVER_STM32H && MG_ARCH == MG_ARCH_CUBE
3562+
#define MG_NEIRQ NVIC_EnableIRQ(ETH_IRQn)
3563+
#else
3564+
#define MG_NEIRQ
3565+
#endif
3566+
35493567
#define MG_TCPIP_DRIVER_INIT(mgr) \
35503568
do { \
35513569
static struct mg_tcpip_driver_stm32h_data driver_data_; \
@@ -3560,7 +3578,7 @@ struct mg_tcpip_driver_stm32h_data {
35603578
mif_.driver_data = &driver_data_; \
35613579
MG_SET_MAC_ADDRESS(mif_.mac); \
35623580
mg_tcpip_init(mgr, &mif_); \
3563-
NVIC_EnableIRQ(ETH_IRQn); \
3581+
MG_NEIRQ; \
35643582
MG_INFO(("Driver: stm32h, MAC: %M", mg_print_mac, mif_.mac)); \
35653583
} while (0)
35663584

src/arch_cube.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,19 @@
4545
#endif
4646
#endif
4747

48+
#ifndef MG_TLS
49+
#define MG_TLS MG_TLS_BUILTIN
50+
#endif
51+
4852
#if !defined(MG_OTA) && defined(STM32F1) || defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
4953
#define MG_OTA MG_OTA_STM32F
5054
#elif !defined(MG_OTA) && defined(STM32H5)
5155
#define MG_OTA MG_OTA_STM32H5
5256
#elif !defined(MG_OTA) && defined(STM32H7)
5357
#define MG_OTA MG_OTA_STM32H7
5458
#endif
59+
// use HAL-defined execute-in-ram section
60+
#define MG_IRAM __attribute__((section(".RamFunc")))
5561

5662
#ifndef STM32H5
5763
#define HAL_ICACHE_IsEnabled() 0

src/drivers/stm32f.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ struct mg_tcpip_driver_stm32f_data {
2828
#define MG_DRIVER_MDC_CR 4
2929
#endif
3030

31+
#if MG_ARCH == MG_ARCH_CUBE
32+
#define MG_NEIRQ NVIC_EnableIRQ(ETH_IRQn)
33+
#else
34+
#define MG_NEIRQ
35+
#endif
36+
3137
#define MG_TCPIP_DRIVER_INIT(mgr) \
3238
do { \
3339
static struct mg_tcpip_driver_stm32f_data driver_data_; \
@@ -40,8 +46,8 @@ struct mg_tcpip_driver_stm32f_data {
4046
mif_.driver = &mg_tcpip_driver_stm32f; \
4147
mif_.driver_data = &driver_data_; \
4248
MG_SET_MAC_ADDRESS(mif_.mac); \
49+
MG_NEIRQ; \
4350
mg_tcpip_init(mgr, &mif_); \
44-
NVIC_EnableIRQ(ETH_IRQn); \
4551
MG_INFO(("Driver: stm32f, MAC: %M", mg_print_mac, mif_.mac)); \
4652
} while (0)
4753

src/drivers/stm32h.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ struct mg_tcpip_driver_stm32h_data {
4040
#define MG_DRIVER_MDC_CR 4
4141
#endif
4242

43+
#if MG_ENABLE_DRIVER_STM32H && MG_ARCH == MG_ARCH_CUBE
44+
#define MG_NEIRQ NVIC_EnableIRQ(ETH_IRQn)
45+
#else
46+
#define MG_NEIRQ
47+
#endif
48+
4349
#define MG_TCPIP_DRIVER_INIT(mgr) \
4450
do { \
4551
static struct mg_tcpip_driver_stm32h_data driver_data_; \
@@ -54,7 +60,7 @@ struct mg_tcpip_driver_stm32h_data {
5460
mif_.driver_data = &driver_data_; \
5561
MG_SET_MAC_ADDRESS(mif_.mac); \
5662
mg_tcpip_init(mgr, &mif_); \
57-
NVIC_EnableIRQ(ETH_IRQn); \
63+
MG_NEIRQ; \
5864
MG_INFO(("Driver: stm32h, MAC: %M", mg_print_mac, mif_.mac)); \
5965
} while (0)
6066

0 commit comments

Comments
 (0)