class WIZNET5K – control WIZnet5x00 Ethernet modules 类WIZNET5K——控制WIZnet5x00以太网模块 =====================================================
This class allows you to control WIZnet5x00 Ethernet adaptors based on the W5200 and W5500 chipsets. The particular chipset that is supported by the firmware is selected at compile-time via the MICROPY_PY_WIZNET5K option. 这个类允许您基于 W5200和W5500芯片组。所支持的特定芯片组 固件在编译时通过MICROPY_PY_WIZNET5K选择 选择。
Example usage:: 用法例子:
import network nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4) print(nic.ifconfig())
# now use socket as usual # 现在像往常一样使用套接字 …
For this example to work the WIZnet5x00 module must have the following connections: 为了使这个示例工作,WIZnet5x00模块必须具有以下连接:
MOSI connected to X8
MISO connected to X7
SCLK connected to X6
nSS connected to X5
nRESET connected to X4
It is possible to use other SPI busses and other pins for nSS and nRESET. 有可能使用其他SPI总线和其他引脚的nSS和nRESET。
Constructors 构造函数 ————
- class network.WIZNET5K(spi, pin_cs, pin_rst)¶
Create a WIZNET5K driver object, initialise the WIZnet5x00 module using the given SPI bus and pins, and return the WIZNET5K object. 创建一个WIZNET5K驱动程序对象,使用给定的初始化WIZnet5x00模块 并返回WIZNET5K对象。
Arguments are: 参数:
spi is an SPI object which is the SPI bus that the WIZnet5x00 is connected to (the MOSI, MISO and SCLK pins).
spi is an SPI object WIZnet5x00是哪一种SPI总线 连接到(MOSI,MISO和SCLK pins)。
pin_cs is a Pin object which is connected to the WIZnet5x00 nSS pin.
pin_cs is a Pin object 连接到WIZnet5x00 nSS引脚。
pin_rst is a Pin object which is connected to the WIZnet5x00 nRESET pin.
pin_rst is a Pin object 连接到WIZnet5x00 nRESET引脚。
All of these objects will be initialised by the driver, so there is no need to initialise them yourself. For example, you can use:: 所有这些对象都将被驱动程序初始化,所以没有必要这样做 初始化自己。例如,你可以用:
nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
Methods 方法 ——-
- WIZNET5K.isconnected()¶
Returns
True
if the physical Ethernet link is connected and up. ReturnsFalse
otherwise. 如果物理以太网连接成功,返回``True``。 返回``False``。
- WIZNET5K.ifconfig([(ip, subnet, gateway, dns)])¶
Get/set IP address, subnet mask, gateway and DNS. 获取/设置IP地址,子网掩码,网关和DNS。
When called with no arguments, this method returns a 4-tuple with the above information. 在不带参数的情况下调用该方法时,将返回一个包含上述信息的4元组。
To set the above values, pass a 4-tuple with the required information. For example:: 要设置上述值,需要传递一个包含所需信息的4元组。例如:
nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
- WIZNET5K.regs()¶
Dump the WIZnet5x00 registers. Useful for debugging. 转储WIZnet5x00寄存器。用于调试。