You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/mocks/generated/trezorio/__init__.pyi

257 lines
6.2 KiB

from typing import *
# extmod/modtrezorio/modtrezorio-flash.h
class FlashOTP:
"""
"""
def __init__(self) -> None:
"""
"""
def write(self, block: int, offset: int, data: bytes) -> None:
"""
Writes data to OTP flash
"""
def read(self, block: int, offset: int, data: bytearray) -> None:
"""
Reads data from OTP flash
"""
def lock(self, block: int) -> None:
"""
Lock OTP flash block
"""
def is_locked(self, block: int) -> bool:
"""
Is OTP flash block locked?
"""
# extmod/modtrezorio/modtrezorio-flash.h
class FlashArea:
"""
Area of the flash memory
"""
def size(self) -> int:
"""
Returns size of the flash area
"""
def hash(
self,
offset: int,
length: int,
challenge: bytes | None = None,
callback: Callable[[int], None] | None = None,
) -> bytes:
"""
Computes a Blake2s hash of a segment of the flash area.
Offset and length must be aligned to 1024 bytes.
An optional challenge can be used as the Blake2s key.
The progress callback will be invoked every 16 kB with the number of
bytes processed so far.
"""
if __debug__:
def read(self, offset: int, data: bytearray) -> None:
"""
Reads data from flash area. Will read exact length of data
bytearray. Offset and length of data must be aligned to 1024 bytes.
"""
if __debug__:
def write(self, offset: int, data: bytes) -> None:
"""
Writes data to flash area.
Offset and written data size must be a multiple of FLASH_BLOCK_SIZE,
that is, 4 bytes on F4 or 16 bytes on U5.
"""
if __debug__:
def erase_sector(self, offset: int) -> None:
"""
Erases a flash area sector starting at specified offset.
"""
if __debug__:
def erase(self) -> None:
"""
Erases the whole flash area.
"""
# extmod/modtrezorio/modtrezorio-hid.h
class HID:
"""
USB HID interface configuration.
"""
def __init__(
self,
iface_num: int,
ep_in: int,
ep_out: int,
emu_port: int,
report_desc: bytes,
subclass: int = 0,
protocol: int = 0,
polling_interval: int = 1,
max_packet_len: int = 64,
) -> None:
"""
"""
def iface_num(self) -> int:
"""
Returns the configured number of this interface.
"""
def write(self, msg: bytes) -> int:
"""
Sends message using USB HID (device) or UDP (emulator).
"""
def write_blocking(self, msg: bytes, timeout_ms: int) -> int:
"""
Sends message using USB HID (device) or UDP (emulator).
"""
# extmod/modtrezorio/modtrezorio-poll.h
def poll(ifaces: Iterable[int], list_ref: list, timeout_ms: int) -> bool:
"""
Wait until one of `ifaces` is ready to read or write (using masks
`list_ref`:
`list_ref[0]` - the interface number, including the mask
`list_ref[1]` - for touch event, tuple of:
(event_type, x_position, y_position)
- for button event (T1), tuple of:
(event type, button number)
- for USB read event, received bytes
If timeout occurs, False is returned, True otherwise.
"""
# extmod/modtrezorio/modtrezorio-sbu.h
class SBU:
"""
"""
def __init__(self) -> None:
"""
"""
def set(self, sbu1: bool, sbu2: bool) -> None:
"""
Sets SBU wires to sbu1 and sbu2 values respectively
"""
# extmod/modtrezorio/modtrezorio-usb.h
class USB:
"""
USB device configuration.
"""
def __init__(
self,
vendor_id: int,
product_id: int,
release_num: int,
device_class: int = 0,
device_subclass: int = 0,
device_protocol: int = 0,
manufacturer: str = "",
product: str = "",
interface: str = "",
usb21_enabled: bool = True,
usb21_landing: bool = True,
) -> None:
"""
"""
def add(self, iface: HID | VCP | WebUSB) -> None:
"""
Registers passed interface into the USB stack.
"""
def open(self, serial_number: str) -> None:
"""
Initializes the USB stack.
"""
def close(self) -> None:
"""
Cleans up the USB stack.
"""
# extmod/modtrezorio/modtrezorio-vcp.h
class VCP:
"""
USB VCP interface configuration.
"""
def __init__(
self,
iface_num: int,
data_iface_num: int,
ep_in: int,
ep_out: int,
ep_cmd: int,
emu_port: int,
) -> None:
"""
"""
def iface_num(self) -> int:
"""
Returns the configured number of this interface.
"""
# extmod/modtrezorio/modtrezorio-webusb.h
class WebUSB:
"""
USB WebUSB interface configuration.
"""
def __init__(
self,
iface_num: int,
ep_in: int,
ep_out: int,
emu_port: int,
subclass: int = 0,
protocol: int = 0,
polling_interval: int = 1,
max_packet_len: int = 64,
) -> None:
"""
"""
def iface_num(self) -> int:
"""
Returns the configured number of this interface.
"""
def write(self, msg: bytes) -> int:
"""
Sends message using USB WebUSB (device) or UDP (emulator).
"""
from . import fatfs, sdcard, flash_area
POLL_READ: int # wait until interface is readable and return read data
POLL_WRITE: int # wait until interface is writable
TOUCH: int # interface id of the touch events
TOUCH_START: int # event id of touch start event
TOUCH_MOVE: int # event id of touch move event
TOUCH_END: int # event id of touch end event
BUTTON: int # interface id of button events
BUTTON_PRESSED: int # button down event
BUTTON_RELEASED: int # button up event
BUTTON_LEFT: int # button number of left button
BUTTON_RIGHT: int # button number of right button
USB_CHECK: int # interface id for check of USB data connection
WireInterface = Union[HID, WebUSB]