|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing WIZnet 5x00 related utility functions. |
|
8 """ |
|
9 |
|
10 |
|
11 def wiznetInit(): |
|
12 """ |
|
13 Function to get the WIZnet 5x00 initialization code. |
|
14 |
|
15 @return string containing the code to initialize the WIZnet 5x00 ethernet interface |
|
16 @rtype str |
|
17 """ |
|
18 return """ |
|
19 def w5x00_init(): |
|
20 global nic |
|
21 |
|
22 try: |
|
23 nic |
|
24 except NameError: |
|
25 nic = None |
|
26 |
|
27 if nic is None: |
|
28 import network |
|
29 from machine import Pin, SPI |
|
30 |
|
31 spi = SPI(0, 2_000_000, mosi=Pin(19), miso=Pin(16), sck=Pin(18)) |
|
32 nic = network.WIZNET5K(spi, Pin(17), Pin(20)) |
|
33 """ |