diff -r 7e073ff57760 -r 05cbf70e8f10 src/eric7/MicroPython/EthernetDialogs/WiznetUtilities.py --- a/src/eric7/MicroPython/EthernetDialogs/WiznetUtilities.py Sun Mar 12 17:01:54 2023 +0100 +++ b/src/eric7/MicroPython/EthernetDialogs/WiznetUtilities.py Tue Mar 14 13:16:06 2023 +0100 @@ -8,9 +8,9 @@ """ -def wiznetInit(): +def mpyWiznetInit(): """ - Function to get the WIZnet 5x00 initialization code. + Function to get the WIZnet 5x00 initialization code for MicroPython. @return string containing the code to initialize the WIZnet 5x00 ethernet interface @rtype str @@ -31,3 +31,41 @@ spi = SPI(0, 2_000_000, mosi=Pin(19), miso=Pin(16), sck=Pin(18)) nic = network.WIZNET5K(spi, Pin(17), Pin(20)) """ + + +def cpyWiznetInit(): + """ + Function to get the WIZnet 5x00 initialization code for CircuitPython. + + @return string containing the code to initialize the WIZnet 5x00 ethernet interface + @rtype str + """ + return """ +def w5x00_init(): + global nic + + try: + nic + except NameError: + nic = None + + if nic is None: + import board + import busio + import digitalio + from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K + + SPI0_RX = board.GP16 + SPI0_CSn = board.GP17 + SPI0_SCK = board.GP18 + SPI0_TX = board.GP19 + W5x00_RSTn = board.GP20 + + ethernetRst = digitalio.DigitalInOut(W5x00_RSTn) + ethernetRst.direction = digitalio.Direction.OUTPUT + + cs = digitalio.DigitalInOut(SPI0_CSn) + spi = busio.SPI(SPI0_SCK, MOSI=SPI0_TX, MISO=SPI0_RX) + + nic = WIZNET5K(spi, cs, reset=ethernetRst, is_dhcp=False) +"""