mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
core/trezorio: move sdcard functions to a submodule
This commit is contained in:
parent
30529d218d
commit
b2084a19be
@ -27,9 +27,9 @@
|
||||
#include "sdcard.h"
|
||||
// clang-format on
|
||||
|
||||
DSTATUS disk_initialize(BYTE pdrv) {
|
||||
return disk_status(pdrv);
|
||||
}
|
||||
/// package: trezorio.__init__
|
||||
|
||||
DSTATUS disk_initialize(BYTE pdrv) { return disk_status(pdrv); }
|
||||
|
||||
DSTATUS disk_status(BYTE pdrv) {
|
||||
return (sectrue == sdcard_is_present()) ? 0 : (STA_NOINIT | STA_NODISK);
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "embed/extmod/trezorobj.h"
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// class FlashOTP:
|
||||
/// """
|
||||
/// """
|
||||
|
@ -17,6 +17,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// class HID:
|
||||
/// """
|
||||
/// USB HID interface configuration.
|
||||
|
@ -26,6 +26,8 @@
|
||||
#define POLL_READ (0x0000)
|
||||
#define POLL_WRITE (0x0100)
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// def poll(ifaces: Iterable[int], list_ref: List, timeout_us: int) -> bool:
|
||||
/// """
|
||||
/// Wait until one of `ifaces` is ready to read or write (using masks
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "sbu.h"
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// class SBU:
|
||||
/// """
|
||||
/// """
|
||||
|
@ -24,6 +24,8 @@ enum {
|
||||
USB_OPENED = 1,
|
||||
};
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// class USB:
|
||||
/// """
|
||||
/// USB device configuration.
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
void pendsv_kbd_intr(void);
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// class VCP:
|
||||
/// """
|
||||
/// USB VCP interface configuration.
|
||||
|
@ -17,6 +17,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// class WebUSB:
|
||||
/// """
|
||||
/// USB WebUSB interface configuration.
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "modtrezorio-usb.h"
|
||||
// clang-format on
|
||||
|
||||
/// package: trezorio.__init__
|
||||
|
||||
/// POLL_READ: int # wait until interface is readable and return read data
|
||||
/// POLL_WRITE: int # wait until interface is writable
|
||||
///
|
||||
@ -66,7 +68,7 @@ STATIC const mp_rom_map_elem_t mp_module_trezorio_globals_table[] = {
|
||||
|
||||
{MP_ROM_QSTR(MP_QSTR_SBU), MP_ROM_PTR(&mod_trezorio_SBU_type)},
|
||||
|
||||
{MP_ROM_QSTR(MP_QSTR_SDCard), MP_ROM_PTR(&mod_trezorio_SDCard_type)},
|
||||
{MP_ROM_QSTR(MP_QSTR_sdcard), MP_ROM_PTR(&mod_trezorio_sdcard_module)},
|
||||
|
||||
{MP_ROM_QSTR(MP_QSTR_USB), MP_ROM_PTR(&mod_trezorio_USB_type)},
|
||||
{MP_ROM_QSTR(MP_QSTR_HID), MP_ROM_PTR(&mod_trezorio_HID_type)},
|
||||
|
@ -220,46 +220,6 @@ class SBU:
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-sdcard.h
|
||||
class SDCard:
|
||||
"""
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
"""
|
||||
|
||||
def present(self) -> bool:
|
||||
"""
|
||||
Returns True if SD card is detected, False otherwise.
|
||||
"""
|
||||
|
||||
def power(self, state: bool) -> bool:
|
||||
"""
|
||||
Power on or power off the SD card interface.
|
||||
Returns True if in case of success, False otherwise.
|
||||
"""
|
||||
|
||||
def capacity(self) -> int:
|
||||
"""
|
||||
Returns capacity of the SD card in bytes, or zero if not present.
|
||||
"""
|
||||
|
||||
def read(self, block_num: int, buf: bytearray) -> None:
|
||||
"""
|
||||
Reads blocks starting with block_num from the SD card into buf.
|
||||
Number of bytes read is length of buf rounded down to multiply of
|
||||
SDCARD_BLOCK_SIZE. Returns True if in case of success, False otherwise.
|
||||
"""
|
||||
|
||||
def write(self, block_num: int, buf: bytes) -> None:
|
||||
"""
|
||||
Writes blocks starting with block_num from buf to the SD card.
|
||||
Number of bytes written is length of buf rounded down to multiply of
|
||||
SDCARD_BLOCK_SIZE. Returns True if in case of success, False otherwise.
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-usb.h
|
||||
class USB:
|
||||
"""
|
50
core/mocks/generated/trezorio/sdcard.pyi
Normal file
50
core/mocks/generated/trezorio/sdcard.pyi
Normal file
@ -0,0 +1,50 @@
|
||||
from typing import *
|
||||
BLOCK_SIZE: int # size of SD card block
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-sdcard.h
|
||||
def is_present() -> bool:
|
||||
"""
|
||||
Returns True if SD card is detected, False otherwise.
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-sdcard.h
|
||||
def power_on() -> None:
|
||||
"""
|
||||
Power on the SD card interface.
|
||||
Raises OSError if the SD card cannot be powered on, e.g., when there
|
||||
is no SD card inserted.
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-sdcard.h
|
||||
def power_off() -> None:
|
||||
"""
|
||||
Power off the SD card interface.
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-sdcard.h
|
||||
def capacity() -> int:
|
||||
"""
|
||||
Returns capacity of the SD card in bytes, or zero if not present.
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-sdcard.h
|
||||
def read(block_num: int, buf: bytearray) -> None:
|
||||
"""
|
||||
Reads blocks starting with block_num from the SD card into buf.
|
||||
Number of bytes read is length of buf rounded down to multiply of
|
||||
SDCARD_BLOCK_SIZE. Returns True if in case of success, False otherwise.
|
||||
"""
|
||||
|
||||
|
||||
# extmod/modtrezorio/modtrezorio-sdcard.h
|
||||
def write(block_num: int, buf: bytes) -> None:
|
||||
"""
|
||||
Writes blocks starting with block_num from buf to the SD card.
|
||||
Number of bytes written is length of buf rounded down to multiply of
|
||||
SDCARD_BLOCK_SIZE. Returns True if in case of success, False otherwise.
|
||||
"""
|
Loading…
Reference in New Issue
Block a user