Skip to content

Commit cbccf25

Browse files
TinyuZhaolbuque
authored andcommitted
libs/stamplc: Add StamPLC driver support.
Signed-off-by: tinyu <tinyu.zhao@gmail.com>
1 parent f3a1865 commit cbccf25

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

m5stack/libs/stamplc/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
_attrs = {
66
"ACStamPLC": "ac",
7+
"PoEStamPLC": "poe",
78
}
89

910

m5stack/libs/stamplc/manifest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(
88
"__init__.py",
99
"ac.py",
10+
"poe.py",
1011
),
1112
base_path="..",
1213
opt=0,

m5stack/libs/stamplc/poe.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import network
6+
import machine
7+
import builtins
8+
9+
10+
class PoEStamPLC:
11+
"""Create an PoEStamPLC object
12+
13+
:param int cs_pin: The chip select pin number.
14+
:param int rst_pin: The reset pin number.
15+
:param int int_pin: The interrupt pin number.
16+
17+
UiFlow2 Code Block:
18+
19+
|init.png|
20+
21+
MicroPython Code Block:
22+
23+
.. code-block:: python
24+
25+
from stamplc import PoEStamPLC
26+
27+
stamplc_poe_0 = PoEStamPLC()
28+
"""
29+
30+
def __new__(cls, cs_pin=11, rst_pin=3, int_pin=14):
31+
_spi_handle = machine.SPI(
32+
1,
33+
sck=machine.Pin(7),
34+
mosi=machine.Pin(8),
35+
miso=machine.Pin(9),
36+
)
37+
nic = network.LAN(
38+
0,
39+
phy_addr=0,
40+
phy_type=network.PHY_W5500,
41+
spi=_spi_handle,
42+
cs=machine.Pin(cs_pin),
43+
int=machine.Pin(int_pin),
44+
)
45+
mac = builtins.int.from_bytes(machine.unique_id(), "big")
46+
mac = mac + 3
47+
# esp32-s3 no eth mac, so use sta mac + 3
48+
nic.config(mac=mac.to_bytes(6, "big"))
49+
nic.active(True)
50+
return nic

0 commit comments

Comments
 (0)