mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-19 19:40:56 +00:00
Split PHY code into phy.{c,h}; add PHY config to STM32H driver
This commit is contained in:
1 parent
98782e44c2
commit
928aed4342
10 files changed
+382
-304
No files matched your search
+35
-5
@@ -2937,6 +2937,28 @@ struct mg_tcpip_driver_imxrt_data {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
struct mg_phy {
|
||||
uint16_t (*read_reg)(uint8_t addr, uint8_t reg);
|
||||
void (*write_reg)(uint8_t addr, uint8_t reg, uint16_t value);
|
||||
};
|
||||
|
||||
// PHY configuration settings, bitmask
|
||||
enum {
|
||||
MG_PHY_LEDS_ACTIVE_HIGH =
|
||||
(1 << 0), // Set if PHY LEDs are connected to ground
|
||||
MG_PHY_CLOCKS_MAC =
|
||||
(1 << 1), // Set when PHY clocks MAC. Otherwise, MAC clocks PHY
|
||||
};
|
||||
|
||||
enum { MG_PHY_SPEED_10M, MG_PHY_SPEED_100M, MG_PHY_SPEED_1000M };
|
||||
|
||||
void mg_phy_init(struct mg_phy *, uint8_t addr, uint8_t config);
|
||||
bool mg_phy_up(struct mg_phy *, uint8_t addr, bool *full_duplex,
|
||||
uint8_t *speed);
|
||||
|
||||
|
||||
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_RA) && MG_ENABLE_DRIVER_RA
|
||||
|
||||
struct mg_tcpip_driver_ra_data {
|
||||
@@ -3037,7 +3059,7 @@ struct mg_tcpip_driver_stm32f_data {
|
||||
|
||||
#define MG_TCPIP_DRIVER_DATA \
|
||||
static struct mg_tcpip_driver_stm32f_data driver_data = { \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
.phy_addr = MG_TCPIP_PHY_ADDR, \
|
||||
};
|
||||
|
||||
@@ -3059,23 +3081,31 @@ 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 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
|
||||
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
|
||||
|
||||
#ifndef MG_DRIVER_MDC_CR
|
||||
#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, \
|
||||
.mdc_cr = MG_DRIVER_MDC_CR, \
|
||||
.phy_addr = MG_TCPIP_PHY_ADDR, \
|
||||
};
|
||||
|
||||
#define MG_TCPIP_DRIVER_CODE &mg_tcpip_driver_stm32h
|
||||
|
||||
Reference in new issue
Block a user