-
Notifications
You must be signed in to change notification settings - Fork 9
/
machine.py
52 lines (41 loc) · 982 Bytes
/
machine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Fake Micropython Machine class
See https://docs.micropython.org/en/latest/library/machine.html
"""
import binascii
class machine(object):
"""docstring for machine"""
UNKNOWN_RESET = 0
PWRON_RESET = 1
HARD_RESET = 2
WDT_RESET = 3
DEEPSLEEP_RESET = 4
SOFT_RESET = 5
def __init__(self):
pass
@staticmethod
def reset_cause() -> int:
"""
Get last reset cause
:returns: Reset cause
:rtype: int
"""
return machine.SOFT_RESET
@staticmethod
def unique_id() -> bytes:
"""
Get unique device ID
:returns: Device ID
:rtype: bytes
"""
return binascii.unhexlify(b'DEADBEEF')
@staticmethod
def freq() -> int:
"""
Get current CPU frequency
:returns: CPU frequency in Hz
:rtype: int
"""
return 160 * 1000 * 1000