Skip to content

Commit a220ea4

Browse files
authored
Merge pull request #133 from whj4674672/master
[add] ETH 的依赖
2 parents 8903157 + 140f0ae commit a220ea4

File tree

5 files changed

+175
-51
lines changed

5 files changed

+175
-51
lines changed

libraries/Kconfig

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ menu "Board extended module"
5858
bool "Industry-IO"
5959
default n
6060
if ART_PI_USING_INDUSTRY_IO
61-
config PHY_USING_LAN8720A
62-
bool
63-
6461
config INDUSTRY_IO_USING_ETH
6562
select BSP_USING_ETH
6663
select PHY_USING_LAN8720A
@@ -199,11 +196,11 @@ menu "On-chip Peripheral"
199196
comment "Notice: PB6 --> 22; PB7 --> 23"
200197
config BSP_I2C1_SCL_PIN
201198
int "I2C1 scl pin number"
202-
range 1 176
199+
range 0 175
203200
default 22
204201
config BSP_I2C1_SDA_PIN
205202
int "I2C1 sda pin number"
206-
range 1 176
203+
range 0 175
207204
default 23
208205
endif
209206
menuconfig BSP_USING_I2C2
@@ -217,7 +214,7 @@ menu "On-chip Peripheral"
217214
default 127
218215
config BSP_I2C2_SDA_PIN
219216
int "I2C2 sda pin number"
220-
range 1 176
217+
range 0 175
221218
default 125
222219
endif
223220
menuconfig BSP_USING_I2C3
@@ -227,11 +224,11 @@ menu "On-chip Peripheral"
227224
comment "Notice: PH12 --> 124; PH11 --> 123"
228225
config BSP_I2C3_SCL_PIN
229226
int "i2c3 scl pin number"
230-
range 1 176
227+
range 0 175
231228
default 123
232229
config BSP_I2C3_SDA_PIN
233230
int "I2C3 sda pin number"
234-
range 1 176
231+
range 0 175
235232
default 124
236233
endif
237234
endif
@@ -255,8 +252,24 @@ menu "On-chip Peripheral"
255252

256253
menuconfig BSP_USING_ETH
257254
bool "Enable Ethernet"
255+
default n
258256
select RT_USING_LWIP
259-
default n
257+
if BSP_USING_ETH
258+
comment "Notice: PA3 --> 3"
259+
config ETH_RESET_PIN
260+
int "ETH RESET PIN"
261+
range 0 175
262+
default 3
263+
endif
264+
if BSP_USING_ETH
265+
choice
266+
prompt "Choose Eth PHY"
267+
default PHY_USING_LAN8720A
268+
config PHY_USING_LAN8720A
269+
bool "USING LAN8720A"
270+
default n
271+
endchoice
272+
endif
260273

261274
config BSP_USING_LCD
262275
bool "Enable LCD"

libraries/drivers/drv_eth.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* 2019-06-10 SummerGift optimize PHY state detection process
1111
* 2019-09-03 xiaofan optimize link change detection process
1212
* 2020-07-17 wanghaijing support h7
13+
* 2020-11-30 wanghaijing add phy reset
1314
*/
1415

1516
#include<rtthread.h>
@@ -103,7 +104,14 @@ static void dump_hex(const rt_uint8_t *ptr, rt_size_t buflen)
103104
}
104105
#endif
105106

106-
extern void phy_reset(void);
107+
static void phy_reset(void)
108+
{
109+
rt_pin_write(ETH_RESET_PIN, PIN_LOW);
110+
rt_thread_mdelay(50);
111+
rt_pin_write(ETH_RESET_PIN, PIN_HIGH);
112+
}
113+
114+
107115
/* EMAC initialization function */
108116
static rt_err_t rt_stm32_eth_init(rt_device_t dev)
109117
{
@@ -492,6 +500,9 @@ static int rt_hw_stm32_eth_init(void)
492500
{
493501
rt_err_t state = RT_EOK;
494502

503+
rt_pin_mode(ETH_RESET_PIN, PIN_MODE_OUTPUT);
504+
rt_pin_write(ETH_RESET_PIN, PIN_HIGH);
505+
495506
stm32_eth_device.ETH_Speed = ETH_SPEED_100M;
496507
stm32_eth_device.ETH_Mode = ETH_FULLDUPLEX_MODE;
497508

0 commit comments

Comments
 (0)