mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-09 16:21:45 +00:00
Refactor autoinit code
This commit is contained in:
1 parent
15bd8b4fe9
commit
fafc5c8348
14 files changed
+111
-303
No files matched your search
@@ -5,13 +5,4 @@
|
||||
#include "Driver_ETH_MAC.h" // keep this include
|
||||
#include "Driver_ETH_PHY.h" // keep this include
|
||||
|
||||
#ifndef MG_MAC_ADDRESS
|
||||
#define MG_MAC_ADDRESS MG_MAC_ADDRESS_RANDOM
|
||||
#endif
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA int driver_data;
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_cmsis
|
||||
#define MG_TCPIP_DRIVER_NAME "cmsis"
|
||||
|
||||
#endif
|
||||
@@ -19,10 +19,6 @@ struct mg_tcpip_driver_imxrt_data {
|
||||
uint8_t phy_addr; // PHY address
|
||||
};
|
||||
|
||||
#ifndef MG_MAC_ADDRESS
|
||||
#define MG_MAC_ADDRESS MG_MAC_ADDRESS_RANDOM
|
||||
#endif
|
||||
|
||||
#ifndef MG_TCPIP_PHY_ADDR
|
||||
#define MG_TCPIP_PHY_ADDR 2
|
||||
#endif
|
||||
@@ -31,13 +27,4 @@ struct mg_tcpip_driver_imxrt_data {
|
||||
#define MG_DRIVER_MDC_CR 24
|
||||
#endif
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA \
|
||||
static struct mg_tcpip_driver_imxrt_data driver_data = { \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
.phy_addr = MG_TCPIP_PHY_ADDR, \
|
||||
};
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_imxrt
|
||||
#define MG_TCPIP_DRIVER_NAME "imxrt"
|
||||
|
||||
#endif
|
||||
@@ -9,33 +9,4 @@ struct mg_tcpip_driver_ra_data {
|
||||
uint8_t phy_addr; // PHY address
|
||||
};
|
||||
|
||||
#undef MG_ENABLE_TCPIP_DRIVER_INIT
|
||||
#define MG_ENABLE_TCPIP_DRIVER_INIT 0 // TODO(): needs SystemCoreClock
|
||||
#if 0
|
||||
#ifndef MG_MAC_ADDRESS
|
||||
#define MG_MAC_ADDRESS MG_MAC_ADDRESS_RANDOM
|
||||
#endif
|
||||
|
||||
#ifndef MG_TCPIP_PHY_ADDR
|
||||
#define MG_TCPIP_PHY_ADDR 1
|
||||
#endif
|
||||
|
||||
#ifndef MG_DRIVER_RA_CLOCK
|
||||
#define MG_DRIVER_RA_CLOCK
|
||||
#endif
|
||||
|
||||
#ifndef MG_DRIVER_RA_IRQNO
|
||||
#define MG_DRIVER_RA_IRQNO 0
|
||||
#endif
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA \
|
||||
static struct mg_tcpip_driver_ra_data driver_data = { \
|
||||
.clock = MG_DRIVER_RA_CLOCK, \
|
||||
.irqno = MG_DRIVER_RA_CLOCK, \
|
||||
.phy_addr = MG_TCPIP_PHY_ADDR, \
|
||||
};
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_ra
|
||||
#define MG_TCPIP_DRIVER_NAME "ra"
|
||||
#endif
|
||||
#endif
|
||||
@@ -6,20 +6,8 @@ struct mg_tcpip_driver_same54_data {
|
||||
int mdc_cr;
|
||||
};
|
||||
|
||||
#ifndef MG_MAC_ADDRESS
|
||||
#define MG_MAC_ADDRESS MG_MAC_ADDRESS_RANDOM
|
||||
#endif
|
||||
|
||||
#ifndef MG_DRIVER_MDC_CR
|
||||
#define MG_DRIVER_MDC_CR 5
|
||||
#endif
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA \
|
||||
static struct mg_tcpip_driver_same54_data driver_data = { \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
};
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_same54
|
||||
#define MG_TCPIP_DRIVER_NAME "same54"
|
||||
|
||||
#endif
|
||||
+15
-12
@@ -20,10 +20,6 @@ struct mg_tcpip_driver_stm32f_data {
|
||||
uint8_t phy_addr; // PHY address
|
||||
};
|
||||
|
||||
#ifndef MG_MAC_ADDRESS
|
||||
#define MG_MAC_ADDRESS MG_MAC_ADDRESS_RANDOM
|
||||
#endif
|
||||
|
||||
#ifndef MG_TCPIP_PHY_ADDR
|
||||
#define MG_TCPIP_PHY_ADDR 0
|
||||
#endif
|
||||
@@ -32,13 +28,20 @@ struct mg_tcpip_driver_stm32f_data {
|
||||
#define MG_DRIVER_MDC_CR 4
|
||||
#endif
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA \
|
||||
static struct mg_tcpip_driver_stm32f_data driver_data = { \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
.phy_addr = MG_TCPIP_PHY_ADDR, \
|
||||
};
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_stm32f
|
||||
#define MG_TCPIP_DRIVER_NAME "stm32f"
|
||||
#define MG_TCPIP_DRIVER_INIT(mgr) \
|
||||
do { \
|
||||
static struct mg_tcpip_driver_stm32f_data driver_data_; \
|
||||
static struct mg_tcpip_if mif_; \
|
||||
driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \
|
||||
driver_data_.phy_addr = MG_TCPIP_PHY_ADDR; \
|
||||
mif_.ip = MG_TCPIP_IP; \
|
||||
mif_.mask = MG_TCPIP_MASK; \
|
||||
mif_.gw = MG_TCPIP_GW; \
|
||||
mif_.driver = &mg_tcpip_driver_stm32f; \
|
||||
mif_.driver_data = &driver_data_; \
|
||||
MG_SET_MAC_ADDRESS(mif_.mac); \
|
||||
mg_tcpip_init(mgr, &mif_); \
|
||||
MG_INFO(("Driver: stm32f, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
+18
-15
@@ -12,19 +12,15 @@ struct mg_tcpip_driver_stm32h_data {
|
||||
// 100-150 MHz HCLK/62 1
|
||||
// 20-35 MHz HCLK/16 2
|
||||
// 35-60 MHz HCLK/26 3
|
||||
// 150-250 MHz HCLK/102 4 <-- value for Nucleo-H* on max speed
|
||||
// driven by HSI 250-300 MHz HCLK/124 5 <-- value for Nucleo-H* on
|
||||
// max speed driven by CSI 110, 111 Reserved
|
||||
// 150-250 MHz HCLK/102 4 <-- value for max speed HSI
|
||||
// 250-300 MHz HCLK/124 5 <-- value for Nucleo-H* on CSI
|
||||
// 110, 111 Reserved
|
||||
int mdc_cr; // Valid values: -1, 0, 1, 2, 3, 4, 5
|
||||
|
||||
uint8_t phy_addr; // PHY address
|
||||
uint8_t phy_conf; // PHY config
|
||||
};
|
||||
|
||||
#ifndef MG_MAC_ADDRESS
|
||||
#define MG_MAC_ADDRESS MG_MAC_ADDRESS_RANDOM
|
||||
#endif
|
||||
|
||||
#ifndef MG_TCPIP_PHY_ADDR
|
||||
#define MG_TCPIP_PHY_ADDR 0
|
||||
#endif
|
||||
@@ -33,13 +29,20 @@ struct mg_tcpip_driver_stm32h_data {
|
||||
#define MG_DRIVER_MDC_CR 4
|
||||
#endif
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA \
|
||||
static struct mg_tcpip_driver_stm32h_data driver_data = { \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
.phy_addr = MG_TCPIP_PHY_ADDR, \
|
||||
};
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_stm32h
|
||||
#define MG_TCPIP_DRIVER_NAME "stm32h"
|
||||
#define MG_TCPIP_DRIVER_INIT(mgr) \
|
||||
do { \
|
||||
static struct mg_tcpip_driver_stm32h_data driver_data_; \
|
||||
static struct mg_tcpip_if mif_; \
|
||||
driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \
|
||||
driver_data_.phy_addr = MG_TCPIP_PHY_ADDR; \
|
||||
mif_.ip = MG_TCPIP_IP; \
|
||||
mif_.mask = MG_TCPIP_MASK; \
|
||||
mif_.gw = MG_TCPIP_GW; \
|
||||
mif_.driver = &mg_tcpip_driver_stm32h; \
|
||||
mif_.driver_data = &driver_data_; \
|
||||
MG_SET_MAC_ADDRESS(mif_.mac); \
|
||||
mg_tcpip_init(mgr, &mif_); \
|
||||
MG_INFO(("Driver: stm32h, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
@@ -15,21 +15,8 @@ struct mg_tcpip_driver_tm4c_data {
|
||||
int mdc_cr; // Valid values: -1, 0, 1, 2, 3
|
||||
};
|
||||
|
||||
#ifndef MG_MAC_ADDRESS
|
||||
#define MG_MAC_ADDRESS MG_MAC_ADDRESS_RANDOM
|
||||
#endif
|
||||
|
||||
#ifndef MG_DRIVER_MDC_CR
|
||||
#define MG_DRIVER_MDC_CR 1
|
||||
#endif
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA \
|
||||
static struct mg_tcpip_driver_tm4c_data driver_data = { \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
};
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_tm4c
|
||||
#define MG_TCPIP_DRIVER_NAME "tm4c"
|
||||
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user