Showing preview only (3,548K chars total). Download the full file or copy to clipboard to get everything.
Repository: RT-Thread-packages/micropython
Branch: master
Commit: 97e1a5f1435e
Files: 405
Total size: 3.3 MB
Directory structure:
gitextract_erc644zb/
├── .gitignore
├── LICENSE
├── README.md
├── README_ZH.md
├── SConscript
├── docs/
│ ├── external_c_modules.md
│ ├── firmware-develop.md
│ ├── introduction.md
│ ├── micropython-ide.md
│ ├── micropython-librarys.md
│ ├── micropython-mpy.md
│ ├── micropython_for_pandora_iot_board.md
│ ├── micropython_for_sparrow_one_board.md
│ ├── micropython_for_w601_iot_board.md
│ ├── spec-librarys/
│ │ ├── machine/
│ │ │ ├── ADC.md
│ │ │ ├── I2C.md
│ │ │ ├── LCD.md
│ │ │ ├── PWM.md
│ │ │ ├── Pin.md
│ │ │ ├── RTC.md
│ │ │ ├── SPI.md
│ │ │ ├── Timer.md
│ │ │ ├── UART.md
│ │ │ └── WDT.md
│ │ ├── machine.md
│ │ ├── micropython.md
│ │ ├── network/
│ │ │ └── wlan.md
│ │ ├── network.md
│ │ └── rtthread.md
│ ├── std-librarys/
│ │ ├── _thread.md
│ │ ├── builtins.md
│ │ ├── cmath.md
│ │ ├── gc.md
│ │ ├── math.md
│ │ ├── rtthread.md
│ │ ├── sys.md
│ │ ├── uarray.md
│ │ ├── ubinascii.md
│ │ ├── ucollections.md
│ │ ├── uctypes.md
│ │ ├── uerrno.md
│ │ ├── uhashlib.md
│ │ ├── uheapq.md
│ │ ├── uio.md
│ │ ├── ujson.md
│ │ ├── uos.md
│ │ ├── urandom.md
│ │ ├── ure.md
│ │ ├── uselect.md
│ │ ├── usocket.md
│ │ ├── ussl.md
│ │ ├── ustruct.md
│ │ ├── utime.md
│ │ └── uzlib.md
│ └── tools-mpy-cross.md
├── drivers/
│ └── bus/
│ ├── qspi.h
│ ├── softqspi.c
│ ├── softspi.c
│ └── spi.h
├── extmod/
│ ├── axtls-include/
│ │ ├── config.h
│ │ └── version.h
│ ├── crypto-algorithms/
│ │ ├── sha256.c
│ │ └── sha256.h
│ ├── lwip-include/
│ │ ├── arch/
│ │ │ ├── cc.h
│ │ │ └── perf.h
│ │ └── lwipopts.h
│ ├── machine_i2c.c
│ ├── machine_i2c.h
│ ├── machine_mem.c
│ ├── machine_mem.h
│ ├── machine_pinbase.c
│ ├── machine_pinbase.h
│ ├── machine_pulse.c
│ ├── machine_pulse.h
│ ├── machine_signal.c
│ ├── machine_signal.h
│ ├── machine_spi.c
│ ├── machine_spi.h
│ ├── misc.h
│ ├── modbtree.c
│ ├── modframebuf.c
│ ├── modonewire.c
│ ├── modubinascii.c
│ ├── modubinascii.h
│ ├── moducryptolib.c
│ ├── moductypes.c
│ ├── moduhashlib.c
│ ├── moduheapq.c
│ ├── modujson.c
│ ├── modurandom.c
│ ├── modure.c
│ ├── moduselect.c
│ ├── modussl_axtls.c
│ ├── modussl_mbedtls.c
│ ├── modutimeq.c
│ ├── moduwebsocket.c
│ ├── moduwebsocket.h
│ ├── moduzlib.c
│ ├── modwebrepl.c
│ ├── modwebsocket.c
│ ├── modwebsocket.h
│ ├── re1.5/
│ │ ├── charclass.c
│ │ ├── compilecode.c
│ │ ├── dumpcode.c
│ │ ├── re1.5.h
│ │ └── recursiveloop.c
│ ├── uos_dupterm.c
│ ├── utime_mphal.c
│ ├── utime_mphal.h
│ ├── uzlib/
│ │ ├── adler32.c
│ │ ├── crc32.c
│ │ ├── defl_static.h
│ │ ├── tinf.h
│ │ ├── tinf_compat.h
│ │ ├── tinfgzip.c
│ │ ├── tinflate.c
│ │ ├── tinfzlib.c
│ │ ├── uzlib.h
│ │ └── uzlib_conf.h
│ ├── vfs.c
│ ├── vfs.h
│ ├── vfs_fat.c
│ ├── vfs_fat.h
│ ├── vfs_fat_diskio.c
│ ├── vfs_fat_file.c
│ ├── vfs_posix.c
│ ├── vfs_posix.h
│ ├── vfs_posix_file.c
│ ├── vfs_reader.c
│ ├── virtpin.c
│ ├── virtpin.h
│ └── webrepl/
│ ├── manifest.py
│ ├── webrepl.py
│ ├── webrepl_setup.py
│ └── websocket_helper.py
├── lib/
│ ├── mp-readline/
│ │ ├── readline.c
│ │ └── readline.h
│ ├── netutils/
│ │ ├── netutils.c
│ │ └── netutils.h
│ ├── oofatfs/
│ │ ├── diskio.h
│ │ ├── ff.c
│ │ ├── ff.h
│ │ ├── ffconf.h
│ │ └── option/
│ │ ├── ccsbcs.c
│ │ └── unicode.c
│ ├── timeutils/
│ │ ├── timeutils.c
│ │ └── timeutils.h
│ └── utils/
│ ├── gchelper.h
│ ├── gchelper_m0.s
│ ├── gchelper_m3.s
│ ├── interrupt_char.c
│ ├── interrupt_char.h
│ ├── mpirq.c
│ ├── mpirq.h
│ ├── printf.c
│ ├── pyexec.c
│ ├── pyexec.h
│ ├── stdout_helpers.c
│ └── sys_stdio_mphal.c
├── port/
│ ├── frozen_mpy.c
│ ├── gccollect.c
│ ├── genhdr/
│ │ ├── gen_qstr.py
│ │ ├── moduledefs.h
│ │ ├── mpversion.h
│ │ └── qstrdefs.generated.h
│ ├── modules/
│ │ ├── machine/
│ │ │ ├── machine_adc.c
│ │ │ ├── machine_adc.h
│ │ │ ├── machine_hw_i2c.c
│ │ │ ├── machine_hw_spi.c
│ │ │ ├── machine_lcd.c
│ │ │ ├── machine_lcd.h
│ │ │ ├── machine_pin.c
│ │ │ ├── machine_pwm.c
│ │ │ ├── machine_pwm.h
│ │ │ ├── machine_rtc.c
│ │ │ ├── machine_rtc.h
│ │ │ ├── machine_timer.c
│ │ │ ├── machine_timer.h
│ │ │ ├── machine_uart.c
│ │ │ ├── machine_uart.h
│ │ │ ├── machine_wdt.c
│ │ │ ├── machine_wdt.h
│ │ │ ├── modmachine.c
│ │ │ └── modmachine.h
│ │ ├── modffi.c
│ │ ├── modfile.c
│ │ ├── modnetwork.c
│ │ ├── modnetwork.h
│ │ ├── modnetwork_wlan.c
│ │ ├── modpyb.c
│ │ ├── modrtthread.c
│ │ ├── moduos.c
│ │ ├── moduos_file.c
│ │ ├── moduos_file.h
│ │ ├── modusocket.c
│ │ ├── modutils.c
│ │ ├── modutime.c
│ │ └── user/
│ │ └── moduserfunc.c
│ ├── mpconfigport.h
│ ├── mpgetcharport.c
│ ├── mpgetcharport.h
│ ├── mphalport.c
│ ├── mphalport.h
│ ├── mpputsnport.c
│ ├── mpputsnport.h
│ ├── mpthreadport.c
│ ├── mpthreadport.h
│ ├── mpy_main.c
│ ├── mpy_project_cfg.h
│ ├── native/
│ │ ├── easyflash_module.c
│ │ ├── easyflash_module.py
│ │ ├── native_module.c
│ │ └── native_module.py
│ └── qstrdefsport.h
├── py/
│ ├── argcheck.c
│ ├── asmarm.c
│ ├── asmarm.h
│ ├── asmbase.c
│ ├── asmbase.h
│ ├── asmthumb.c
│ ├── asmthumb.h
│ ├── asmx64.c
│ ├── asmx64.h
│ ├── asmx86.c
│ ├── asmx86.h
│ ├── asmxtensa.c
│ ├── asmxtensa.h
│ ├── bc.c
│ ├── bc.h
│ ├── bc0.h
│ ├── binary.c
│ ├── binary.h
│ ├── builtin.h
│ ├── builtinevex.c
│ ├── builtinhelp.c
│ ├── builtinimport.c
│ ├── compile.c
│ ├── compile.h
│ ├── dynruntime.h
│ ├── dynruntime.mk
│ ├── emit.h
│ ├── emitbc.c
│ ├── emitcommon.c
│ ├── emitglue.c
│ ├── emitglue.h
│ ├── emitinlinethumb.c
│ ├── emitinlinextensa.c
│ ├── emitnarm.c
│ ├── emitnative.c
│ ├── emitnthumb.c
│ ├── emitnx64.c
│ ├── emitnx86.c
│ ├── emitnxtensa.c
│ ├── emitnxtensawin.c
│ ├── formatfloat.c
│ ├── formatfloat.h
│ ├── frozenmod.c
│ ├── frozenmod.h
│ ├── gc.c
│ ├── gc.h
│ ├── grammar.h
│ ├── lexer.c
│ ├── lexer.h
│ ├── makecompresseddata.py
│ ├── makemoduledefs.py
│ ├── makeqstrdata.py
│ ├── makeqstrdefs.py
│ ├── makeversionhdr.py
│ ├── malloc.c
│ ├── map.c
│ ├── misc.h
│ ├── mkenv.mk
│ ├── mkrules.mk
│ ├── modarray.c
│ ├── modbuiltins.c
│ ├── modcmath.c
│ ├── modcollections.c
│ ├── modgc.c
│ ├── modio.c
│ ├── modmath.c
│ ├── modmicropython.c
│ ├── modstruct.c
│ ├── modsys.c
│ ├── modthread.c
│ ├── moduerrno.c
│ ├── mpconfig.h
│ ├── mperrno.h
│ ├── mphal.h
│ ├── mpprint.c
│ ├── mpprint.h
│ ├── mpstate.c
│ ├── mpstate.h
│ ├── mpthread.h
│ ├── mpz.c
│ ├── mpz.h
│ ├── nativeglue.c
│ ├── nativeglue.h
│ ├── nlr.c
│ ├── nlr.h
│ ├── nlrpowerpc.c
│ ├── nlrsetjmp.c
│ ├── nlrthumb.c
│ ├── nlrx64.c
│ ├── nlrx86.c
│ ├── nlrxtensa.c
│ ├── obj.c
│ ├── obj.h
│ ├── objarray.c
│ ├── objarray.h
│ ├── objattrtuple.c
│ ├── objbool.c
│ ├── objboundmeth.c
│ ├── objcell.c
│ ├── objclosure.c
│ ├── objcomplex.c
│ ├── objdeque.c
│ ├── objdict.c
│ ├── objenumerate.c
│ ├── objexcept.c
│ ├── objexcept.h
│ ├── objfilter.c
│ ├── objfloat.c
│ ├── objfun.c
│ ├── objfun.h
│ ├── objgenerator.c
│ ├── objgenerator.h
│ ├── objgetitemiter.c
│ ├── objint.c
│ ├── objint.h
│ ├── objint_longlong.c
│ ├── objint_mpz.c
│ ├── objlist.c
│ ├── objlist.h
│ ├── objmap.c
│ ├── objmodule.c
│ ├── objmodule.h
│ ├── objnamedtuple.c
│ ├── objnamedtuple.h
│ ├── objnone.c
│ ├── objobject.c
│ ├── objpolyiter.c
│ ├── objproperty.c
│ ├── objrange.c
│ ├── objreversed.c
│ ├── objset.c
│ ├── objsingleton.c
│ ├── objslice.c
│ ├── objstr.c
│ ├── objstr.h
│ ├── objstringio.c
│ ├── objstringio.h
│ ├── objstrunicode.c
│ ├── objtuple.c
│ ├── objtuple.h
│ ├── objtype.c
│ ├── objtype.h
│ ├── objzip.c
│ ├── opmethods.c
│ ├── pairheap.c
│ ├── pairheap.h
│ ├── parse.c
│ ├── parse.h
│ ├── parsenum.c
│ ├── parsenum.h
│ ├── parsenumbase.c
│ ├── parsenumbase.h
│ ├── persistentcode.c
│ ├── persistentcode.h
│ ├── profile.c
│ ├── profile.h
│ ├── py.mk
│ ├── pystack.c
│ ├── pystack.h
│ ├── qstr.c
│ ├── qstr.h
│ ├── qstrdefs.h
│ ├── reader.c
│ ├── reader.h
│ ├── repl.c
│ ├── repl.h
│ ├── ringbuf.c
│ ├── ringbuf.h
│ ├── runtime.c
│ ├── runtime.h
│ ├── runtime0.h
│ ├── runtime_utils.c
│ ├── scheduler.c
│ ├── scope.c
│ ├── scope.h
│ ├── sequence.c
│ ├── showbc.c
│ ├── smallint.c
│ ├── smallint.h
│ ├── stackctrl.c
│ ├── stackctrl.h
│ ├── stream.c
│ ├── stream.h
│ ├── unicode.c
│ ├── unicode.h
│ ├── vm.c
│ ├── vmentrytable.h
│ ├── vstr.c
│ └── warning.c
└── tools/
└── mpy-cross/
├── hellortt.mpy
└── hellortt.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/.vscode/settings.json
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2013, 2014 Damien P. George
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: README.md
================================================
# MicroPython
[中文页](README_ZH.md) | English
## 1. Introduction
This is a port of `MicroPython` on RT-Thread, which can run on **RT-Thread 3.0** or higher. This software package can run `MicroPython` on embedded systems equipped with RT-Thread.
If it is the first time to come into contact with RT-Thread MicroPython, it is recommended that you use RT-Thread officially supported development boards to get started quickly. These development boards have complete firmware functions and provide source code, suitable for introductory learning, and officially support development boards [firmware download Please click on me](https://www.rt-thread.org/qa/forum.php?mod=viewthread&tid=12305&extra=page%3D1%26filter%3Dtypeid%26typeid%3D20).
### 1.1 Directory structure
| Name | Description |
| ---- | ---- |
| docs | Document directory, including getting started guide and development manual |
| drivers | MicroPython source code directory |
| extmod | MicroPython Source Code Directory |
| lib | MicroPython source code directory |
| py | MicroPython source code directory |
| port | Porting code directory |
| LICENSE | Micropython MIT License |
### 1.2 License
RT-Thread MicroPython follows the MIT license, see the `LICENSE` file for details.
### 1.3 Dependency
- RT-Thread 3.0+
## 2. How to open RT-Thread MicroPython
To use `MicroPython package`, you need to select it in the RT-Thread package manager. The specific path is as follows:

Then let the RT-Thread package manager automatically update, or use the `pkgs --update` command to update the package to the BSP.
## 3. Use RT-Thread MicroPython
### 3.1 Add software package to project
After selecting `MicroPython package`, when compiling with `bsp` again, it will be added to the `bsp` project for compilation.
* For firmware development, please refer to [《MicroPython Firmware Development Guide》](./docs/firmware-develop.md)
* For more MicroPython documentation, please visit [RT-Thread Documentation Center](https://www.rt-thread.org/document/site/submodules/micropython/docs/introduction/)
### 3.2 Using MicroPython IDE
[RT-Thread MicroPython IDE](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython) provides a powerful development environment for MicroPython, which can be directly searched and downloaded through the VScode application store. Examples are as follows:

### 3.3 Add C extension to MicroPython
In order to facilitate users to add their own C functions to MicroPython to be called by Python scripts, RT-Thread provides [MicroPython C binding code automatic generator](https://summerlife.github.io/RT-MicroPython-Generator/) For everyone to use. With this tool, users only need a few simple steps to achieve C function extension. The following figure shows the form of the automatically generated C code.

## 4. Matters needing attention
- Need to use **RT-Thread 3.0** or above
- Select the `latest` version of `Micropython` in the `menuconfig` option
- Currently, the `ffi` module under `System Module` only supports GCC toolchain, and relevant information needs to be added to the link script
## 5. Development resources
* [RT-Thread MicroPython Forum](https://www.rt-thread.org/qa/forum.php)
* [RT-Thread MicroPython Documentation Center](https://www.rt-thread.org/document/site/submodules/micropython/docs/introduction/)
* [Click to join the RT-Thread MicroPython exchange group](https://jq.qq.com/?_wv=1027&k=5EhyEjx)
================================================
FILE: README_ZH.md
================================================
# MicroPython
中文页 | [English](README.md)
## 1、介绍
这是一个在 RT-Thread 上的 `MicroPython` 移植,可以运行在 **RT-Thread 3.0** 版本以上。通过该软件包可以在搭载了 RT-Thread 的嵌入式系统上运行 `MicroPython`。
如果是第一次接触 RT-Thread MicroPython,推荐你先通过 RT-Thread 官方支持的开发板来快速上手,这些开发板的固件功能完善并提供源代码,适合入门学习,官方支持开发板 [固件下载请点我](https://www.rt-thread.org/qa/forum.php?mod=viewthread&tid=12305&extra=page%3D1%26filter%3Dtypeid%26typeid%3D20)。
### 1.1 目录结构
| 名称 | 说明 |
| ---- | ---- |
| docs | 文档目录,包括入门指南和开发手册 |
| drivers | MicroPython 源代码目录 |
| extmod | MicroPython 源代码目录 |
| lib | MicroPython 源代码目录 |
| py | MicroPython 源代码目录 |
| port | 移植代码目录 |
| LICENSE | Micropython MIT 许可证 |
### 1.2 许可证
RT-Thread MicroPython 遵循 MIT 许可,详见 `LICENSE` 文件。
### 1.3 依赖
- RT-Thread 3.0+
## 2、如何打开 RT-Thread MicroPython
使用 `MicroPython package` 需要在 RT-Thread 的包管理器中选择它,具体路径如下:

然后让 RT-Thread 的包管理器自动更新,或者使用 `pkgs --update` 命令更新包到 BSP 中。
## 3、使用 RT-Thread MicroPython
### 3.1 添加软件包到工程
选中 `MicroPython package` 后,再次进行 `bsp` 编译时,它会被加入到 `bsp` 工程中进行编译。
* 固件开发可参考 [《MicroPython 固件开发指南》](./docs/firmware-develop.md)
* 查阅更多 MicroPython 说明文档请访问 [RT-Thread 文档中心](https://www.rt-thread.org/document/site/submodules/micropython/docs/introduction/)
### 3.2 使用 MicroPython IDE
[RT-Thread MicroPython IDE](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython) 为 MicroPython 提供了强大的开发环境,可以通过 VScode 应用商店直接查询下载,示例如下所示:

### 3.3 向 MicroPython 添加 C 扩展
为了方便用户添加自己编写的 C 函数到 MicroPython 中被 Python 脚本调用,RT-Thread 提供了 [MicroPython C 绑定代码自动生成器](https://summerlife.github.io/RT-MicroPython-Generator/) 供大家使用。通过该工具,用户只需要简单几步,即可实现 C 函数扩展,下图展示了自动生成的 C 代码的形式。

## 4、注意事项
- 需要使用 **RT-Thread 3.0** 以上版本
- 在 `menuconfig` 选项中选择 `Micropython` 的 `latest` 版本
- 目前 `System Module` 下的 `ffi` 模块只支持 GCC 工具链,且需要在链接脚本中添加相关段信息
## 5、开发资源
* [RT-Thread MicroPython 论坛](https://www.rt-thread.org/qa/forum.php)
* [RT-Thread MicroPython 文档中心](https://www.rt-thread.org/document/site/submodules/micropython/docs/introduction/)
* [点击加入 RT-Thread MicroPython 交流群](https://jq.qq.com/?_wv=1027&k=5EhyEjx)
================================================
FILE: SConscript
================================================
from building import *
import rtconfig
# get current directory
cwd = GetCurrentDir()
# The set of source files associated with this SConscript file.
src = Glob('py/*.c')
src += Glob('lib/mp-readline/*.c')
src += Glob('lib/utils/*.c')
src += Glob('extmod/*.c')
src += Glob('port/*.c')
src += Glob('port/modules/*.c')
src += Glob('port/modules/machine/*.c')
src += Glob('port/modules/user/*.c')
src += Glob('lib/netutils/*.c')
src += Glob('lib/timeutils/*.c')
src += Glob('drivers/bus/*.c')
src += Glob('port/native/*.c')
path = [cwd + '/']
path += [cwd + '/port']
path += [cwd + '/port/modules']
path += [cwd + '/port/modules/machine']
LOCAL_CCFLAGS = ''
if rtconfig.PLATFORM in ['gcc', 'armclang']:
LOCAL_CCFLAGS += ' -std=gnu99'
elif rtconfig.PLATFORM in ['keil']:
LOCAL_CCFLAGS += ' --c99 --gnu'
group = DefineGroup('MicroPython', src, depend = ['PKG_USING_MICROPYTHON'], CPPPATH = path, LOCAL_CCFLAGS = LOCAL_CCFLAGS)
Return('group')
================================================
FILE: docs/external_c_modules.md
================================================
# 为 MicroPython 扩展 C 模块
当使用原生 MicroPython 进行开发时,你可能会遇到这样一些限制,比如官方没有实现自己想要的功能,或者你觉得这些实现不符合自己的工作需求。此时,添加自己的 C 模块到 MicroPython 中是一个不错的选择,你可以按照自己的想法,设计适合自己的 Python 函数调用。
为了帮助各位开发者快速添加 C 模块,RT-Thread 提供了相应的辅助工具 [C 绑定代码自动生成器](https://summerlife.github.io/RT-MicroPython-Generator/)。该工具可以帮助开发者自动生成 C 代码和 MicroPython 之间的接口层,开发者只需将 C 语言编写的功能代码添加到指定位置,MicroPython 即可直接调用该功能。
## Python 调用 C 函数的实现原理
C 语言和 Python 是两种完全不同的语言,如何使用 MicroPython 来调用 C 语言所实现的函数是许多小伙伴非常疑惑的地方。简单来说,这个问题的关键点在于,如何用 C 语言的形式在 MicroPython 源代码中**表述函数的入参和出参**。我举一个例子来讲解这个问题, 请观察如下 Python 函数:
```python
def add(a, b):
return a + b
```
该函数有两个入参,返回一个参数。此时如果能用 C 语言表示该 **Python 函数的输入输出参数**,就可以将一个实现该功能的 C 函数对接到 MicroPython 中。
### 添加用户函数到 MicroPython
假设上述函数的参数类型都为整形,通过自动生成器可以得到如下样板函数:
```c
STATIC mp_obj_t add(
mp_obj_t arg_1_obj,
mp_obj_t arg_2_obj) {
mp_int_t arg_1 = mp_obj_get_int(arg_1_obj); /* 通过 Python 获取的第一个整形参数 arg_1 */
mp_int_t arg_2 = mp_obj_get_int(arg_2_obj); /* 通过 Python 获取的第二个整形参数 arg_2 */
mp_int_t ret_val;
/* Your code start! */
ret_val = arg_1 + arg_2; /* 处理入参 arg_1 和 arg_2,并将结果赋给返回值 ret_val */
/* Your code end! */
return mp_obj_new_int(ret_val); /* 向 python 返回整形参数 ret_val */
}
MP_DEFINE_CONST_FUN_OBJ_2(add_obj, add);
```
生成器会处理好需要导出到 MicroPython 的函数的入参和出参,而开发者只需要编写相应的代码来处理这些输入参数,并且把返回值赋给输出参数即可。 通过包含头文件的方式,可以调用先前编写的 C 函数来对输入参数进行处理,或者根据输入参数来执行相应的动作,添加控制硬件的驱动的原理也是一样的。
最终使用 Python 调用 C 函数的效果如下:
```python
>>> import userfunc
>>> userfunc.add(666,777)
1443
```
### 添加用户模块到 MicroPython
添加用户模块到 MicroPython 中也不难,首先应当熟练掌握上述添加 C 函数的过程,然后参考 PR [add module userfunc to MicroPython](https://github.com/RT-Thread-packages/micropython/pull/144) 来添加属于自己的模块,该 PR 实现了添加 `userfunc` 模块到 MicroPython 的功能,你可以按照同样的方式将自己编写的模块注册到 MicroPython 中,要注意仔细查看这个 PR 中修改的 4 个文件,不要漏掉修改的细节。
================================================
FILE: docs/firmware-develop.md
================================================
## MicroPython 固件开发指南
如果手上没有官方支持固件的开发板,就需要自己来动手制作 MicroPython 固件了。由于 RT-Thread 官方提供了 [MicroPython 软件包](https://github.com/RT-Thread-packages/micropython),并且 MicroPython 底层和硬件绑定时对接了 RT-Thread 驱动框架,因此可以很方便地在运行了 RT-Thread 的板卡上将 MicroPython 跑起来。
**注意**:RT-Thread MicroPython 需要运行在 **RT-Thread 3.0** 版本以上。
### 选择合适的 BSP 平台
RT-Thread MicroPython mini 版本占用资源最大不超过:
- ROM : 190KB
- RAM : 20KB
只要系统资源满足上述要求,常见的许多开发板都可以运行 MicroPython,例如 STM32 系列 BSP。
接下来我们以 `rt-thread\bsp\stm32\stm32f407-atk-explorer` 上的 MDK 工程为例,讲解如何在 BSP 的基础上制作 MicroPython 固件。
### 获取 MicroPython 软件包
先使用 `pkgs --upgrade` 命令更新软件包列表,然后通过 env 工具选中 MicroPython 软件包,最后使用 `pkgs --update` 命令将软件包拉取到本地。

### 增大 main 线程栈
为了能后续在 main 线程中启动 MicroPython 运行时环境,需要增大 main 线程的栈大小,这里我们将栈大小增加到 8k。

### 配置 MicroPython 运行环境堆大小
接下来根据板卡内存实际剩余情况来给 MicroPython 运行环境分配内存,这里填写的数值越大,就能运行更大代码量的 Python 程序。但是如果这里填写的数值超过了实际可分配内存,就可能会出现无法分配内存而报错。因此在配置此项目之前,需要对系统 RAM 资源的分配情况有一定了解。
#### 查看系统剩余内存
重新生成工程,编译下载后通过 `msh` 的 `free` 命令来查看内存使用情况。

#### 配置系统
通过上一步查询的内存分配情况,对系统 RAM 资源有了一定的了解。在本次示例中,我们分配 20k 内存用于 MicroPython 运行时环境。后续如果想要运行更多 MicroPython 代码,可以将更多空余内存分配给 MicroPython 运行时环境,配置如下图所示:

### 在系统根目录挂载文件系统
最后要确保系统中 `/` 目录挂载了文件系统。有了文件系统,后续才能使用 [**MicroPython 开发环境**](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython) 将 Python 代码文件同步到板卡中来运行。
1. 打开 MicroPython 的文件同步功能选项

2. 本次示例使用的开发板,文件系统存放在 SPI Flash 上,BSP 对该存储设备的支持已经做好了,在这里只需开启 elm-fat 文件系统即可,对系统进行如下配置:

配置完成后,记得要使用 `scons --target=mkd5` 重新生成工程,使配置在工程中生效。
当你在自己的板卡上运行 MicroPython 时,你可以自由选择文件系统的存储介质,但是有一点很重要,文件系统要被挂载到根目录 / 上,这样才能保证在后续使用 MicroPython IDE 进行文件传输时不会出错。
### 在 main 线程中启动 MicroPython
最后要在 main 线程中启动 MicroPython,代码修改如下所示:
```c
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include <dfs_fs.h>
#include <rtdevice.h>
/* 文件系统所在分区名称,根据实际情况填写 */
#define FS_PARTITION_NAME "W25Q128"
int main(void)
{
/* 挂载 elm 文件系统到 / 目录,如果你所使用的开发板没有文件系统也可以跳过这一步 */
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) == 0)
{
rt_kprintf("Filesystem initialized!");
}
else
{
/* 如果挂载失败,则尝试在文件系统分区重新创建文件系统 */
dfs_mkfs("elm", FS_PARTITION_NAME);
/* 尝试重新挂载文件系统 */
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) == 0)
{
/* 仍然挂载文件系统失败,请自行检查失败原因 */
rt_kprintf("Failed to initialize filesystem!");
}
}
rt_thread_mdelay(100);
while(1)
{
/* 在这里让程序进入循环,通过这种方式实现 MicroPython 的软复位*/
extern void mpy_main(const char *filename);
/* 启动 MicroPython */
mpy_main(NULL);
}
return RT_EOK;
}
```
重新编译工程并下载程序到板卡中,就会在 main 线程中自动启动 MicroPython,接下来就可以使用 [**RT-Thread MicroPython 开发环境**](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython) 来进行应用开发了。 通过开发环境连接到开发板,即可看到 MicroPython 的交互环境 REPL,如下图所示:

================================================
FILE: docs/introduction.md
================================================
# MicroPython 入门必读
本文档将初步介绍 MicroPython 的基本概念,RT-Thread MicroPython 的特性与优势,以及可以被用在哪些领域。
## 主要特性
- MicroPython 是 Python 3 编程语言的一种精简而高效的实现,它包含 Python 标准库的一个子集,并被优化为在微控制器和受限环境中运行。
- RT-Thread MicroPython 可以运行在任何搭载了 RT-Thread 操作系统并且有一定资源的嵌入式平台上。
- MicroPython 可以运行在有一定资源的开发板上,给你一个低层次的 Python 操作系统,可以用来控制各种电子系统。
- MicroPython 富有各种高级特性,比如交互式提示、任意精度整数、闭包函数、列表解析、生成器、异常处理等等。
- MicroPython 的目标是尽可能与普通 Python 兼容,使开发者能够轻松地将代码从桌面端转移到微控制器或嵌入式系统。程序可移植性很强,因为不需要考虑底层驱动,所以程序移植变得轻松和容易。
## MicroPython 的优势
- Python 是一款容易上手的脚本语言,同时具有强大的功能,语法优雅简单。使用 MicroPython 编程可以降低嵌入式的开发门槛,让更多的人体验嵌入式的乐趣。
- 通过 MicroPython 实现硬件底层的访问和控制,不需要了解底层寄存器、数据手册、厂家的库函数等,即可轻松控制硬件。
- 外设与常用功能都有相应的模块,降低开发难度,使开发和移植变得容易和快速。
## MicroPython 的应用领域
- MicroPython 在嵌入式系统上完整实现了 Python3 的核心功能,可以在产品开发的各个阶段给开发者带来便利。
- 通过 MicroPython 提供的库和函数,开发者可以快速控制 LED、液晶、舵机、多种传感器、SD、UART、I2C 等,实现各种功能,而不用再去研究底层硬件模块的使用方法,翻看寄存器手册。这样不但降低了开发难度,而且减少了重复开发工作,可以加快开发速度,提高开发效率。以前需要较高水平的嵌入式工程师花费数天甚至数周才能完成的功能,现在普通的嵌入式开发者用几个小时就能实现类似的功能。
- 随着半导体技术的不断发展,芯片的功能、内部的存储器容量和资源不断增加,成本不断降低,可以使用 MicroPython 来进行开发设计的应用领域也会越来越多。
### 产品原型验证
- 众所周知,在开发新产品时,原型设计是一个非常重要的环节,这个环节需要以最快速的方式设计出产品的大致模型,并验证业务流程或者技术点。与传统开发方法相比,使用 MicroPython 对于原型验证非常有用,让原型验证过程变得轻松,加速原型验证过程。
- 在进行一些物联网功能开发时,网络功能也是 MicroPython 的长处,可以利用现成的众多 MicroPython 网络模块,节省开发时间。而这些功能如果使用 C/C++ 来完成,会耗费几倍的时间。
### 硬件测试
- 嵌入式产品在开发时,一般会分为硬件开发及软件开发。硬件工程师并不一定都擅长软件开发,所以在测试新硬件时,经常需要软件工程师参与。这就导致软件工程师可能会耗费很多时间帮助硬件工程师查找设计或者焊接问题。有了 MicroPython 后,将 MicroPython 固件烧入待测试的新硬件,在检查焊接、连线等问题时,只需使用简单的 Python 命令即可测试。这样,硬件工程师一人即可搞定,再也不用麻烦别人了。
### 创客 DIY
- MicroPython 无需复杂的设置,不需要安装特别的软件环境和额外的硬件,使用任何文本编辑器就可以进行编程。大部分硬件功能,使用一个命令就能驱动,不用了解硬件底层就能快速开发。这些特性使得 MicroPython 非常适合创客使用来开发一些有创意的项目。
- 下面是使用 MicroPython 开发的一些 DIY 项目:
- [显示温湿度的 WIFI 时钟](https://www.bilibili.com/video/av15929152?from=search&seid=16285206333541196172)
- [OpenMV 智能摄像头](https://www.bilibili.com/video/av16418889?from=search&seid=16285206333541196172)
- [快速实现人脸识别](https://www.bilibili.com/video/av73853903?from=search&seid=9793819178982436353)
- [搭建 MQTT 服务器](http://www.360doc.com/content/17/1218/22/8473307_714341237.shtml)
### 教育
- MicroPython 使用简单、方便,非常适合于编程入门。在校学生或者业余爱好者都可以通过 MicroPython 快速的开发一些好玩的项目,在开发的过程中学习编程思想,提高自己的动手能力。
================================================
FILE: docs/micropython-ide.md
================================================
# MicroPython IDE
RT-Thread 为广大开发者提供了 VSCode 最好用的 MicroPython 插件 来帮助大家使用 MicroPython 来开发应用程序。该插件为 MicroPython 开发提供了功能强大的开发环境,主要特性如下:
- 便捷的开发板连接方式(串口、网络、USB)
- 支持基于 MicroPython 的代码智能补全与语法检查
- 支持 MicroPython REPL 交互环境
- 提供丰富的代码示例与 demo 程序
- 提供工程同步功能
- 支持下载单个文件或文件夹至开发板
- 支持在内存中快速运行代码文件功能
- 支持运行代码片段功能
- 支持多款主流 MicroPython 开发板
- 支持 Windows、Ubuntu、Mac 操作系统
### 安装 IDE 开发环境
开发者可以通过 RT-Thread MicroPython IDE 来快速开发 MicroPython 应用,下图展示了 IDE 的快速调试功能:

可通过查看如下文档进一步了解并使用 RT-Thread MicroPython IDE:
- [RT-Thread MicroPython Develop Environment](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython)
================================================
FILE: docs/micropython-librarys.md
================================================
# MicroPython 库
### MicroPython 标准库
- [`Builtin functions and exceptions`](std-librarys/builtins.md) – 内置函数与异常
- [`cmath`](std-librarys/cmath.md) – 复数运算函数功能
- [`gc`](std-librarys/gc.md) – 控制垃圾收集器
- [`math`](std-librarys/math.md) – 数学函数功能
- [`sys`](std-librarys/sys.md) – 系统特定功能
- [`uarray`](std-librarys/uarray.md) – 数组存储功能
- [`ubinascii`](std-librarys/ubinascii.md) – 二进制与 ASCII 码转换功能
- [`ucollections`](std-librarys/ucollections.md) – 集合与容器类型
- [`uerrno`](std-librarys/uerrno.md) – 系统错误码
- [`uhashlib`](std-librarys/uhashlib.md) – 哈希算法
- [`uheapq`](std-librarys/uheapq.md) – 堆队列算法
- [`uio`](std-librarys/uio.md) – 输入输出流
- [`ujson`](std-librarys/ujson.md) – JSON 编解码
- [`uos`](std-librarys/uos.md) – 基本的操作系统服务
- [`ure`](std-librarys/ure.md) – 正则表达式
- [`uselect`](std-librarys/uselect.md) – 在一组 streams 上等待事件
- [`usocket`](std-librarys/usocket.md) – socket 模块
- [`ussl`](std-librarys/ussl.md) – SSL/TLS 模块
- [`ustruct`](std-librarys/ustruct.md) – 原生数据类型的打包和解包
- [`utime`](std-librarys/utime.md) – 时间相关功能
- [`uzlib`](std-librarys/uzlib.md) – zlib 解压
- [`_thread`](std-librarys/_thread.md) – 多线程支持
### MicroPython 特定库
在 RT-Thread 移植的 MicroPython 版本中,实现了如下特定功能库:
- [`micropython`](spec-librarys/micropython.md) – 实现 MicroPython 内部功能访问与控制
- [`rtthread`](spec-librarys/rtthread.md) – RT-Thread 系统功能模块
- [`machine`](spec-librarys/machine.md) – 硬件控制模块
- [Pin](spec-librarys/machine/Pin.md)
- [I2C ](spec-librarys/machine/I2C.md)
- [SPI](spec-librarys/machine/SPI.md)
- [UART](spec-librarys/machine/UART.md)
- [LCD](spec-librarys/machine/LCD.md)
- [RTC](spec-librarys/machine/RTC.md)
- [PWM](spec-librarys/machine/PWM.md)
- [ADC](spec-librarys/machine/ADC.md)
- [WDT](spec-librarys/machine/WDT.md)
- [TIMER](spec-librarys/machine/Timer.md)
- [`network`](spec-librarys/network.md) – 网络功能配置模块
- [wlan](spec-librarys/network/wlan.md)
================================================
FILE: docs/micropython-mpy.md
================================================
# MicroPython .mpy 文件详解
MicroPython 定义了 `.mpy` 文件的概念,该文件是一种二进制容器文件格式,在其中包含了预编译的 Python 代码,这种类型的文件可以像普通的 `.py` 模块一样被导入到 MicroPython 程序中。举个例子来说明这种类型文件的使用方法。例如,只要 `foo.mpy` 存在于指定的路径中,我们就可以通过 `import foo` 语句来导入 `foo.mpy` 文件。
这种类型文件的导入规则是这样的,首先按顺序搜索 `sys.path` 中列出的每个目录。当搜索特定目录时,首先查找 `foo.py`,如果找不到该目录,则查找 `foo.mpy`,如果没有找到,则在下一个目录中继续搜索。通过这种方式,`foo.py` 文件的优先级将高于 `foo.mpy` 文件。这些 `.mpy` 文件中的主要内容是字节码,这种类型的文件可以通过 `mpy-cross` 程序从 Python 源文件(`.py`文件)生成。
================================================
FILE: docs/micropython_for_pandora_iot_board.md
================================================
# MicroPython for Pandora IoT Board

[**IoT Board 潘多拉**](https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-18400369818.12.2ba47ea5PzJxZx&id=583843059625) 是 RT-Thread 推出的一款物联网开发板,它给开发者带来了物联网时代的无限可能。而现在,它已经不仅仅是一块简单的物联网开发板,因为它已经全面支持 **MicroPython** 。在 IoT Board 上,你将会体验到有别于传统的,前所未有的开发方式。
借助于 MicroPython,你将有能力使用 Python 语言控制所有硬件外设,体验高级语言带来的便利特性,与此同时你还可以利用高级软件库快速实现你的 IoT 构想。
## 硬件支持
Pandora MicroPython 固件硬件功能如下所示:
| 外设名称 | 引脚号 | 简介 |
| -------- | ---------------------------------------------- | ----------------------------------------- |
| pin | PA4 PA8, PB8-9 PB10-15, PC2 PC4 PC6-7, PD12-15 | 开发板引出的可自由分配的 IO,支持引脚中断 |
| led | PE7 | 红色 led 灯 |
| rgb | R: PE7, G: PE8, B: PE9 | rgb 灯 |
| key | KEY0: PD10, KEY1: PD9, KEY2: PD8 | 输入按键 |
| uart1 | PA9, PA10 | 串口1 |
| i2c | | 软件 i2c 可选择任意 pin |
| spi | | 软件 spi 可选择任意引出 pin |
| adc | PC4 | adc1,通道 13 |
| pwm | PB0 | pwm3, 通道 3, 用于红外发射 |
| timer | | 硬件定时器 15 |
| wdt | | 看门狗 |
| rtc | | 实时时钟 |
| beeper | PB2 | 蜂鸣器 |
| lcd | | lcd 显示屏 |
| wifi | | wifi 网络连接 |
| aht10 | CLK: PD6, SDA: PC1 | 温湿度传感器 |
| ap3216c | CLK: PC0, SDA: PC1 | 接近与光强传感器 |
| icm20608 | CLK: PC0, SDA: PC1 | 六轴传感器 |
## 入门必读
如果您从来没有了解过 MicroPython, 可以阅读这篇简短的文章来 [带你入门 MicroPython](introduction.md)。
## 开启 MicroPython 之旅
推荐遵循如下步骤开始进行 MicroPython 开发:
- 在您的开发板上烧录合适的固件
- 在 PC 机上安装 RT-Thread MicroPython 开发环境并连接上开发板
接下来就可以尽情挥洒您的创意了,更详细的内容可以点击下文中的链接来进一步了解。
### 下载合适的固件
- [Pandora IoT Board firmware](https://www.rt-thread.org/qa/forum.php?mod=viewthread&tid=12305&extra=page%3D1%26filter%3Dtypeid%26typeid%3D20)
### 安装 IDE 开发环境
- [RT-Thread MicroPython develop environment](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython)
## 开发资料
### 示例程序
以下示例程序可以在 RT-Thread MicroPython IDE 开发环境中直接添加到工程:

### MicroPython 模块详解
- [MicroPython Librarys](micropython-librarys.md)
## 联系我们
如果在使用的过程中遇到问题,您可以用如下方式联系我们:
- 在 github 上提交 issue
- [RT-Thread MicroPython 官方论坛](https://www.rt-thread.org/qa/forum.php?mod=forumdisplay&fid=2&filter=typeid&typeid=20)
- RT-Thread MicroPython 交流 QQ 群:703840633
================================================
FILE: docs/micropython_for_sparrow_one_board.md
================================================
# MicroPython for sparrow one board

[**麻雀一号开发板**](https://item.taobao.com/item.htm?spm=a1z10.1-c.w4004-5210898174.2.29401ae39JyGKY&id=606684373403) 是 RT-Thread 推出的一款物联网音视频开发板,现在它已经全面支持 **MicroPython** 。在麻雀一号开发板上,你将会体验到有别于传统的,前所未有的开发方式。
借助于 MicroPython,你将有能力使用 Python 语言控制所有硬件外设,体验高级语言带来的便利特性,与此同时你还可以利用高级软件库快速实现你的 IoT 构想。
## 硬件支持
麻雀一号开发板固件硬件功能如下所示:
| 外设名称 | 简介 |
| --------- | ---------------------------------------------------------- |
| key | 输入按键 |
| uart1 | 串口1 |
| lcd | lcd 显示屏 |
| wifi | wifi 网络连接 |
| bluetooth | 蓝牙 |
| player | 扬声器,音频播放 |
| recorder | 麦克风,录音功能 |
| camera | 摄像头,可拍照并存入文件系统,开启 TCP Server 查看实时图像 |
## 入门必读
如果您从来没有了解过 MicroPython, 可以阅读这篇简短的文章来 [带你入门 MicroPython](https://github.com/RT-Thread-packages/micropython/blob/master/docs/introduction.md)。
## 开启 MicroPython 之旅
推荐遵循如下步骤开始进行 MicroPython 开发:
- 在您的开发板上烧录合适的固件
- 在 PC 机上安装 RT-Thread MicroPython 开发环境并连接上开发板
接下来就可以尽情挥洒您的创意了,更详细的内容可以点击下文中的链接来进一步了解。
### 下载合适的固件
- [Sparrow One Board firmware](https://www.rt-thread.org/qa/forum.php?mod=viewthread&tid=12305&extra=page%3D1%26filter%3Dtypeid%26typeid%3D20)
### 安装 IDE 开发环境
- [RT-Thread MicroPython develop environment](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython)
## 开发资料
### 示例程序
以下示例程序可以在 RT-Thread MicroPython IDE 开发环境中直接添加到工程:

### MicroPython 模块详解
- [MicroPython Librarys](https://github.com/RT-Thread-packages/micropython/blob/master/docs/micropython-librarys.md)
## 联系我们
如果在使用的过程中遇到问题,您可以用如下方式联系我们:
- 在 github 上提交 issue
- [RT-Thread MicroPython 官方论坛](https://www.rt-thread.org/qa/forum.php?mod=forumdisplay&fid=2&filter=typeid&typeid=20)
- RT-Thread MicroPython 交流 QQ 群:703840633
================================================
FILE: docs/micropython_for_w601_iot_board.md
================================================
# MicroPython for W601 IoT Board

[**W601 IoT Board**](https://item.taobao.com/item.htm?spm=a230r.1.14.13.7c5b4a9bS2LYUD&id=602233847745&ns=1&abbucket=17#detail) 是 RT-Thread 推出的一款物联网开发板,它给开发者带来了物联网时代的无限可能。而现在,它已经不仅仅是一块简单的物联网开发板,因为它已经全面支持 **MicroPython** 。在 IoT Board 上,你将会体验到有别于传统的,前所未有的开发方式。
借助于 MicroPython,你将有能力使用 Python 语言控制所有硬件外设,体验高级语言带来的便利特性,与此同时你还可以利用高级软件库快速实现你的 IoT 构想。
## 硬件支持
W601 IoT Board MicroPython 固件硬件功能如下所示:
| 外设名称 | 引脚号 | 简介 |
| -------- | -------------------------------------- | ----------------------------------------- |
| pin | PA11, PB4、10-14 、17-18、23-26、30-31 | 开发板引出的可自由分配的 IO,支持引脚中断 |
| led | PA13 | 红色 led 灯 |
| rgb | R: PA13, G: PA14, B: PA15 | rgb 灯 |
| key | KEY0: PA7, KEY1: PA6, | 输入按键 |
| uart1 | PA4, PA5 | 串口1 |
| i2c | | 软件 i2c 可选择任意 pin |
| spi | | 软件 spi 可选择任意引出 pin |
| adc | PB23 - 26 | adc,通道 5 - 8 |
| pwm | PB17、PB18 | pwm1, 通道 1、2 |
| timer | | 硬件定时器 1 |
| wdt | | 看门狗 |
| rtc | | 实时时钟 |
| beeper | PB15 | 蜂鸣器 |
| lcd | | lcd 显示屏 |
| wifi | | wifi 网络连接 |
| aht10 | CLK: PA0, SDA: PA1 | 温湿度传感器 |
| ap3216c | CLK: PA2, SDA: PA1 | 接近与光强传感器 |
## 入门必读
如果您从来没有了解过 MicroPython, 可以阅读这篇简短的文章来 [带你入门 MicroPython](https://github.com/RT-Thread-packages/micropython/blob/master/docs/introduction.md)。
## 开启 MicroPython 之旅
推荐遵循如下步骤开始进行 MicroPython 开发:
- 在您的开发板上烧录合适的固件
- 在 PC 机上安装 RT-Thread MicroPython 开发环境并连接上开发板
接下来就可以尽情挥洒您的创意了,更详细的内容可以点击下文中的链接来进一步了解。
### 下载合适的固件
- [W601 IoT Board firmware](https://www.rt-thread.org/qa/forum.php?mod=viewthread&tid=12305&extra=page%3D1%26filter%3Dtypeid%26typeid%3D20)
### 安装 IDE 开发环境
- [RT-Thread MicroPython develop environment](https://marketplace.visualstudio.com/items?itemName=RT-Thread.rt-thread-micropython)
## 开发资料
### 示例程序
以下示例程序可以在 RT-Thread MicroPython IDE 开发环境中直接添加到工程:

### MicroPython 模块详解
- [MicroPython Librarys](https://github.com/RT-Thread-packages/micropython/blob/master/docs/micropython-librarys.md)
## 联系我们
如果在使用的过程中遇到问题,您可以用如下方式联系我们:
- 在 github 上提交 issue
- [RT-Thread MicroPython 官方论坛](https://www.rt-thread.org/qa/forum.php?mod=forumdisplay&fid=2&filter=typeid&typeid=20)
- RT-Thread MicroPython 交流 QQ 群:703840633
================================================
FILE: docs/spec-librarys/machine/ADC.md
================================================
## machine.ADC
**machine.ADC** 类是 machine 模块下的一个硬件类,用于指定 ADC 设备的配置和控制,提供对 ADC 设备的操作方法。
- ADC(Analog-to-Digital Converter,模数转换器),用于将连续变化的模拟信号转化为离散的数字信号。
- ADC 设备两个重要参数:采样值、分辨率;
- 采样值:当前时间由模拟信号转化的数值信号的数值;
- 分辨率:以二进制(或十进制)数的位数来表示,一般有 8 位、10 位、12 位、16 位等,它说明模数转换器对输入信号的分辨能力,位数越多,表示分辨率越高,采样值会更精确。
### 构造函数
在 RT-Thread MicroPython 中 `ADC` 对象的构造函数如下:
#### **class machine.ADC**(id, channel)
- **id**:使用的 ADC 设备编号,`id = 1` 表示编号为 1 的 ADC 设备,或者表示使用的 ADC 设备名,如 `id = "adc"` 表示设备名为 `adc` 的 ADC 设备;
- **channel**:使用的 ADC 设备通道号,每个 ADC 设备对应多个通道;
例如:`ADC(1,4)` 表示当前使用编号为 1 的 ADC 设备的 4 通道。
### 方法
#### **ADC.init**(channel)
根据输入的层参数初始化 ADC 对象,入参为使用的 ADC 对象通道号;
#### **ADC.deinit**()
用于关闭 ADC 对象,ADC 对象 deinit 之后需要重新 init 才能使用。
#### **ADC.read**()
用于获取并返回当前 ADC 对象的采样值。例如当前采样值为 2048,对应设备的分辨率为 12位,当前设备参考电压为 3.3V ,则该 ADC 对象通道上实际电压值的计算公式为:**采样值 * 参考电压 / (1 << 分辨率位数)**,即 `vol = 2048 / 4096 * 3.3 V = 1.15V`。
### 示例
``` python
>>> from machine import ADC # 从 machine 导入 ADC 类
>>> adc = ADC(1, 13) # 创建 ADC 对象,当前使用编号为 1 的 ADC 设备的 13 通道
>>> adc.read() # 获取 ADC 对象采样值
4095
>>> adc.deinit() # 关闭 ADC 对象
>>> adc.init(13) # 开启并重新配置 ADC 对象
```
================================================
FILE: docs/spec-librarys/machine/I2C.md
================================================
## machine.I2C
**machine.I2C** 类是 `machine` 模块下面的一个硬件类,用于对 `I2C` 的配置和控制,提供对 `I2C` 设备的操作方法。
- `I2C` 是一种用于设备间通信的两线协议。在物理层上,它由两根线组成:`SCL` 和 `SDA` ,即时钟和数据线。
- `I2C` 对象被创建到一个特定的总线上,它们可以在创建时被初始化,也可以之后再来初始化。
- 打印 `I2C` 对象会打印出配置时的信息。
### 构造函数
在 RT-Thread MicroPython 中 `I2C` 对象的构造函数如下:
#### **class machine.I2C**(id= -1, scl, sda, freq=400000)
使用下面的参数构造并返回一个新的 `I2C` 对象:
- **id** :标识特定的 `I2C` 外设。如果填入 id = -1,即选择软件模拟的方式实现 `I2C`,这时可以使用任意引脚来模拟 `I2C` 总线 ,这样在初始化时就必须指定 `scl` 和 `sda` 。
软件 I2C 的初始化方式可参考 [软件 I2C 示例](#i2c_2)。
硬件 I2C 的初始化方式可参考 [硬件 I2C 示例](#i2c_3)。
- **scl** : 应该是一个 `Pin` 对象,指定为一个用于 `scl` 的 `Pin` 对象。
- **sda** : 应该是一个 `Pin` 对象,指定为一个用于 `sda` 的 `Pin` 对象。
- **freq** :应该是为 `scl` 设置的最大频率。
### 方法
#### **I2C.init**(scl, sda, freq=400000)
初始化 `I2C` 总线,参数介绍可以参考构造函数中的参数。
#### **I2C.deinit**()
关闭 `I2C` 总线。
#### **I2C.scan**()
扫描所有 0x08 和 0x77 之间的 `I2C` 地址,然后返回一个有响应地址的列表。如果一个设备在总线上收到了他的地址,就会通过拉低 `SDA` 的方式来响应。
### I2C 基础方法
下面的方法实现了基本的 `I2C` 总线操作,可以组合成任何的 `I2C` 通信操作,如果需要对总线进行更多的控制,可以可以使用他们,否则可以使用后面介绍的标准使用方法。
#### **I2C.start**()
在总线上产生一个启动信号。(`SCL` 为高时,`SDA` 转换为低)
#### **I2C.stop**()
在总线上产生一个停止信号。(`SCL` 为高时,`SDA` 转换为高)
#### **I2C.readinto**(buf, nack=True)
从总线上读取字节并将他们存储到 `buf` 中,读取的字节数时 `buf` 的长度。在收到最后一个字节以外的所有内容后,将在总线上发送 `ACK`。在收到最后一个字节之后,如果 `NACK` 是正确的,那么就会发送一个 `NACK`,否则将会发送 `ACK`。
#### **I2C.write**(buf)
将 `buf` 中的数据接入到总线,检查每个字节之后是否收到 `ACK`,并在收到 `NACK` 时停止传输剩余的字节。这个函数返回接收到的 `ACK` 的数量。
### I2C 标准总线操作
下面的方法实现了标准 `I2C` 主设备对一个给定从设备的读写操作。
#### **I2C.readfrom**(addr, nbytes, stop=True)
从 `addr` 指定的从设备中读取 n 个字节,如果 `stop = True`,那么在传输结束时会产生一个停止信号。函数会返回一个存储着读到数据的字节对象。
#### **I2C.readfrom_into**(addr, buf, stop=True)
从 `addr` 指定的从设备中读取数据存储到 `buf` 中,读取的字节数将是 `buf` 的长度,如果 `stop = True`,那么在传输结束时会产生一个停止信号。
这个方法没有返回值。
#### **I2C.writeto**(addr, buf, stop=True)
将 `buf` 中的数据写入到 `addr` 指定的的从设备中,如果在写的过程中收到了 `NACK` 信号,那么就不会发送剩余的字节。如果 `stop = True`,那么在传输结束时会产生一个停止信号,即使收到一个 `NACK`。这个函数返回接收到的 `ACK` 的数量。
### 内存操作
一些 `I2C` 设备充当一个内存设备,可以读取和写入。在这种情况下,有两个与 `I2C` 相关的地址,从机地址和内存地址。下面的方法是与这些设备进行通信的便利函数。
#### **I2C.readfrom_mem**(addr, memaddr, nbytes, \*, addrsize=8)
从 `addr` 指定的从设备中 `memaddr` 地址开始读取 n 个字节。`addrsize` 参数指定地址的长度。返回一个存储读取数据的字节对象。
#### **I2C.readfrom_mem_into**(addr, memaddr, buf, \*, addrsize=8)
从 `addr` 指定的从设备中 `memaddr` 地址读取数据到 `buf` 中,,读取的字节数是 `buf` 的长度。
这个方法没有返回值。
#### **I2C.writeto_mem**(addr, memaddr, buf, \*, addrsize=8)
将 `buf` 里的数据写入 `addr` 指定的从机的 `memaddr` 地址中。
这个方法没有返回值。
### 示例
#### 软件模拟 I2C
```python
>>> from machine import Pin, I2C
>>> clk = Pin(("clk", 29), Pin.OUT_OD) # Select the 29 pin device as the clock
>>> sda = Pin(("sda", 30), Pin.OUT_OD) # Select the 30 pin device as the data line
>>> i2c = I2C(-1, clk, sda, freq=100000) # create I2C peripheral at frequency of 100kHz
>>> i2c.scan() # scan for slaves, returning a list of 7-bit addresses
[81] # Decimal representation
>>> i2c.writeto(0x51, b'123') # write 3 bytes to slave with 7-bit address 42
3
>>> i2c.readfrom(0x51, 4) # read 4 bytes from slave with 7-bit address 42
b'\xf8\xc0\xc0\xc0'
>>> i2c.readfrom_mem(0x51, 0x02, 1) # read 1 bytes from memory of slave 0x51(7-bit),
b'\x12' # starting at memory-address 8 in the slave
>>> i2c.writeto_mem(0x51, 2, b'\x10') # write 1 byte to memory of slave 42,
# starting at address 2 in the slave
```
#### 硬件 I2C
需要先开启 `I2C` 设备驱动,查找设备可以在 `msh` 中输入`list_device` 命令。
在构造函数的第一个参数传入 `0`,系统就会搜索名为 `i2c0` 的设备,找到之后使用这个设备来构建 `I2C` 对象:
```python
>>> from machine import Pin, I2C
>>> i2c = I2C(0) # create I2C peripheral at frequency of 100kHz
>>> i2c.scan() # scan for slaves, returning a list of 7-bit addresses
[81] # Decimal representation
```
更多内容可参考 [machine.I2C](http://docs.micropython.org/en/latest/pyboard/library/machine.I2C.html) 。
================================================
FILE: docs/spec-librarys/machine/LCD.md
================================================
## machine.LCD
**machine.LCD** 类是 machine 模块下面的一个硬件类,用于对 LCD 的配置和控制,提供对 LCD 设备的操作方法。
IoT board 板载一块 1.3 寸,分辨率为 `240*240` 的 LCD 显示屏,因此对该屏幕操作时,(x, y) 坐标的范围是 `0 - 239`。
### 构造函数
在 RT-Thread MicroPython 中 `LCD` 对象的构造函数如下:
#### **class machine.LCD**()
在给定总线上构造一个 `LCD` 对象,无入参,初始化的对象取决于特定硬件,初始化方式可参考 [示例](#_3)。
### 方法
#### **LCD.light**(value)
控制是否开启 LCD 背光,入参为 True 则打开 LCD 背光,入参为 False 则关闭 LCD 背光。
#### **LCD.fill**(color)
根据给定的颜色填充整个屏幕,支持多种颜色,可以传入的参数有:
```
WHITE BLACK BLUE BRED GRED GBLUE RED MAGENTA GREEN CYAN YELLOW BROWN BRRED GRAY GRAY175 GRAY151 GRAY187 GRAY240
```
详细的使用方法可参考[示例](#_3)。
#### **LCD.pixel**(x, y, color)
向指定的位置(x, y)画点,点的颜色为 color 指定的颜色,可指定的颜色和上一个功能相同。
> 注意:(x, y) 坐标不要超过实际范围,使用下面的方法对坐标进行操作时同样需要遵循此限制。
#### **LCD.text**(str, x, y, size)
在指定的位置(x,y)写入字符串,字符串由 str 指定,字体的大小由 size 指定,size 的大小可为 16,24,32。
#### **LCD.line**(x1, y1, x2, y2)
在 LCD 上画一条直线,起始地址为 (x1, y1),终点为(x2, y2)。
#### **LCD.rectangle**(x1, y1, x2, y2)
在 LCD 上画一个矩形,左上角的位置为(x1, y1),右下角的位置为(x2, y2)。
#### **LCD.circle**(x1, y1, r)
在 LCD 上画一个圆形,圆心的位置为(x1, y1),半径长度为 r。
#### **LCD.show_bmp**( x, y, pathname)
在 LCD 指定位置上显示 32-bit bmp 格式的图片信息,注意显示 bmp 图片时,(x, y) 坐标是图片的左下角。
### 示例
```python
from machine import LCD # 从 machine 导入 LCD 类
lcd = LCD() # 创建一个 lcd 对象
lcd.light(False) # 关闭背光
lcd.light(True) # 打开背光
lcd.fill(lcd.BLACK) # 将整个 LCD 填充为黑色
lcd.fill(lcd.RED) # 将整个 LCD 填充为红色
lcd.fill(lcd.GRAY) # 将整个 LCD 填充为灰色
lcd.fill(lcd.WHITE) # 将整个 LCD 填充为白色
lcd.pixel(50, 50, lcd.BLUE) # 将(50,50)位置的像素填充为蓝色
lcd.text("hello RT-Thread", 0, 0, 16) # 在(0, 0) 位置以 16 字号打印字符串
lcd.text("hello RT-Thread", 0, 16, 24) # 在(0, 16)位置以 24 字号打印字符串
lcd.text("hello RT-Thread", 0, 48, 32) # 在(0, 48)位置以 32 字号打印字符串
lcd.line(0, 50, 239, 50) # 以起点(0,50),终点(239,50)画一条线
lcd.line(0, 50, 239, 50) # 以起点(0,50),终点(239,50)画一条线
lcd.rectangle(100, 100, 200, 200) # 以左上角为(100,100),右下角(200,200)画矩形
lcd.circle(150, 150, 80) # 以圆心位置(150,150),半径为 80 画圆
lcd.show_bmp(180, 50, "sun.bmp") # 以位置(180,50)为图片左下角坐标显示文件系统中的 bmp 图片 "sun.bmp"
```
================================================
FILE: docs/spec-librarys/machine/PWM.md
================================================
## machine.PWM
**machine.PWM** 类是 machine 模块下的一个硬件类,用于指定 PWM 设备的配置和控制,提供对 PWM 设备的操作方法。
- PWM (Pulse Width Modulation,脉冲宽度调制) 是一种对模拟信号电平进行数字编码的方式;
- PWM 设备可以通过调节有效电平在一个周期信号中的比例时间来操作设备;
- PWM 设备两个重要的参数:频率(freq)和占空比(duty);
- 频率:从一个上升沿(下降沿)到下一个上升沿(下降沿)的时间周期,单位为 Hz;
- 占空比:有效电平(通常为电平)在一个周期内的时间比例;
### 构造函数
在 RT-Thread MicroPython 中 `PWM` 对象的构造函数如下:
#### **class machine.PWM**(id, channel, freq, duty)
在给定的总线上构建一个 `PWM` 对象,参数介绍如下:
- **id**:使用的 PWM 设备编号,如 `id = 1` 表示编号为 1 的 PWM 设备,或者表示使用的 PWM 设备名,如 `id = "pwm"` 表示设备名为 `pwm` 的 PWM 设备;
- **channel**:使用的 PWM 设备通道号,每个 PWM 设备包含多个通道,范围为 [0, 4];
- **freq**:初始化频率,范围 [1, 156250];
- **duty**:初始化占空比数值,范围 [0 255];
例如:`PWM(1,4,100,100)` 表示当前使用 编号为 1 的 PWM 设备的 4 通道,初始化频率为 1000 Hz,初始化占空比的数值为 100。
### 方法
#### **PWM.init**(channel, freq, duty)
根据输入的参数初始化 PWM 对象,参数说明同上。
#### **PWM.deinit**()
用于关闭 PWM 对象,对象 deinit 之后需要重新 init 才能使用。
#### **PWM.freq**(freq)
用于获取或者设置 PWM 对象的频率,频率的范围为 [1, 156250]。如果参数为空,返回当前 PWM 对象的频率;如果参数非空,则使用该参数设置当前 PWM 对象的频率。
#### **PWM.duty**(duty)
用于获取或者设置 PWM 对象的占空比数值,占空比数值的范围为 [0, 255],例如 `duty = 100`,表示当前设备占空比为 `100/255 = 39.22%` 。如果参数为空,返回当前 PWM 对象的占空比数值;如果参数非空,则使用该参数设置当前 PWM 对象的占空比数值。
### 示例
``` python
>>> from machine import PWM # 从 machine 导入 PWM 类
>>> pwm = PWM(3, 3, 1000, 100) # 创建 PWM 对象,当前使用编号为 3 的 PWM 设备的 3 通道,初始化的频率为 1000Hz,占空比数值为 100(占空比为 100/255 = 39.22%)
>>> pwm.freq(2000) # 设置 PWM 对象频率
>>> pwm.freq() # 获取 PWM 对象频率
2000
>>> pwm.duty(200) # 设置 PWM 对象占空比数值
>>> pwm.duty() # 获取 PWM 对象占空比数值
200
>>> pwm.deinit() # 关闭 PWM 对象
>>> pwm.init(3, 1000, 100) # 开启并重新配置 PWM 对象
```
================================================
FILE: docs/spec-librarys/machine/Pin.md
================================================
## machine.Pin
**machine.Pin** 类是 machine 模块下面的一个硬件类,用于对引脚的配置和控制,提供对 `Pin` 设备的操作方法。
`Pin` 对象用于控制输入/输出引脚(也称为 `GPIO`)。`Pin` 对象通常与一个物理引脚相关联,他可以驱动输出电压和读取输入电压。Pin 类中有设置引脚模式(输入/输出)的方法,也有获取和设置数字逻辑(`0` 或 `1`)的方法。
一个 `Pin` 对象是通过一个标识符来构造的,它明确地指定了一个特定的输入输出。标识符的形式和物理引脚的映射是特定于一次移植的。标识符可以是整数,字符串或者是一个带有端口和引脚号码的元组。在 RT-Thread MicroPython 中,引脚标识符是一个由代号和引脚号组成的元组,如 `Pin(("PB15", 31), Pin.OUT_PP)` 中的` ("PB15", 31)`。
### 构造函数
在 RT-Thread MicroPython 中 `Pin` 对象的构造函数如下:
#### **class machine.Pin**( id, mode = -1, pull = -1,value)
- **id** :由用户自定义的引脚名和 `Pin` 设备引脚号组成,如 ("PB15", 31),"PB15" 为用户自定义的引脚名,`31` 为 `RT-Thread Pin` 设备驱动在本次移植中的引脚号。
- **mode** : 指定引脚模式,可以是以下几种:
- **Pin.IN** :输入模式
- **Pin.OUT_PP** :输出模式
- **Pin.OUT_OD** :开漏模式
- **pull** : 如果指定的引脚连接了上拉下拉电阻,那么可以配置成下面的状态:
- **None** :没有上拉或者下拉电阻。
- **Pin.PULL_UP** :使能上拉电阻。
- **Pin.PULL_DOWN** :使能下拉电阻。
- **value** : `value` 的值只对输出模式和开漏输出模式有效,用来设置初始输出值。
### 方法
#### **Pin.init**(mode= -1, pull= -1, \*, value, drive, alt)
根据输入的参数重新初始化引脚。只有那些被指定的参数才会被设置,其余引脚的状态将保持不变,详细的参数可以参考上面的构造函数。
#### **Pin.value**([x])
如果没有给定参数 `x` ,这个方法可以获得引脚的值。
如果给定参数 `x` ,如 `0` 或 `1`,那么设置引脚的值为 逻辑 `0` 或 逻辑 `1`。
#### **Pin.name**()
返回引脚对象在构造时用户自定义的引脚名。
#### **Pin.irq**(handler=None, trigger=(Pin.IRQ_RISING))
配置在引脚的触发源处于活动状态时调用的中断处理程序。如果引脚模式是, `Pin.IN` 则触发源是引脚上的外部值。 如果引脚模式是, `Pin.OUT` 则触发源是引脚的输出缓冲器。 否则,如果引脚模式是, `Pin.OPEN_DRAIN` 那么触发源是状态'0'的输出缓冲器和状态'1'的外部引脚值。
参数:
- `handler` 是一个可选的函数,在中断触发时调用
- `trigger` 配置可以触发中断的事件。可能的值是:
- `Pin.IRQ_FALLING` 下降沿中断
- `Pin.IRQ_RISING` 上升沿中断
- `Pin.IRQ_RISING_FALLING` 上升沿或下降沿中断
- `Pin.IRQ_LOW_LEVEL` 低电平中断
- `Pin.IRQ_HIGH_LEVEL` 高电平中断
### 常量
下面的常量用来配置 `Pin` 对象。
#### 选择引脚模式:
##### **Pin.IN**
##### **Pin.OUT_PP**
##### **Pin.OUT_OD**
#### 选择上/下拉模式:
##### **Pin.PULL_UP**
##### **Pin.PULL_DOWN**
##### **None**
使用值 `None` 代表不进行上下拉。
#### 选择中断触发模式:
##### **Pin.IRQ_FALLING**
##### **Pin.IRQ_RISING**
##### **Pin.IRQ_RISING_FALLING**
##### **Pin.IRQ_LOW_LEVEL**
##### **Pin.IRQ_HIGH_LEVEL**
### 示例一
控制引脚输出高低电平信号,并读取按键引脚电平信号。
```
from machine import Pin
PIN_OUT = 31
PIN_IN = 58
p_out = Pin(("PB15", PIN_OUT), Pin.OUT_PP)
p_out.value(1) # set io high
p_out.value(0) # set io low
p_in = Pin(("key_0", PIN_IN), Pin.IN, Pin.PULL_UP)
print(p_in.value() ) # get value, 0 or 1
```
### 示例二
上升沿信号触发引脚中断后执行中断处理函数。
```
from machine import Pin
PIN_KEY0 = 58 # PD10
key_0 = Pin(("key_0", PIN_KEY0), Pin.IN, Pin.PULL_UP)
def func(v):
print("Hello rt-thread!")
key_0.irq(trigger=Pin.IRQ_RISING, handler=func)
```
更多内容可参考 [machine.Pin](http://docs.micropython.org/en/latest/pyboard/library/machine.Pin.html) 。
================================================
FILE: docs/spec-librarys/machine/RTC.md
================================================
## machine.RTC
**machine.RTC** 类是 machine 模块下面的一个硬件类,用于对指定 RTC 设备的配置和控制,提供对 RTC 设备的操作方法。
- RTC(Real-Time Clock )实时时钟可以提供精确的实时时间,它可以用于产生年、月、日、时、分、秒等信息。
### 构造函数
在 RT-Thread MicroPython 中 `RTC` 对象的构造函数如下:
#### **class machine.RTC**()
所以在给定的总线上构造一个 `RTC` 对象,无入参对象,使用方式可参考 [示例](#_3)。
### 方法
#### **RTC.init**(datetime)
根据传入的参数初始化 RTC 设备起始时间。入参 `datetime` 为一个时间元组,格式如下:
```
(year, month, day, wday, hour, minute, second, yday)
```
参数介绍如下所示:
- **year**:年份;
- **month**:月份,范围 [1, 12];
- **day**:日期,范围 [1, 31];
- **wday**:星期,范围 [0, 6],0 表示星期一,以此类推;
- **hour**:小时,范围 [0, 23];
- **minute**:分钟,范围[0, 59];
- **second**:秒,范围[0, 59];
- **yday**:从当前年份 1 月 1 日开始的天数,范围 [0, 365],一般置位 0 未实现。
使用的方式可参考 [示例](#_3)。
#### **RTC.deinit**()
重置 RTC 设备时间到 2015 年 1 月 1日,重新运行 RTC 设备。
#### **RTC.now**()
获取当前时间,返回值为上述 `datetime` 时间元组格式。
### 示例
```python
>>> from machine import RTC
>>> rtc = RTC() # 创建 RTC 设备对象
>>> rtc.init((2019,6,5,2,10,22,30,0)) # 设置初始化时间
>>> rtc.now() # 获取当前时间
(2019, 6, 5, 2, 10, 22, 40, 0)
>>> rtc.deinit() # 重置时间到2015年1月1日
>>> rtc.now() # 获取当前时间
(2015, 1, 1, 3, 0, 0, 1, 0)
```
================================================
FILE: docs/spec-librarys/machine/SPI.md
================================================
## machine.SPI
**machine.SPI** 类是 machine 模块下面的一个硬件类,用于对 SPI 的配置和控制,提供对 SPI 设备的操作方法。
- `SPI` 是一个由主机驱动的同步串行协议。在物理层,总线有三根:`SCK`、`MOSI`、`MISO`。多个设备可以共享同一总线,每个设备都由一个单独的信号 `SS` 来选中,也称片选信号。
- 主机通过片选信号选定一个设备进行通信。`SS` 信号的管理应该由用户代码负责。(通过 [machine.Pin](Pin.md))
### 构造函数
在 RT-Thread MicroPython 中 `SPI` 对象的构造函数如下:
#### **class machine.SPI**(id, ...)
在给定总线上构造一个 `SPI` 对象,`id` 取决于特定的移植。
如果想要使用软件 `SPI` , 即使用引脚模拟 `SPI` 总线,那么初始化的第一个参数需要设置为 `-1` ,可参考 [软件 SPI 示例](#spi) 。
使用硬件 `SPI` 在初始化时只需传入 `SPI` 设备的编号即可,如 '50' 表示 `SPI5` 总线上的第 0 个设备。初始化方式可参考 [硬件 SPI 示例](#spi_1)。
如果没有额外的参数,`SPI` 对象会被创建,但是不会被初始化,如果给出额外的参数,那么总线将被初始化,初始化参数可以参考下面的 `SPI.init` 方法。
### 方法
#### **SPI.init**(baudrate=1000000, \*, polarity=0, phase=0, bits=8, firstbit=SPI.MSB, sck=None, mosi=None, miso=None)
用给定的参数初始化`SPI`总线:
- **baudrate** :`SCK` 时钟频率。
- **polarity** :极性可以是 `0` 或 `1`,是时钟空闲时所处的电平。
- **phase** :相位可以是 `0` 或 `1`,分别在第一个或者第二个时钟边缘采集数据。
- **bits** :每次传输的数据长度,一般是 8 位。
- **firstbit** :传输数据从高位开始还是从低位开始,可以是 `SPI.MSB` 或者 `SPI.LSB`。
- **sck** :用于 `sck` 的 `machine.Pin` 对象。
- **mosi** :用于 `mosi` 的 `machine.Pin` 对象。
- **miso** :用于`miso` 的 `machine.Pin` 对象。
#### **SPI.deinit**()
关闭 `SPI` 总线。
#### **SPI.read**(nbytes, write=0x00)
读出 n 字节的同时不断的写入 `write` 给定的单字节。返回一个存放着读出数据的字节对象。
#### **SPI.readinto**(buf, write=0x00)
读出 n 字节到 `buf` 的同时不断地写入 `write` 给定的单字节。
这个方法返回读入的字节数。
#### **SPI.write**(buf)
写入 `buf` 中包含的字节。返回`None`。
#### **SPI.write_readinto**(write_buf, read_buf)
在读出数据到 `readbuf` 时,从 `writebuf` 中写入数据。缓冲区可以是相同的或不同,但是两个缓冲区必须具有相同的长度。返回 `None`。
### 常量
#### **SPI.MSB**
设置从高位开始传输数据。
#### **SPI.LSB**
设置从低位开始传输数据。
### 示例
#### 软件模拟 SPI
```
>>> from machine import Pin, SPI
>>> clk = Pin(("clk", 26), Pin.OUT_PP)
>>> mosi = Pin(("mosi", 27), Pin.OUT_PP)
>>> miso = Pin(("miso", 28), Pin.IN)
>>> spi = SPI(-1, 500000, polarity = 0, phase = 0, bits = 8, firstbit = 0, sck = clk, mosi = mosi, miso = miso)
>>> print(spi)
SoftSPI(baudrate=500000, polarity=0, phase=0, sck=clk, mosi=mosi, miso=miso)
>>> spi.write("hello rt-thread!")
>>> spi.read(10)
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
```
#### 硬件 SPI
需要先开启 `SPI` 设备驱动,查找设备可以在 `msh` 中输入`list_device` 命令。
在构造函数的第一个参数传入 `50`,系统就会搜索名为 `spi50` 的设备,找到之后使用这个设备来构建 `SPI` 对象:
```
>>> from machine import SPI
>>> spi = SPI(50)
>>> print(spi)
SPI(device port : spi50)
>>> spi.write(b'\x9f')
>>> spi.read(5)
b'\xff\xff\xff\xff\xff'
>>> buf = bytearray(1)
>>> spi.write_readinto(b"\x9f",buf)
>>> buf
bytearray(b'\xef')
>>> spi.init(100000,0,0,8,1) # Resetting SPI parameter
```
更多内容可参考 [machine.SPI](http://docs.micropython.org/en/latest/pyboard/library/machine.SPI.html) 。
================================================
FILE: docs/spec-librarys/machine/Timer.md
================================================
## machine.Timer
**machine.Timer** 类是 machine 模块下的一个硬件类,用于 Timer 设备的配置和控制,提供对 Timer 设备的操作方法。
- Timer(硬件定时器),是一种用于处理周期性和定时性事件的设备。
- Timer 硬件定时器主要通过内部计数器模块对脉冲信号进行计数,实现周期性设备控制的功能。
- Timer 硬件定时器可以自定义**超时时间**和**超时回调函数**,并且提供两种**定时器模式**:
- `ONE_SHOT`:定时器只执行一次设置的回调函数;
- `PERIOD`:定时器会周期性执行设置的回调函数;
- 打印 Timer 对象会打印出配置的信息。
### 构造函数
在 RT-Thread MicroPython 中 `Timer` 对象的构造函数如下:
#### **class machine.Timer**(id)
- **id**:使用的 Timer 设备编号,`id = 1` 表示编号为 1 的 Timer 设备,或者表示使用的 timer 设备名,如 `id = "timer"` 表示设备名为 `timer` 的 Timer 设备;
该函数主要用于通过设备编号创建 Timer 设备对象。
### 方法
#### **Timer.init**(mode = Timer.PERIODIC, period = 0, callback = None)
- **mode**:设置 Timer 定时器模式,可以设置两种模式:`ONE_SHOT`(执行一次)、`PERIOD`(周期性执行),默认设置的模式为 `PERIOD` 模式;
- **period**:设置 Timer 定时器定时周期,单位:毫秒(ms)
- **callback**:设置 Timer 定义器超时回调函数,默认设置的函数为 None 空函数,设置的函数格式如下所示:
```python
def callback_test(device): # 回调函数有且只有一个入参,为创建的 Timer 对象
print("Timer callback test")
print(device) # 打印 Timer 对象配置信息
```
该函数使用方式如下示例所示:
```python
timer.init(wdt.PERIOD, 5000, callback_test) # 设置定时器模式为周期性执行,超时时间为 5 秒, 超时函数为 callback_test
```
#### **Timer.deinit**()
该函数用于停止并关闭 Timer 设备。
### 常量
下面的常量用来配置 `Timer` 对象。
#### 选择定时器模式:
##### **Timer.PERIODIC**
##### **Timer.ONE_SHOT**
### 示例
```python
>>> from machine import Timer # 从 machine 导入 Timer 类
>>> timer = Timer(15) # 创建 Timer 对象,当前设备编号为 11
>>> # 进入粘贴模式
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== def callback_test(device): # 定义超时回调函数
=== print("Timer callback test")
>>> timer.init(timer.PERIODIC, 5000, callback_test) # 初始化 Timer 对象,设置定时器模式为循环执行,超时时间为 5 秒,超时回调函数 callback_test
>>> Timer callback test # 5 秒超时循环执行回调函数,打印日志
>>> Timer callback test
>>> Timer callback test
>>> timer.init(timer.ONE_SHOT, 5000, callback_test) # 设置定时器模式为只执行一次,超时时间为 5 秒,超时回调函数为 callback_test
>>> Timer callback test # 5 秒超时后执行一次回调函数,打印日志
>>> timer.deinit() # 停止并关闭 Timer 定时器
```
更多内容可参考 [machine.Timer](http://docs.micropython.org/en/latest/library/machine.Timer.html)。
================================================
FILE: docs/spec-librarys/machine/UART.md
================================================
## machine.UART
**machine.UART** 类是 machine 模块下面的一个硬件类,用于对 UART 的配置和控制,提供对 UART 设备的操作方法。
`UART` 实现了标准的 `uart/usart` 双工串行通信协议,在物理层上,他由两根数据线组成:`RX` 和 `TX`。通信单元是一个字符,它可以是 8 或 9 位宽。
### 构造函数
在 RT-Thread MicroPython 中 `UART` 对象的构造函数如下:
#### **class machine.UART**(id, ...)
在给定总线上构造一个 `UART` 对象,`id` 取决于特定的移植。
初始化参数可以参考下面的 `UART.init` 方法。
使用硬件 UART 在初始化时只需传入 `UART` 设备的编号即可,如传入 `1` 表示 `uart1` 设备。
初始化方式可参考 [示例](#_3)。
### 方法
#### **UART.init**(baudrate = 9600, bits=8, parity=None, stop=1)
- **baudrate** :`SCK` 时钟频率。
- **bits** :每次发送数据的长度。
- **parity** :校验方式。
- **stop** :停止位的长度。
#### **UART.deinit**()
关闭串口总线。
#### **UART.read**([nbytes])
读取字符,如果指定读 n 个字节,那么最多读取 n 个字节,否则就会读取尽可能多的数据。
返回值:一个包含读入数据的字节对象。如果如果超时则返回 `None`。
#### **UART.readinto**(buf[, nbytes])
读取字符到 `buf` 中,如果指定读 n 个字节,那么最多读取 n 个字节,否则就读取尽可能多的数据。另外读取数据的长度不超过 `buf` 的长度。
返回值:读取和存储到 `buf` 中的字节数。如果超时则返回 `None`。
#### **UART.readline**()
读一行数据,以换行符结尾。
返回值:读入的行数,如果超时则返回 `None`。
#### **UART.write**(buf)
将 `buf` 中的数据写入总线。
返回值:写入的字节数,如果超时则返回 `None`。
### 示例
在构造函数的第一个参数传入`1`,系统就会搜索名为 `uart1` 的设备,找到之后使用这个设备来构建 `UART` 对象:
```python
from machine import UART
uart = UART(1, 115200) # init with given baudrate
uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters
uart.read(10) # read 10 characters, returns a bytes object
uart.read() # read all available characters
uart.readline() # read a line
uart.readinto(buf) # read and store into the given buffer
uart.write('abc') # write the 3 characters
```
更多内容可参考 [machine.UART](http://docs.micropython.org/en/latest/pyboard/library/machine.UART.html) 。
================================================
FILE: docs/spec-librarys/machine/WDT.md
================================================
## machine.WDT
**machine.WDT** 类是 machine 模块下的一个硬件类,用于 WDT 设备的配置和控制,提供对 WDT 设备的操作方法。
如下为 WDT 设备基本介绍:
- WDT(WatchDog Timer,硬件看门狗),是一个定时器设备,用于系统程序结束或出错导致系统进入不可恢复状态时重启系统。
- WDT 启动之后,计数器开始计数,在计数器溢出前没有被复位,会对 CPU 产生一个复位信号使设备重启(简称 “被狗咬”);
- 系统正常运行时,需要在 WDT 设备允许的时间间隔内对看门狗计数清零(简称“喂狗”),WDT 设备一旦启动,需要定时“喂狗”以确保设备正常运行。
### 构造函数
在 RT-Thread MicroPython 中 `WDT` 对象的构造函数如下:
#### **class machine.WDT**(id = "wdt", timeout=5)
- **id**: 使用的 WDT 设备编号,`id = 1` 表示编号为 1 的 WDT 设备,或者表示使用的 WDT 设备名,如 `id = "wdt"` 表示设备名为 `wdt` 的 WDT 设备;
- **timeout**:设置看门狗超时时间,单位:秒(s);
用于创建一个 WDT 对象并且启动 WDT 功能。一旦启动,设置的超时时间无法改动,WDT 功能无法停止。
如果该函数入参为空,则设置超时时间为 5 秒;如果入参非空,则使用该入参设置 WDT 超时时间,超时时间最小设置为 1 秒。
### 方法
#### **WDT.feed**()
用于执行“喂狗”操作,清空看门狗设备计数。应用程序应该合理的周期性调用该函数,以防止系统重启。
### 示例
``` python
>>> from machine import WDT # 从 machine 导入 WDT 类
>>> wdt = WDT() # 创建 WDT 对象,默认超时时间为 5 秒
>>> wdt = WDT(10) # 创建 WDT 对象,设置超时时间为 10 秒
>>> wdt.feed() # 在 10 秒超时时间内需要执行“喂狗”操作,清空看门狗设备计数,否则系统将重启
```
更多内容可参考 [machine.WDT](http://docs.micropython.org/en/latest/library/machine.WDT.html) 。
================================================
FILE: docs/spec-librarys/machine.md
================================================
## **machine** – 与硬件相关的功能
**machine** 模块包含与特定开发板上的硬件相关的特定函数。 在这个模块中的大多数功能允许实现直接和不受限制地访问和控制系统上的硬件块(如CPU,定时器,总线等)。如果使用不当,会导致故障,死机,崩溃,在极端的情况下,硬件会损坏。
需要注意的是,由于不同开发板的硬件资源不同,MicroPython 移植所能控制的硬件也是不一样的。因此对于控制硬件的例程来说,在使用前需要修改相关的配置参数来适配不同的开发板,或者直接运行已经对某一开发板适配好的 MicroPython 示例程序。本文档中的例程都是基于 RT-Thread IoT Board 潘多拉开发板而讲解的。
### 函数
#### 复位相关函数
##### **machine.info**()
显示关于系统介绍和内存占用等信息。
##### **machine.reset**() 注:暂未实现
重启设备,类似于按下复位按钮。
##### **machine.reset_cause**() 注:暂未实现
获得复位的原因,查看可能的返回值的常量。
#### 中断相关函数
##### **machine.disable_irq**()
禁用中断请求。返回先前的 `IRQ` 状态,该状态应该被认为是一个未知的值。这个返回值应该在 `disable_irq` 函数被调用之前被传给 `enable_irq` 函数来重置中断到初始状态。
##### **machine.enable_irq**(state)
重新使能中断请求。状态参数应该是从最近一次禁用功能的调用中返回的值。
#### 功耗相关函数
##### **machine.freq**()
返回 `CPU` 的运行频率。
##### **machine.idle**() 注:暂未实现
阻断给 `CPU` 的时钟信号,在较短或者较长的周期里减少功耗。当中断发生时,外设将继续工作。
##### **machine.sleep**() 注:暂未实现
停止 `CPU` 并禁止除了 `WLAN` 之外的所有外设。系统会从睡眠请求的地方重新恢复工作。为了确保唤醒一定会发生,应当首先配置中断源。
##### **machine.deepsleep**() 注:暂未实现
停止 `CPU` 和所有外设(包括网络接口)。执行从主函数中恢复,就像被复位一样。复位的原因可以检查 `machine.DEEPSLEEP` 参数获得。为了确保唤醒一定会发生,应该首先配置中断源,比如一个引脚的变换或者 `RTC` 的超时。
================================================
FILE: docs/spec-librarys/micropython.md
================================================
# micropython – 内部功能访问与控制模块
## Functions
### micropython.const(expr)
Used to declare that the expression is a constant so that the compile can optimise it. The use of this function should be as follows:
```python
from micropython import const
CONST_X = const(123)
CONST_Y = const(2 * CONST_X + 1)
```
Constants declared this way are still accessible as global variables from outside the module they are declared in. On the other hand, if a constant begins with an underscore then it is hidden, it is not available as a global variable, and does not take up any memory during execution.
This const function is recognised directly by the MicroPython parser and is provided as part of the micropython module mainly so that scripts can be written which run under both CPython and MicroPython, by following the above pattern.
### micropython.opt_level([level])
If level is given then this function sets the optimisation level for subsequent compilation of scripts, and returns None. Otherwise it returns the current optimisation level.
- The optimisation level controls the following compilation features:
- Assertions: at level 0 assertion statements are enabled and compiled into the bytecode; at levels 1 and higher assertions are not compiled.
- Built-in __debug__ variable: at level 0 this variable expands to True; at levels 1 and higher it expands to False.
Source-code line numbers: at levels 0, 1 and 2 source-code line number are stored along with the bytecode so that exceptions can report the line number they occurred at; at levels 3 and higher line numbers are not stored.
- The default optimisation level is usually level 0.
### micropython.alloc_emergency_exception_buf(size)
Allocate size bytes of RAM for the emergency exception buffer (a good size is around 100 bytes). The buffer is used to create exceptions in cases when normal RAM allocation would fail (eg within an interrupt handler) and therefore give useful traceback information in these situations.
A good way to use this function is to put it at the start of your main script (eg boot.py or main.py) and then the emergency exception buffer will be active for all the code following it.
### micropython.mem_info([verbose])
Print information about currently used memory. If the verbose argument is given then extra information is printed.
The information that is printed is implementation dependent, but currently includes the amount of stack and heap used. In verbose mode it prints out the entire heap indicating which blocks are used and which are free.
### micropython.qstr_info([verbose])
Print information about currently interned strings. If the verbose argument is given then extra information is printed.
The information that is printed is implementation dependent, but currently includes the number of interned strings and the amount of RAM they use. In verbose mode it prints out the names of all RAM-interned strings.
### micropython.stack_use()
Return an integer representing the current amount of stack that is being used. The absolute value of this is not particularly useful, rather it should be used to compute differences in stack usage at different points.
### micropython.heap_lock()
### micropython.heap_unlock()
Lock or unlock the heap. When locked no memory allocation can occur and a MemoryError will be raised if any heap allocation is attempted.
These functions can be nested, ie heap_lock() can be called multiple times in a row and the lock-depth will increase, and then heap_unlock() must be called the same number of times to make the heap available again.
If the REPL becomes active with the heap locked then it will be forcefully unlocked.
### micropython.kbd_intr(chr)
Set the character that will raise a KeyboardInterrupt exception. By default this is set to 3 during script execution, corresponding to Ctrl-C. Passing -1 to this function will disable capture of Ctrl-C, and passing 3 will restore it.
This function can be used to prevent the capturing of Ctrl-C on the incoming stream of characters that is usually used for the REPL, in case that stream is used for other purposes.
### micropython.schedule(func, arg)
Schedule the function func to be executed “very soon”. The function is passed the value arg as its single argument. “Very soon” means that the MicroPython runtime will do its best to execute the function at the earliest possible time, given that it is also trying to be efficient, and that the following conditions hold:
- A scheduled function will never preempt another scheduled function.
- Scheduled functions are always executed “between opcodes” which means that all fundamental Python operations (such as appending to a list) are guaranteed to be atomic.
- A given port may define “critical regions” within which scheduled functions will never be executed. Functions may be scheduled within a critical region but they will not be executed until that region is exited. An example of a critical region is a preempting interrupt handler (an IRQ).
A use for this function is to schedule a callback from a preempting IRQ. Such an IRQ puts restrictions on the code that runs in the IRQ (for example the heap may be locked) and scheduling a function to call later will lift those restrictions.
Note: If schedule() is called from a preempting IRQ, when memory allocation is not allowed and the callback to be passed to schedule() is a bound method, passing this directly will fail. This is because creating a reference to a bound method causes memory allocation. A solution is to create a reference to the method in the class constructor and to pass that reference to schedule(). This is discussed in detail here reference documentation under “Creation of Python objects”.
There is a finite queue to hold the scheduled functions and schedule() will raise a RuntimeError if the queue is full.
================================================
FILE: docs/spec-librarys/network/wlan.md
================================================
## class WLAN – 控制内置的 WiFi 网络接口
该类为 WiFi 网络处理器提供一个驱动程序。使用示例:
```python
import network
# enable station interface and connect to WiFi access point
nic = network.WLAN(network.STA_IF)
nic.active(True)
nic.connect('your-ssid', 'your-password')
# now use sockets as usual
```
### 构造函数
在 RT-Thread MicroPython 中 `WLAN` 对象的构造函数如下:
#### class network.WLAN(interface_id)
创建一个 WLAN 网络接口对象。支持的接口是 ` network.STA_IF`(STA 模式,可以连接到上游的 WiFi 热点上) 和 `network.AP_IF`(AP 模式,允许其他 WiFi 客户端连接到自身的热点)。下面方法的可用性取决于接口的类型。例如,只有STA 接口可以使用 `WLAN.connect()` 方法连接到 AP 热点上。
### 方法
#### **WLAN.active**([is_active])
如果向该方法传入布尔数值,传入 True 则使能卡,传入 False 则禁止网卡。否则,如果不传入参数,则查询当前网卡的状态。
#### **WLAN.connect**(ssid, password)
使用指定的账号和密码链接指定的无线热点。
#### **WLAN.disconnect**()
从当前链接的无线网络中断开。
#### **WLAN.scan**()
扫描当前可以连接的无线网络。
只能在 STA 模式下进行扫描,使用元组列表的形式返回 WiFi 接入点的相关信息。
(ssid, bssid, channel, rssi, authmode, hidden)
#### **WLAN.status**([param])
返回当前无线连接的状态。
当调用该方法时没有附带参数,就会返回值描述当前网络连接的状态。如果还没有从热点连接中获得 IP 地址,此时的状态为 `STATION_IDLE`。如果已经从连接的无线网络中获得 IP 地址,此时的状态为 `STAT_GOT_IP`。
当调用该函数使用的参数为 `rssi` 时,则返回 `rssi` 的值,该函数目前只支持这一个参数。
#### **WLAN.isconnected**()
在 STA 模式时,如果已经连接到 WiFi 网络,并且获得了 IP 地址,则返回 True。如果处在 AP 模式,此时已经与客户端建立连接,则返回 True。其他情况下都返回 False。
#### WLAN.ifconfig([(ip, subnet, gateway, dns)])
获取或者设置网络接口的参数,IP 地址,子网掩码,网关,DNS 服务器。当调用该方法不附带参数时,该方法会返回一个包含四个元素的元组来描述上面的信息。想要设置上面的值,传入一个包含上述四个元素的元组,例如:
```python
nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
```
#### **WLAN.config**('param')
#### WLAN.config(param=value, ...)
获取或者设置一般网络接口参数,这些方法允许处理标准的 ip 配置之外的其他参数,如 `WLAN. ifconfig()` 函数处理的参数。这些参数包括特定网络和特定硬件的参数。对于参数的设置,应该使用关键字的语法,可以一次性设置多个参数。
当查询参数时,参数名称的引用应该为字符串,且每次只能查询一个参数。
```python
# Set WiFi access point name (formally known as ESSID) and WiFi password
ap.config(essid='My_AP', password="88888888")
# Query params one by one
print(ap.config('essid'))
print(ap.config('channel'))
```
下面是目前支持的参数:
| Parameter | Description |
| --------- | --------------------------------- |
| mac | MAC address (bytes) |
| essid | WiFi access point name (string) |
| channel | WiFi channel (integer) |
| hidden | Whether ESSID is hidden (boolean) |
| password | Access password (string) |
### 示例
STA 模式下:
```python
import network
wlan = network.WLAN(network.STA_IF)
wlan.scan()
wlan.connect("rtthread","02188888888")
wlan.isconnected()
```
AP 模式下:
```python
import network
ap = network.WLAN(network.AP_IF)
ap.config(essid="hello_rt-thread", password="88888888")
ap.active(True)
ap.config("essid")
```
================================================
FILE: docs/spec-librarys/network.md
================================================
## network – 网络配置
此模块提供网络驱动程序和路由配置。特定硬件的网络驱动程序在此模块中可用,用于配置硬件网络接口。然后,配置接口提供的网络服务可以通过 `usocket` 模块使用。
### 专用的网络类配置
下面具体的类实现了抽象网卡的接口,并提供了一种控制各种网络接口的方法。
- [class WLAN – control built-in WiFi interfaces](network/wlan.md)
================================================
FILE: docs/spec-librarys/rtthread.md
================================================
## **rtthread** – 系统相关函数
**rtthread** 模块提供了与 RT-Thread 操作系统相关的功能,如查看栈使用情况等。
### 函数
#### rtthread.current_tid()
返回当前线程的 id 。
#### rtthread.is_preempt_thread()
返回是否是可抢占线程。
### 示例
```
>>> import rtthread
>>>
>>> rtthread.is_preempt_thread() # determine if it's a preemptible thread
True
>>> rtthread.current_tid() # current thread id
268464956
>>>
```
================================================
FILE: docs/std-librarys/_thread.md
================================================
## _thread – 多线程支持
`_thread` 模块提供了用于处理多线程的基本方法——多个控制线程共享它们的全局数据空间。为了实现同步,提供了简单的锁(也称为互斥锁或二进制信号量)。
### 示例
```python
import _thread
import time
def testThread():
while True:
print("Hello from thread")
time.sleep(2)
_thread.start_new_thread(testThread, ())
while True:
pass
```
输出结果(启动新的线程,每隔两秒打印字符):
Hello from thread
Hello from thread
Hello from thread
Hello from thread
Hello from thread
更多内容可参考 [_thread](http://docs.micropython.org/en/latest/pyboard/library/_thread.html) 。
================================================
FILE: docs/std-librarys/builtins.md
================================================
# Builtin functions and exceptions
所有的内饰函数和异常类型都在下面描述。
## 函数和类型
- abs()
- all()
- any()
- bin()
- **class** bool
- **class** bytearray
- **class** bytes
- callable()
- chr()
- classmethod()
- compile()
- **class** complex
- delattr(obj, name)
- **class** dict
- dir()
- divmod()
- enumerate()
- eval()
- exec()
- filter()
- **class** float
- **class** frozenset
- getattr()
- globals()
- hasattr()
- hash()
- hex()
- id()
- input()
- **class** int
- classmethod from_bytes(bytes, byteorder)
In MicroPython, byteorder parameter must be positional (this is compatible with CPython).
- to_bytes(size, byteorder)
In MicroPython, byteorder parameter must be positional (this is compatible with CPython).
- isinstance()
- issubclass()
- iter()
- len()
- class list
- locals()
- map()
- max()
- **class** memoryview
- min()
- next()
- **class** object
- oct()
- open()
- ord()
- pow()
- print()
- property()
- range()
- repr()
- reversed()
- round()
- class set
- setattr()
- **class** slice
- The slice builtin is the type that slice objects have.
- sorted()
- staticmethod()
- **class** str
- sum()
- super()
- **class** tuple
- type()
- zip()
## 异常类型
- **exception** AssertionError
- **exception** AttributeError
- **exception** Exception
- **exception** ImportError
- **exception** IndexError
- **exception** KeyboardInterrupt
- **exception** KeyError
- **exception** MemoryError
- **exception** NameError
- **exception** NotImplementedError
- **exception** OSError
- See CPython documentation: OSError. MicroPython doesn’t implement errno attribute, instead use the standard way to access exception arguments: exc.args[0].
- **exception** RuntimeError
- **exception** StopIteration
- **exception** SyntaxError
- **exception** SystemExit
- See CPython documentation: SystemExit.
- **exception** TypeError
- See CPython documentation: TypeError.
- **exception** ValueError
- **exception** ZeroDivisionError
================================================
FILE: docs/std-librarys/cmath.md
================================================
## **cmath** – 复数运算函数功能
`cmath` 模块提供了一些用于复数运算的函数。这个模块中的函数接受整数、浮点数或复数作为参数。他们还将接受任何有复数或浮点方法的 Python 对象:这些方法分别用于将对象转换成复数或浮点数,然后将该函数应用到转换的结果中。
### 函数
#### **cmath.cos**(z)
返回``z``的余弦。
#### **cmath.exp**(z)
返回``z``的指数。
#### **cmath.log**(z)
返回``z``的对数。
#### **cmath.log10**(z)
返回``z``的常用对数。
#### **cmath.phase**(z)
返回``z``的相位, 范围是(-pi, +pi],以弧度表示。
#### **cmath.polar**(z)
返回``z``的极坐标。
#### **cmath.rect**(r, phi)
返回`模量r`和相位``phi``的复数。
#### **cmath.sin**(z)
返回``z``的正弦。
#### **cmath.sqrt**(z)
返回``z``的平方根。
### 常数
#### **cmath.e**
自然对数的指数。
#### **cmath.pi**
圆周率。
更多内容可参考 [cmath](http://docs.micropython.org/en/latest/pyboard/library/cmath.html) 。
================================================
FILE: docs/std-librarys/gc.md
================================================
## **gc** – 控制垃圾回收
**gc** 模块提供了垃圾收集器的控制接口。
### 函数
#### **gc.enable**()
允许自动回收内存碎片。
#### **gc.disable**()
禁止自动回收,但可以通过collect()函数进行手动回收内存碎片。
#### **gc.collect**()
运行一次垃圾回收。
#### **gc.mem_alloc**()
返回已分配的内存数量。
#### **gc.mem_free**()
返回剩余的内存数量。
更多内容可参考 [gc](http://docs.micropython.org/en/latest/pyboard/library/gc.html) 。
================================================
FILE: docs/std-librarys/math.md
================================================
## **math** – 数学函数
**math** 模块提供了对 C 标准定义的数学函数的访问。
> 注意:本模块需要带有硬件 FPU,精度是32位,这个模块需要浮点功能支持。
### 常数
#### **math.e**
自然对数的底数。
示例:
```
>>>import math
>>>print(math.e)
2.718282
```
#### **math.pi**
圆周长与直径的比值。
示例:
```
>>> print(math.pi)
3.141593
```
### 函数
#### **math.acos(x)**
传入弧度值,计算cos(x)的反三角函数。
#### **math.acosh(x)**
返回 ``x`` 的逆双曲余弦。
#### **math.asin(x)**
传入弧度值,计算sin(x)的反三角函数。
示例:
```
>>> x = math.asin(0.5)
>>> print(x)
0.5235988
```
#### **math.asinh(x)**
返回``x`` 的逆双曲正弦。
#### **math.atan(x)**
返回 ``x`` 的逆切线。
#### **math.atan2(y, x)**
Return the principal value of the inverse tangent of y/x.
#### **math.atanh(x)**
Return the inverse hyperbolic tangent of x.
#### **math.ceil(x)**
向上取整。
示例:
```
>>> x = math.ceil(5.6454)
>>> print(x)
6
```
#### **math.copysign(x, y)**
Return x with the sign of y.
#### **math.cos(x)**
传入弧度值,计算余弦。
示例:计算cos60°
```
>>> math.cos(math.radians(60))
0.5
```
#### **math.cosh(x)**
Return the hyperbolic cosine of x.
#### **math.degrees(x)**
弧度转化为角度。
示例:
```
>>> x = math.degrees(1.047198)
>>> print(x)
60.00002
```
#### **math.erf(x)**
Return the error function of x.
#### **math.erfc(x)**
Return the complementary error function of x.
#### **math.exp(x)**
计算e的x次方(幂)。
示例:
```
>>> x = math.exp(2)
>>> print(x)
7.389056
```
#### **math.expm1(x)**
计算 math.exp(x) - 1。
#### **math.fabs(x)**
计算绝对值。
示例:
```
>>> x = math.fabs(-5)
>>> print(x)
5.0
>>> y = math.fabs(5.0)
>>> print(y)
5.0
```
#### **math.floor(x)**
向下取整。
示例:
```
>>> x = math.floor(2.99)
>>> print(x)
2
>>> y = math.floor(-2.34)
>>> print(y)
-3
```
#### **math.fmod(x, y)**
取x除以y的模。
示例:
```
>>> x = math.fmod(4, 5)
>>> print(x)
4.0
```
#### **math.frexp(x)**
Decomposes a floating-point number into its mantissa and exponent. The returned value is the tuple (m, e) such that x == m * 2**e exactly. If x == 0 then the function returns (0.0, 0), otherwise the relation 0.5 <= abs(m) < 1 holds.
#### **math.gamma(x)**
返回伽马函数。
示例:
```
>>> x = math.gamma(5.21)
>>> print(x)
33.08715
```
#### **math.isfinite(x)**
Return True if x is finite.
#### **math.isinf(x)**
Return True if x is infinite.
#### **math.isnan(x)**
Return True if x is not-a-number
#### **math.ldexp(x, exp)**
Return x * (2**exp).
#### **math.lgamma(x)**
返回伽马函数的自然对数。
示例:
```
>>> x = math.lgamma(5.21)
>>> print(x)
3.499145
```
#### **math.log(x)**
计算以e为底的x的对数。
示例:
```
>>> x = math.log(10)
>>> print(x)
2.302585
```
#### **math.log10(x)**
计算以10为底的x的对数。
示例:
```
>>> x = math.log10(10)
>>> print(x)
1.0
```
#### **math.log2(x)**
计算以2为底的x的对数。
示例:
```
>>> x = math.log2(8)
>>> print(x)
3.0
```
#### **math.modf(x)**
Return a tuple of two floats, being the fractional and integral parts of x. Both return values have the same sign as x.
#### **math.pow(x, y)**
计算 x 的 y 次方(幂)。
示例:
```
>>> x = math.pow(2, 3)
>>> print(x)
8.0
```
#### **math.radians(x)**
角度转化为弧度。
示例:
```
>>> x = math.radians(60)
>>> print(x)
1.047198
```
#### **math.sin(x)**
传入弧度值,计算正弦。
示例:计算sin90°
```
>>> math.sin(math.radians(90))
1.0
```
#### **math.sinh(x)**
Return the hyperbolic sine of x.
#### **math.sqrt(x)**
计算平方根。
示例:
```
>>> x = math.sqrt(9)
>>> print(x)
3.0
```
#### **math.tan(x)**
传入弧度值,计算正切。
示例:计算tan60°
```
>>> math.tan(math.radians(60))
1.732051
```
#### **math.tanh(x)**
Return the hyperbolic tangent of x.
#### **math.trunc(x)**
取整。
示例:
```
>>> x = math.trunc(5.12)
>>> print(x)
5
>>> y = math.trunc(-6.8)
>>> print(y)
-6
```
更多内容可参考 [math](http://docs.micropython.org/en/latest/pyboard/library/math.html) 。
================================================
FILE: docs/std-librarys/rtthread.md
================================================
## **rtthread** – 系统相关函数
**rtthread** 模块提供了与 RT-Thread 操作系统相关的功能,如查看栈使用情况等。
### 函数
#### rtthread.current_tid()
返回当前线程的 id 。
#### rtthread.is_preempt_thread()
返回是否是可抢占线程。
#### rtthread.stacks_analyze()
返回当前系统线程和栈使用信息。
### 示例
```
>>> import rtthread
>>>
>>> rtthread.is_preempt_thread() # determine if code is running in a preemptible thread
True
>>> rtthread.current_tid() # current thread id
268464956
>>> rtthread.stacks_analyze() # show thread information
thread pri status sp stack size max used left tick error
---------- --- ------- ---------- ---------- ------ ---------- ---
elog_async 31 suspend 0x000000a8 0x00000400 26% 0x00000003 000
tshell 20 ready 0x00000260 0x00001000 39% 0x00000003 000
tidle 31 ready 0x00000070 0x00000100 51% 0x0000000f 000
SysMonitor 30 suspend 0x000000a4 0x00000200 32% 0x00000005 000
timer 4 suspend 0x00000080 0x00000200 25% 0x00000009 000
>>>
```
================================================
FILE: docs/std-librarys/sys.md
================================================
## **sys** – 系统特有功能函数
**sys** 模块提供系统特有的功能。
### 函数
#### **sys.exit**(retval=0)
终止当前程序给定的退出代码。 函数会抛出 `SystemExit` 异常。
#### **sys.print_exception**(exc, file=sys.stdout)
打印异常与追踪到一个类似文件的对象 file (或者缺省 `sys.stdout` ).
> 提示:这是 CPython 中回溯模块的简化版本。不同于 `traceback.print_exception()`,这个函数用异常值代替了异常类型、异常参数和回溯对象。文件参数在对应位置,不支持更多参数。CPython 兼容回溯模块在 `micropython-lib`。
### 常数
#### **sys.argv**
当前程序启动时参数的可变列表。
#### **sys.byteorder**
系统字节顺序 (“little” or “big”).
#### **sys.implementation**
关于当前 Python 实现的信息,对于 MicroPython 来说,有以下属性:
- 名称 - ‘’micropython“
- 版本 - 元组(主要,次要,小),比如(1,9,3)
#### **sys.modules**
已加载模块的字典。在一部分移植中,它可能不包含内置模块。
#### **sys.path**
用来搜索导入模块地址的列表。
#### **sys.platform**
返回当前平台的信息。
#### **sys.stderr**
标准错误流。
#### **sys.stdin**
标准输入流。
#### **sys.stdout**
标准输出流。
#### **sys.version**
符合的 Python 语言版本,如字符串。
#### **sys.version_info**
本次实现使用的 Python 语言版本,用一个元组的方式表示。
### 示例
```
>>> import sys
>>> sys.version
'3.4.0'
>>> sys.version_info
(3, 4, 0)
>>> sys.path
['', '/libs/mpy/']
>>> sys.__name__
'sys'
>>> sys.platform
'rt-thread'
>>> sys.byteorder
'little'
```
更多内容可参考 [sys](http://docs.micropython.org/en/latest/pyboard/library/sys.html) 。
================================================
FILE: docs/std-librarys/uarray.md
================================================
## **array** – 数字数据数组
**array** 模块定义了一个对象类型,它可以简洁地表示基本值的数组:字符、整数、浮点数。支持代码格式: b, B, h, H, i, I, l, L, q, Q, f, d (最后2个需要支持浮点数)。
### 构造函数
#### **class array.array**(typecode[, iterable])
用给定类型的元素创建数组。数组的初始内容由 iterable 提供,如果没有提供,则创建一个空数组。
```
typecode:数组的类型
iterable:数组初始内容
```
示例:
```python
>>> import array
>>> a = array.array('i', [2, 4, 1, 5])
>>> b = array.array('f')
>>> print(a)
array('i', [2, 4, 1, 5])
>>> print(b)
array('f')
```
### 方法
#### **array.append**(val)
将一个新元素追加到数组的末尾。
示例:
```python
>>> a = array.array('f', [3, 6])
>>> print(a)
array('f', [3.0, 6.0])
>>> a.append(7.0)
>>> print(a)
array('f', [3.0, 6.0, 7.0])
```
#### **array.extend**(iterable)
将一个新的数组追加到数组的末尾,注意追加的数组和原来数组的数据类型要保持一致。
示例:
```python
>>> a = array.array('i', [1, 2, 3])
>>> b = array.array('i', [4, 5])
>>> a.extend(b)
>>> print(a)
array('i', [1, 2, 3, 4, 5])
```
更多内容可参考 [array](http://docs.micropython.org/en/latest/pyboard/library/array.html) 。
================================================
FILE: docs/std-librarys/ubinascii.md
================================================
## **ubinascii** – 二进制/ ASCII转换
`ubinascii` 模块包含许多在二进制和各种 ascii 编码的二进制表示之间转换的方法。
### 函数
#### **ubinascii.hexlify**(data[, sep])
将字符串转换为十六进制表示的字符串。
示例:
```
>>> ubinascii.hexlify('hello RT-Thread')
b'68656c6c6f2052542d546872656164'
>>> ubinascii.hexlify('summer')
b'73756d6d6572'
```
如果指定了第二个参数sep,它将用于分隔两个十六进制数。
示例:
```
如果指定了第二个参数sep,它将用于分隔两个十六进制数。
示例:
>>> ubinascii.hexlify('hello RT-Thread'," ")
b'68 65 6c 6c 6f 20 52 54 2d 54 68 72 65 61 64'
>>> ubinascii.hexlify('hello RT-Thread',",")
b'68,65,6c,6c,6f,20,52,54,2d,54,68,72,65,61,64'
```
#### **ubinascii.unhexlify**(data)
转换十六进制字符串为二进制字符串,功能和 hexlify 相反。
示例:
```
>>> ubinascii.unhexlify('73756d6d6572')
b'summer'
```
#### **ubinascii.a2b_base64**(data)
Base64编码的数据转换为二进制表示。返回字节串。
#### **ubinascii.b2a_base64**(data)
编码base64格式的二进制数据。返回的字符串。
更多内容可参考 [ubinascii](http://docs.micropython.org/en/latest/pyboard/library/ubinascii.html) 。
================================================
FILE: docs/std-librarys/ucollections.md
================================================
## **ucollections** – 集合与容器类型
**ucollections** 模块实现了专门的容器数据类型,它提供了 Python 的通用内置容器的替代方案,包括了字典、列表、集合和元组。
### 类
#### **ucollections.namedtuple**(name, fields)
这是工厂函数创建一个新的 `namedtuple` 型与一个特定的字段名称和集合。`namedtuple` 是元组允许子类要访问它的字段不仅是数字索引,而且还具有属性使用符号字段名访问语法。 字段是字符串序列指定字段名称。为了兼容的实现也可以用空间分隔的字符串命名的字段(但效率较低) 。
代码示例:
```python
from ucollections import namedtuple
MyTuple = namedtuple("MyTuple", ("id", "name"))
t1 = MyTuple(1, "foo")
t2 = MyTuple(2, "bar")
print(t1.name)
assert t2.name == t2[1]
ucollections.OrderedDict(...)
```
#### **ucollections.OrderedDict**(...)
字典类型的子类,会记住并保留键/值的追加顺序。当有序的字典被迭代输出时,键/值 会按照他们被添加的顺序返回 :
```python
from ucollections import OrderedDict
# To make benefit of ordered keys, OrderedDict should be initialized
# from sequence of (key, value) pairs.
d = OrderedDict([("z", 1), ("a", 2)])
# More items can be added as usual
d["w"] = 5
d["b"] = 3
for k, v in d.items():
print(k, v)
```
输出:
z 1
a 2
w 5
b 3
更多的内容可参考 [ucollections](http://docs.micropython.org/en/latest/pyboard/library/ucollections.html) 。
================================================
FILE: docs/std-librarys/uctypes.md
================================================
## **uctypes** – 以结构化的方式访问二进制数据
uctypes 模块用来访问二进制数据结构,它提供 C 兼容的数据类型。
### 常量
- uctypes.LITTLE_ENDIAN — 小端压缩结构。
- uctypes.BIG_ENDIAN — 大端压缩结构类型。
- NATIVE — mricopython 本地的存储类型
### 构造函数
#### class uctypes.struct(addr, descriptor, type)
将内存中以 c 形式打包的结构体或联合体转换为字典,并返回该字典。
```
addr:开始转换的地址
descriptor:转换描述符
格式:"field_name":offset|uctypes.UINT32
offset:偏移量,
单位:字节、VOID、UINT8、INT8、UINT16、INT16、UINT32、INT32、UINT64、INT64、BFUINT8、BFINT8、BFUINT16、BFINT16、BFUINT32、BFINT32、BF_POS、BF_LEN、FLOAT32、FLOAT64、PTR、ARRAY
type:c 结构体或联合体存储类型,默认为本地存储类型
```
示例:
```python
>>> a = b"0123"
>>> s = uctypes.struct(uctypes.addressof(a), {"a": uctypes.UINT8 | 0, "b": uctypes.UINT16 | 1}, uctypes.LITTLE_ENDIAN)
>>> print(s)
<struct STRUCT 3ffc7360>
>>> print(s.a)
48
>>> s.a = 49
>>> print(a)
b'1123'
```
### 方法
#### **uctypes.sizeof**(struct)
按字节返回数据的大小。参数可以是类或者数据对象 (或集合)。
示例:
```python
>>> a = b"0123"
>>>b = uctypes.struct(uctypes.addressof(a), {"a": uctypes.UINT8 | 0, "b": uctypes.UINT16 | 1}, uctypes.LITTLE_ENDIAN)
>>> b.a
48
>>> print(uctypes.sizeof(b))
3
```
#### **uctypes.addressof**(obj)
返回对象地址。参数需要是 bytes, bytearray 。
示例:
```python
>>> a = b"0123"
>>> print(uctypes.addressof(a))
1073504048
```
#### **uctypes.bytes_at**(addr, size)
捕捉从 addr 开始到 size 个地址偏移量结束的内存数据为 bytearray 对象并返回。
示例:
```python
>>> a = b"0123"
>>>print( uctypes.bytes_at(uctypes.addressof(a), 4))
b'0123'
```
#### **uctypes.bytearray_at**(addr, size)
捕捉给定大小和地址内存为 bytearray 对象。与 bytes_at() 函数不同的是,它可以被再次写入,可以访问给定地址的参数。
示例:
```python
>>> a = b"0123"
>>> print(uctypes.bytearray_at(uctypes.addressof(a), 2))
bytearray(b'01')
```
更多内容可参考 [uctypes](http://docs.micropython.org/en/latest/pyboard/library/uctypes.html) 。
================================================
FILE: docs/std-librarys/uerrno.md
================================================
## **uerrno** – 系统错误码模块
`uerrno` 模块提供了标准的 errno 系统符号,每个符号都有对应的整数值。
### 示例
```python
try:
uos.mkdir("my_dir")
except OSError as exc:
if exc.args[0] == uerrno.EEXIST:
print("Directory already exists")
uerrno.errorcode
Dictionary mapping numeric error codes to strings with symbolic error code (see above):
>>> print(uerrno.errorcode[uerrno.EEXIST])
EEXIST
```
更多内容可参考 [uerrno](http://docs.micropython.org/en/latest/pyboard/library/uerrno.html) 。
================================================
FILE: docs/std-librarys/uhashlib.md
================================================
## **uhashlib** – 哈希算法
`uhashlib` 模块实现了二进制数据哈希算法。
### 算法功能
#### **SHA256**
当代的散列算法(SHA2系列),它适用于密码安全的目的。被包含在 MicroPython 内核中,除非有特定的代码大小限制,否则推荐任何开发板都支持这个功能。
#### **SHA1**
上一代的算法,不推荐新的应用使用这种算法,但是 SHA1 算法是互联网标准和现有应用程序的一部分,所以针对网络连接便利的开发板会提供这种功能。
#### **MD5**
一种遗留下来的算法,作为密码使用被认为是不安全的。只有特定的开发板,为了兼容老的应用才会提供这种算法。
### 函数
#### **class uhashlib.sha256**([data])
创建一个SHA256哈希对象并提供 data 赋值。
#### **class uhashlib.sha1**([data])
创建一个SHA1哈希对象并提供 data 赋值。
#### **class uhashlib.md5**([data])
创建一个MD5哈希对象并提供 data 赋值。
#### **hash.update**(data)
将更多二进制数据放入哈希表中。
#### **hash.digest**()
返回字节对象哈希的所有数据。调用此方法后,将无法将更多数据送入哈希。
#### **hash.hexdigest**()
此方法没有实现, 使用 ubinascii.hexlify(hash.digest()) 达到类似效果。
更多内容可参考 [uhashlib](http://docs.micropython.org/en/latest/pyboard/library/uhashlib.html) 。
================================================
FILE: docs/std-librarys/uheapq.md
================================================
## **uheapq** – 堆排序算法
`uheapq` 模块提供了堆排序相关算法,堆队列是一个列表,它的元素以特定的方式存储。
### 函数
#### **uheapq.heappush**(heap, item)
将对象压入堆中。
#### **uheapq.heappop**(heap)
从 heap 弹出第一个元素并返回。 如果是堆时空的会抛出 IndexError。
#### **uheapq.heapify**(x)
将列表 x 转换成堆。
更多内容可参考 [uheapq](http://docs.micropython.org/en/latest/pyboard/library/uheapq.html) 。
================================================
FILE: docs/std-librarys/uio.md
================================================
## **uio** – 输入/输出流
**uio** 模块包含流类型 (类似文件) 对象和帮助函数。
### 函数
#### **uio.open**(name, mode='r', \*\*kwargs)
打开一个文件,关联到内建函数``open()``。所有端口 (用于访问文件系统) 需要支持模式参数,但支持其他参数不同的端口。
### 类
#### **class uio.FileIO**(...)
这个文件类型用二进制方式打开文件,等于使用``open(name, “rb”)``。 不应直接使用这个实例。
#### **class uio.TextIOWrapper**(...)
这个类型以文本方式打开文件,等同于使用``open(name, “rt”)``不应直接使用这个实例。
#### **class uio.StringIO**([string])
#### **class uio.BytesIO**([string])
内存文件对象。`StringIO` 用于文本模式 I/O (用 “t” 打开文件),`BytesIO` 用于二进制方式 (用 “b” 方式)。文件对象的初始内容可以用字符串参数指定(`stringio`用普通字符串,`bytesio`用`bytes`对象)。所有的文件方法,如 `read(), write(), seek(), flush(), close()` 都可以用在这些对象上,包括下面方法:
#### **getvalue**()
获取缓存区内容。
更多内容可参考 [uio](http://docs.micropython.org/en/latest/pyboard/library/uio.html) 。
================================================
FILE: docs/std-librarys/ujson.md
================================================
## **ujson** – JSON编码与解码
`ujson` 模块提供 Python 对象到 JSON(JavaScript Object Notation) 数据格式的转换。
### 函数
#### **ujson.dumps**(obj)
将 dict 类型转换成 str。
```
obj:要转换的对象
```
示例:
```
>>> obj = {1:2, 3:4, "a":6}
>>> print(type(obj), obj) #原来为dict类型
<class 'dict'> {3: 4, 1: 2, 'a': 6}
>>> jsObj = json.dumps(obj) #将dict类型转换成str
>>> print(type(jsObj), jsObj)
<class 'str'> {3: 4, 1: 2, "a": 6}
```
#### **ujson.loads**(str)
解析 JSON 字符串并返回对象。如果字符串格式错误将引发 ValueError 异常。
示例:
```
>>> obj = {1:2, 3:4, "a":6}
>>> jsDumps = json.dumps(obj)
>>> jsLoads = json.loads(jsDumps)
>>> print(type(obj), obj)
<class 'dict'> {3: 4, 1: 2, 'a': 6}
>>> print(type(jsDumps), jsDumps)
<class 'str'> {3: 4, 1: 2, "a": 6}
>>> print(type(jsLoads), jsLoads)
<class 'dict'> {'a': 6, 1: 2, 3: 4}
```
更多内容可参考 [ujson](http://docs.micropython.org/en/latest/pyboard/library/ujson.html) 。
================================================
FILE: docs/std-librarys/uos.md
================================================
## **uos** – 基本的操作系统服务
`uos` 模块包含了对文件系统的访问操作,是对应 CPython 模块的一个子集。
### 函数
#### **uos.chdir**(path)
更改当前目录。
#### **uos.getcwd**()
获取当前目录。
#### **uos.listdir**([dir])
没有参数就列出当前目录,否则列出给定目录。
#### **uos.mkdir**(path)
创建一个目录。
#### **uos.remove**(path)
删除文件。
#### **uos.rmdir**(path)
删除目录。
#### **uos.rename**(old_path, new_path)
重命名文件或者文件夹。
#### **uos.stat**(path)
获取文件或目录的状态。
#### **uos.sync**()
同步所有的文件系统。
### 示例
```
>>> import uos
>>> uos. # Tab
__name__ uname chdir getcwd
listdir mkdir remove rmdir
stat unlink mount umount
>>> uos.mkdir("rtthread")
>>> uos.getcwd()
'/'
>>> uos.chdir("rtthread")
>>> uos.getcwd()
'/rtthread'
>>> uos.listdir()
['web_root', 'rtthread', '11']
>>> uos.rmdir("11")
>>> uos.listdir()
['web_root', 'rtthread']
>>>
```
更多内容可参考 [uos](http://docs.micropython.org/en/latest/pyboard/library/uos.html) 。
================================================
FILE: docs/std-librarys/urandom.md
================================================
## **urandom** - 随机数生成模块
`urandom` 模块实现了伪随机数生成器。
### 函数
#### **urandom.choice**(obj)
随机生成对象 obj 中的元数。
```
obj:元数列表
```
示例:
```python
>>> print(random.choice("DFRobot"))
R
>>> print(random.choice("DFRobot"))
D
>>> print(random.choice([0, 2, 4, 3]))
3
>>> print(random.choice([0, 2, 4, 3]))
3
>>> print(random.choice([0, 2, 4, 3]))
2
```
#### **urandom.getrandbits**(size)
随机生成 0 到 size 个位二进制数范围内的正整数。 比如 :
- size = 4,那么便是从 0 到0b1111中随机一个正整数。
- size = 8,那么便是从 0 到 0b11111111中随机一个正整数。
```python
size:位大小
```
示例:
```python
>>> print( random.getrandbits(1)) #1位二进制位,范围为0~1(十进制:0~1)
1
>>> print(random.getrandbits(1))
0
>>> print(random.getrandbits(8)) #8位二进制位,范围为0000 0000~1111 11111(十进制:0~255)
224
>>> print(random.getrandbits(8))
155
```
#### **urandom.randint**(start, end)
随机生成一个 start 到 end 之间的整数。
```
start:指定范围内的开始值,包含在范围内
end:指定范围内的结束值,包含在范围内
```
示例:
```python
>>> import random
>>> print(random.randint(1, 4))
4
>>> print(random.randint(1, 4))
2
```
#### **urandom.random**()
随机生成一个 0 到 1 之间的浮点数。
示例:
```python
>>> print(random.random())
0.7111824
>>> print(random.random())
0.3168149
```
#### **urandom.randrange**(start, end, step)
随机生成 start 到 end 并且递增为 step 的范围内的正整数。例如,randrange(0, 8, 2)中,随机生成的数为 0、2、4、6 中任一个。
```
start:指定范围内的开始值,包含在范围内
end:指定范围内的结束值,包含在范围内
step:递增基数
```
示例:
```python
>>> print(random.randrange(2, 8, 2))
4
>>> print(random.randrange(2, 8, 2))
6
>>> print(random.randrange(2, 8, 2))
2
```
#### **urandom.seed**(sed)
指定随机数种子,通常和其他随机数生成函数搭配使用。
**注意:**
MicroPython 中的随机数其实是一个稳定算法得出的稳定结果序列,而不是一个随机序列。sed 就是这个算法开始计算的第一个值。所以就会出现只要 sed 是一样的,那么后续所有“随机”结果和顺序也都完全一致。
```
sed:随机数种子
```
示例:
```python
import random
for j in range(0, 2):
random.seed(13) #指定随机数种子
for i in range(0, 10): #生成0到10范围内的随机序列
print(random.randint(1, 10))
print("end")
```
运行结果:
```
5
2
3
2
3
4
2
5
8
2
end
5
2
3
2
3
4
2
5
8
2
end
```
从上面可以看到生成两个随机数列表是一样的,你也可以多生成几个随机数列表查看结果。
#### **urandom.uniform**(start, end)
随机生成start到end之间的浮点数。
```
start:指定范围内的开始值,包含在范围内
stop:指定范围内的结束值,包含在范围内
```
示例:
```python
>>> print(random.uniform(2, 4))
2.021441
>>> print(random.uniform(2, 4))
3.998012
```
更多内容可参考 [urandom](https://docs.python.org/3/library/random.html?highlight=random#module-random) 。
================================================
FILE: docs/std-librarys/ure.md
================================================
## **ure** – 正则表达式
`ure` 模块用于测试字符串的某个模式,执行正则表达式操作。
### 匹配字符集
#### 匹配任意字符
``'.'``
#### 匹配字符集合,支持单个字符和一个范围
``'[]'``
#### 支持多种匹配元字符
``'^'``
``'$'``
``'?'``
``'*'``
``'+'``
``'??'``
``'*?'``
``'+?'``
``'{m,n}'``
### 函数
#### **ure.compile**(regex)
编译正则表达式,返回 regex 对象。
#### **ure.match**(regex, string)
用 string 匹配 regex,匹配总是从字符串的开始匹配。
#### **ure.search**(regex, string)
在 string 中搜索 regex。不同于匹配,它搜索第一个匹配位置的正则表达式字符串 (结果可能会是0)。
#### **ure.DEBUG**
标志值,显示表达式的调试信息。
### **正则表达式对象**:
编译正则表达式,使用 `ure.compile()` 创建实例。
#### **regex.match**(string)
#### **regex.search**(string)
#### **regex.split**(string, max_split=-1)
### **匹配对象** :
匹配对象是 match() 和 search() 方法的返回值。
#### **match.group**([index])
只支持数字组。
更多内容可参考 [ure](http://docs.micropython.org/en/latest/pyboard/library/ure.html) 。
================================================
FILE: docs/std-librarys/uselect.md
================================================
## **uselect** – 等待流事件
`uselect` 模块提供了等待数据流的事件功能。
### 常数
#### **select.POLLIN** - 读取可用数据
#### **select.POLLOUT** - 写入更多数据
#### **select.POLLERR** - 发生错误
#### **select.POLLHUP** - 流结束/连接终止检测
### 函数
#### **select.select**(rlist, wlist, xlist[, timeout])
监控对象何时可读或可写,一旦监控的对象状态改变,返回结果(阻塞线程)。这个函数是为了兼容,效率不高,推荐用 `poll` 函数 。
```
rlist:等待读就绪的文件描述符数组
wlist:等待写就绪的文件描述符数组
xlist:等待异常的数组
timeout:等待时间(单位:秒)
```
示例:
```python
def selectTest():
global s
rs, ws, es = select.select([s,], [], [])
#程序会在此等待直到对象s可读
print(rs)
for i in rs:
if i == s:
print("s can read now")
data,addr=s.recvfrom(1024)
print('received:',data,'from',addr)
```
### Poll 类
#### **select.poll**()
创建 poll 实例。
示例:
```
>>>poller = select.poll()
>>>print(poller)
<poll>
```
#### **poll.register**(obj[, eventmask])
注册一个用以监控的对象,并设置被监控对象的监控标志位 flag。
```
obj:被监控的对象
flag:被监控的标志
select.POLLIN — 可读
select.POLLHUP — 已挂断
select.POLLERR — 出错
select.POLLOUT — 可写
```
#### **poll.unregister**(obj)
解除监控的对象的注册。
```
obj:注册过的对象
```
示例:
```
>>>READ_ONLY = select.POLLIN | select.POLLHUP | select.POLLERR
>>>READ_WRITE = select.POLLOUT | READ_ONLY
>>>poller.register(s, READ_WRITE)
>>>poller.unregister(s)
```
#### **poll.modify**(obj, eventmask)
修改已注册的对象监控标志。
```
obj:已注册的被监控对象
flag:修改为的监控标志
```
示例:
```
>>>READ_ONLY = select.POLLIN | select.POLLHUP | select.POLLERR
>>>READ_WRITE = select.POLLOUT | READ_ONLY
>>>poller.register(s, READ_WRITE)
>>>poller.modify(s, READ_ONLY)
```
#### **poll.poll**([timeout])
等待至少一个已注册的对象准备就绪。返回 (obj, event, ...) 元组, event 元素指定了一个流发生的事件,是上面所描述的 `select.POLL*`常量组合。 根据平台和版本的不同,在元组中可能有其他元素,所以不要假定元组的大小是 2 。如果超时,则返回空列表。
更多内容可参考 [uselect](http://docs.micropython.org/en/latest/pyboard/library/uselect.html) 。
================================================
FILE: docs/std-librarys/usocket.md
================================================
## **usocket** – 套接字模块
`usocket` 模块提供对BSD套接字接口的访问。
### 常数
#### 地址簇
- socket.AF_INET =2 — TCP/IP – IPv4
- socket.AF_INET6 =10 — TCP/IP – IPv6
#### 套接字类型
- socket.SOCK_STREAM =1 — TCP流
- socket.SOCK_DGRAM =2 — UDP数据报
- socket.SOCK_RAW =3 — 原始套接字
- socket.SO_REUSEADDR =4 — socket可重用
#### IP协议号
- socket.IPPROTO_TCP =16
- socket.IPPROTO_UDP =17
#### 套接字选项级别
- socket.SOL_SOCKET =4095
### 函数
#### **socket.socket**
`socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)`
创建新的套接字,使用指定的地址、类型和协议号。
#### **socket.getaddrinfo**(host, port)
将主机域名(host)和端口(port)转换为用于创建套接字的5元组序列。元组列表的结构如下:
```
(family, type, proto, canonname, sockaddr)
```
示例:
```
>>> info = socket.getaddrinfo("rt-thread.org", 10000)
>>> print(info)
[(2, 1, 0, '', ('118.31.15.152', 10000))]
```
#### **socket.close**()
关闭套接字。一旦关闭后,套接字所有的功能都将失效。远端将接收不到任何数据 (清理队列数据后)。 虽然在垃圾回收时套接字会自动关闭,但还是推荐在必要时用 close() 去关闭。
#### **socket.bind**(address)
将套接字绑定到地址,套接字不能是已经绑定的。
#### **socket.listen**([backlog])
监听套接字,使服务器能够接收连接。
```
backlog:接受套接字的最大个数,至少为0,如果没有指定,则默认一个合理值。
```
#### **socket.accept**()
接收连接请求。
**注意:**
只能在绑定地址端口号和监听后调用,返回 conn 和 address。
```
conn:新的套接字对象,可以用来收发消息
address:连接到服务器的客户端地址
```
#### **socket.connect**(address)
连接服务器。
```
address:服务器地址和端口号的元组或列表
```
#### **socket.send**(bytes)
发送数据,并返回成功发送的字节数,返回字节数可能比发送的数据长度少。
```
bytes:bytes类型数据
```
#### **socket.recv**(bufsize)
接收数据,返回接收到的数据对象。
```
bufsize:指定一次接收的最大数据量
```
示例:
```
data = conn.recv(1024)
```
#### **socket.sendto**(bytes, address)
发送数据,目标由address决定,常用于UDP通信,返回发送的数据大小。
```
bytes:bytes类型数据
address:目标地址和端口号的元组
```
示例:
```
data = sendto("hello RT-Thread", ("192.168.10.110", 100))
```
#### **socket.recvfrom**(bufsize)
接收数据,常用于UDP通信,并返回接收到的数据对象和对象的地址。
```
bufsize:指定一次接收的最大数据量
```
示例:
```
data,addr=fd.recvfrom(1024)
```
#### **socket.setsockopt**(level, optname, value)
根据选项值设置套接字。
```
level:套接字选项级别
optname:套接字的选项
value:可以是一个整数,也可以是一个表示缓冲区的bytes类对象。
```
示例:
```
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
```
#### **socket.settimeout**(value)
设置超时时间,单位:秒。
示例:
```
s.settimeout(2)
```
#### **socket.setblocking**(flag)
设置阻塞或非阻塞模式: 如果 flag 是 false,设置非阻塞模式。
#### **socket.read**([size])
Read up to size bytes from the socket. Return a bytes object. If size is not given, it reads all data available from the socket until EOF; as such the method will not return until the socket is closed. This function tries to read as much data as requested (no “short reads”). This may be not possible with non-blocking socket though, and then less data will be returned.
#### **socket.readinto**(buf[, nbytes])
Read bytes into the buf. If nbytes is specified then read at most that many bytes. Otherwise, read at most len(buf) bytes. Just as read(), this method follows “no short reads” policy.
Return value: number of bytes read and stored into buf.
#### **socket.readline**()
接收一行数据,遇换行符结束,并返回接收数据的对象 。
#### **socket.write**(buf)
将字节类型数据写入套接字,并返回写入成功的数据大小。
### 示例
#### TCP Server example
```
>>> import usocket
>>> s = usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM) # Create STREAM TCP socket
>>> s.bind(('192.168.12.32', 6001))
>>> s.listen(5)
>>> s.setblocking(True)
>>> sock,addr=s.accept()
>>> sock.recv(10)
b'rt-thread\r'
>>> s.close()
```
#### TCP Client example
```
>>> import usocket
>>> s = usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM)
>>> s.connect(("192.168.10.110",6000))
>>> s.send("micropython")
11
>>> s.close()
```
`connect to a web site example`:
```
s = socket.socket()
s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1])
```
更多的内容可参考 [usocket](http://docs.micropython.org/en/latest/pyboard/library/usocket.html) 。
================================================
FILE: docs/std-librarys/ussl.md
================================================
# ussl – SSL/TLS 模块
This module implements a subset of the corresponding* [`CPython`](http://docs.micropython.org/en/latest/reference/glossary.html#term-cpython) *module, as described below. For more information, refer to the original CPython documentation: [`ssl`](https://docs.python.org/3.5/library/ssl.html#module-ssl).
This module provides access to Transport Layer Security (previously and widely known as “Secure Sockets Layer”) encryption and peer authentication facilities for network sockets, both client-side and server-side.
## 功能函数
- `ussl.wrap_socket`(sock, server_side=False, key=None, cert=None)
Takes a [`stream`](http://docs.micropython.org/en/latest/reference/glossary.html#term-stream) *sock* (usually usocket.socket instance of `SOCK_STREAM` type), and returns an instance of ssl.SSLSocket, which wraps the underlying stream in an SSL context. Returned object has the usual [`stream`](http://docs.micropython.org/en/latest/reference/glossary.html#term-stream) interface methods like `read()`, `write()`, etc. In MicroPython, the returned object does not expose socket interface and methods like `recv()`, `send()`. In particular, a server-side SSL socket should be created from a normal socket returned from[`accept()`](http://docs.micropython.org/en/latest/library/usocket.html#usocket.socket.accept) on a non-SSL listening server socket. Depending on the underlying module implementation in a particular [`MicroPython port`](http://docs.micropython.org/en/latest/reference/glossary.html#term-micropython-port), some or all keyword arguments above may be not supported.
Warning: Some implementations of `ussl` module do NOT validate server certificates, which makes an SSL connection established prone to man-in-the-middle attacks.
## 异常类型
- `ssl.SSLError`
This exception does NOT exist. Instead its base class, OSError, is used.
## 常量
- `ussl.CERT_NONE`
- `ussl.CERT_OPTIONAL`
- `ussl.CERT_REQUIRED`
- Supported values for **cert_reqs** parameter.
================================================
FILE: docs/std-librarys/ustruct.md
================================================
## **ustruct** – 打包和解包原始数据类型
**ustruct** 模块在 Python 值和以 Python 字节对象表示的 C 结构之间执行转换。
- 支持 size/byte 的前缀: @, <, >, !.
- 支持的格式代码: b, B, h, H, i, I, l, L, q, Q, s, P, f, d (最后2个需要支持浮点数).
### 函数
#### **ustruct.calcsize**(fmt)
返回存放某一类型数据 fmt 需要的字节数。
```
fmt:数据类型
b — 字节型
B — 无符号字节型
h — 短整型
H — 无符号短整型
i — 整型
I — 无符号整型
l — 整型
L — 无符号整型
q — 长整型
Q — 无符号长整型
f — 浮点型
d — 双精度浮点型
P — 无符号型
```
示例:
```python
>>> print(struct.calcsize("i"))
4
>>> print(struct.calcsize("B"))
1
```
#### **ustruct.pack**(fmt, v1, v2, ...)
按照格式字符串 fmt 打包参数 v1, v2, ... 。返回值是参数打包后的字节对象。
```
fmt:同上
```
示例:
```python
>>> struct.pack("ii", 3, 2)
b'\x03\x00\x00\x00\x02\x00\x00\x00'
```
#### **ustruct.unpack**(fmt, data)
从 fmt 中解包数据。返回值是解包后参数的元组。
```
data:要解压的字节对象
```
示例:
```python
>>> buf = struct.pack("bb", 1, 2)
>>> print(buf)
b'\x01\x02'
>>> print(struct.unpack("bb", buf))
(1, 2)
```
#### **ustruct.pack_into**(fmt, buffer, offset, v1, v2, ...)
按照格式字符串 fmt 压缩参数 v1, v2, ... 到缓冲区 buffer,开始位置是 offset。当offset 为负数时,从缓冲区末尾开始计数。
#### **ustruct.unpack_from**(fmt, data, offset=0)
以 fmt 作为规则从 data 的 offset 位置开始解包数据,如果 offset 是负数就是从缓冲区末尾开始计算。返回值是解包后的参数元组。
```python
>>> buf = struct.pack("bb", 1, 2)
>>> print(struct.unpack("bb", buf))
(1, 2)
>>> print(struct.unpack_from("b", buf, 1))
(2,)
```
更多的内容可参考 [ustruct](http://docs.micropython.org/en/latest/pyboard/library/ustruct.html) 。
================================================
FILE: docs/std-librarys/utime.md
================================================
## **utime** – 时间相关函数
**utime** 模块提供获取当前时间和日期、测量时间间隔和延迟的功能。
**初始时刻**: `Unix` 使用 `POSIX` 系统标准,从 1970-01-01 00:00:00 `UTC` 开始。
嵌入式程序从 2000-01-01 00:00:00 `UTC` 开始。
**保持实际日历日期/时间**:需要一个实时时钟 `(RTC)`。在底层系统 (包括一些 `RTOS` 中),`RTC` 已经包含在其中。设置时间是通过 `OS/RTOS` 而不是 MicroPython 完成,查询日期/时间也需要通过系统 `API`。对于裸板系统时钟依赖于 ``machine.RTC()`` 对象。设置时间通过 ``machine.RTC().datetime(tuple)`` 函数,并通过下面方式维持:
* 后备电池 (可能是选件、扩展板等)。
* 使用网络时间协议 (需要用户设置)。
* 每次上电时手工设置 (大部分只是在硬复位时需要设置,少部分每次复位都需要设置)。
如果实际时间不是通过系统 / MicroPython RTC 维持,那么下面函数结果可能不是和预期的相同。
### 函数
#### **utime.localtime**([secs])
从初始时间的秒转换为元组: (年, 月, 日, 时, 分, 秒, 星期, ``yearday``) 。如果 ``secs`` 是空或者 ``None``,那么使用当前时间。
- `year ` 年份包括世纪(例如2014)。
- `month` 范围 1-12
- `day` 范围 1-31
- `hour` 范围 0-23
- `minute` 范围 0-59
- `second` 范围 0-59
- `weekday` 范围 0-6 对应周一到周日
- `yearday` 范围 1-366
#### **utime.mktime**()
时间的反函数,它的参数是完整8参数的元组,返回值一个整数自2000年1月1日以来的秒数。
#### **utime.sleep**(seconds)
休眠指定的时间(秒),``Seconds`` 可以是浮点数。注意有些版本的 MicroPython不支持浮点数,为了兼容可以使用 ``sleep_ms()`` 和 ``sleep_us()``函数。
#### **utime.sleep_ms**(ms)
延时指定毫秒,参数不能小于0。
#### **utime.sleep_us**(us)
延时指定微秒,参数不能小于0。
#### **utime.ticks_ms**()
返回不断递增的毫秒计数器,在某些值后会重新计数(未指定)。计数值本身无特定意义,只适合用在``ticks_diff()``。
注: 直接在这些值上执行标准数学运算(+,-)或关系运算符(<,>,>,> =)会导致无效结果。执行数学运算然后传递结果作为参数给`ticks_diff()` 或 ` ticks_add() ` 也将导致函数产生无效结果。
#### **utime.ticks_us**()
和上面 `ticks_ms()` 类似,只是返回微秒。
#### **utime.ticks_cpu**()
与 ``ticks_ms()`` 和 ``ticks_us()`` 类似,具有更高精度 (使用 CPU 时钟),并非每个端口都实现此功能。
#### **utime.ticks_add**(ticks, delta)
给定一个数字作为节拍的偏移值 `delta`,这个数字的值是正数或者负数都可以。
给定一个 `ticks` 节拍值,本函数允许根据节拍值的模算数定义来计算给定节拍值之前或者之后 `delta` 个节拍的节拍值 。
`ticks` 参数必须是 `ticks_ms()`, `ticks_us()`, or `ticks_cpu()` 函数的直接返回值。然而,`delta` 可以是一个任意整数或者是数字表达式。`ticks_add` 函数对计算事件/任务的截至时间很有用。(注意:必须使用 `ticksdiff()` 函数来处理
最后期限)。
代码示例:
```python
## 查找 100ms 之前的节拍值
print(utime.ticks_add(utime.ticks_ms(), -100))
## 计算操作的截止时间然后进行测试
deadline = utime.ticks_add(utime.ticks_ms(), 200)
while utime.ticks_diff(deadline, utime.ticks_ms()) > 0:
do_a_little_of_something()
## 找出本次移植节拍值的最大值
print(utime.ticks_add(0, -1))
```
#### **utime.ticks_diff**(ticks1, ticks2)
计算两次调用 `ticksms()`, `ticks_us()`, 或 `ticks_cpu()`之间的时间。因为这些函数的计数值可能会回绕,所以不能直接相减,需要使用 `ticks_diff()` 函数。“旧” 时间需要在 “新” 时间之前,否则结果无法确定。这个函数不要用在计算很长的时间 (因为 `ticks*()` 函数会回绕,通常周期不是很长)。通常用法是在带超时的轮询事件中调用:
代码示例:
```python
## 等待 GPIO 引脚有效,但是最多等待500微秒
start = time.ticks_us()
while pin.value() == 0:
if time.ticks_diff(time.ticks_us(), start) > 500:
raise TimeoutError
```
#### **utime.time**()
返回从开始时间的秒数(整数),假设 `RTC` 已经按照前面方法设置好。如果 `RTC` 没有设置,函数将返回参考点开始计算的秒数 (对于 `RTC` 没有后备电池的板子,上电或复位后的情况)。如果你开发便携版的 MicroPython 应用程序,你不要依赖函数来提供超过秒级的精度。如果需要高精度,使用 `ticks_ms()` 和 `ticks_us()` 函数。如果需要日历时间,使用不带参数的 `localtime()` 是更好选择。
!!! tip "与 CPython 的区别"
在 `CPython` 中,这个函数用浮点数返回从 `Unix` 开始时间(1970-01-01 00:00 `UTC`)的秒数,通常是毫秒级的精度。在 MicroPython 中,只有 `Unix` 版才使用相同开始时间,如果允许浮点精度,将返回亚秒精度。嵌入式硬件通常没有用浮点数表示长时间访问和亚秒精度,所以返回值是整数。一些嵌入式系统硬件不支持 `RTC` 电池供电方式,所以返回的秒数是从最后上电、或相对某个时间、以及特定硬件时间 (如复位)。
### 示例
```
>>> import utime
>>> utime.sleep(1) # sleep for 1 second
>>> utime.sleep_ms(500) # sleep for 500 milliseconds
>>> utime.sleep_us(10) # sleep for 10 microseconds
>>> start = utime.ticks_ms() # get value of millisecond counter
>>> delta = utime.ticks_diff(utime.ticks_ms(), start) # compute time difference
>>> delta
6928
>>> print(utime.ticks_add(utime.ticks_ms(), -100))
1140718
>>> print(utime.ticks_add(0, -1))
1073741823
```
更多内容可参考 [`utime`](http://docs.micropython.org/en/latest/pyboard/library/utime.html#module-utime) 。
================================================
FILE: docs/std-librarys/uzlib.md
================================================
## **uzlib** – zlib 解压缩
`uzlib` 模块实现了使用 DEFLATE 算法解压缩二进制数据 (常用的 zlib 库和 gzip 文档)。目前不支持压缩。
### 函数
#### **uzlib.decompress**(data)
返回解压后的 bytes 数据。
更多内容可参考 [uzlib](http://docs.micropython.org/en/latest/pyboard/library/uzlib.html) 。
================================================
FILE: docs/tools-mpy-cross.md
================================================
# 生成并运行 .mpy 文件
Python 工程中,.py 文件可以被编译成 .pyc 字节码文件。使用这类预先编译好的二进制文件的优势是一定程度上能够保护源代码,同时可以提高程序的加载速度。在 micropython 中同样地提供了类似的功能,能够将 .py 文件编译成 .mpy 文件,并且能够在 MCU 内直接运行,减少资源消耗的同时提高了程序的加载速度。本篇演示使用潘多拉开发板,以 hello world 工程为例,编译并运行该 demo。
## 使用 mpy-cross 工具编译
RT-Thread 为开发者提供了便利的开发环境 ,针对 windows 平台提供了可以直接运行的 mpy-cross.exe,无需拖带 Linux 环境,轻量且速度快。
本文将在 windows 环境中,使用软件包中提供的 mpy-cross.exe 软件。
在 RT-Thread/micropython 项目里找到 tools 文件夹,下载 mpy-cross.exe。
这里以 `hellortt.py` 示例:
```python
class HelloRtt:
def __repr__(self):
self.__call__()
return ""
def __call__(self):
print("hello world!!")
print("hello RTT")
hello = HelloRtt()
```
首先将需要被编译的 `hellortt.py` 文件拖入到 mpy-cross.exe 所在文件夹中,在按住 shift 键的同时,点击鼠标右键,选择 `在此处打开 Powershell 窗口`( cmd 窗口在这里也是可以使用的)。然后在 Powershell 中,键入 `.\mpy-cross.exe` 后面接上需要编译的工程 `hellortt.py`:

此时如果编译成功将会生成 mpy 文件,上图编译成功后,在文件夹中生成了 `hellortt.mpy` 文件。我们将 `hellortt.mpy` 拷贝到 MCU 的文件系统上,便可以像 .py 文件一样被 import 并调用。
## 拷贝至 MCU 文件系统中
将生成好的 .mpy 文件,拷贝至 MicroPython IDE 的工程中,并选中它,右键下载到开发板的文件系统中,如图:

当下载完成之后,便可以在串口命令行中尝试 import 该 mpy 文件,执行该文件的函数,确认能够正常使用:

如果运行时出现 `ValueError: invalid .mpy file` 错误,有可能是 MCU 上 的 micropython 固件与 mpy-cross 版本固件不相符所致,当前提供的 mpy-cross 工具支持 v1.12 版本的固件 。
================================================
FILE: drivers/bus/qspi.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_DRIVERS_BUS_QSPI_H
#define MICROPY_INCLUDED_DRIVERS_BUS_QSPI_H
#include "py/mphal.h"
enum {
MP_QSPI_IOCTL_INIT,
MP_QSPI_IOCTL_DEINIT,
MP_QSPI_IOCTL_BUS_ACQUIRE,
MP_QSPI_IOCTL_BUS_RELEASE,
};
typedef struct _mp_qspi_proto_t {
int (*ioctl)(void *self, uint32_t cmd);
void (*write_cmd_data)(void *self, uint8_t cmd, size_t len, uint32_t data);
void (*write_cmd_addr_data)(void *self, uint8_t cmd, uint32_t addr, size_t len, const uint8_t *src);
uint32_t (*read_cmd)(void *self, uint8_t cmd, size_t len);
void (*read_cmd_qaddr_qdata)(void *self, uint8_t cmd, uint32_t addr, size_t len, uint8_t *dest);
} mp_qspi_proto_t;
typedef struct _mp_soft_qspi_obj_t {
mp_hal_pin_obj_t cs;
mp_hal_pin_obj_t clk;
mp_hal_pin_obj_t io0;
mp_hal_pin_obj_t io1;
mp_hal_pin_obj_t io2;
mp_hal_pin_obj_t io3;
} mp_soft_qspi_obj_t;
extern const mp_qspi_proto_t mp_soft_qspi_proto;
#endif // MICROPY_INCLUDED_DRIVERS_BUS_QSPI_H
================================================
FILE: drivers/bus/softqspi.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "drivers/bus/qspi.h"
#define CS_LOW(self) mp_hal_pin_write(self->cs, 0)
#define CS_HIGH(self) mp_hal_pin_write(self->cs, 1)
#ifdef MICROPY_HW_SOFTQSPI_SCK_LOW
// Use externally provided functions for SCK control and IO reading
#define SCK_LOW(self) MICROPY_HW_SOFTQSPI_SCK_LOW(self)
#define SCK_HIGH(self) MICROPY_HW_SOFTQSPI_SCK_HIGH(self)
#define NIBBLE_READ(self) MICROPY_HW_SOFTQSPI_NIBBLE_READ(self)
#else
// Use generic pin functions for SCK control and IO reading
#define SCK_LOW(self) mp_hal_pin_write(self->clk, 0)
#define SCK_HIGH(self) mp_hal_pin_write(self->clk, 1)
#define NIBBLE_READ(self) ( \
mp_hal_pin_read(self->io0) \
| (mp_hal_pin_read(self->io1) << 1) \
| (mp_hal_pin_read(self->io2) << 2) \
| (mp_hal_pin_read(self->io3) << 3))
#endif
STATIC void nibble_write(mp_soft_qspi_obj_t *self, uint8_t v) {
mp_hal_pin_write(self->io0, v & 1);
mp_hal_pin_write(self->io1, (v >> 1) & 1);
mp_hal_pin_write(self->io2, (v >> 2) & 1);
mp_hal_pin_write(self->io3, (v >> 3) & 1);
}
STATIC int mp_soft_qspi_ioctl(void *self_in, uint32_t cmd) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
switch (cmd) {
case MP_QSPI_IOCTL_INIT:
mp_hal_pin_high(self->cs);
mp_hal_pin_output(self->cs);
// Configure pins
mp_hal_pin_write(self->clk, 0);
mp_hal_pin_output(self->clk);
//mp_hal_pin_write(self->clk, 1);
mp_hal_pin_output(self->io0);
mp_hal_pin_input(self->io1);
mp_hal_pin_write(self->io2, 1);
mp_hal_pin_output(self->io2);
mp_hal_pin_write(self->io3, 1);
mp_hal_pin_output(self->io3);
break;
}
return 0; // success
}
STATIC void mp_soft_qspi_transfer(mp_soft_qspi_obj_t *self, size_t len, const uint8_t *src, uint8_t *dest) {
// Will run as fast as possible, limited only by CPU speed and GPIO time
mp_hal_pin_input(self->io1);
mp_hal_pin_output(self->io0);
if (self->io3) {
mp_hal_pin_write(self->io2, 1);
mp_hal_pin_output(self->io2);
mp_hal_pin_write(self->io3, 1);
mp_hal_pin_output(self->io3);
}
if (src) {
for (size_t i = 0; i < len; ++i) {
uint8_t data_out = src[i];
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j, data_out <<= 1) {
mp_hal_pin_write(self->io0, (data_out >> 7) & 1);
mp_hal_pin_write(self->clk, 1);
data_in = (data_in << 1) | mp_hal_pin_read(self->io1);
mp_hal_pin_write(self->clk, 0);
}
if (dest != NULL) {
dest[i] = data_in;
}
}
} else {
for (size_t i = 0; i < len; ++i) {
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j) {
mp_hal_pin_write(self->clk, 1);
data_in = (data_in << 1) | mp_hal_pin_read(self->io1);
mp_hal_pin_write(self->clk, 0);
}
if (dest != NULL) {
dest[i] = data_in;
}
}
}
}
STATIC void mp_soft_qspi_qread(mp_soft_qspi_obj_t *self, size_t len, uint8_t *buf) {
// Make all IO lines input
mp_hal_pin_input(self->io2);
mp_hal_pin_input(self->io3);
mp_hal_pin_input(self->io0);
mp_hal_pin_input(self->io1);
// Will run as fast as possible, limited only by CPU speed and GPIO time
while (len--) {
SCK_HIGH(self);
uint8_t data_in = NIBBLE_READ(self);
SCK_LOW(self);
SCK_HIGH(self);
*buf++ = (data_in << 4) | NIBBLE_READ(self);
SCK_LOW(self);
}
}
STATIC void mp_soft_qspi_qwrite(mp_soft_qspi_obj_t *self, size_t len, const uint8_t *buf) {
// Make all IO lines output
mp_hal_pin_output(self->io2);
mp_hal_pin_output(self->io3);
mp_hal_pin_output(self->io0);
mp_hal_pin_output(self->io1);
// Will run as fast as possible, limited only by CPU speed and GPIO time
for (size_t i = 0; i < len; ++i) {
nibble_write(self, buf[i] >> 4);
SCK_HIGH(self);
SCK_LOW(self);
nibble_write(self, buf[i]);
SCK_HIGH(self);
SCK_LOW(self);
}
//mp_hal_pin_input(self->io1);
}
STATIC void mp_soft_qspi_write_cmd_data(void *self_in, uint8_t cmd, size_t len, uint32_t data) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint32_t cmd_buf = cmd | data << 8;
CS_LOW(self);
mp_soft_qspi_transfer(self, 1 + len, (uint8_t*)&cmd_buf, NULL);
CS_HIGH(self);
}
STATIC void mp_soft_qspi_write_cmd_addr_data(void *self_in, uint8_t cmd, uint32_t addr, size_t len, const uint8_t *src) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint8_t cmd_buf[4] = {cmd, addr >> 16, addr >> 8, addr};
CS_LOW(self);
mp_soft_qspi_transfer(self, 4, cmd_buf, NULL);
mp_soft_qspi_transfer(self, len, src, NULL);
CS_HIGH(self);
}
STATIC uint32_t mp_soft_qspi_read_cmd(void *self_in, uint8_t cmd, size_t len) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint32_t cmd_buf = cmd;
CS_LOW(self);
mp_soft_qspi_transfer(self, 1 + len, (uint8_t*)&cmd_buf, (uint8_t*)&cmd_buf);
CS_HIGH(self);
return cmd_buf >> 8;
}
STATIC void mp_soft_qspi_read_cmd_qaddr_qdata(void *self_in, uint8_t cmd, uint32_t addr, size_t len, uint8_t *dest) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint8_t cmd_buf[7] = {cmd, addr >> 16, addr >> 8, addr};
CS_LOW(self);
mp_soft_qspi_transfer(self, 1, cmd_buf, NULL);
mp_soft_qspi_qwrite(self, 6, &cmd_buf[1]); // 3 addr bytes, 1 extra byte (0), 2 dummy bytes (4 dummy cycles)
mp_soft_qspi_qread(self, len, dest);
CS_HIGH(self);
}
const mp_qspi_proto_t mp_soft_qspi_proto = {
.ioctl = mp_soft_qspi_ioctl,
.write_cmd_data = mp_soft_qspi_write_cmd_data,
.write_cmd_addr_data = mp_soft_qspi_write_cmd_addr_data,
.read_cmd = mp_soft_qspi_read_cmd,
.read_cmd_qaddr_qdata = mp_soft_qspi_read_cmd_qaddr_qdata,
};
================================================
FILE: drivers/bus/softspi.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "drivers/bus/spi.h"
int mp_soft_spi_ioctl(void *self_in, uint32_t cmd) {
mp_soft_spi_obj_t *self = (mp_soft_spi_obj_t*)self_in;
switch (cmd) {
case MP_SPI_IOCTL_INIT:
mp_hal_pin_write(self->sck, self->polarity);
mp_hal_pin_output(self->sck);
mp_hal_pin_output(self->mosi);
mp_hal_pin_input(self->miso);
break;
case MP_SPI_IOCTL_DEINIT:
break;
}
return 0;
}
void mp_soft_spi_transfer(void *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
mp_soft_spi_obj_t *self = (mp_soft_spi_obj_t*)self_in;
uint32_t delay_half = self->delay_half;
// only MSB transfer is implemented
// If a port defines MICROPY_HW_SOFTSPI_MIN_DELAY, and the configured
// delay_half is equal to this value, then the software SPI implementation
// will run as fast as possible, limited only by CPU speed and GPIO time.
#ifdef MICROPY_HW_SOFTSPI_MIN_DELAY
if (delay_half == MICROPY_HW_SOFTSPI_MIN_DELAY) {
for (size_t i = 0; i < len; ++i) {
uint8_t data_out = src[i];
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j, data_out <<= 1) {
mp_hal_pin_write(self->mosi, (data_out >> 7) & 1);
mp_hal_pin_write(self->sck, 1 - self->polarity);
data_in = (data_in << 1) | mp_hal_pin_read(self->miso);
mp_hal_pin_write(self->sck, self->polarity);
}
if (dest != NULL) {
dest[i] = data_in;
}
}
return;
}
#endif
for (size_t i = 0; i < len; ++i) {
uint8_t data_out = src[i];
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j, data_out <<= 1) {
mp_hal_pin_write(self->mosi, (data_out >> 7) & 1);
if (self->phase == 0) {
mp_hal_delay_us_fast(delay_half);
mp_hal_pin_write(self->sck, 1 - self->polarity);
} else {
mp_hal_pin_write(self->sck, 1 - self->polarity);
mp_hal_delay_us_fast(delay_half);
}
data_in = (data_in << 1) | mp_hal_pin_read(self->miso);
if (self->phase == 0) {
mp_hal_delay_us_fast(delay_half);
mp_hal_pin_write(self->sck, self->polarity);
} else {
mp_hal_pin_write(self->sck, self->polarity);
mp_hal_delay_us_fast(delay_half);
}
}
if (dest != NULL) {
dest[i] = data_in;
}
}
}
const mp_spi_proto_t mp_soft_spi_proto = {
.ioctl = mp_soft_spi_ioctl,
.transfer = mp_soft_spi_transfer,
};
================================================
FILE: drivers/bus/spi.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_DRIVERS_BUS_SPI_H
#define MICROPY_INCLUDED_DRIVERS_BUS_SPI_H
#include "py/mphal.h"
enum {
MP_SPI_IOCTL_INIT,
MP_SPI_IOCTL_DEINIT,
};
typedef struct _mp_spi_proto_t {
int (*ioctl)(void *self, uint32_t cmd);
void (*transfer)(void *self, size_t len, const uint8_t *src, uint8_t *dest);
} mp_spi_proto_t;
typedef struct _mp_soft_spi_obj_t {
uint32_t delay_half; // microsecond delay for half SCK period
uint8_t polarity;
uint8_t phase;
mp_hal_pin_obj_t sck;
mp_hal_pin_obj_t mosi;
mp_hal_pin_obj_t miso;
} mp_soft_spi_obj_t;
extern const mp_spi_proto_t mp_soft_spi_proto;
int mp_soft_spi_ioctl(void *self, uint32_t cmd);
void mp_soft_spi_transfer(void *self, size_t len, const uint8_t *src, uint8_t *dest);
#endif // MICROPY_INCLUDED_DRIVERS_BUS_SPI_H
================================================
FILE: extmod/axtls-include/config.h
================================================
/*
* Automatically generated header file: don't edit
*/
#define HAVE_DOT_CONFIG 1
#define CONFIG_PLATFORM_LINUX 1
#undef CONFIG_PLATFORM_CYGWIN
#undef CONFIG_PLATFORM_WIN32
/*
* General Configuration
*/
#define PREFIX "/usr/local"
#undef CONFIG_DEBUG
#undef CONFIG_STRIP_UNWANTED_SECTIONS
#undef CONFIG_VISUAL_STUDIO_7_0
#undef CONFIG_VISUAL_STUDIO_8_0
#undef CONFIG_VISUAL_STUDIO_10_0
#define CONFIG_VISUAL_STUDIO_7_0_BASE ""
#define CONFIG_VISUAL_STUDIO_8_0_BASE ""
#define CONFIG_VISUAL_STUDIO_10_0_BASE ""
#define CONFIG_EXTRA_CFLAGS_OPTIONS ""
#define CONFIG_EXTRA_LDFLAGS_OPTIONS ""
/*
* SSL Library
*/
#undef CONFIG_SSL_SERVER_ONLY
#undef CONFIG_SSL_CERT_VERIFICATION
#undef CONFIG_SSL_FULL_MODE
#define CONFIG_SSL_SKELETON_MODE 1
#define CONFIG_SSL_ENABLE_SERVER 1
#define CONFIG_SSL_ENABLE_CLIENT 1
#undef CONFIG_SSL_DIAGNOSTICS
#define CONFIG_SSL_PROT_LOW 1
#undef CONFIG_SSL_PROT_MEDIUM
#undef CONFIG_SSL_PROT_HIGH
#define CONFIG_SSL_AES 1
#define CONFIG_SSL_USE_DEFAULT_KEY 1
#define CONFIG_SSL_PRIVATE_KEY_LOCATION ""
#define CONFIG_SSL_PRIVATE_KEY_PASSWORD ""
#define CONFIG_SSL_X509_CERT_LOCATION ""
#undef CONFIG_SSL_GENERATE_X509_CERT
#define CONFIG_SSL_X509_COMMON_NAME ""
#define CONFIG_SSL_X509_ORGANIZATION_NAME ""
#define CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME ""
#undef CONFIG_SSL_HAS_PEM
#undef CONFIG_SSL_USE_PKCS12
#define CONFIG_SSL_EXPIRY_TIME
#define CONFIG_X509_MAX_CA_CERTS 0
#define CONFIG_SSL_MAX_CERTS 3
#undef CONFIG_SSL_CTX_MUTEXING
#undef CONFIG_USE_DEV_URANDOM
#undef CONFIG_WIN32_USE_CRYPTO_LIB
#undef CONFIG_OPENSSL_COMPATIBLE
#undef CONFIG_PERFORMANCE_TESTING
#undef CONFIG_SSL_TEST
#undef CONFIG_AXTLSWRAP
#undef CONFIG_AXHTTPD
#undef CONFIG_HTTP_STATIC_BUILD
#define CONFIG_HTTP_PORT
#define CONFIG_HTTP_HTTPS_PORT
#define CONFIG_HTTP_SESSION_CACHE_SIZE
#define CONFIG_HTTP_WEBROOT ""
#define CONFIG_HTTP_TIMEOUT
#undef CONFIG_HTTP_HAS_CGI
#define CONFIG_HTTP_CGI_EXTENSIONS ""
#undef CONFIG_HTTP_ENABLE_LUA
#define CONFIG_HTTP_LUA_PREFIX ""
#undef CONFIG_HTTP_BUILD_LUA
#define CONFIG_HTTP_CGI_LAUNCHER ""
#undef CONFIG_HTTP_DIRECTORIES
#undef CONFIG_HTTP_HAS_AUTHORIZATION
#undef CONFIG_HTTP_HAS_IPV6
#undef CONFIG_HTTP_ENABLE_DIFFERENT_USER
#define CONFIG_HTTP_USER ""
#undef CONFIG_HTTP_VERBOSE
#undef CONFIG_HTTP_IS_DAEMON
/*
* Language Bindings
*/
#undef CONFIG_BINDINGS
#undef CONFIG_CSHARP_BINDINGS
#undef CONFIG_VBNET_BINDINGS
#define CONFIG_DOT_NET_FRAMEWORK_BASE ""
#undef CONFIG_JAVA_BINDINGS
#define CONFIG_JAVA_HOME ""
#undef CONFIG_PERL_BINDINGS
#define CONFIG_PERL_CORE ""
#define CONFIG_PERL_LIB ""
#undef CONFIG_LUA_BINDINGS
#define CONFIG_LUA_CORE ""
/*
* Samples
*/
#undef CONFIG_SAMPLES
#undef CONFIG_C_SAMPLES
#undef CONFIG_CSHARP_SAMPLES
#undef CONFIG_VBNET_SAMPLES
#undef CONFIG_JAVA_SAMPLES
#undef CONFIG_PERL_SAMPLES
#undef CONFIG_LUA_SAMPLES
#undef CONFIG_BIGINT_CLASSICAL
#undef CONFIG_BIGINT_MONTGOMERY
#undef CONFIG_BIGINT_BARRETT
#undef CONFIG_BIGINT_CRT
#undef CONFIG_BIGINT_KARATSUBA
#define MUL_KARATSUBA_THRESH
#define SQU_KARATSUBA_THRESH
#undef CONFIG_BIGINT_SLIDING_WINDOW
#undef CONFIG_BIGINT_SQUARE
#undef CONFIG_BIGINT_CHECK_ON
#undef CONFIG_INTEGER_32BIT
#undef CONFIG_INTEGER_16BIT
#undef CONFIG_INTEGER_8BIT
================================================
FILE: extmod/axtls-include/version.h
================================================
#define AXTLS_VERSION "(no version)"
================================================
FILE: extmod/crypto-algorithms/sha256.c
================================================
/*********************************************************************
* Source: https://github.com/B-Con/crypto-algorithms
* Filename: sha256.c
* Author: Brad Conte (brad AT bradconte.com)
* Copyright: This code is released into the public domain.
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Implementation of the SHA-256 hashing algorithm.
SHA-256 is one of the three algorithms in the SHA2
specification. The others, SHA-384 and SHA-512, are not
offered in this implementation.
Algorithm specification can be found here:
* http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
This implementation uses little endian byte order.
*********************************************************************/
/*************************** HEADER FILES ***************************/
#include <stdlib.h>
#include "sha256.h"
/****************************** MACROS ******************************/
#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
/**************************** VARIABLES *****************************/
static const WORD k[64] = {
0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
};
/*********************** FUNCTION DEFINITIONS ***********************/
static void sha256_transform(CRYAL_SHA256_CTX *ctx, const BYTE data[])
{
WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
for (i = 0, j = 0; i < 16; ++i, j += 4)
m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
for ( ; i < 64; ++i)
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
a = ctx->state[0];
b = ctx->state[1];
c = ctx->state[2];
d = ctx->state[3];
e = ctx->state[4];
f = ctx->state[5];
g = ctx->state[6];
h = ctx->state[7];
for (i = 0; i < 64; ++i) {
t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
t2 = EP0(a) + MAJ(a,b,c);
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
ctx->state[0] += a;
ctx->state[1] += b;
ctx->state[2] += c;
ctx->state[3] += d;
ctx->state[4] += e;
ctx->state[5] += f;
ctx->state[6] += g;
ctx->state[7] += h;
}
void sha256_init(CRYAL_SHA256_CTX *ctx)
{
ctx->datalen = 0;
ctx->bitlen = 0;
ctx->state[0] = 0x6a09e667;
ctx->state[1] = 0xbb67ae85;
ctx->state[2] = 0x3c6ef372;
ctx->state[3] = 0xa54ff53a;
ctx->state[4] = 0x510e527f;
ctx->state[5] = 0x9b05688c;
ctx->state[6] = 0x1f83d9ab;
ctx->state[7] = 0x5be0cd19;
}
void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len)
{
WORD i;
for (i = 0; i < len; ++i) {
ctx->data[ctx->datalen] = data[i];
ctx->datalen++;
if (ctx->datalen == 64) {
sha256_transform(ctx, ctx->data);
ctx->bitlen += 512;
ctx->datalen = 0;
}
}
}
void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[])
{
WORD i;
i = ctx->datalen;
// Pad whatever data is left in the buffer.
if (ctx->datalen < 56) {
ctx->data[i++] = 0x80;
while (i < 56)
ctx->data[i++] = 0x00;
}
else {
ctx->data[i++] = 0x80;
while (i < 64)
ctx->data[i++] = 0x00;
sha256_transform(ctx, ctx->data);
memset(ctx->data, 0, 56);
}
// Append to the padding the total message's length in bits and transform.
ctx->bitlen += ctx->datalen * 8;
ctx->data[63] = ctx->bitlen;
ctx->data[62] = ctx->bitlen >> 8;
ctx->data[61] = ctx->bitlen >> 16;
ctx->data[60] = ctx->bitlen >> 24;
ctx->data[59] = ctx->bitlen >> 32;
ctx->data[58] = ctx->bitlen >> 40;
ctx->data[57] = ctx->bitlen >> 48;
ctx->data[56] = ctx->bitlen >> 56;
sha256_transform(ctx, ctx->data);
// Since this implementation uses little endian byte ordering and SHA uses big endian,
// reverse all the bytes when copying the final state to the output hash.
for (i = 0; i < 4; ++i) {
hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0x000000ff;
hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0x000000ff;
hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff;
}
}
================================================
FILE: extmod/crypto-algorithms/sha256.h
================================================
/*********************************************************************
* Source: https://github.com/B-Con/crypto-algorithms
* Filename: sha256.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright: This code is released into the public domain.
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding SHA1 implementation.
*********************************************************************/
#ifndef SHA256_H
#define SHA256_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
typedef struct {
BYTE data[64];
WORD datalen;
unsigned long long bitlen;
WORD state[8];
} CRYAL_SHA256_CTX;
/*********************** FUNCTION DECLARATIONS **********************/
void sha256_init(CRYAL_SHA256_CTX *ctx);
void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len);
void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[]);
#endif // SHA256_H
================================================
FILE: extmod/lwip-include/arch/cc.h
================================================
#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H
#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H
#include <stdint.h>
// Generate lwip's internal types from stdint
typedef uint8_t u8_t;
typedef int8_t s8_t;
typedef uint16_t u16_t;
typedef int16_t s16_t;
typedef uint32_t u32_t;
typedef int32_t s32_t;
typedef u32_t mem_ptr_t;
#define U16_F "hu"
#define S16_F "hd"
#define X16_F "hx"
#define U32_F "u"
#define S32_F "d"
#define X32_F "x"
#define X8_F "02x"
#define SZT_F "u"
#define BYTE_ORDER LITTLE_ENDIAN
#define LWIP_CHKSUM_ALGORITHM 2
#include <assert.h>
#define LWIP_PLATFORM_DIAG(x)
#define LWIP_PLATFORM_ASSERT(x) { assert(1); }
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT __attribute__((packed))
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END
#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H
================================================
FILE: extmod/lwip-include/arch/perf.h
================================================
#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H
#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H
#define PERF_START /* null definition */
#define PERF_STOP(x) /* null definition */
#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H
================================================
FILE: extmod/lwip-include/lwipopts.h
================================================
#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H
#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H
#include <py/mpconfig.h>
#include <py/misc.h>
#include <py/mphal.h>
// We're running without an OS for this port. We don't provide any services except light protection.
#define NO_SYS 1
#define SYS_LIGHTWEIGHT_PROT 1
#include <stdint.h>
typedef uint32_t sys_prot_t;
#define TCP_LISTEN_BACKLOG 1
// We'll put these into a proper ifdef once somebody implements an ethernet driver
#define LWIP_ARP 0
#define LWIP_ETHERNET 0
#define LWIP_DNS 1
#define LWIP_NETCONN 0
#define LWIP_SOCKET 0
#ifdef MICROPY_PY_LWIP_SLIP
#define LWIP_HAVE_SLIPIF 1
#endif
// For now, we can simply define this as a macro for the timer code. But this function isn't
// universal and other ports will need to do something else. It may be necessary to move
// things like this into a port-provided header file.
#define sys_now mp_hal_ticks_ms
#endif // MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H
================================================
FILE: extmod/machine_i2c.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/runtime.h"
#include "extmod/machine_i2c.h"
#if MICROPY_PY_MACHINE_I2C
typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t;
STATIC void mp_hal_i2c_delay(machine_i2c_obj_t *self) {
// We need to use an accurate delay to get acceptable I2C
// speeds (eg 1us should be not much more than 1us).
mp_hal_delay_us_fast(self->us_delay);
}
STATIC void mp_hal_i2c_scl_low(machine_i2c_obj_t *self) {
mp_hal_pin_od_low(self->scl);
}
STATIC int mp_hal_i2c_scl_release(machine_i2c_obj_t *self) {
uint32_t count = self->us_timeout;
mp_hal_pin_od_high(self->scl);
mp_hal_i2c_delay(self);
// For clock stretching, wait for the SCL pin to be released, with timeout.
for (; mp_hal_pin_read(self->scl) == 0 && count; --count) {
mp_hal_delay_us_fast(1);
}
if (count == 0) {
return -MP_ETIMEDOUT;
}
return 0; // success
}
STATIC void mp_hal_i2c_sda_low(machine_i2c_obj_t *self) {
mp_hal_pin_od_low(self->sda);
}
STATIC void mp_hal_i2c_sda_release(machine_i2c_obj_t *self) {
mp_hal_pin_od_high(self->sda);
}
STATIC int mp_hal_i2c_sda_read(machine_i2c_obj_t *self) {
return mp_hal_pin_read(self->sda);
}
STATIC int mp_hal_i2c_start(machine_i2c_obj_t *self) {
mp_hal_i2c_sda_release(self);
mp_hal_i2c_delay(self);
int ret = mp_hal_i2c_scl_release(self);
if (ret != 0) {
return ret;
}
mp_hal_i2c_sda_low(self);
mp_hal_i2c_delay(self);
return 0; // success
}
STATIC int mp_hal_i2c_stop(machine_i2c_obj_t *self) {
mp_hal_i2c_delay(self);
mp_hal_i2c_sda_low(self);
mp_hal_i2c_delay(self);
int ret = mp_hal_i2c_scl_release(self);
mp_hal_i2c_sda_release(self);
mp_hal_i2c_delay(self);
return ret;
}
STATIC void mp_hal_i2c_init(machine_i2c_obj_t *self, uint32_t freq) {
self->us_delay = 500000 / freq;
if (self->us_delay == 0) {
self->us_delay = 1;
}
mp_hal_pin_open_drain(self->scl);
mp_hal_pin_open_drain(self->sda);
mp_hal_i2c_stop(self); // ignore error
}
// return value:
// 0 - byte written and ack received
// 1 - byte written and nack received
// <0 - error, with errno being the negative of the return value
STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) {
mp_hal_i2c_delay(self);
mp_hal_i2c_scl_low(self);
for (int i = 7; i >= 0; i--) {
if ((val >> i) & 1) {
mp_hal_i2c_sda_release(self);
} else {
mp_hal_i2c_sda_low(self);
}
mp_hal_i2c_delay(self);
int ret = mp_hal_i2c_scl_release(self);
if (ret != 0) {
mp_hal_i2c_sda_release(self);
return ret;
}
mp_hal_i2c_scl_low(self);
}
mp_hal_i2c_sda_release(self);
mp_hal_i2c_delay(self);
int ret = mp_hal_i2c_scl_release(self);
if (ret != 0) {
return ret;
}
int ack = mp_hal_i2c_sda_read(self);
mp_hal_i2c_delay(self);
mp_hal_i2c_scl_low(self);
return ack;
}
// return value:
// 0 - success
// <0 - error, with errno being the negative of the return value
STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack) {
mp_hal_i2c_delay(self);
mp_hal_i2c_scl_low(self);
mp_hal_i2c_delay(self);
uint8_t data = 0;
for (int i = 7; i >= 0; i--) {
int ret = mp_hal_i2c_scl_release(self);
if (ret != 0) {
return ret;
}
data = (data << 1) | mp_hal_i2c_sda_read(self);
mp_hal_i2c_scl_low(self);
mp_hal_i2c_delay(self);
}
*val = data;
// send ack/nack bit
if (!nack) {
mp_hal_i2c_sda_low(self);
}
mp_hal_i2c_delay(self);
int ret = mp_hal_i2c_scl_release(self);
if (ret != 0) {
mp_hal_i2c_sda_release(self);
return ret;
}
mp_hal_i2c_scl_low(self);
mp_hal_i2c_sda_release(self);
return 0; // success
}
// return value:
// >=0 - success; for read it's 0, for write it's number of acks received
// <0 - error, with errno being the negative of the return value
int mp_machine_soft_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, size_t n, mp_machine_i2c_buf_t *bufs, unsigned int flags) {
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
// start the I2C transaction
int ret = mp_hal_i2c_start(self);
if (ret != 0) {
return ret;
}
// write the slave address
ret = mp_hal_i2c_write_byte(self, (addr << 1) | (flags & MP_MACHINE_I2C_FLAG_READ));
if (ret < 0) {
return ret;
} else if (ret != 0) {
// nack received, release the bus cleanly
mp_hal_i2c_stop(self);
return -MP_ENODEV;
}
int transfer_ret = 0;
for (; n--; ++bufs) {
size_t len = bufs->len;
uint8_t *buf = bufs->buf;
if (flags & MP_MACHINE_I2C_FLAG_READ) {
// read bytes from the slave into the given buffer(s)
while (len--) {
ret = mp_hal_i2c_read_byte(self, buf++, (n | len) == 0);
if (ret != 0) {
return ret;
}
}
} else {
// write bytes from the given buffer(s) to the slave
while (len--) {
ret = mp_hal_i2c_write_byte(self, *buf++);
if (ret < 0) {
return ret;
} else if (ret != 0) {
// nack received, stop sending
n = 0;
break;
}
++transfer_ret; // count the number of acks
}
}
}
// finish the I2C transaction
if (flags & MP_MACHINE_I2C_FLAG_STOP) {
ret = mp_hal_i2c_stop(self);
if (ret != 0) {
return ret;
}
}
return transfer_ret;
}
/******************************************************************************/
// Generic helper functions
// For use by ports that require a single buffer of data for a read/write transfer
int mp_machine_i2c_transfer_adaptor(mp_obj_base_t *self, uint16_t addr, size_t n, mp_machine_i2c_buf_t *bufs, unsigned int flags) {
size_t len;
uint8_t *buf;
if (n == 1) {
// Use given single buffer
len = bufs[0].len;
buf = bufs[0].buf;
} else {
// Combine buffers into a single one
len = 0;
for (size_t i = 0; i < n; ++i) {
len += bufs[i].len;
}
buf = m_new(uint8_t, len);
if (!(flags & MP_MACHINE_I2C_FLAG_READ)) {
len = 0;
for (size_t i = 0; i < n; ++i) {
memcpy(buf + len, bufs[i].buf, bufs[i].len);
len += bufs[i].len;
}
}
}
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
int ret = i2c_p->transfer_single(self, addr, len, buf, flags);
if (n > 1) {
if (flags & MP_MACHINE_I2C_FLAG_READ) {
// Copy data from single buffer to individual ones
len = 0;
for (size_t i = 0; i < n; ++i) {
memcpy(bufs[i].buf, buf + len, bufs[i].len);
len += bufs[i].len;
}
}
m_del(uint8_t, buf, len);
}
return ret;
}
STATIC int mp_machine_i2c_readfrom(mp_obj_base_t *self, uint16_t addr, uint8_t *dest, size_t len, bool stop) {
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
mp_machine_i2c_buf_t buf = {.len = len, .buf = dest};
unsigned int flags = MP_MACHINE_I2C_FLAG_READ | (stop ? MP_MACHINE_I2C_FLAG_STOP : 0);
return i2c_p->transfer(self, addr, 1, &buf, flags);
}
STATIC int mp_machine_i2c_writeto(mp_obj_base_t *self, uint16_t addr, const uint8_t *src, size_t len, bool stop) {
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
mp_machine_i2c_buf_t buf = {.len = len, .buf = (uint8_t*)src};
unsigned int flags = stop ? MP_MACHINE_I2C_FLAG_STOP : 0;
return i2c_p->transfer(self, addr, 1, &buf, flags);
}
/******************************************************************************/
// MicroPython bindings for I2C
STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_scl, ARG_sda, ARG_freq, ARG_timeout };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_scl, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_sda, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_freq, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 400000} },
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 255} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
self->scl = mp_hal_get_pin_obj(args[ARG_scl].u_obj);
self->sda = mp_hal_get_pin_obj(args[ARG_sda].u_obj);
self->us_timeout = args[ARG_timeout].u_int;
mp_hal_i2c_init(self, args[ARG_freq].u_int);
}
STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// check the id argument, if given
if (n_args > 0) {
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
#if defined(MICROPY_PY_MACHINE_I2C_MAKE_NEW)
// dispatch to port-specific constructor
extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args);
#else
mp_raise_ValueError("invalid I2C peripheral");
#endif
}
--n_args;
++args;
}
// create new soft I2C object
machine_i2c_obj_t *self = m_new_obj(machine_i2c_obj_t);
self->base.type = &machine_i2c_type;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
machine_i2c_obj_init_helper(self, n_args, args, &kw_args);
return MP_OBJ_FROM_PTR(self);
}
STATIC mp_obj_t machine_i2c_obj_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
machine_i2c_obj_init_helper(MP_OBJ_TO_PTR(args[0]), n_args - 1, args + 1, kw_args);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_init_obj, 1, machine_i2c_obj_init);
STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in);
mp_obj_t list = mp_obj_new_list(0, NULL);
// 7-bit addresses 0b0000xxx and 0b1111xxx are reserved
for (int addr = 0x08; addr < 0x78; ++addr) {
int ret = mp_machine_i2c_writeto(self, addr, NULL, 0, true);
if (ret == 0) {
mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr));
}
}
return list;
}
MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_scan_obj, machine_i2c_scan);
STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->start == NULL) {
mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
}
int ret = i2c_p->start(self);
if (ret != 0) {
mp_raise_OSError(-ret);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_start_obj, machine_i2c_start);
STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->stop == NULL) {
mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
}
int ret = i2c_p->stop(self);
if (ret != 0) {
mp_raise_OSError(-ret);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_stop_obj, machine_i2c_stop);
STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->read == NULL) {
mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
}
// get the buffer to read into
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
// work out if we want to send a nack at the end
bool nack = (n_args == 2) ? true : mp_obj_is_true(args[2]);
// do the read
int ret = i2c_p->read(self, bufinfo.buf, bufinfo.len, nack);
if (ret != 0) {
mp_raise_OSError(-ret);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readinto_obj, 2, 3, machine_i2c_readinto);
STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
if (i2c_p->write == NULL) {
mp_raise_msg(&mp_type_OSError, "I2C operation not supported");
}
// get the buffer to write from
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
// do the write
int ret = i2c_p->write(self, bufinfo.buf, bufinfo.len);
if (ret < 0) {
mp_raise_OSError(-ret);
}
// return number of acks received
return MP_OBJ_NEW_SMALL_INT(ret);
}
MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_write_obj, machine_i2c_write);
STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_int_t addr = mp_obj_get_int(args[1]);
vstr_t vstr;
vstr_init_len(&vstr, mp_obj_get_int(args[2]));
bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]);
int ret = mp_machine_i2c_readfrom(self, addr, (uint8_t*)vstr.buf, vstr.len, stop);
if (ret < 0) {
mp_raise_OSError(-ret);
}
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_obj, 3, 4, machine_i2c_readfrom);
STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_int_t addr = mp_obj_get_int(args[1]);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]);
int ret = mp_machine_i2c_readfrom(self, addr, bufinfo.buf, bufinfo.len, stop);
if (ret < 0) {
mp_raise_OSError(-ret);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_into_obj, 3, 4, machine_i2c_readfrom_into);
STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_int_t addr = mp_obj_get_int(args[1]);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ);
bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]);
int ret = mp_machine_i2c_writeto(self, addr, bufinfo.buf, bufinfo.len, stop);
if (ret < 0) {
mp_raise_OSError(-ret);
}
// return number of acks received
return MP_OBJ_NEW_SMALL_INT(ret);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writeto_obj, 3, 4, machine_i2c_writeto);
STATIC mp_obj_t machine_i2c_writevto(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_int_t addr = mp_obj_get_int(args[1]);
// Get the list of data buffer(s) to write
size_t nitems;
const mp_obj_t *items;
mp_obj_get_array(args[2], &nitems, (mp_obj_t**)&items);
// Get the stop argument
bool stop = (n_args == 3) ? true : mp_obj_is_true(args[3]);
// Extract all buffer data, skipping zero-length buffers
size_t alloc = nitems == 0 ? 1 : nitems;
size_t nbufs = 0;
mp_machine_i2c_buf_t *bufs = mp_local_alloc(alloc * sizeof(mp_machine_i2c_buf_t));
for (; nitems--; ++items) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(*items, &bufinfo, MP_BUFFER_READ);
if (bufinfo.len > 0) {
bufs[nbufs].len = bufinfo.len;
bufs[nbufs++].buf = bufinfo.buf;
}
}
// Make sure there is at least one buffer, empty if needed
if (nbufs == 0) {
bufs[0].len = 0;
bufs[0].buf = NULL;
nbufs = 1;
}
// Do the I2C transfer
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
int ret = i2c_p->transfer(self, addr, nbufs, bufs, stop ? MP_MACHINE_I2C_FLAG_STOP : 0);
mp_local_free(bufs);
if (ret < 0) {
mp_raise_OSError(-ret);
}
// Return number of acks received
return MP_OBJ_NEW_SMALL_INT(ret);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writevto_obj, 3, 4, machine_i2c_writevto);
STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
uint8_t memaddr_buf[4];
size_t memaddr_len = 0;
for (int16_t i = addrsize - 8; i >= 0; i -= 8) {
memaddr_buf[memaddr_len++] = memaddr >> i;
}
int ret = mp_machine_i2c_writeto(self, addr, memaddr_buf, memaddr_len, false);
if (ret != memaddr_len) {
// must generate STOP
mp_machine_i2c_writeto(self, addr, NULL, 0, true);
return ret;
}
return mp_machine_i2c_readfrom(self, addr, buf, len, true);
}
STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
// Create buffer with memory address
size_t memaddr_len = 0;
uint8_t memaddr_buf[4];
for (int16_t i = addrsize - 8; i >= 0; i -= 8) {
memaddr_buf[memaddr_len++] = memaddr >> i;
}
// Create partial write buffers
mp_machine_i2c_buf_t bufs[2] = {
{.len = memaddr_len, .buf = memaddr_buf},
{.len = len, .buf = (uint8_t*)buf},
};
// Do I2C transfer
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
return i2c_p->transfer(self, addr, 2, bufs, MP_MACHINE_I2C_FLAG_STOP);
}
STATIC const mp_arg_t machine_i2c_mem_allowed_args[] = {
{ MP_QSTR_addr, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_memaddr, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_arg, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_addrsize, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
};
STATIC mp_obj_t machine_i2c_readfrom_mem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_addr, ARG_memaddr, ARG_n, ARG_addrsize };
mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args,
MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args);
// create the buffer to store data into
vstr_t vstr;
vstr_init_len(&vstr, mp_obj_get_int(args[ARG_n].u_obj));
// do the transfer
int ret = read_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int,
args[ARG_addrsize].u_int, (uint8_t*)vstr.buf, vstr.len);
if (ret < 0) {
mp_raise_OSError(-ret);
}
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
}
MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_readfrom_mem_obj, 1, machine_i2c_readfrom_mem);
STATIC mp_obj_t machine_i2c_readfrom_mem_into(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_addr, ARG_memaddr, ARG_buf, ARG_addrsize };
mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args,
MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args);
// get the buffer to store data into
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[ARG_buf].u_obj, &bufinfo, MP_BUFFER_WRITE);
// do the transfer
int ret = read_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int,
args[ARG_addrsize].u_int, bufinfo.buf, bufinfo.len);
if (ret < 0) {
mp_raise_OSError(-ret);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_readfrom_mem_into_obj, 1, machine_i2c_readfrom_mem_into);
STATIC mp_obj_t machine_i2c_writeto_mem(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_addr, ARG_memaddr, ARG_buf, ARG_addrsize };
mp_arg_val_t args[MP_ARRAY_SIZE(machine_i2c_mem_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args,
MP_ARRAY_SIZE(machine_i2c_mem_allowed_args), machine_i2c_mem_allowed_args, args);
// get the buffer to write the data from
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[ARG_buf].u_obj, &bufinfo, MP_BUFFER_READ);
// do the transfer
int ret = write_mem(pos_args[0], args[ARG_addr].u_int, args[ARG_memaddr].u_int,
args[ARG_addrsize].u_int, bufinfo.buf, bufinfo.len);
if (ret < 0) {
mp_raise_OSError(-ret);
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_writeto_mem_obj, 1, machine_i2c_writeto_mem);
STATIC const mp_rom_map_elem_t machine_i2c_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_i2c_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&machine_i2c_scan_obj) },
// primitive I2C operations
{ MP_ROM_QSTR(MP_QSTR_start), MP_ROM_PTR(&machine_i2c_start_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&machine_i2c_stop_obj) },
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&machine_i2c_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&machine_i2c_write_obj) },
// standard bus operations
{ MP_ROM_QSTR(MP_QSTR_readfrom), MP_ROM_PTR(&machine_i2c_readfrom_obj) },
{ MP_ROM_QSTR(MP_QSTR_readfrom_into), MP_ROM_PTR(&machine_i2c_readfrom_into_obj) },
{ MP_ROM_QSTR(MP_QSTR_writeto), MP_ROM_PTR(&machine_i2c_writeto_obj) },
{ MP_ROM_QSTR(MP_QSTR_writevto), MP_ROM_PTR(&machine_i2c_writevto_obj) },
// memory operations
{ MP_ROM_QSTR(MP_QSTR_readfrom_mem), MP_ROM_PTR(&machine_i2c_readfrom_mem_obj) },
{ MP_ROM_QSTR(MP_QSTR_readfrom_mem_into), MP_ROM_PTR(&machine_i2c_readfrom_mem_into_obj) },
{ MP_ROM_QSTR(MP_QSTR_writeto_mem), MP_ROM_PTR(&machine_i2c_writeto_mem_obj) },
};
MP_DEFINE_CONST_DICT(mp_machine_soft_i2c_locals_dict, machine_i2c_locals_dict_table);
int mp_machine_soft_i2c_read(mp_obj_base_t *self_in, uint8_t *dest, size_t len, bool nack) {
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
while (len--) {
int ret = mp_hal_i2c_read_byte(self, dest++, nack && (len == 0));
if (ret != 0) {
return ret;
}
}
return 0; // success
}
int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t len) {
machine_i2c_obj_t *self = (machine_i2c_obj_t*)self_in;
int num_acks = 0;
while (len--) {
int ret = mp_hal_i2c_write_byte(self, *src++);
if (ret < 0) {
return ret;
} else if (ret != 0) {
// nack received, stop sending
break;
}
++num_acks;
}
return num_acks;
}
STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
.start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start,
.stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop,
.read = mp_machine_soft_i2c_read,
.write = mp_machine_soft_i2c_write,
.transfer = mp_machine_soft_i2c_transfer,
};
const mp_obj_type_t machine_i2c_type = {
{ &mp_type_type },
.name = MP_QSTR_I2C,
.make_new = machine_i2c_make_new,
.protocol = &mp_machine_soft_i2c_p,
.locals_dict = (mp_obj_dict_t*)&mp_machine_soft_i2c_locals_dict,
};
#endif // MICROPY_PY_MACHINE_I2C
================================================
FILE: extmod/machine_i2c.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H
#include "py/obj.h"
#define MP_MACHINE_I2C_FLAG_READ (0x01) // if not set then it's a write
#define MP_MACHINE_I2C_FLAG_STOP (0x02)
typedef struct _mp_machine_i2c_buf_t {
size_t len;
uint8_t *buf;
} mp_machine_i2c_buf_t;
// I2C protocol
// the first 4 methods can be NULL, meaning operation is not supported
// transfer_single only needs to be set if transfer=mp_machine_i2c_transfer_adaptor
typedef struct _mp_machine_i2c_p_t {
int (*start)(mp_obj_base_t *obj);
int (*stop)(mp_obj_base_t *obj);
int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack);
int (*write)(mp_obj_base_t *obj, const uint8_t *src, size_t len);
int (*transfer)(mp_obj_base_t *obj, uint16_t addr, size_t n, mp_machine_i2c_buf_t *bufs, unsigned int flags);
int (*transfer_single)(mp_obj_base_t *obj, uint16_t addr, size_t len, uint8_t *buf, unsigned int flags);
} mp_machine_i2c_p_t;
typedef struct _mp_machine_soft_i2c_obj_t {
mp_obj_base_t base;
uint32_t us_delay;
uint32_t us_timeout;
mp_hal_pin_obj_t scl;
mp_hal_pin_obj_t sda;
} mp_machine_soft_i2c_obj_t;
extern const mp_obj_type_t machine_i2c_type;
extern const mp_obj_dict_t mp_machine_soft_i2c_locals_dict;
int mp_machine_i2c_transfer_adaptor(mp_obj_base_t *self, uint16_t addr, size_t n, mp_machine_i2c_buf_t *bufs, unsigned int flags);
int mp_machine_soft_i2c_transfer(mp_obj_base_t *self, uint16_t addr, size_t n, mp_machine_i2c_buf_t *bufs, unsigned int flags);
#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H
================================================
FILE: extmod/machine_mem.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/runtime.h"
#include "extmod/machine_mem.h"
#if MICROPY_PY_MACHINE
// If you wish to override the functions for mapping the machine_mem read/write
// address, then add a #define for MICROPY_MACHINE_MEM_GET_READ_ADDR and/or
// MICROPY_MACHINE_MEM_GET_WRITE_ADDR in your mpconfigport.h. Since the
// prototypes are identical, it is allowable for both of the macros to evaluate
// the to same function.
//
// It is expected that the modmachine.c file for a given port will provide the
// implementations, if the default implementation isn't used.
#if !defined(MICROPY_MACHINE_MEM_GET_READ_ADDR) || !defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR)
STATIC uintptr_t machine_mem_get_addr(mp_obj_t addr_o, uint align) {
uintptr_t addr = mp_obj_int_get_truncated(addr_o);
if ((addr & (align - 1)) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "address %08x is not aligned to %d bytes", addr, align));
}
return addr;
}
#if !defined(MICROPY_MACHINE_MEM_GET_READ_ADDR)
#define MICROPY_MACHINE_MEM_GET_READ_ADDR machine_mem_get_addr
#endif
#if !defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR)
#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR machine_mem_get_addr
#endif
#endif
STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "<%u-bit memory>", 8 * self->elem_size);
}
STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
// TODO support slice index to read/write multiple values at once
machine_mem_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (value == MP_OBJ_NULL) {
// delete
return MP_OBJ_NULL; // op not supported
} else if (value == MP_OBJ_SENTINEL) {
// load
uintptr_t addr = MICROPY_MACHINE_MEM_GET_READ_ADDR(index, self->elem_size);
uint32_t val;
switch (self->elem_size) {
case 1: val = (*(uint8_t*)addr); break;
case 2: val = (*(uint16_t*)addr); break;
default: val = (*(uint32_t*)addr); break;
}
return mp_obj_new_int(val);
} else {
// store
uintptr_t addr = MICROPY_MACHINE_MEM_GET_WRITE_ADDR(index, self->elem_size);
uint32_t val = mp_obj_get_int_truncated(value);
switch (self->elem_size) {
case 1: (*(uint8_t*)addr) = val; break;
case 2: (*(uint16_t*)addr) = val; break;
default: (*(uint32_t*)addr) = val; break;
}
return mp_const_none;
}
}
const mp_obj_type_t machine_mem_type = {
{ &mp_type_type },
.name = MP_QSTR_mem,
.print = machine_mem_print,
.subscr = machine_mem_subscr,
};
const machine_mem_obj_t machine_mem8_obj = {{&machine_mem_type}, 1};
const machine_mem_obj_t machine_mem16_obj = {{&machine_mem_type}, 2};
const machine_mem_obj_t machine_mem32_obj = {{&machine_mem_type}, 4};
#endif // MICROPY_PY_MACHINE
================================================
FILE: extmod/machine_mem.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H
#include "py/obj.h"
typedef struct _machine_mem_obj_t {
mp_obj_base_t base;
unsigned elem_size; // in bytes
} machine_mem_obj_t;
extern const mp_obj_type_t machine_mem_type;
extern const machine_mem_obj_t machine_mem8_obj;
extern const machine_mem_obj_t machine_mem16_obj;
extern const machine_mem_obj_t machine_mem32_obj;
#if defined(MICROPY_MACHINE_MEM_GET_READ_ADDR)
uintptr_t MICROPY_MACHINE_MEM_GET_READ_ADDR(mp_obj_t addr_o, uint align);
#endif
#if defined(MICROPY_MACHINE_MEM_GET_WRITE_ADDR)
uintptr_t MICROPY_MACHINE_MEM_GET_WRITE_ADDR(mp_obj_t addr_o, uint align);
#endif
#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H
================================================
FILE: extmod/machine_pinbase.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/mpconfig.h"
#if MICROPY_PY_MACHINE
#include "py/obj.h"
#include "py/runtime.h"
#include "extmod/virtpin.h"
#include "extmod/machine_pinbase.h"
// PinBase class
// As this is abstract class, its instance is null.
// But there should be an instance, as the rest of instance code
// expects that there will be concrete object for inheritance.
typedef struct _mp_pinbase_t {
mp_obj_base_t base;
} mp_pinbase_t;
STATIC const mp_pinbase_t pinbase_singleton = {
.base = { &machine_pinbase_type },
};
STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
(void)type;
(void)n_args;
(void)n_kw;
(void)args;
return MP_OBJ_FROM_PTR(&pinbase_singleton);
}
mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode);
mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
(void)errcode;
switch (request) {
case MP_PIN_READ: {
mp_obj_t dest[2];
mp_load_method(obj, MP_QSTR_value, dest);
return mp_obj_get_int(mp_call_method_n_kw(0, 0, dest));
}
case MP_PIN_WRITE: {
mp_obj_t dest[3];
mp_load_method(obj, MP_QSTR_value, dest);
dest[2] = (arg == 0 ? mp_const_false : mp_const_true);
mp_call_method_n_kw(1, 0, dest);
return 0;
}
}
return -1;
}
STATIC const mp_pin_p_t pinbase_pin_p = {
.ioctl = pinbase_ioctl,
};
const mp_obj_type_t machine_pinbase_type = {
{ &mp_type_type },
.name = MP_QSTR_PinBase,
.make_new = pinbase_make_new,
.protocol = &pinbase_pin_p,
};
#endif // MICROPY_PY_MACHINE
================================================
FILE: extmod/machine_pinbase.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H
#include "py/obj.h"
extern const mp_obj_type_t machine_pinbase_type;
#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H
================================================
FILE: extmod/machine_pulse.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/runtime.h"
#include "py/mperrno.h"
#include "extmod/machine_pulse.h"
#if MICROPY_PY_MACHINE_PULSE
MP_WEAK mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) {
mp_uint_t start = mp_hal_ticks_us();
while (mp_hal_pin_read(pin) != pulse_level) {
if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) {
return (mp_uint_t)-2;
}
}
start = mp_hal_ticks_us();
while (mp_hal_pin_read(pin) == pulse_level) {
if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) {
return (mp_uint_t)-1;
}
}
return mp_hal_ticks_us() - start;
}
STATIC mp_obj_t machine_time_pulse_us_(size_t n_args, const mp_obj_t *args) {
mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(args[0]);
int level = 0;
if (mp_obj_is_true(args[1])) {
level = 1;
}
mp_uint_t timeout_us = 1000000;
if (n_args > 2) {
timeout_us = mp_obj_get_int(args[2]);
}
mp_uint_t us = machine_time_pulse_us(pin, level, timeout_us);
// May return -1 or -2 in case of timeout
return mp_obj_new_int(us);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_time_pulse_us_obj, 2, 3, machine_time_pulse_us_);
#endif
================================================
FILE: extmod/machine_pulse.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H
#include "py/obj.h"
#include "py/mphal.h"
mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(machine_time_pulse_us_obj);
#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H
================================================
FILE: extmod/machine_signal.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/mpconfig.h"
#if MICROPY_PY_MACHINE
#include <string.h>
#include "py/obj.h"
#include "py/runtime.h"
#include "extmod/virtpin.h"
#include "extmod/machine_signal.h"
// Signal class
typedef struct _machine_signal_t {
mp_obj_base_t base;
mp_obj_t pin;
bool invert;
} machine_signal_t;
STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_obj_t pin;
bool invert = false;
#if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW)
mp_pin_p_t *pin_p = NULL;
if (n_args > 0 && mp_obj_is_obj(args[0])) {
mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
pin_p = (mp_pin_p_t*)pin_base->type->protocol;
}
if (pin_p == NULL) {
// If first argument isn't a Pin-like object, we filter out "invert"
// from keyword arguments and pass them all to the exported Pin
// constructor to create one.
mp_obj_t *pin_args = mp_local_alloc((n_args + n_kw * 2) * sizeof(mp_obj_t));
memcpy(pin_args, args, n_args * sizeof(mp_obj_t));
const mp_obj_t *src = args + n_args;
mp_obj_t *dst = pin_args + n_args;
mp_obj_t *sig_value = NULL;
for (size_t cnt = n_kw; cnt; cnt--) {
if (*src == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
invert = mp_obj_is_true(src[1]);
n_kw--;
} else {
*dst++ = *src;
*dst++ = src[1];
}
if (*src == MP_OBJ_NEW_QSTR(MP_QSTR_value)) {
// Value is pertained to Signal, so we should invert
// it for Pin if needed, and we should do it only when
// inversion status is guaranteedly known.
sig_value = dst - 1;
}
src += 2;
}
if (invert && sig_value != NULL) {
*sig_value = mp_obj_is_true(*sig_value) ? MP_OBJ_NEW_SMALL_INT(0) : MP_OBJ_NEW_SMALL_INT(1);
}
// Here we pass NULL as a type, hoping that mp_pin_make_new()
// will just ignore it as set a concrete type. If not, we'd need
// to expose port's "default" pin type too.
pin = MICROPY_PY_MACHINE_PIN_MAKE_NEW(NULL, n_args, n_kw, pin_args);
mp_local_free(pin_args);
}
else
#endif
// Otherwise there should be 1 or 2 args
{
if (n_args == 1) {
pin = args[0];
if (n_kw == 0) {
} else if (n_kw == 1 && args[1] == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
invert = mp_obj_is_true(args[2]);
} else {
goto error;
}
} else {
error:
mp_raise_TypeError(NULL);
}
}
machine_signal_t *o = m_new_obj(machine_signal_t);
o->base.type = type;
o->pin = pin;
o->invert = invert;
return MP_OBJ_FROM_PTR(o);
}
STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
(void)errcode;
machine_signal_t *self = MP_OBJ_TO_PTR(self_in);
switch (request) {
case MP_PIN_READ: {
return mp_virtual_pin_read(self->pin) ^ self->invert;
}
case MP_PIN_WRITE: {
mp_virtual_pin_write(self->pin, arg ^ self->invert);
return 0;
}
}
return -1;
}
// fast method for getting/setting signal value
STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 1, false);
if (n_args == 0) {
// get pin
return MP_OBJ_NEW_SMALL_INT(mp_virtual_pin_read(self_in));
} else {
// set pin
mp_virtual_pin_write(self_in, mp_obj_is_true(args[0]));
return mp_const_none;
}
}
STATIC mp_obj_t signal_value(size_t n_args, const mp_obj_t *args) {
return signal_call(args[0], n_args - 1, 0, args + 1);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(signal_value_obj, 1, 2, signal_value);
STATIC mp_obj_t signal_on(mp_obj_t self_in) {
mp_virtual_pin_write(self_in, 1);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_on_obj, signal_on);
STATIC mp_obj_t signal_off(mp_obj_t self_in) {
mp_virtual_pin_write(self_in, 0);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_off_obj, signal_off);
STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&signal_value_obj) },
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&signal_on_obj) },
{ MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&signal_off_obj) },
};
STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table);
STATIC const mp_pin_p_t signal_pin_p = {
.ioctl = signal_ioctl,
};
const mp_obj_type_t machine_signal_type = {
{ &mp_type_type },
.name = MP_QSTR_Signal,
.make_new = signal_make_new,
.call = signal_call,
.protocol = &signal_pin_p,
.locals_dict = (void*)&signal_locals_dict,
};
#endif // MICROPY_PY_MACHINE
================================================
FILE: extmod/machine_signal.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H
#include "py/obj.h"
extern const mp_obj_type_t machine_signal_type;
#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H
================================================
FILE: extmod/machine_spi.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include "py/runtime.h"
#include "extmod/machine_spi.h"
#if MICROPY_PY_MACHINE_SPI
// if a port didn't define MSB/LSB constants then provide them
#ifndef MICROPY_PY_MACHINE_SPI_MSB
#define MICROPY_PY_MACHINE_SPI_MSB (0)
#define MICROPY_PY_MACHINE_SPI_LSB (1)
#endif
/******************************************************************************/
// MicroPython bindings for generic machine.SPI
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
// check the id argument, if given
if (n_args > 0) {
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
#if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW)
// dispatch to port-specific constructor
extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args);
#else
mp_raise_ValueError("invalid SPI peripheral");
#endif
}
--n_args;
++args;
}
// software SPI
return mp_machine_soft_spi_make_new(type, n_args, n_kw, args);
}
STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
spi_p->init(s, n_args - 1, args + 1, kw_args);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init);
STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) {
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
if (spi_p->deinit != NULL) {
spi_p->deinit(s);
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_spi_deinit_obj, machine_spi_deinit);
STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) {
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
spi_p->transfer(s, len, src, dest);
}
STATIC mp_obj_t mp_machine_spi_read(size_t n_args, const mp_obj_t *args) {
vstr_t vstr;
vstr_init_len(&vstr, mp_obj_get_int(args[1]));
memset(vstr.buf, n_args == 3 ? mp_obj_get_int(args[2]) : 0, vstr.len);
mp_machine_spi_transfer(args[0], vstr.len, vstr.buf, vstr.buf);
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_read_obj, 2, 3, mp_machine_spi_read);
STATIC mp_obj_t mp_machine_spi_readinto(size_t n_args, const mp_obj_t *args) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
memset(bufinfo.buf, n_args == 3 ? mp_obj_get_int(args[2]) : 0, bufinfo.len);
mp_machine_spi_transfer(args[0], bufinfo.len, bufinfo.buf, bufinfo.buf);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_readinto_obj, 2, 3, mp_machine_spi_readinto);
STATIC mp_obj_t mp_machine_spi_write(mp_obj_t self, mp_obj_t wr_buf) {
mp_buffer_info_t src;
mp_get_buffer_raise(wr_buf, &src, MP_BUFFER_READ);
mp_machine_spi_transfer(self, src.len, (const uint8_t*)src.buf, NULL);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(mp_machine_spi_write_obj, mp_machine_spi_write);
STATIC mp_obj_t mp_machine_spi_write_readinto(mp_obj_t self, mp_obj_t wr_buf, mp_obj_t rd_buf) {
mp_buffer_info_t src;
mp_get_buffer_raise(wr_buf, &src, MP_BUFFER_READ);
mp_buffer_info_t dest;
mp_get_buffer_raise(rd_buf, &dest, MP_BUFFER_WRITE);
if (src.len != dest.len) {
mp_raise_ValueError("buffers must be the same length");
}
mp_machine_spi_transfer(self, src.len, src.buf, dest.buf);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_3(mp_machine_spi_write_readinto_obj, mp_machine_spi_write_readinto);
STATIC const mp_rom_map_elem_t machine_spi_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_spi_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_spi_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_machine_spi_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_machine_spi_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_machine_spi_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_write_readinto), MP_ROM_PTR(&mp_machine_spi_write_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_MSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_MSB) },
{ MP_ROM_QSTR(MP_QSTR_LSB), MP_ROM_INT(MICROPY_PY_MACHINE_SPI_LSB) },
};
MP_DEFINE_CONST_DICT(mp_machine_spi_locals_dict, machine_spi_locals_dict_table);
/******************************************************************************/
// Implementation of soft SPI
STATIC uint32_t baudrate_from_delay_half(uint32_t delay_half) {
#ifdef MICROPY_HW_SOFTSPI_MIN_DELAY
if (delay_half == MICROPY_HW_SOFTSPI_MIN_DELAY) {
return MICROPY_HW_SOFTSPI_MAX_BAUDRATE;
} else
#endif
{
return 500000 / delay_half;
}
}
STATIC uint32_t baudrate_to_delay_half(uint32_t baudrate) {
#ifdef MICROPY_HW_SOFTSPI_MIN_DELAY
if (baudrate >= MICROPY_HW_SOFTSPI_MAX_BAUDRATE) {
return MICROPY_HW_SOFTSPI_MIN_DELAY;
} else
#endif
{
uint32_t delay_half = 500000 / baudrate;
// round delay_half up so that: actual_baudrate <= requested_baudrate
if (500000 % baudrate != 0) {
delay_half += 1;
}
return delay_half;
}
}
STATIC void mp_machine_soft_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
mp_machine_soft_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "SoftSPI(baudrate=%u, polarity=%u, phase=%u,"
" sck=" MP_HAL_PIN_FMT ", mosi=" MP_HAL_PIN_FMT ", miso=" MP_HAL_PIN_FMT ")",
baudrate_from_delay_half(self->spi.delay_half), self->spi.polarity, self->spi.phase,
mp_hal_pin_name(self->spi.sck), mp_hal_pin_name(self->spi.mosi), mp_hal_pin_name(self->spi.miso));
}
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} },
{ MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
{ MP_QSTR_firstbit, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = MICROPY_PY_MACHINE_SPI_MSB} },
{ MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// create new object
mp_machine_soft_spi_obj_t *self = m_new_obj(mp_machine_soft_spi_obj_t);
self->base.type = &mp_machine_soft_spi_type;
// set parameters
self->spi.delay_half = baudrate_to_delay_half(args[ARG_baudrate].u_int);
self->spi.polarity = args[ARG_polarity].u_int;
self->spi.phase = args[ARG_phase].u_int;
if (args[ARG_bits].u_int != 8) {
mp_raise_ValueError("bits must be 8");
}
if (args[ARG_firstbit].u_int != MICROPY_PY_MACHINE_SPI_MSB) {
mp_raise_ValueError("firstbit must be MSB");
}
if (args[ARG_sck].u_obj == MP_OBJ_NULL
|| args[ARG_mosi].u_obj == MP_OBJ_NULL
|| args[ARG_miso].u_obj == MP_OBJ_NULL) {
mp_raise_ValueError("must specify all of sck/mosi/miso");
}
self->spi.sck = mp_hal_get_pin_obj(args[ARG_sck].u_obj);
self->spi.mosi = mp_hal_get_pin_obj(args[ARG_mosi].u_obj);
self->spi.miso = mp_hal_get_pin_obj(args[ARG_miso].u_obj);
// configure bus
mp_soft_spi_ioctl(&self->spi, MP_SPI_IOCTL_INIT);
return MP_OBJ_FROM_PTR(self);
}
STATIC void mp_machine_soft_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_machine_soft_spi_obj_t *self = (mp_machine_soft_spi_obj_t*)self_in;
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_sck, ARG_mosi, ARG_miso };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_baudrate, MP_ARG_INT, {.u_int = -1} },
{ MP_QSTR_polarity, MP_ARG_INT, {.u_int = -1} },
{ MP_QSTR_phase, MP_ARG_INT, {.u_int = -1} },
{ MP_QSTR_sck, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_mosi, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
if (args[ARG_baudrate].u_int != -1) {
self->spi.delay_half = baudrate_to_delay_half(args[ARG_baudrate].u_int);
}
if (args[ARG_polarity].u_int != -1) {
self->spi.polarity = args[ARG_polarity].u_int;
}
if (args[ARG_phase].u_int != -1) {
self->spi.phase = args[ARG_phase].u_int;
}
if (args[ARG_sck].u_obj != MP_OBJ_NULL) {
self->spi.sck = mp_hal_get_pin_obj(args[ARG_sck].u_obj);
}
if (args[ARG_mosi].u_obj != MP_OBJ_NULL) {
self->spi.mosi = mp_hal_get_pin_obj(args[ARG_mosi].u_obj);
}
if (args[ARG_miso].u_obj != MP_OBJ_NULL) {
self->spi.miso = mp_hal_get_pin_obj(args[ARG_miso].u_obj);
}
// configure bus
mp_soft_spi_ioctl(&self->spi, MP_SPI_IOCTL_INIT);
}
STATIC void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
mp_machine_soft_spi_obj_t *self = (mp_machine_soft_spi_obj_t*)self_in;
mp_soft_spi_transfer(&self->spi, len, src, dest);
}
const mp_machine_spi_p_t mp_machine_soft_spi_p = {
.init = mp_machine_soft_spi_init,
.deinit = NULL,
.transfer = mp_machine_soft_spi_transfer,
};
const mp_obj_type_t mp_machine_soft_spi_type = {
{ &mp_type_type },
.name = MP_QSTR_SoftSPI,
.print = mp_machine_soft_spi_print,
.make_new = mp_machine_spi_make_new, // delegate to master constructor
.protocol = &mp_machine_soft_spi_p,
.locals_dict = (mp_obj_dict_t*)&mp_machine_spi_locals_dict,
};
#endif // MICROPY_PY_MACHINE_SPI
================================================
FILE: extmod/machine_spi.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H
#include "py/obj.h"
#include "py/mphal.h"
#include "drivers/bus/spi.h"
// SPI protocol
typedef struct _mp_machine_spi_p_t {
void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
void (*deinit)(mp_obj_base_t *obj); // can be NULL
void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest);
} mp_machine_spi_p_t;
typedef struct _mp_machine_soft_spi_obj_t {
mp_obj_base_t base;
mp_soft_spi_obj_t spi;
} mp_machine_soft_spi_obj_t;
extern const mp_machine_spi_p_t mp_machine_soft_spi_p;
extern const mp_obj_type_t mp_machine_soft_spi_type;
extern const mp_obj_dict_t mp_machine_spi_locals_dict;
mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_read_obj);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_machine_spi_readinto_obj);
MP_DECLARE_CONST_FUN_OBJ_2(mp_machine_spi_write_obj);
MP_DECLARE_CONST_FUN_OBJ_3(mp_machine_spi_write_readinto_obj);
#endif // MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H
================================================
FILE: extmod/misc.h
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2014-2016 Damien P. George
* Copyright (c) 2016 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_EXTMOD_MISC_H
#define MICROPY_INCLUDED_EXTMOD_MISC_H
// This file contains cumulative declarations for extmod/ .
#include <stddef.h>
#include "py/runtime.h"
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_uos_dupterm_obj);
#if MICROPY_PY_OS_DUPTERM
bool mp_uos_dupterm_is_builtin_stream(mp_const_obj_t stream);
uintptr_t mp_uos_dupterm_poll(uintptr_t poll_flags);
int mp_uos_dupterm_rx_chr(void);
void mp_uos_dupterm_tx_strn(const char *str, size_t len);
void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc);
#else
#define mp_uos_dupterm_tx_strn(s, l)
#endif
#endif // MICROPY_INCLUDED_EXTMOD_MISC_H
================================================
FILE: extmod/modbtree.c
================================================
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include <errno.h> // for declaration of global errno variable
#include <fcntl.h>
#include "py/runtime.h"
#include "py/stream.h"
#if MICROPY_PY_BTREE
#include <db.h>
#include <../../btree/btree.h>
typedef struct _mp_obj_btree_t {
mp_obj_base_t base;
DB *db;
mp_obj_t start_key;
mp_obj_t end_key;
#define FLAG_END_KEY_INCL 1
#define FLAG_DESC 2
#define FLAG_ITER_TYPE_MASK 0xc0
#define FLAG_ITER_KEYS 0x40
#define FLAG_ITER_VALUES 0x80
#define FLAG_ITER_ITEMS 0xc0
byte flags;
byte next_flags;
} mp_obj_btree_t;
#if !MICROPY_ENABLE_DYNRUNTIME
STATIC const mp_obj_type_t btree_type;
#endif
#define CHECK_ERROR(res) \
if (res == RET_ERROR) { \
mp_raise_OSError(errno); \
}
void __dbpanic(DB *db) {
mp_printf(&mp_plat_print, "__dbpanic(%p)\n", db);
}
STATIC mp_obj_btree_t *btree_new(DB *db) {
mp_obj_btree_t *o = m_new_obj(mp_obj_btree_t);
o->base.type = &btree_type;
o
gitextract_erc644zb/
├── .gitignore
├── LICENSE
├── README.md
├── README_ZH.md
├── SConscript
├── docs/
│ ├── external_c_modules.md
│ ├── firmware-develop.md
│ ├── introduction.md
│ ├── micropython-ide.md
│ ├── micropython-librarys.md
│ ├── micropython-mpy.md
│ ├── micropython_for_pandora_iot_board.md
│ ├── micropython_for_sparrow_one_board.md
│ ├── micropython_for_w601_iot_board.md
│ ├── spec-librarys/
│ │ ├── machine/
│ │ │ ├── ADC.md
│ │ │ ├── I2C.md
│ │ │ ├── LCD.md
│ │ │ ├── PWM.md
│ │ │ ├── Pin.md
│ │ │ ├── RTC.md
│ │ │ ├── SPI.md
│ │ │ ├── Timer.md
│ │ │ ├── UART.md
│ │ │ └── WDT.md
│ │ ├── machine.md
│ │ ├── micropython.md
│ │ ├── network/
│ │ │ └── wlan.md
│ │ ├── network.md
│ │ └── rtthread.md
│ ├── std-librarys/
│ │ ├── _thread.md
│ │ ├── builtins.md
│ │ ├── cmath.md
│ │ ├── gc.md
│ │ ├── math.md
│ │ ├── rtthread.md
│ │ ├── sys.md
│ │ ├── uarray.md
│ │ ├── ubinascii.md
│ │ ├── ucollections.md
│ │ ├── uctypes.md
│ │ ├── uerrno.md
│ │ ├── uhashlib.md
│ │ ├── uheapq.md
│ │ ├── uio.md
│ │ ├── ujson.md
│ │ ├── uos.md
│ │ ├── urandom.md
│ │ ├── ure.md
│ │ ├── uselect.md
│ │ ├── usocket.md
│ │ ├── ussl.md
│ │ ├── ustruct.md
│ │ ├── utime.md
│ │ └── uzlib.md
│ └── tools-mpy-cross.md
├── drivers/
│ └── bus/
│ ├── qspi.h
│ ├── softqspi.c
│ ├── softspi.c
│ └── spi.h
├── extmod/
│ ├── axtls-include/
│ │ ├── config.h
│ │ └── version.h
│ ├── crypto-algorithms/
│ │ ├── sha256.c
│ │ └── sha256.h
│ ├── lwip-include/
│ │ ├── arch/
│ │ │ ├── cc.h
│ │ │ └── perf.h
│ │ └── lwipopts.h
│ ├── machine_i2c.c
│ ├── machine_i2c.h
│ ├── machine_mem.c
│ ├── machine_mem.h
│ ├── machine_pinbase.c
│ ├── machine_pinbase.h
│ ├── machine_pulse.c
│ ├── machine_pulse.h
│ ├── machine_signal.c
│ ├── machine_signal.h
│ ├── machine_spi.c
│ ├── machine_spi.h
│ ├── misc.h
│ ├── modbtree.c
│ ├── modframebuf.c
│ ├── modonewire.c
│ ├── modubinascii.c
│ ├── modubinascii.h
│ ├── moducryptolib.c
│ ├── moductypes.c
│ ├── moduhashlib.c
│ ├── moduheapq.c
│ ├── modujson.c
│ ├── modurandom.c
│ ├── modure.c
│ ├── moduselect.c
│ ├── modussl_axtls.c
│ ├── modussl_mbedtls.c
│ ├── modutimeq.c
│ ├── moduwebsocket.c
│ ├── moduwebsocket.h
│ ├── moduzlib.c
│ ├── modwebrepl.c
│ ├── modwebsocket.c
│ ├── modwebsocket.h
│ ├── re1.5/
│ │ ├── charclass.c
│ │ ├── compilecode.c
│ │ ├── dumpcode.c
│ │ ├── re1.5.h
│ │ └── recursiveloop.c
│ ├── uos_dupterm.c
│ ├── utime_mphal.c
│ ├── utime_mphal.h
│ ├── uzlib/
│ │ ├── adler32.c
│ │ ├── crc32.c
│ │ ├── defl_static.h
│ │ ├── tinf.h
│ │ ├── tinf_compat.h
│ │ ├── tinfgzip.c
│ │ ├── tinflate.c
│ │ ├── tinfzlib.c
│ │ ├── uzlib.h
│ │ └── uzlib_conf.h
│ ├── vfs.c
│ ├── vfs.h
│ ├── vfs_fat.c
│ ├── vfs_fat.h
│ ├── vfs_fat_diskio.c
│ ├── vfs_fat_file.c
│ ├── vfs_posix.c
│ ├── vfs_posix.h
│ ├── vfs_posix_file.c
│ ├── vfs_reader.c
│ ├── virtpin.c
│ ├── virtpin.h
│ └── webrepl/
│ ├── manifest.py
│ ├── webrepl.py
│ ├── webrepl_setup.py
│ └── websocket_helper.py
├── lib/
│ ├── mp-readline/
│ │ ├── readline.c
│ │ └── readline.h
│ ├── netutils/
│ │ ├── netutils.c
│ │ └── netutils.h
│ ├── oofatfs/
│ │ ├── diskio.h
│ │ ├── ff.c
│ │ ├── ff.h
│ │ ├── ffconf.h
│ │ └── option/
│ │ ├── ccsbcs.c
│ │ └── unicode.c
│ ├── timeutils/
│ │ ├── timeutils.c
│ │ └── timeutils.h
│ └── utils/
│ ├── gchelper.h
│ ├── gchelper_m0.s
│ ├── gchelper_m3.s
│ ├── interrupt_char.c
│ ├── interrupt_char.h
│ ├── mpirq.c
│ ├── mpirq.h
│ ├── printf.c
│ ├── pyexec.c
│ ├── pyexec.h
│ ├── stdout_helpers.c
│ └── sys_stdio_mphal.c
├── port/
│ ├── frozen_mpy.c
│ ├── gccollect.c
│ ├── genhdr/
│ │ ├── gen_qstr.py
│ │ ├── moduledefs.h
│ │ ├── mpversion.h
│ │ └── qstrdefs.generated.h
│ ├── modules/
│ │ ├── machine/
│ │ │ ├── machine_adc.c
│ │ │ ├── machine_adc.h
│ │ │ ├── machine_hw_i2c.c
│ │ │ ├── machine_hw_spi.c
│ │ │ ├── machine_lcd.c
│ │ │ ├── machine_lcd.h
│ │ │ ├── machine_pin.c
│ │ │ ├── machine_pwm.c
│ │ │ ├── machine_pwm.h
│ │ │ ├── machine_rtc.c
│ │ │ ├── machine_rtc.h
│ │ │ ├── machine_timer.c
│ │ │ ├── machine_timer.h
│ │ │ ├── machine_uart.c
│ │ │ ├── machine_uart.h
│ │ │ ├── machine_wdt.c
│ │ │ ├── machine_wdt.h
│ │ │ ├── modmachine.c
│ │ │ └── modmachine.h
│ │ ├── modffi.c
│ │ ├── modfile.c
│ │ ├── modnetwork.c
│ │ ├── modnetwork.h
│ │ ├── modnetwork_wlan.c
│ │ ├── modpyb.c
│ │ ├── modrtthread.c
│ │ ├── moduos.c
│ │ ├── moduos_file.c
│ │ ├── moduos_file.h
│ │ ├── modusocket.c
│ │ ├── modutils.c
│ │ ├── modutime.c
│ │ └── user/
│ │ └── moduserfunc.c
│ ├── mpconfigport.h
│ ├── mpgetcharport.c
│ ├── mpgetcharport.h
│ ├── mphalport.c
│ ├── mphalport.h
│ ├── mpputsnport.c
│ ├── mpputsnport.h
│ ├── mpthreadport.c
│ ├── mpthreadport.h
│ ├── mpy_main.c
│ ├── mpy_project_cfg.h
│ ├── native/
│ │ ├── easyflash_module.c
│ │ ├── easyflash_module.py
│ │ ├── native_module.c
│ │ └── native_module.py
│ └── qstrdefsport.h
├── py/
│ ├── argcheck.c
│ ├── asmarm.c
│ ├── asmarm.h
│ ├── asmbase.c
│ ├── asmbase.h
│ ├── asmthumb.c
│ ├── asmthumb.h
│ ├── asmx64.c
│ ├── asmx64.h
│ ├── asmx86.c
│ ├── asmx86.h
│ ├── asmxtensa.c
│ ├── asmxtensa.h
│ ├── bc.c
│ ├── bc.h
│ ├── bc0.h
│ ├── binary.c
│ ├── binary.h
│ ├── builtin.h
│ ├── builtinevex.c
│ ├── builtinhelp.c
│ ├── builtinimport.c
│ ├── compile.c
│ ├── compile.h
│ ├── dynruntime.h
│ ├── dynruntime.mk
│ ├── emit.h
│ ├── emitbc.c
│ ├── emitcommon.c
│ ├── emitglue.c
│ ├── emitglue.h
│ ├── emitinlinethumb.c
│ ├── emitinlinextensa.c
│ ├── emitnarm.c
│ ├── emitnative.c
│ ├── emitnthumb.c
│ ├── emitnx64.c
│ ├── emitnx86.c
│ ├── emitnxtensa.c
│ ├── emitnxtensawin.c
│ ├── formatfloat.c
│ ├── formatfloat.h
│ ├── frozenmod.c
│ ├── frozenmod.h
│ ├── gc.c
│ ├── gc.h
│ ├── grammar.h
│ ├── lexer.c
│ ├── lexer.h
│ ├── makecompresseddata.py
│ ├── makemoduledefs.py
│ ├── makeqstrdata.py
│ ├── makeqstrdefs.py
│ ├── makeversionhdr.py
│ ├── malloc.c
│ ├── map.c
│ ├── misc.h
│ ├── mkenv.mk
│ ├── mkrules.mk
│ ├── modarray.c
│ ├── modbuiltins.c
│ ├── modcmath.c
│ ├── modcollections.c
│ ├── modgc.c
│ ├── modio.c
│ ├── modmath.c
│ ├── modmicropython.c
│ ├── modstruct.c
│ ├── modsys.c
│ ├── modthread.c
│ ├── moduerrno.c
│ ├── mpconfig.h
│ ├── mperrno.h
│ ├── mphal.h
│ ├── mpprint.c
│ ├── mpprint.h
│ ├── mpstate.c
│ ├── mpstate.h
│ ├── mpthread.h
│ ├── mpz.c
│ ├── mpz.h
│ ├── nativeglue.c
│ ├── nativeglue.h
│ ├── nlr.c
│ ├── nlr.h
│ ├── nlrpowerpc.c
│ ├── nlrsetjmp.c
│ ├── nlrthumb.c
│ ├── nlrx64.c
│ ├── nlrx86.c
│ ├── nlrxtensa.c
│ ├── obj.c
│ ├── obj.h
│ ├── objarray.c
│ ├── objarray.h
│ ├── objattrtuple.c
│ ├── objbool.c
│ ├── objboundmeth.c
│ ├── objcell.c
│ ├── objclosure.c
│ ├── objcomplex.c
│ ├── objdeque.c
│ ├── objdict.c
│ ├── objenumerate.c
│ ├── objexcept.c
│ ├── objexcept.h
│ ├── objfilter.c
│ ├── objfloat.c
│ ├── objfun.c
│ ├── objfun.h
│ ├── objgenerator.c
│ ├── objgenerator.h
│ ├── objgetitemiter.c
│ ├── objint.c
│ ├── objint.h
│ ├── objint_longlong.c
│ ├── objint_mpz.c
│ ├── objlist.c
│ ├── objlist.h
│ ├── objmap.c
│ ├── objmodule.c
│ ├── objmodule.h
│ ├── objnamedtuple.c
│ ├── objnamedtuple.h
│ ├── objnone.c
│ ├── objobject.c
│ ├── objpolyiter.c
│ ├── objproperty.c
│ ├── objrange.c
│ ├── objreversed.c
│ ├── objset.c
│ ├── objsingleton.c
│ ├── objslice.c
│ ├── objstr.c
│ ├── objstr.h
│ ├── objstringio.c
│ ├── objstringio.h
│ ├── objstrunicode.c
│ ├── objtuple.c
│ ├── objtuple.h
│ ├── objtype.c
│ ├── objtype.h
│ ├── objzip.c
│ ├── opmethods.c
│ ├── pairheap.c
│ ├── pairheap.h
│ ├── parse.c
│ ├── parse.h
│ ├── parsenum.c
│ ├── parsenum.h
│ ├── parsenumbase.c
│ ├── parsenumbase.h
│ ├── persistentcode.c
│ ├── persistentcode.h
│ ├── profile.c
│ ├── profile.h
│ ├── py.mk
│ ├── pystack.c
│ ├── pystack.h
│ ├── qstr.c
│ ├── qstr.h
│ ├── qstrdefs.h
│ ├── reader.c
│ ├── reader.h
│ ├── repl.c
│ ├── repl.h
│ ├── ringbuf.c
│ ├── ringbuf.h
│ ├── runtime.c
│ ├── runtime.h
│ ├── runtime0.h
│ ├── runtime_utils.c
│ ├── scheduler.c
│ ├── scope.c
│ ├── scope.h
│ ├── sequence.c
│ ├── showbc.c
│ ├── smallint.c
│ ├── smallint.h
│ ├── stackctrl.c
│ ├── stackctrl.h
│ ├── stream.c
│ ├── stream.h
│ ├── unicode.c
│ ├── unicode.h
│ ├── vm.c
│ ├── vmentrytable.h
│ ├── vstr.c
│ └── warning.c
└── tools/
└── mpy-cross/
├── hellortt.mpy
└── hellortt.py
Showing preview only (280K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2966 symbols across 273 files)
FILE: drivers/bus/qspi.h
type mp_qspi_proto_t (line 38) | typedef struct _mp_qspi_proto_t {
type mp_soft_qspi_obj_t (line 46) | typedef struct _mp_soft_qspi_obj_t {
FILE: drivers/bus/softqspi.c
function STATIC (line 52) | STATIC void nibble_write(mp_soft_qspi_obj_t *self, uint8_t v) {
function STATIC (line 59) | STATIC int mp_soft_qspi_ioctl(void *self_in, uint32_t cmd) {
function STATIC (line 83) | STATIC void mp_soft_qspi_transfer(mp_soft_qspi_obj_t *self, size_t len, ...
function STATIC (line 122) | STATIC void mp_soft_qspi_qread(mp_soft_qspi_obj_t *self, size_t len, uin...
function STATIC (line 140) | STATIC void mp_soft_qspi_qwrite(mp_soft_qspi_obj_t *self, size_t len, co...
function STATIC (line 161) | STATIC void mp_soft_qspi_write_cmd_data(void *self_in, uint8_t cmd, size...
function STATIC (line 169) | STATIC void mp_soft_qspi_write_cmd_addr_data(void *self_in, uint8_t cmd,...
function STATIC (line 178) | STATIC uint32_t mp_soft_qspi_read_cmd(void *self_in, uint8_t cmd, size_t...
function STATIC (line 187) | STATIC void mp_soft_qspi_read_cmd_qaddr_qdata(void *self_in, uint8_t cmd...
FILE: drivers/bus/softspi.c
function mp_soft_spi_ioctl (line 29) | int mp_soft_spi_ioctl(void *self_in, uint32_t cmd) {
function mp_soft_spi_transfer (line 47) | void mp_soft_spi_transfer(void *self_in, size_t len, const uint8_t *src,...
FILE: drivers/bus/spi.h
type mp_spi_proto_t (line 36) | typedef struct _mp_spi_proto_t {
type mp_soft_spi_obj_t (line 41) | typedef struct _mp_soft_spi_obj_t {
FILE: extmod/crypto-algorithms/sha256.c
function sha256_transform (line 44) | static void sha256_transform(CRYAL_SHA256_CTX *ctx, const BYTE data[])
function sha256_init (line 85) | void sha256_init(CRYAL_SHA256_CTX *ctx)
function sha256_update (line 99) | void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len)
function sha256_final (line 114) | void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[])
FILE: extmod/crypto-algorithms/sha256.h
type BYTE (line 20) | typedef unsigned char BYTE;
type WORD (line 21) | typedef unsigned int WORD;
type CRYAL_SHA256_CTX (line 23) | typedef struct {
FILE: extmod/lwip-include/arch/cc.h
type u8_t (line 8) | typedef uint8_t u8_t;
type s8_t (line 9) | typedef int8_t s8_t;
type u16_t (line 10) | typedef uint16_t u16_t;
type s16_t (line 11) | typedef int16_t s16_t;
type u32_t (line 12) | typedef uint32_t u32_t;
type s32_t (line 13) | typedef int32_t s32_t;
type u32_t (line 15) | typedef u32_t mem_ptr_t;
FILE: extmod/lwip-include/lwipopts.h
type sys_prot_t (line 13) | typedef uint32_t sys_prot_t;
FILE: extmod/machine_i2c.c
type mp_machine_soft_i2c_obj_t (line 38) | typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t;
function STATIC (line 40) | STATIC void mp_hal_i2c_delay(machine_i2c_obj_t *self) {
function STATIC (line 46) | STATIC void mp_hal_i2c_scl_low(machine_i2c_obj_t *self) {
function STATIC (line 50) | STATIC int mp_hal_i2c_scl_release(machine_i2c_obj_t *self) {
function STATIC (line 65) | STATIC void mp_hal_i2c_sda_low(machine_i2c_obj_t *self) {
function STATIC (line 69) | STATIC void mp_hal_i2c_sda_release(machine_i2c_obj_t *self) {
function STATIC (line 73) | STATIC int mp_hal_i2c_sda_read(machine_i2c_obj_t *self) {
function STATIC (line 77) | STATIC int mp_hal_i2c_start(machine_i2c_obj_t *self) {
function STATIC (line 89) | STATIC int mp_hal_i2c_stop(machine_i2c_obj_t *self) {
function STATIC (line 99) | STATIC void mp_hal_i2c_init(machine_i2c_obj_t *self, uint32_t freq) {
function STATIC (line 113) | STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) {
function STATIC (line 149) | STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, i...
function mp_machine_soft_i2c_transfer (line 185) | int mp_machine_soft_i2c_transfer(mp_obj_base_t *self_in, uint16_t addr, ...
function mp_machine_i2c_transfer_adaptor (line 247) | int mp_machine_i2c_transfer_adaptor(mp_obj_base_t *self, uint16_t addr, ...
function STATIC (line 288) | STATIC int mp_machine_i2c_readfrom(mp_obj_base_t *self, uint16_t addr, u...
function STATIC (line 295) | STATIC int mp_machine_i2c_writeto(mp_obj_base_t *self, uint16_t addr, co...
function STATIC (line 305) | STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, size_t ...
function STATIC (line 321) | STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n...
function STATIC (line 346) | STATIC mp_obj_t machine_i2c_obj_init(size_t n_args, const mp_obj_t *args...
function STATIC (line 352) | STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
function STATIC (line 366) | STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
function STATIC (line 380) | STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
function STATIC (line 394) | STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
function STATIC (line 418) | STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) {
function STATIC (line 440) | STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) {
function STATIC (line 454) | STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t ...
function STATIC (line 468) | STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) {
function STATIC (line 483) | STATIC mp_obj_t machine_i2c_writevto(size_t n_args, const mp_obj_t *args) {
function STATIC (line 529) | STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, u...
function STATIC (line 545) | STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, ...
function STATIC (line 573) | STATIC mp_obj_t machine_i2c_readfrom_mem(size_t n_args, const mp_obj_t *...
function STATIC (line 595) | STATIC mp_obj_t machine_i2c_readfrom_mem_into(size_t n_args, const mp_ob...
function STATIC (line 615) | STATIC mp_obj_t machine_i2c_writeto_mem(size_t n_args, const mp_obj_t *p...
function mp_machine_soft_i2c_read (line 660) | int mp_machine_soft_i2c_read(mp_obj_base_t *self_in, uint8_t *dest, size...
function mp_machine_soft_i2c_write (line 671) | int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src...
FILE: extmod/machine_i2c.h
type mp_machine_i2c_buf_t (line 34) | typedef struct _mp_machine_i2c_buf_t {
type mp_machine_i2c_p_t (line 42) | typedef struct _mp_machine_i2c_p_t {
type mp_machine_soft_i2c_obj_t (line 51) | typedef struct _mp_machine_soft_i2c_obj_t {
FILE: extmod/machine_mem.c
function STATIC (line 42) | STATIC uintptr_t machine_mem_get_addr(mp_obj_t addr_o, uint align) {
function STATIC (line 57) | STATIC void machine_mem_print(const mp_print_t *print, mp_obj_t self_in,...
function STATIC (line 63) | STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_...
FILE: extmod/machine_mem.h
type machine_mem_obj_t (line 31) | typedef struct _machine_mem_obj_t {
FILE: extmod/machine_pinbase.c
type mp_pinbase_t (line 40) | typedef struct _mp_pinbase_t {
function STATIC (line 48) | STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_arg...
function mp_uint_t (line 57) | mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, ...
FILE: extmod/machine_pulse.c
function MP_WEAK (line 33) | MP_WEAK mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_...
function STATIC (line 49) | STATIC mp_obj_t machine_time_pulse_us_(size_t n_args, const mp_obj_t *ar...
FILE: extmod/machine_signal.c
type machine_signal_t (line 39) | typedef struct _machine_signal_t {
function STATIC (line 45) | STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args...
function STATIC (line 119) | STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintp...
function STATIC (line 136) | STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw...
function STATIC (line 148) | STATIC mp_obj_t signal_value(size_t n_args, const mp_obj_t *args) {
function STATIC (line 153) | STATIC mp_obj_t signal_on(mp_obj_t self_in) {
function STATIC (line 159) | STATIC mp_obj_t signal_off(mp_obj_t self_in) {
FILE: extmod/machine_spi.c
function mp_obj_t (line 46) | mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_arg...
function STATIC (line 66) | STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp...
function STATIC (line 74) | STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) {
function STATIC (line 84) | STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const voi...
function STATIC (line 90) | STATIC mp_obj_t mp_machine_spi_read(size_t n_args, const mp_obj_t *args) {
function STATIC (line 99) | STATIC mp_obj_t mp_machine_spi_readinto(size_t n_args, const mp_obj_t *a...
function STATIC (line 108) | STATIC mp_obj_t mp_machine_spi_write(mp_obj_t self, mp_obj_t wr_buf) {
function STATIC (line 116) | STATIC mp_obj_t mp_machine_spi_write_readinto(mp_obj_t self, mp_obj_t wr...
function STATIC (line 146) | STATIC uint32_t baudrate_from_delay_half(uint32_t delay_half) {
function STATIC (line 157) | STATIC uint32_t baudrate_to_delay_half(uint32_t baudrate) {
function STATIC (line 173) | STATIC void mp_machine_soft_spi_print(const mp_print_t *print, mp_obj_t ...
function STATIC (line 181) | STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, ...
function STATIC (line 225) | STATIC void mp_machine_soft_spi_init(mp_obj_base_t *self_in, size_t n_ar...
function STATIC (line 263) | STATIC void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t ...
FILE: extmod/machine_spi.h
type mp_machine_spi_p_t (line 34) | typedef struct _mp_machine_spi_p_t {
type mp_machine_soft_spi_obj_t (line 40) | typedef struct _mp_machine_soft_spi_obj_t {
FILE: extmod/modbtree.c
type mp_obj_btree_t (line 40) | typedef struct _mp_obj_btree_t {
function __dbpanic (line 64) | void __dbpanic(DB *db) {
function STATIC (line 68) | STATIC mp_obj_btree_t *btree_new(DB *db) {
function STATIC (line 78) | STATIC void btree_print(const mp_print_t *print, mp_obj_t self_in, mp_pr...
function STATIC (line 84) | STATIC mp_obj_t btree_flush(mp_obj_t self_in) {
function STATIC (line 90) | STATIC mp_obj_t btree_close(mp_obj_t self_in) {
function STATIC (line 96) | STATIC mp_obj_t btree_put(size_t n_args, const mp_obj_t *args) {
function STATIC (line 106) | STATIC mp_obj_t btree_get(size_t n_args, const mp_obj_t *args) {
function STATIC (line 123) | STATIC mp_obj_t btree_seq(size_t n_args, const mp_obj_t *args) {
function STATIC (line 145) | STATIC mp_obj_t btree_init_iter(size_t n_args, const mp_obj_t *args, byt...
function STATIC (line 162) | STATIC mp_obj_t btree_keys(size_t n_args, const mp_obj_t *args) {
function STATIC (line 167) | STATIC mp_obj_t btree_values(size_t n_args, const mp_obj_t *args) {
function STATIC (line 172) | STATIC mp_obj_t btree_items(size_t n_args, const mp_obj_t *args) {
function STATIC (line 177) | STATIC mp_obj_t btree_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_...
function STATIC (line 195) | STATIC mp_obj_t btree_iternext(mp_obj_t self_in) {
function STATIC (line 251) | STATIC mp_obj_t btree_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t ...
function STATIC (line 284) | STATIC mp_obj_t btree_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o...
function STATIC (line 335) | STATIC mp_obj_t mod_btree_open(size_t n_args, const mp_obj_t *pos_args, ...
FILE: extmod/modframebuf.c
type mp_obj_framebuf_t (line 36) | typedef struct _mp_obj_framebuf_t {
type mp_framebuf_p_t (line 48) | typedef struct _mp_framebuf_p_t {
function STATIC (line 65) | STATIC void mono_horiz_setpixel(const mp_obj_framebuf_t *fb, int x, int ...
function STATIC (line 71) | STATIC uint32_t mono_horiz_getpixel(const mp_obj_framebuf_t *fb, int x, ...
function STATIC (line 77) | STATIC void mono_horiz_fill_rect(const mp_obj_framebuf_t *fb, int x, int...
function STATIC (line 93) | STATIC void mvlsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y, ui...
function STATIC (line 99) | STATIC uint32_t mvlsb_getpixel(const mp_obj_framebuf_t *fb, int x, int y) {
function STATIC (line 103) | STATIC void mvlsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, i...
function STATIC (line 117) | STATIC void rgb565_setpixel(const mp_obj_framebuf_t *fb, int x, int y, u...
function STATIC (line 121) | STATIC uint32_t rgb565_getpixel(const mp_obj_framebuf_t *fb, int x, int ...
function STATIC (line 125) | STATIC void rgb565_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, ...
function STATIC (line 137) | STATIC void gs2_hmsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y,...
function STATIC (line 145) | STATIC uint32_t gs2_hmsb_getpixel(const mp_obj_framebuf_t *fb, int x, in...
function STATIC (line 151) | STATIC void gs2_hmsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y...
function STATIC (line 161) | STATIC void gs4_hmsb_setpixel(const mp_obj_framebuf_t *fb, int x, int y,...
function STATIC (line 171) | STATIC uint32_t gs4_hmsb_getpixel(const mp_obj_framebuf_t *fb, int x, in...
function STATIC (line 179) | STATIC void gs4_hmsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y...
function STATIC (line 212) | STATIC void gs8_setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint...
function STATIC (line 217) | STATIC uint32_t gs8_getpixel(const mp_obj_framebuf_t *fb, int x, int y) {
function STATIC (line 221) | STATIC void gs8_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int...
function setpixel (line 239) | static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, u...
function getpixel (line 243) | static inline uint32_t getpixel(const mp_obj_framebuf_t *fb, int x, int ...
function STATIC (line 247) | STATIC void fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, ...
function STATIC (line 262) | STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_ar...
function STATIC (line 305) | STATIC mp_int_t framebuf_get_buffer(mp_obj_t self_in, mp_buffer_info_t *...
function STATIC (line 314) | STATIC mp_obj_t framebuf_fill(mp_obj_t self_in, mp_obj_t col_in) {
function STATIC (line 322) | STATIC mp_obj_t framebuf_fill_rect(size_t n_args, const mp_obj_t *args) {
function STATIC (line 338) | STATIC mp_obj_t framebuf_pixel(size_t n_args, const mp_obj_t *args) {
function STATIC (line 355) | STATIC mp_obj_t framebuf_hline(size_t n_args, const mp_obj_t *args) {
function STATIC (line 370) | STATIC mp_obj_t framebuf_vline(size_t n_args, const mp_obj_t *args) {
function STATIC (line 385) | STATIC mp_obj_t framebuf_rect(size_t n_args, const mp_obj_t *args) {
function STATIC (line 404) | STATIC mp_obj_t framebuf_line(size_t n_args, const mp_obj_t *args) {
function STATIC (line 470) | STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
function STATIC (line 513) | STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_...
function STATIC (line 545) | STATIC mp_obj_t framebuf_text(size_t n_args, const mp_obj_t *args) {
function STATIC (line 608) | STATIC mp_obj_t legacy_framebuffer1(size_t n_args, const mp_obj_t *args) {
FILE: extmod/modonewire.c
function STATIC (line 46) | STATIC int onewire_bus_reset(mp_hal_pin_obj_t pin) {
function STATIC (line 58) | STATIC int onewire_bus_readbit(mp_hal_pin_obj_t pin) {
function STATIC (line 71) | STATIC void onewire_bus_writebit(mp_hal_pin_obj_t pin, int value) {
function STATIC (line 87) | STATIC mp_obj_t onewire_reset(mp_obj_t pin_in) {
function STATIC (line 92) | STATIC mp_obj_t onewire_readbit(mp_obj_t pin_in) {
function STATIC (line 97) | STATIC mp_obj_t onewire_readbyte(mp_obj_t pin_in) {
function STATIC (line 107) | STATIC mp_obj_t onewire_writebit(mp_obj_t pin_in, mp_obj_t value_in) {
function STATIC (line 113) | STATIC mp_obj_t onewire_writebyte(mp_obj_t pin_in, mp_obj_t value_in) {
function STATIC (line 124) | STATIC mp_obj_t onewire_crc8(mp_obj_t data) {
FILE: extmod/modubinascii.c
function mp_obj_t (line 35) | mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) {
function mp_obj_t (line 76) | mp_obj_t mod_binascii_unhexlify(mp_obj_t data) {
function mod_binascii_sextet (line 108) | static int mod_binascii_sextet(byte ch) {
function mp_obj_t (line 124) | mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) {
function mp_obj_t (line 167) | mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) {
function mp_obj_t (line 223) | mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
FILE: extmod/moducryptolib.c
type ctr_params (line 49) | struct ctr_params {
type mbedtls_aes_ctx_with_key (line 69) | struct mbedtls_aes_ctx_with_key {
type mp_obj_aes_t (line 82) | typedef struct _mp_obj_aes_t {
function is_ctr_mode (line 92) | static inline bool is_ctr_mode(int block_mode) {
type ctr_params (line 100) | struct ctr_params
type ctr_params (line 102) | struct ctr_params
function STATIC (line 106) | STATIC void aes_initial_set_key_impl(AES_CTX_IMPL *ctx, const uint8_t *k...
function STATIC (line 111) | STATIC void aes_final_set_key_impl(AES_CTX_IMPL *ctx, bool encrypt) {
function STATIC (line 117) | STATIC void aes_process_ecb_impl(AES_CTX_IMPL *ctx, const uint8_t in[16]...
function STATIC (line 135) | STATIC void aes_process_cbc_impl(AES_CTX_IMPL *ctx, const uint8_t *in, u...
function STATIC (line 145) | STATIC void aes_process_ctr_impl(AES_CTX_IMPL *ctx, const uint8_t *in, u...
function STATIC (line 172) | STATIC void aes_initial_set_key_impl(AES_CTX_IMPL *ctx, const uint8_t *k...
function STATIC (line 181) | STATIC void aes_final_set_key_impl(AES_CTX_IMPL *ctx, bool encrypt) {
function STATIC (line 198) | STATIC void aes_process_ecb_impl(AES_CTX_IMPL *ctx, const uint8_t in[16]...
function STATIC (line 202) | STATIC void aes_process_cbc_impl(AES_CTX_IMPL *ctx, const uint8_t *in, u...
function STATIC (line 207) | STATIC void aes_process_ctr_impl(AES_CTX_IMPL *ctx, const uint8_t *in, u...
function STATIC (line 214) | STATIC mp_obj_t ucryptolib_aes_make_new(const mp_obj_type_t *type, size_...
function STATIC (line 264) | STATIC mp_obj_t aes_process(size_t n_args, const mp_obj_t *args, bool en...
function STATIC (line 336) | STATIC mp_obj_t ucryptolib_aes_encrypt(size_t n_args, const mp_obj_t *ar...
function STATIC (line 341) | STATIC mp_obj_t ucryptolib_aes_decrypt(size_t n_args, const mp_obj_t *ar...
FILE: extmod/moductypes.c
type mp_obj_uctypes_struct_t (line 112) | typedef struct _mp_obj_uctypes_struct_t {
function syntax_error (line 119) | void syntax_error(void) {
function STATIC (line 123) | STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_...
function STATIC (line 136) | STATIC void uctypes_struct_print(const mp_print_t *print, mp_obj_t self_...
function mp_uint_t (line 164) | static inline mp_uint_t uctypes_struct_scalar_size(int val_type) {
function STATIC (line 173) | STATIC mp_uint_t uctypes_struct_agg_size(mp_obj_tuple_t *t, int layout_t...
function STATIC (line 212) | STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, ...
function STATIC (line 272) | STATIC mp_obj_t uctypes_struct_sizeof(size_t n_args, const mp_obj_t *arg...
function mp_obj_t (line 299) | static inline mp_obj_t get_unaligned(uint val_type, byte *p, int big_end...
function set_unaligned (line 305) | static inline void set_unaligned(uint val_type, byte *p, int big_endian,...
function mp_uint_t (line 311) | static inline mp_uint_t get_aligned_basic(uint val_type, void *p) {
function set_aligned_basic (line 324) | static inline void set_aligned_basic(uint val_type, void *p, mp_uint_t v) {
function STATIC (line 336) | STATIC mp_obj_t get_aligned(uint val_type, void *p, mp_int_t index) {
function STATIC (line 366) | STATIC void set_aligned(uint val_type, void *p, mp_int_t index, mp_obj_t...
function STATIC (line 406) | STATIC mp_obj_t uctypes_struct_attr_op(mp_obj_t self_in, qstr attr, mp_o...
function STATIC (line 525) | STATIC void uctypes_struct_attr(mp_obj_t self_in, qstr attr, mp_obj_t *d...
function STATIC (line 538) | STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_i...
function STATIC (line 617) | STATIC mp_obj_t uctypes_struct_unary_op(mp_unary_op_t op, mp_obj_t self_...
function STATIC (line 636) | STATIC mp_int_t uctypes_get_buffer(mp_obj_t self_in, mp_buffer_info_t *b...
function STATIC (line 651) | STATIC mp_obj_t uctypes_struct_addressof(mp_obj_t buf) {
function STATIC (line 662) | STATIC mp_obj_t uctypes_struct_bytearray_at(mp_obj_t ptr, mp_obj_t size) {
function STATIC (line 671) | STATIC mp_obj_t uctypes_struct_bytes_at(mp_obj_t ptr, mp_obj_t size) {
FILE: extmod/moduhashlib.c
type mp_obj_hash_t (line 61) | typedef struct _mp_obj_hash_t {
function STATIC (line 77) | STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size...
function STATIC (line 89) | STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) {
function STATIC (line 97) | STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) {
function STATIC (line 109) | STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size...
function STATIC (line 120) | STATIC mp_obj_t uhashlib_sha256_update(mp_obj_t self_in, mp_obj_t arg) {
function STATIC (line 128) | STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) {
function STATIC (line 159) | STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t...
function STATIC (line 170) | STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) {
function STATIC (line 178) | STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) {
function STATIC (line 195) | STATIC mp_obj_t uhashlib_sha1_make_new(const mp_obj_type_t *type, size_t...
function STATIC (line 207) | STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg) {
function STATIC (line 215) | STATIC mp_obj_t uhashlib_sha1_digest(mp_obj_t self_in) {
function STATIC (line 246) | STATIC mp_obj_t uhashlib_md5_make_new(const mp_obj_type_t *type, size_t ...
function STATIC (line 257) | STATIC mp_obj_t uhashlib_md5_update(mp_obj_t self_in, mp_obj_t arg) {
function STATIC (line 265) | STATIC mp_obj_t uhashlib_md5_digest(mp_obj_t self_in) {
function STATIC (line 282) | STATIC mp_obj_t uhashlib_md5_make_new(const mp_obj_type_t *type, size_t ...
function STATIC (line 294) | STATIC mp_obj_t uhashlib_md5_update(mp_obj_t self_in, mp_obj_t arg) {
function STATIC (line 302) | STATIC mp_obj_t uhashlib_md5_digest(mp_obj_t self_in) {
FILE: extmod/moduheapq.c
function STATIC (line 34) | STATIC mp_obj_list_t *uheapq_get_heap(mp_obj_t heap_in) {
function STATIC (line 41) | STATIC void uheapq_heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_po...
function STATIC (line 56) | STATIC void uheapq_heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) {
function STATIC (line 73) | STATIC mp_obj_t mod_uheapq_heappush(mp_obj_t heap_in, mp_obj_t item) {
function STATIC (line 81) | STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
function STATIC (line 97) | STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) {
FILE: extmod/modujson.c
function STATIC (line 37) | STATIC mp_obj_t mod_ujson_dump(mp_obj_t obj, mp_obj_t stream) {
function STATIC (line 45) | STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) {
type ujson_stream_t (line 67) | typedef struct _ujson_stream_t {
function STATIC (line 79) | STATIC byte ujson_stream_next(ujson_stream_t *s) {
function STATIC (line 90) | STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
function STATIC (line 283) | STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
FILE: extmod/modurandom.c
function STATIC (line 44) | STATIC uint32_t yasmarang(void)
function STATIC (line 61) | STATIC uint32_t yasmarang_randbelow(uint32_t n) {
function STATIC (line 75) | STATIC mp_obj_t mod_urandom_getrandbits(mp_obj_t num_in) {
function STATIC (line 87) | STATIC mp_obj_t mod_urandom_seed(mp_obj_t seed_in) {
function STATIC (line 99) | STATIC mp_obj_t mod_urandom_randrange(size_t n_args, const mp_obj_t *arg...
function STATIC (line 141) | STATIC mp_obj_t mod_urandom_randint(mp_obj_t a_in, mp_obj_t b_in) {
function STATIC (line 152) | STATIC mp_obj_t mod_urandom_choice(mp_obj_t seq) {
function STATIC (line 165) | STATIC mp_float_t yasmarang_float(void) {
function STATIC (line 189) | STATIC mp_obj_t mod_urandom_random(void) {
function STATIC (line 194) | STATIC mp_obj_t mod_urandom_uniform(mp_obj_t a_in, mp_obj_t b_in) {
function STATIC (line 206) | STATIC mp_obj_t mod_urandom___init__() {
FILE: extmod/modure.c
type mp_obj_re_t (line 44) | typedef struct _mp_obj_re_t {
type mp_obj_match_t (line 49) | typedef struct _mp_obj_match_t {
function STATIC (line 57) | STATIC void match_print(const mp_print_t *print, mp_obj_t self_in, mp_pr...
function STATIC (line 63) | STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) {
function STATIC (line 82) | STATIC mp_obj_t match_groups(mp_obj_t self_in) {
function STATIC (line 99) | STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_ob...
function STATIC (line 124) | STATIC mp_obj_t match_span(size_t n_args, const mp_obj_t *args) {
function STATIC (line 131) | STATIC mp_obj_t match_start(size_t n_args, const mp_obj_t *args) {
function STATIC (line 138) | STATIC mp_obj_t match_end(size_t n_args, const mp_obj_t *args) {
function STATIC (line 170) | STATIC void re_print(const mp_print_t *print, mp_obj_t self_in, mp_print...
function STATIC (line 176) | STATIC mp_obj_t ure_exec(bool is_anchored, uint n_args, const mp_obj_t *...
function STATIC (line 199) | STATIC mp_obj_t re_match(size_t n_args, const mp_obj_t *args) {
function STATIC (line 204) | STATIC mp_obj_t re_search(size_t n_args, const mp_obj_t *args) {
function STATIC (line 209) | STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) {
function STATIC (line 256) | STATIC mp_obj_t re_sub_helper(mp_obj_t self_in, size_t n_args, const mp_...
function STATIC (line 361) | STATIC mp_obj_t re_sub(size_t n_args, const mp_obj_t *args) {
function STATIC (line 388) | STATIC mp_obj_t mod_re_compile(size_t n_args, const mp_obj_t *args) {
function STATIC (line 417) | STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_...
function STATIC (line 426) | STATIC mp_obj_t mod_re_match(size_t n_args, const mp_obj_t *args) {
function STATIC (line 431) | STATIC mp_obj_t mod_re_search(size_t n_args, const mp_obj_t *args) {
function STATIC (line 437) | STATIC mp_obj_t mod_re_sub(size_t n_args, const mp_obj_t *args) {
FILE: extmod/moduselect.c
type poll_obj_t (line 47) | typedef struct _poll_obj_t {
function STATIC (line 54) | STATIC void poll_map_add(mp_map_t *poll_map, const mp_obj_t *obj, mp_uin...
function STATIC (line 78) | STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, size_t *rwx_num) {
function STATIC (line 115) | STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) {
type mp_obj_poll_t (line 183) | typedef struct _mp_obj_poll_t {
function STATIC (line 194) | STATIC mp_obj_t poll_register(size_t n_args, const mp_obj_t *args) {
function STATIC (line 208) | STATIC mp_obj_t poll_unregister(mp_obj_t self_in, mp_obj_t obj_in) {
function STATIC (line 217) | STATIC mp_obj_t poll_modify(mp_obj_t self_in, mp_obj_t obj_in, mp_obj_t ...
function STATIC (line 228) | STATIC mp_uint_t poll_poll_internal(uint n_args, const mp_obj_t *args) {
function STATIC (line 262) | STATIC mp_obj_t poll_poll(size_t n_args, const mp_obj_t *args) {
function STATIC (line 287) | STATIC mp_obj_t poll_ipoll(size_t n_args, const mp_obj_t *args) {
function STATIC (line 302) | STATIC mp_obj_t poll_iternext(mp_obj_t self_in) {
function STATIC (line 352) | STATIC mp_obj_t select_poll(void) {
FILE: extmod/modussl_axtls.c
type mp_obj_ssl_socket_t (line 38) | typedef struct _mp_obj_ssl_socket_t {
type ssl_args (line 48) | struct ssl_args {
function ussl_raise_error (line 87) | void ussl_raise_error(int err) {
function STATIC (line 120) | STATIC mp_obj_ssl_socket_t *ussl_socket_new(mp_obj_t sock, struct ssl_ar...
function STATIC (line 182) | STATIC void ussl_socket_print(const mp_print_t *print, mp_obj_t self_in,...
function STATIC (line 188) | STATIC mp_uint_t ussl_socket_read(mp_obj_t o_in, void *buf, mp_uint_t si...
function STATIC (line 237) | STATIC mp_uint_t ussl_socket_write(mp_obj_t o_in, const void *buf, mp_ui...
function STATIC (line 253) | STATIC mp_uint_t ussl_socket_ioctl(mp_obj_t o_in, mp_uint_t request, uin...
function STATIC (line 264) | STATIC mp_obj_t ussl_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_...
function STATIC (line 307) | STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_a...
FILE: extmod/modussl_mbedtls.c
type mp_obj_ssl_socket_t (line 49) | typedef struct _mp_obj_ssl_socket_t {
type ssl_args (line 61) | struct ssl_args {
function STATIC (line 72) | STATIC void mbedtls_debug(void *ctx, int level, const char *file, int li...
function mbedtls_raise_error (line 79) | void mbedtls_raise_error(int err) {
function STATIC (line 119) | STATIC int _mbedtls_ssl_send(void *ctx, const byte *buf, size_t len) {
function STATIC (line 136) | STATIC int _mbedtls_ssl_recv(void *ctx, byte *buf, size_t len) {
function STATIC (line 154) | STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *a...
function STATIC (line 269) | STATIC mp_obj_t mod_ssl_getpeercert(mp_obj_t o_in, mp_obj_t binary_form) {
function STATIC (line 282) | STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_p...
function STATIC (line 288) | STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, i...
function STATIC (line 311) | STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t ...
function STATIC (line 330) | STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
function STATIC (line 340) | STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_...
function STATIC (line 387) | STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_a...
FILE: extmod/modutimeq.c
type qentry (line 42) | struct qentry {
type mp_obj_utimeq_t (line 49) | typedef struct _mp_obj_utimeq_t {
function STATIC (line 58) | STATIC mp_obj_utimeq_t *utimeq_get_heap(mp_obj_t heap_in) {
function STATIC (line 62) | STATIC bool time_less_than(struct qentry *item, struct qentry *parent) {
function STATIC (line 77) | STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args...
function STATIC (line 88) | STATIC void utimeq_heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_...
function STATIC (line 104) | STATIC void utimeq_heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
function STATIC (line 124) | STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
function STATIC (line 142) | STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
function STATIC (line 167) | STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) {
function STATIC (line 179) | STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) {
function STATIC (line 190) | STATIC mp_obj_t utimeq_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
FILE: extmod/moduwebsocket.c
type mp_obj_websocket_t (line 41) | typedef struct _mp_obj_websocket_t {
function STATIC (line 60) | STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_a...
function STATIC (line 77) | STATIC mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t s...
function STATIC (line 219) | STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_u...
function STATIC (line 257) | STATIC mp_uint_t websocket_ioctl(mp_obj_t self_in, mp_uint_t request, ui...
FILE: extmod/moduzlib.c
type mp_obj_decompio_t (line 44) | typedef struct _mp_obj_decompio_t {
function STATIC (line 51) | STATIC int read_src_stream(TINF_DATA *data) {
function STATIC (line 69) | STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_ar...
function STATIC (line 106) | STATIC mp_uint_t decompio_read(mp_obj_t o_in, void *buf, mp_uint_t size,...
function STATIC (line 149) | STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
FILE: extmod/modwebrepl.c
type webrepl_file (line 47) | struct webrepl_file {
type mp_obj_webrepl_t (line 60) | typedef struct _mp_obj_webrepl_t {
function STATIC (line 76) | STATIC void write_webrepl(mp_obj_t websock, const void *buf, size_t len) {
function STATIC (line 85) | STATIC void write_webrepl_str(mp_obj_t websock, const char *str, int sz) {
function STATIC (line 91) | STATIC void write_webrepl_resp(mp_obj_t websock, uint16_t code) {
function STATIC (line 96) | STATIC mp_obj_t webrepl_make_new(const mp_obj_type_t *type, size_t n_arg...
function STATIC (line 110) | STATIC void check_file_op_finished(mp_obj_webrepl_t *self) {
function STATIC (line 119) | STATIC int write_file_chunk(mp_obj_webrepl_t *self) {
function STATIC (line 134) | STATIC void handle_op(mp_obj_webrepl_t *self) {
function STATIC (line 179) | STATIC mp_uint_t webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t siz...
function STATIC (line 187) | STATIC mp_uint_t _webrepl_read(mp_obj_t self_in, void *buf, mp_uint_t si...
function STATIC (line 296) | STATIC mp_uint_t webrepl_write(mp_obj_t self_in, const void *buf, mp_uin...
function STATIC (line 306) | STATIC mp_uint_t webrepl_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr...
function STATIC (line 321) | STATIC mp_obj_t webrepl_set_password(mp_obj_t passwd_in) {
FILE: extmod/modwebsocket.c
type mp_obj_websocket_t (line 41) | typedef struct _mp_obj_websocket_t {
function STATIC (line 60) | STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_a...
function STATIC (line 77) | STATIC mp_uint_t websocket_read(mp_obj_t self_in, void *buf, mp_uint_t s...
function STATIC (line 219) | STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_u...
function STATIC (line 257) | STATIC mp_uint_t websocket_ioctl(mp_obj_t self_in, mp_uint_t request, ui...
FILE: extmod/re1.5/charclass.c
function _re1_5_classmatch (line 3) | int _re1_5_classmatch(const char *pc, const char *sp)
function _re1_5_namedclassmatch (line 15) | int _re1_5_namedclassmatch(const char *pc, const char *sp)
FILE: extmod/re1.5/compilecode.c
function re1_5_sizecode (line 167) | int re1_5_sizecode(const char *re)
function re1_5_compilecode (line 179) | int re1_5_compilecode(ByteProg *prog, const char *re)
function main (line 213) | int main(int argc, char *argv[])
FILE: extmod/re1.5/dumpcode.c
function re1_5_dumpcode (line 7) | void re1_5_dumpcode(ByteProg *prog)
FILE: extmod/re1.5/re1.5.h
type Regexp (line 18) | typedef struct Regexp Regexp;
type Prog (line 19) | typedef struct Prog Prog;
type ByteProg (line 20) | typedef struct ByteProg ByteProg;
type Inst (line 21) | typedef struct Inst Inst;
type Subject (line 22) | typedef struct Subject Subject;
type Regexp (line 24) | struct Regexp
type Prog (line 56) | struct Prog
type ByteProg (line 62) | struct ByteProg
type Inst (line 70) | struct Inst
type Sub (line 117) | typedef struct Sub Sub;
type Sub (line 119) | struct Sub
type Subject (line 132) | struct Subject {
FILE: extmod/re1.5/recursiveloop.c
function recursiveloop (line 7) | static int
function re1_5_recursiveloopprog (line 82) | int
FILE: extmod/uos_dupterm.c
function mp_uos_deactivate (line 40) | void mp_uos_deactivate(size_t dupterm_idx, const char *msg, mp_obj_t exc) {
function mp_uos_dupterm_poll (line 56) | uintptr_t mp_uos_dupterm_poll(uintptr_t poll_flags) {
function mp_uos_dupterm_rx_chr (line 95) | int mp_uos_dupterm_rx_chr(void) {
function mp_uos_dupterm_tx_strn (line 150) | void mp_uos_dupterm_tx_strn(const char *str, size_t len) {
function STATIC (line 175) | STATIC mp_obj_t mp_uos_dupterm(size_t n_args, const mp_obj_t *args) {
FILE: extmod/utime_mphal.c
function STATIC (line 39) | STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
function STATIC (line 49) | STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
function STATIC (line 58) | STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
function STATIC (line 67) | STATIC mp_obj_t time_ticks_ms(void) {
function STATIC (line 72) | STATIC mp_obj_t time_ticks_us(void) {
function STATIC (line 77) | STATIC mp_obj_t time_ticks_cpu(void) {
function STATIC (line 82) | STATIC mp_obj_t time_ticks_diff(mp_obj_t end_in, mp_obj_t start_in) {
function STATIC (line 94) | STATIC mp_obj_t time_ticks_add(mp_obj_t ticks_in, mp_obj_t delta_in) {
FILE: extmod/uzlib/adler32.c
function uzlib_adler32 (line 44) | uint32_t uzlib_adler32(const void *data, unsigned int length, uint32_t p...
FILE: extmod/uzlib/crc32.c
function uzlib_crc32 (line 49) | uint32_t uzlib_crc32(const void *data, unsigned int length, uint32_t crc)
FILE: extmod/uzlib/defl_static.h
type Outbuf (line 33) | struct Outbuf {
type Outbuf (line 41) | struct Outbuf
type Outbuf (line 42) | struct Outbuf
type Outbuf (line 43) | struct Outbuf
type Outbuf (line 44) | struct Outbuf
type Outbuf (line 45) | struct Outbuf
FILE: extmod/uzlib/tinfgzip.c
function tinf_skip_bytes (line 47) | void tinf_skip_bytes(TINF_DATA *d, int num)
function tinf_get_uint16 (line 52) | uint16_t tinf_get_uint16(TINF_DATA *d)
function uzlib_gzip_parse_header (line 59) | int uzlib_gzip_parse_header(TINF_DATA *d)
FILE: extmod/uzlib/tinflate.c
function tinf_build_bits_base (line 107) | static void tinf_build_bits_base(unsigned char *bits, unsigned short *ba...
function tinf_build_fixed_trees (line 125) | static void tinf_build_fixed_trees(TINF_TREE *lt, TINF_TREE *dt)
function tinf_build_tree (line 150) | static void tinf_build_tree(TINF_TREE *t, const unsigned char *lengths, ...
function uzlib_get_byte (line 192) | unsigned char uzlib_get_byte(TINF_DATA *d)
function tinf_get_le_uint32 (line 218) | uint32_t tinf_get_le_uint32(TINF_DATA *d)
function tinf_get_be_uint32 (line 228) | uint32_t tinf_get_be_uint32(TINF_DATA *d)
function tinf_getbit (line 239) | static int tinf_getbit(TINF_DATA *d)
function tinf_read_bits (line 259) | static unsigned int tinf_read_bits(TINF_DATA *d, int num, int base)
function tinf_decode_symbol (line 277) | static int tinf_decode_symbol(TINF_DATA *d, TINF_TREE *t)
function tinf_decode_trees (line 306) | static int tinf_decode_trees(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt)
function tinf_inflate_block_data (line 406) | static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TRE...
function tinf_inflate_uncompressed_block (line 489) | static int tinf_inflate_uncompressed_block(TINF_DATA *d)
function uzlib_init (line 525) | void uzlib_init(void)
function uzlib_uncompress_init (line 539) | void uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen)
function uzlib_uncompress (line 552) | int uzlib_uncompress(TINF_DATA *d)
function uzlib_uncompress_chksum (line 615) | int uzlib_uncompress_chksum(TINF_DATA *d)
FILE: extmod/uzlib/tinfzlib.c
function uzlib_zlib_parse_header (line 38) | int uzlib_zlib_parse_header(TINF_DATA *d)
FILE: extmod/uzlib/uzlib.h
type TINF_TREE (line 80) | typedef struct {
type uzlib_uncomp (line 85) | struct uzlib_uncomp {
type uzlib_comp (line 148) | struct uzlib_comp {
type uzlib_comp (line 156) | struct uzlib_comp
FILE: extmod/vfs.c
function mp_vfs_mount_t (line 57) | mp_vfs_mount_t *mp_vfs_lookup_path(const char *path, const char **path_o...
function STATIC (line 100) | STATIC mp_vfs_mount_t *lookup_path(mp_obj_t path_in, mp_obj_t *path_out) {
function STATIC (line 111) | STATIC mp_obj_t mp_vfs_proxy_call(mp_vfs_mount_t *vfs, qstr meth_name, s...
function mp_import_stat_t (line 129) | mp_import_stat_t mp_vfs_import_stat(const char *path) {
function STATIC (line 163) | STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) {
function mp_obj_t (line 201) | mp_obj_t mp_vfs_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t ...
function mp_obj_t (line 264) | mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) {
function mp_obj_t (line 297) | mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *...
function mp_obj_t (line 322) | mp_obj_t mp_vfs_chdir(mp_obj_t path_in) {
function mp_obj_t (line 344) | mp_obj_t mp_vfs_getcwd(void) {
type mp_vfs_ilistdir_it_t (line 364) | typedef struct _mp_vfs_ilistdir_it_t {
function STATIC (line 375) | STATIC mp_obj_t mp_vfs_ilistdir_it_iternext(mp_obj_t self_in) {
function mp_obj_t (line 406) | mp_obj_t mp_vfs_ilistdir(size_t n_args, const mp_obj_t *args) {
function mp_obj_t (line 432) | mp_obj_t mp_vfs_listdir(size_t n_args, const mp_obj_t *args) {
function mp_obj_t (line 443) | mp_obj_t mp_vfs_mkdir(mp_obj_t path_in) {
function mp_obj_t (line 453) | mp_obj_t mp_vfs_remove(mp_obj_t path_in) {
function mp_obj_t (line 460) | mp_obj_t mp_vfs_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) {
function mp_obj_t (line 472) | mp_obj_t mp_vfs_rmdir(mp_obj_t path_in) {
function mp_obj_t (line 479) | mp_obj_t mp_vfs_stat(mp_obj_t path_in) {
function mp_obj_t (line 494) | mp_obj_t mp_vfs_statvfs(mp_obj_t path_in) {
FILE: extmod/vfs.h
type mp_vfs_proto_t (line 56) | typedef struct _mp_vfs_proto_t {
type mp_vfs_blockdev_t (line 60) | typedef struct _mp_vfs_blockdev_t {
type mp_vfs_mount_t (line 75) | typedef struct _mp_vfs_mount_t {
FILE: extmod/vfs_fat.c
function STATIC (line 50) | STATIC mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *pa...
function STATIC (line 65) | STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_arg...
function STATIC (line 91) | STATIC mp_obj_t fat_vfs_del(mp_obj_t self_in) {
function STATIC (line 100) | STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) {
type mp_vfs_fat_ilistdir_it_t (line 119) | typedef struct _mp_vfs_fat_ilistdir_it_t {
function STATIC (line 126) | STATIC mp_obj_t mp_vfs_fat_ilistdir_it_iternext(mp_obj_t self_in) {
function STATIC (line 166) | STATIC mp_obj_t fat_vfs_ilistdir_func(size_t n_args, const mp_obj_t *arg...
function STATIC (line 193) | STATIC mp_obj_t fat_vfs_remove_internal(mp_obj_t vfs_in, mp_obj_t path_i...
function STATIC (line 217) | STATIC mp_obj_t fat_vfs_remove(mp_obj_t vfs_in, mp_obj_t path_in) {
function STATIC (line 222) | STATIC mp_obj_t fat_vfs_rmdir(mp_obj_t vfs_in, mp_obj_t path_in) {
function STATIC (line 227) | STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj...
function STATIC (line 247) | STATIC mp_obj_t fat_vfs_mkdir(mp_obj_t vfs_in, mp_obj_t path_o) {
function STATIC (line 260) | STATIC mp_obj_t fat_vfs_chdir(mp_obj_t vfs_in, mp_obj_t path_in) {
function STATIC (line 276) | STATIC mp_obj_t fat_vfs_getcwd(mp_obj_t vfs_in) {
function STATIC (line 289) | STATIC mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
function STATIC (line 338) | STATIC mp_obj_t fat_vfs_statvfs(mp_obj_t vfs_in, mp_obj_t path_in) {
function STATIC (line 366) | STATIC mp_obj_t vfs_fat_mount(mp_obj_t self_in, mp_obj_t readonly, mp_ob...
function STATIC (line 392) | STATIC mp_obj_t vfs_fat_umount(mp_obj_t self_in) {
FILE: extmod/vfs_fat.h
type fs_user_mount_t (line 33) | typedef struct _fs_user_mount_t {
FILE: extmod/vfs_fat_diskio.c
function STATIC (line 47) | STATIC fs_user_mount_t *disk_get_device(void *bdev) {
function DRESULT (line 55) | DRESULT disk_read (
function DRESULT (line 76) | DRESULT disk_write (
function DRESULT (line 103) | DRESULT disk_ioctl (
FILE: extmod/vfs_fat_file.c
type pyb_file_obj_t (line 62) | typedef struct _pyb_file_obj_t {
function STATIC (line 67) | STATIC void file_obj_print(const mp_print_t *print, mp_obj_t self_in, mp...
function STATIC (line 72) | STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t si...
function STATIC (line 83) | STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_ui...
function STATIC (line 100) | STATIC mp_obj_t file_obj___exit__(size_t n_args, const mp_obj_t *args) {
function STATIC (line 106) | STATIC mp_uint_t file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintpt...
function STATIC (line 163) | STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *typ...
function STATIC (line 214) | STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_ar...
function STATIC (line 277) | STATIC mp_obj_t fatfs_builtin_open_self(mp_obj_t self_in, mp_obj_t path,...
FILE: extmod/vfs_posix.c
type mp_obj_vfs_posix_t (line 39) | typedef struct _mp_obj_vfs_posix_t {
function STATIC (line 46) | STATIC const char *vfs_posix_get_path_str(mp_obj_vfs_posix_t *self, mp_o...
function STATIC (line 56) | STATIC mp_obj_t vfs_posix_get_path_obj(mp_obj_vfs_posix_t *self, mp_obj_...
function STATIC (line 66) | STATIC mp_obj_t vfs_posix_fun1_helper(mp_obj_t self_in, mp_obj_t path_in...
function STATIC (line 75) | STATIC mp_import_stat_t mp_vfs_posix_import_stat(void *self_in, const ch...
function STATIC (line 93) | STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_a...
function STATIC (line 109) | STATIC mp_obj_t vfs_posix_mount(mp_obj_t self_in, mp_obj_t readonly, mp_...
function STATIC (line 121) | STATIC mp_obj_t vfs_posix_umount(mp_obj_t self_in) {
function STATIC (line 127) | STATIC mp_obj_t vfs_posix_open(mp_obj_t self_in, mp_obj_t path_in, mp_ob...
function STATIC (line 141) | STATIC mp_obj_t vfs_posix_chdir(mp_obj_t self_in, mp_obj_t path_in) {
function STATIC (line 146) | STATIC mp_obj_t vfs_posix_getcwd(mp_obj_t self_in) {
type vfs_posix_ilistdir_it_t (line 158) | typedef struct _vfs_posix_ilistdir_it_t {
function STATIC (line 165) | STATIC mp_obj_t vfs_posix_ilistdir_it_iternext(mp_obj_t self_in) {
function STATIC (line 222) | STATIC mp_obj_t vfs_posix_ilistdir(mp_obj_t self_in, mp_obj_t path_in) {
type mp_obj_listdir_t (line 240) | typedef struct _mp_obj_listdir_t {
function STATIC (line 246) | STATIC mp_obj_t vfs_posix_mkdir(mp_obj_t self_in, mp_obj_t path_in) {
function STATIC (line 256) | STATIC mp_obj_t vfs_posix_remove(mp_obj_t self_in, mp_obj_t path_in) {
function STATIC (line 261) | STATIC mp_obj_t vfs_posix_rename(mp_obj_t self_in, mp_obj_t old_path_in,...
function STATIC (line 273) | STATIC mp_obj_t vfs_posix_rmdir(mp_obj_t self_in, mp_obj_t path_in) {
function STATIC (line 278) | STATIC mp_obj_t vfs_posix_stat(mp_obj_t self_in, mp_obj_t path_in) {
function STATIC (line 320) | STATIC mp_obj_t vfs_posix_statvfs(mp_obj_t self_in, mp_obj_t path_in) {
FILE: extmod/vfs_posix_file.c
type mp_obj_vfs_posix_file_t (line 39) | typedef struct _mp_obj_vfs_posix_file_t {
function STATIC (line 45) | STATIC void check_fd_is_open(const mp_obj_vfs_posix_file_t *o) {
function STATIC (line 54) | STATIC void vfs_posix_file_print(const mp_print_t *print, mp_obj_t self_...
function mp_obj_t (line 60) | mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file...
function STATIC (line 111) | STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_...
function STATIC (line 122) | STATIC mp_obj_t vfs_posix_file_fileno(mp_obj_t self_in) {
function STATIC (line 129) | STATIC mp_obj_t vfs_posix_file___exit__(size_t n_args, const mp_obj_t *a...
function STATIC (line 135) | STATIC mp_uint_t vfs_posix_file_read(mp_obj_t o_in, void *buf, mp_uint_t...
function STATIC (line 146) | STATIC mp_uint_t vfs_posix_file_write(mp_obj_t o_in, const void *buf, mp...
function STATIC (line 171) | STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, ...
FILE: extmod/vfs_reader.c
type mp_reader_vfs_t (line 37) | typedef struct _mp_reader_vfs_t {
function STATIC (line 44) | STATIC mp_uint_t mp_reader_vfs_readbyte(void *data) {
function STATIC (line 66) | STATIC void mp_reader_vfs_close(void *data) {
function mp_reader_new_file (line 72) | void mp_reader_new_file(mp_reader_t *reader, const char *filename) {
FILE: extmod/virtpin.c
function mp_virtual_pin_read (line 29) | int mp_virtual_pin_read(mp_obj_t pin) {
function mp_virtual_pin_write (line 35) | void mp_virtual_pin_write(mp_obj_t pin, int value) {
FILE: extmod/virtpin.h
type mp_pin_p_t (line 37) | typedef struct _mp_pin_p_t {
FILE: extmod/webrepl/webrepl.py
function setup_conn (line 12) | def setup_conn(port, accept_handler):
function accept_conn (line 31) | def accept_conn(listen_sock):
function stop (line 52) | def stop():
function start (line 61) | def start(port=8266, password=None):
function start_foreground (line 77) | def start_foreground(port=8266):
FILE: extmod/webrepl/webrepl_setup.py
function input_choice (line 9) | def input_choice(prompt, choices):
function getpass (line 15) | def getpass(prompt):
function input_pass (line 18) | def input_pass():
function exists (line 30) | def exists(fname):
function get_daemon_status (line 39) | def get_daemon_status():
function change_daemon (line 49) | def change_daemon(action):
function main (line 70) | def main():
FILE: extmod/webrepl/websocket_helper.py
function server_handshake (line 13) | def server_handshake(sock):
function client_handshake (line 58) | def client_handshake(sock):
FILE: lib/mp-readline/readline.c
function readline_init0 (line 47) | void readline_init0(void) {
function STATIC (line 51) | STATIC char *str_dup_maybe(const char *str) {
function STATIC (line 68) | STATIC void mp_hal_move_cursor_back(uint pos) {
function STATIC (line 83) | STATIC void mp_hal_erase_line_from_cursor(uint n_chars_to_erase) {
type readline_t (line 89) | typedef struct _readline_t {
function readline_process_char (line 101) | int readline_process_char(int c) {
function STATIC (line 357) | STATIC void readline_auto_indent(void) {
function readline_note_newline (line 398) | void readline_note_newline(const char *prompt) {
function readline_init (line 408) | void readline_init(vstr_t *line, const char *prompt) {
function readline (line 422) | int readline(vstr_t *line, const char *prompt) {
function readline_push_history (line 433) | void readline_push_history(const char *line) {
FILE: lib/netutils/netutils.c
function mp_obj_t (line 36) | mp_obj_t netutils_format_ipv4_addr(uint8_t *ip, netutils_endian_t endian) {
function mp_obj_t (line 49) | mp_obj_t netutils_format_inet_addr(uint8_t *ip, mp_uint_t port, netutils...
function netutils_parse_ipv4_addr (line 57) | void netutils_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip, netutil...
function mp_uint_t (line 89) | mp_uint_t netutils_parse_inet_addr(mp_obj_t addr_in, uint8_t *out_ip, ne...
FILE: lib/netutils/netutils.h
type netutils_endian_t (line 36) | typedef enum _netutils_endian_t {
FILE: lib/oofatfs/diskio.h
type BYTE (line 19) | typedef BYTE DSTATUS;
type DRESULT (line 22) | typedef enum {
FILE: lib/oofatfs/ff.c
type FILESEM (line 88) | typedef struct {
function WORD (line 604) | static
function DWORD (line 614) | static
function QWORD (line 627) | static
function st_word (line 645) | static
function st_dword (line 652) | static
function st_qword (line 662) | static
function chk_chr (line 691) | static
function lock_fs (line 704) | static
function unlock_fs (line 713) | static
function FRESULT (line 733) | static
function enq_lock (line 760) | static
function UINT (line 770) | static
function FRESULT (line 802) | static
function clear_lock (line 825) | static
function FRESULT (line 845) | static
function FRESULT (line 874) | static
function FRESULT (line 906) | static
function DWORD (line 945) | static
function DWORD (line 963) | static
function FRESULT (line 1039) | static
function DWORD (line 1105) | static
function FRESULT (line 1146) | static
function FRESULT (line 1183) | static
function FRESULT (line 1209) | static
function DWORD (line 1289) | static
function DWORD (line 1374) | static
function FRESULT (line 1404) | static
function FRESULT (line 1453) | static
function DWORD (line 1566) | static
function st_clust (line 1584) | static
function cmp_lfn (line 1611) | static
function pick_lfn (line 1647) | static
function put_lfn (line 1685) | static
function gen_numname (line 1723) | static
function BYTE (line 1782) | static
function WORD (line 1803) | static
function WORD (line 1825) | static
function DWORD (line 1844) | static
function get_xdir_info (line 1861) | static
function FRESULT (line 1914) | static
function FRESULT (line 1963) | static
function FRESULT (line 1992) | static
function create_xdir (line 2025) | static
function FRESULT (line 2066) | static
function FRESULT (line 2143) | static
function FRESULT (line 2222) | static
function FRESULT (line 2325) | static
function get_fileinfo (line 2373) | static
function WCHAR (line 2475) | static
function pattern_matching (line 2499) | static
function FRESULT (line 2547) | static
function FRESULT (line 2742) | static
function BYTE (line 2830) | static
function FRESULT (line 2858) | static
function FRESULT (line 3065) | static
function FRESULT (line 3101) | FRESULT f_mount (
function FRESULT (line 3117) | FRESULT f_umount (
function FRESULT (line 3137) | FRESULT f_open (
function FRESULT (line 3338) | FRESULT f_read (
function FRESULT (line 3438) | FRESULT f_write (
function FRESULT (line 3676) | FRESULT f_chdir (
function FRESULT (line 3728) | FRESULT f_getcwd (
function FRESULT (line 3804) | FRESULT f_lseek (
function FRESULT (line 3958) | FRESULT f_opendir (
function FRESULT (line 4028) | FRESULT f_closedir (
function FRESULT (line 4061) | FRESULT f_readdir (
function FRESULT (line 4097) | FRESULT f_findnext (
function FRESULT (line 4122) | FRESULT f_findfirst (
function FRESULT (line 4149) | FRESULT f_stat (
function FRESULT (line 4186) | FRESULT f_getfree (
function FRESULT (line 4270) | FRESULT f_truncate (
function FRESULT (line 4320) | FRESULT f_unlink (
function FRESULT (line 4415) | FRESULT f_mkdir (
function FRESULT (line 4508) | FRESULT f_rename (
function FRESULT (line 4613) | FRESULT f_chmod (
function FRESULT (line 4658) | FRESULT f_utime (
function FRESULT (line 4703) | FRESULT f_getlabel (
function FRESULT (line 4791) | FRESULT f_setlabel (
function FRESULT (line 4918) | FRESULT f_expand (
function FRESULT (line 5008) | FRESULT f_forward (
function FRESULT (line 5079) | FRESULT f_mkfs (
function FRESULT (line 5532) | FRESULT f_fdisk (
FILE: lib/oofatfs/ff.h
type BYTE (line 35) | typedef uint8_t BYTE;
type SHORT (line 38) | typedef int16_t SHORT;
type WORD (line 39) | typedef uint16_t WORD;
type WCHAR (line 40) | typedef uint16_t WCHAR;
type INT (line 43) | typedef int INT;
type UINT (line 44) | typedef unsigned int UINT;
type LONG (line 47) | typedef int32_t LONG;
type DWORD (line 48) | typedef uint32_t DWORD;
type QWORD (line 51) | typedef uint64_t QWORD;
type WCHAR (line 78) | typedef WCHAR TCHAR;
type TCHAR (line 84) | typedef char TCHAR;
type QWORD (line 98) | typedef QWORD FSIZE_t;
type DWORD (line 100) | typedef DWORD FSIZE_t;
type FATFS (line 107) | typedef struct {
type _FDID (line 157) | typedef struct {
type FIL (line 179) | typedef struct {
type FF_DIR (line 202) | typedef struct {
type FILINFO (line 221) | typedef struct {
type FRESULT (line 238) | typedef enum {
FILE: lib/oofatfs/option/ccsbcs.c
function WCHAR (line 275) | WCHAR ff_convert ( /* Converted character, Returns zero on error */
function WCHAR (line 303) | WCHAR ff_wtoupper ( /* Returns upper converted character */
FILE: lib/timeutils/timeutils.c
function timeutils_is_leap_year (line 45) | bool timeutils_is_leap_year(mp_uint_t year) {
function mp_uint_t (line 50) | mp_uint_t timeutils_days_in_month(mp_uint_t year, mp_uint_t month) {
function mp_uint_t (line 60) | mp_uint_t timeutils_year_day(mp_uint_t year, mp_uint_t month, mp_uint_t ...
function timeutils_seconds_since_2000_to_struct_time (line 68) | void timeutils_seconds_since_2000_to_struct_time(mp_uint_t t, timeutils_...
function mp_uint_t (line 147) | mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month,
function mp_uint_t (line 161) | mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday,
FILE: lib/timeutils/timeutils.h
type timeutils_struct_time_t (line 30) | typedef struct _timeutils_struct_time_t {
FILE: lib/utils/gchelper.h
type jmp_buf (line 33) | typedef jmp_buf gc_helper_regs_t;
FILE: lib/utils/interrupt_char.c
function mp_hal_set_interrupt_char (line 34) | void mp_hal_set_interrupt_char(int c) {
FILE: lib/utils/mpirq.c
function mp_irq_obj_t (line 54) | mp_irq_obj_t *mp_irq_new(const mp_irq_methods_t *methods, mp_obj_t paren...
function mp_irq_init (line 60) | void mp_irq_init(mp_irq_obj_t *self, const mp_irq_methods_t *methods, mp...
function mp_irq_handler (line 68) | void mp_irq_handler(mp_irq_obj_t *self) {
function STATIC (line 99) | STATIC mp_obj_t mp_irq_flags(mp_obj_t self_in) {
function STATIC (line 105) | STATIC mp_obj_t mp_irq_trigger(size_t n_args, const mp_obj_t *args) {
function STATIC (line 116) | STATIC mp_obj_t mp_irq_call(mp_obj_t self_in, size_t n_args, size_t n_kw...
FILE: lib/utils/mpirq.h
type mp_uint_t (line 46) | typedef mp_uint_t (*mp_irq_trigger_fun_t)(mp_obj_t self, mp_uint_t trigg...
type mp_uint_t (line 47) | typedef mp_uint_t (*mp_irq_info_fun_t)(mp_obj_t self, mp_uint_t info_type);
type mp_irq_methods_t (line 54) | typedef struct _mp_irq_methods_t {
type mp_irq_obj_t (line 59) | typedef struct _mp_irq_obj_t {
FILE: lib/utils/printf.c
function DEBUG_printf (line 41) | int DEBUG_printf(const char *fmt, ...) {
function printf (line 60) | int printf(const char *fmt, ...) {
function vprintf (line 68) | int vprintf(const char *fmt, va_list ap) {
function putchar (line 73) | int putchar(int c) {
function puts (line 80) | int puts(const char *s) {
type strn_print_env_t (line 87) | typedef struct _strn_print_env_t {
function STATIC (line 92) | STATIC void strn_print_strn(void *data, const char *str, size_t len) {
function vsnprintf (line 110) | int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) {
function snprintf (line 125) | int snprintf(char *str, size_t size, const char *fmt, ...) {
FILE: lib/utils/pyexec.c
function STATIC (line 66) | STATIC int parse_compile_execute(const void *source, mp_parse_input_kind...
type repl_t (line 167) | typedef struct _repl_t {
function pyexec_event_repl_init (line 182) | void pyexec_event_repl_init(void) {
function STATIC (line 195) | STATIC int pyexec_raw_repl_process_char(int c) {
function STATIC (line 242) | STATIC int pyexec_friendly_repl_process_char(int c) {
function pyexec_event_repl_process_char (line 355) | int pyexec_event_repl_process_char(int c) {
function pyexec_raw_repl (line 369) | int pyexec_raw_repl(void) {
function pyexec_friendly_repl (line 419) | int pyexec_friendly_repl(void) {
function pyexec_file (line 551) | int pyexec_file(const char *filename) {
function pyexec_str (line 554) | int pyexec_str(vstr_t *str) {
function pyexec_file_if_exists (line 558) | int pyexec_file_if_exists(const char *filename) {
function pyexec_frozen_module (line 571) | int pyexec_frozen_module(const char *name) {
function mp_obj_t (line 594) | mp_obj_t pyb_set_repl_info(mp_obj_t o_value) {
FILE: lib/utils/pyexec.h
type pyexec_mode_kind_t (line 31) | typedef enum {
FILE: lib/utils/stdout_helpers.c
function mp_hal_stdout_tx_strn_cooked (line 14) | void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
function mp_hal_stdout_tx_str (line 24) | void mp_hal_stdout_tx_str(const char *str) {
FILE: lib/utils/sys_stdio_mphal.c
type sys_stdio_obj_t (line 46) | typedef struct _sys_stdio_obj_t {
function stdio_obj_print (line 55) | void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print...
function STATIC (line 60) | STATIC mp_uint_t stdio_read(mp_obj_t self_in, void *buf, mp_uint_t size,...
function STATIC (line 77) | STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_...
function STATIC (line 99) | STATIC mp_obj_t stdio_obj___exit__(size_t n_args, const mp_obj_t *args) {
function STATIC (line 146) | STATIC mp_uint_t stdio_buffer_read(mp_obj_t self_in, void *buf, mp_uint_...
function STATIC (line 153) | STATIC mp_uint_t stdio_buffer_write(mp_obj_t self_in, const void *buf, m...
FILE: port/frozen_mpy.c
type mp_obj_float_t (line 16) | typedef struct _mp_obj_float_t {
type mp_obj_complex_t (line 23) | typedef struct _mp_obj_complex_t {
FILE: port/gccollect.c
function gc_collect (line 31) | void gc_collect(void) {
FILE: port/genhdr/gen_qstr.py
function compute_hash (line 42) | def compute_hash(qstr, bytes_hash):
function make_bytes (line 49) | def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
FILE: port/modules/machine/machine_adc.c
type machine_adc_obj_t (line 43) | typedef struct _machine_adc_obj_t {
function STATIC (line 50) | STATIC void error_check(bool status, const char *msg) {
function STATIC (line 56) | STATIC mp_obj_t machine_adc_make_new(const mp_obj_type_t *type,
function STATIC (line 97) | STATIC mp_obj_t machine_adc_init(size_t n_args, const mp_obj_t *args) {
function STATIC (line 110) | STATIC mp_obj_t machine_adc_deinit(mp_obj_t self_in) {
function STATIC (line 124) | STATIC mp_obj_t machine_adc_read(mp_obj_t self_in) {
FILE: port/modules/machine/machine_hw_i2c.c
type machine_hard_i2c_obj_t (line 47) | typedef struct _machine_hard_i2c_obj_t {
function STATIC (line 56) | STATIC void machine_hard_i2c_print(const mp_print_t *print, mp_obj_t sel...
function STATIC (line 64) | STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, ...
function STATIC (line 92) | STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, u...
function STATIC (line 118) | STATIC int mp_machine_i2c_readfrom(mp_obj_base_t *self_in, uint16_t addr...
function STATIC (line 123) | STATIC int mp_machine_i2c_writeto(mp_obj_base_t *self_in, uint16_t addr,...
function STATIC (line 138) | STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
function STATIC (line 152) | STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) {
function STATIC (line 166) | STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t ...
function STATIC (line 180) | STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) {
function STATIC (line 195) | STATIC mp_obj_t machine_i2c_writevto(size_t n_args, const mp_obj_t *args) {
function STATIC (line 243) | STATIC mp_obj_t machine_i2c_readfrom_mem(size_t n_args, const mp_obj_t *...
function STATIC (line 264) | STATIC mp_obj_t machine_i2c_readfrom_mem_into(size_t n_args, const mp_ob...
function STATIC (line 284) | STATIC mp_obj_t machine_i2c_writeto_mem(size_t n_args, const mp_obj_t *p...
function mp_obj_t (line 323) | mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_a...
FILE: port/modules/machine/machine_hw_spi.c
type machine_hard_spi_obj_t (line 43) | typedef struct _machine_hard_spi_obj_t {
function STATIC (line 48) | STATIC void machine_hard_spi_print(const mp_print_t *print, mp_obj_t sel...
function mp_obj_t (line 53) | mp_obj_t machine_hard_spi_make_new(const mp_obj_type_t *type, size_t n_a...
function STATIC (line 72) | STATIC void machine_hard_spi_init(mp_obj_base_t *self_in, size_t n_args,...
function STATIC (line 118) | STATIC void machine_hard_spi_transfer(mp_obj_base_t *self_in, size_t len...
FILE: port/modules/machine/machine_lcd.c
type machine_lcd_obj_t (line 40) | typedef struct _machine_lcd_obj_t {
function STATIC (line 44) | STATIC void error_check(bool status, const char *msg) {
function STATIC (line 53) | STATIC mp_obj_t machine_lcd_make_new(const mp_obj_type_t *type, size_t n...
function STATIC (line 67) | STATIC mp_obj_t machine_lcd_light(mp_obj_t self_in, mp_obj_t value) {
function STATIC (line 81) | STATIC mp_obj_t machine_lcd_fill(mp_obj_t self_in, mp_obj_t col_in) {
function STATIC (line 93) | STATIC mp_obj_t machine_lcd_pixel(size_t n_args, const mp_obj_t *args) {
function STATIC (line 110) | STATIC mp_obj_t machine_lcd_text(size_t n_args, const mp_obj_t *args) {
function STATIC (line 131) | STATIC mp_obj_t machine_lcd_line(size_t n_args, const mp_obj_t *args) {
function STATIC (line 149) | STATIC mp_obj_t machine_lcd_rectangle(size_t n_args, const mp_obj_t *arg...
function STATIC (line 167) | STATIC mp_obj_t machine_lcd_circle(size_t n_args, const mp_obj_t *args) {
function STATIC (line 183) | STATIC mp_obj_t machine_lcd_set_color(size_t n_args, const mp_obj_t *arg...
function STATIC (line 200) | STATIC mp_obj_t machine_lcd_show_image(size_t n_args, const mp_obj_t *ar...
function STATIC (line 216) | STATIC rt_uint16_t rgb888to565(rt_uint32_t RGB)
function STATIC (line 231) | STATIC mp_obj_t machine_lcd_show_bmp(size_t n_args, const mp_obj_t *args) {
FILE: port/modules/machine/machine_pin.c
function mp_pin_od_write (line 56) | void mp_pin_od_write(void *machine_pin, int stat) {
function mp_hal_pin_open_set (line 65) | void mp_hal_pin_open_set(void *machine_pin, int mode) {
function STATIC (line 75) | STATIC void machine_pin_print(const mp_print_t *print, mp_obj_t self_in,...
function mp_obj_t (line 81) | mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_...
function STATIC (line 113) | STATIC mp_obj_t machine_pin_obj_init_helper(machine_pin_obj_t *self, siz...
function STATIC (line 172) | STATIC mp_obj_t machine_pin_call(mp_obj_t self_in, size_t n_args, size_t...
function STATIC (line 184) | STATIC mp_obj_t machine_pin_obj_init(size_t n_args, const mp_obj_t *args...
function STATIC (line 190) | STATIC mp_obj_t machine_pin_value(size_t n_args, const mp_obj_t *args) {
function STATIC (line 196) | STATIC mp_obj_t machine_pin_name(size_t n_args, const mp_obj_t *args) {
function STATIC (line 203) | STATIC mp_obj_t machine_pin_pin(size_t n_args, const mp_obj_t *args) {
function STATIC (line 208) | STATIC mp_uint_t machine_pin_ioctl(mp_obj_t self_in, mp_uint_t request, ...
function STATIC (line 227) | STATIC void machine_pin_isr_handler(void *arg) {
function STATIC (line 233) | STATIC mp_obj_t machine_pin_irq(size_t n_args, const mp_obj_t *pos_args,...
FILE: port/modules/machine/machine_pwm.c
type machine_pwm_obj_t (line 47) | typedef struct _machine_pwm_obj_t {
function STATIC (line 58) | STATIC void machine_pwm_print(const mp_print_t *print, mp_obj_t self_in,...
function STATIC (line 72) | STATIC void error_check(bool status, const char *msg) {
function STATIC (line 78) | STATIC void machine_pwm_init_helper(machine_pwm_obj_t *self,
function STATIC (line 142) | STATIC mp_obj_t machine_pwm_make_new(const mp_obj_type_t *type,
function STATIC (line 172) | STATIC mp_obj_t machine_pwm_init(size_t n_args,
function STATIC (line 179) | STATIC mp_obj_t machine_pwm_deinit(mp_obj_t self_in) {
function STATIC (line 192) | STATIC mp_obj_t machine_pwm_freq(size_t n_args, const mp_obj_t *args) {
function STATIC (line 225) | STATIC mp_obj_t machine_pwm_duty(size_t n_args, const mp_obj_t *args) {
FILE: port/modules/machine/machine_rtc.c
function STATIC (line 51) | STATIC void error_check(bool status, const char *msg) {
function STATIC (line 57) | STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n...
function STATIC (line 74) | STATIC mp_obj_t machine_rtc_datetime_helper(mp_uint_t n_args, const mp_o...
function STATIC (line 113) | STATIC mp_obj_t machine_rtc_now(mp_uint_t n_args, const mp_obj_t *args) {
function STATIC (line 118) | STATIC mp_obj_t machine_rtc_init(mp_uint_t n_args, const mp_obj_t *args) {
function STATIC (line 123) | STATIC mp_obj_t machine_rtc_deinit(mp_uint_t n_args, const mp_obj_t *arg...
FILE: port/modules/machine/machine_timer.c
type machine_timer_obj_t (line 44) | typedef struct _machine_timer_obj_t {
function STATIC (line 57) | STATIC void error_check(bool status, const char *msg) {
function STATIC (line 63) | STATIC void machine_timer_print(const mp_print_t *print, mp_obj_t self_i...
function STATIC (line 77) | STATIC mp_obj_t machine_timer_make_new(const mp_obj_type_t *type, size_t...
function STATIC (line 119) | STATIC mp_obj_t machine_timer_deinit(mp_obj_t self_in) {
function STATIC (line 134) | STATIC rt_err_t timer_event_handler(rt_device_t dev, rt_size_t size) {
function STATIC (line 141) | STATIC mp_obj_t machine_timer_init(mp_uint_t n_args, const mp_obj_t *arg...
function STATIC (line 216) | STATIC mp_obj_t machine_timer_callback(mp_uint_t n_args, const mp_obj_t ...
FILE: port/modules/machine/machine_uart.c
type machine_uart_obj_t (line 45) | typedef struct _machine_uart_obj_t {
function STATIC (line 50) | STATIC void machine_uart_print(const mp_print_t *print, mp_obj_t self_in...
function STATIC (line 60) | STATIC mp_obj_t machine_uart_make_new(const mp_obj_type_t *type, size_t ...
function STATIC (line 99) | STATIC mp_obj_t machine_uart_init_helper(machine_uart_obj_t *self, size_...
function STATIC (line 165) | STATIC mp_obj_t machine_uart_init(size_t n_args, const mp_obj_t *args, m...
function STATIC (line 170) | STATIC mp_obj_t machine_uart_deinit(mp_obj_t self_in) {
function STATIC (line 177) | STATIC mp_obj_t machine_uart_writechar(mp_obj_t self_in, mp_obj_t char_i...
type rt_event (line 194) | struct rt_event
function STATIC (line 196) | STATIC mp_obj_t machine_uart_readchar(mp_obj_t self_in) {
function STATIC (line 236) | STATIC mp_uint_t machine_uart_read(mp_obj_t self_in, void *buf_in, mp_ui...
function STATIC (line 244) | STATIC mp_uint_t machine_uart_write(mp_obj_t self_in, const void *buf_in...
function STATIC (line 252) | STATIC mp_uint_t machine_uart_ioctl(mp_obj_t obj, mp_uint_t request, uin...
FILE: port/modules/machine/machine_wdt.c
type machine_wdt_obj_t (line 41) | typedef struct _machine_wdt_obj_t {
function STATIC (line 48) | STATIC void error_check(bool status, const char *msg) {
function STATIC (line 54) | STATIC mp_obj_t machine_wdt_make_new(const mp_obj_type_t *type_in, size_...
function STATIC (line 109) | STATIC mp_obj_t machine_wdt_feed(mp_obj_t self_in) {
FILE: port/modules/machine/modmachine.c
function STATIC (line 52) | STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
function STATIC (line 109) | STATIC mp_obj_t machine_unique_id(void) {
function STATIC (line 116) | STATIC mp_obj_t machine_reset(void) {
function STATIC (line 123) | STATIC mp_obj_t machine_soft_reset(void) {
function MP_WEAK (line 134) | MP_WEAK int mp_port_get_freq(int clkid, int *freq)
function STATIC (line 139) | STATIC mp_obj_t machine_freq(void) {
function STATIC (line 157) | STATIC mp_obj_t pyb_wfi(void) {
function STATIC (line 165) | STATIC mp_obj_t pyb_disable_irq(void) {
function STATIC (line 171) | STATIC mp_obj_t pyb_enable_irq(size_t n_args, const mp_obj_t *arg) {
function STATIC (line 185) | STATIC mp_obj_t machine_sleep (void) {
function STATIC (line 192) | STATIC mp_obj_t machine_deepsleep (void) {
function STATIC (line 199) | STATIC mp_obj_t machine_reset_cause(void) {
FILE: port/modules/machine/modmachine.h
type machine_pin_obj_t (line 46) | typedef struct _machine_pin_obj_t {
FILE: port/modules/modffi.c
type ffi_type_t (line 47) | typedef enum {
type mp_obj_opaque_t (line 65) | typedef struct _mp_obj_opaque_t {
type mp_obj_ffimod_t (line 70) | typedef struct _mp_obj_ffimod_t {
type mp_obj_ffivar_t (line 75) | typedef struct _mp_obj_ffivar_t {
type mp_obj_ffifunc_t (line 81) | typedef struct _mp_obj_ffifunc_t {
type mp_obj_fficallback_t (line 90) | typedef struct _mp_obj_fficallback_t {
type ffi_arg (line 97) | typedef unsigned long ffi_arg;
function STATIC (line 104) | STATIC ffi_type_t char2ffi_type(char c)
function STATIC (line 131) | STATIC ffi_type_t get_ffi_type(mp_obj_t o_in)
function STATIC (line 145) | STATIC mp_obj_t return_ffi_value(void *val, char type)
function STATIC (line 177) | STATIC void ffimod_print(const mp_print_t *print, mp_obj_t self_in, mp_p...
function STATIC (line 183) | STATIC mp_obj_t ffimod_close(mp_obj_t self_in) {
function STATIC (line 192) | STATIC mp_obj_t make_func(mp_obj_t rettype_in, void *func, mp_obj_t argt...
function STATIC (line 220) | STATIC mp_obj_t ffimod_func(size_t n_args, const mp_obj_t *args) {
function STATIC (line 233) | STATIC mp_obj_t mod_ffi_func(mp_obj_t rettype, mp_obj_t addr_in, mp_obj_...
function STATIC (line 249) | STATIC void call_py_func(void *ret, int argc, void** args, void *func) {
function STATIC (line 263) | STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, ...
function STATIC (line 277) | STATIC mp_obj_t ffimod_var(mp_obj_t self_in, mp_obj_t vartype_in, mp_obj...
function STATIC (line 295) | STATIC mp_obj_t ffimod_addr(mp_obj_t self_in, mp_obj_t symname_in) {
function STATIC (line 307) | STATIC mp_obj_t ffimod_make_new(const mp_obj_type_t *type, size_t n_args...
function STATIC (line 345) | STATIC void ffifunc_print(const mp_print_t *print, mp_obj_t self_in, mp_...
function STATIC (line 351) | STATIC void ffi_call(void *func, ffi_arg *retval, uint32_t argc, ffi_arg...
function STATIC (line 370) | STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_k...
function STATIC (line 452) | STATIC void fficallback_print(const mp_print_t *print, mp_obj_t self_in,...
function STATIC (line 466) | STATIC void ffivar_print(const mp_print_t *print, mp_obj_t self_in, mp_p...
function STATIC (line 473) | STATIC mp_obj_t ffivar_get(mp_obj_t self_in) {
function STATIC (line 479) | STATIC mp_obj_t ffivar_set(mp_obj_t self_in, mp_obj_t val_in) {
function STATIC (line 500) | STATIC mp_obj_t mod_ffi_open(size_t n_args, const mp_obj_t *args) {
function STATIC (line 505) | STATIC mp_obj_t mod_ffi_as_bytearray(mp_obj_t ptr, mp_obj_t size) {
FILE: port/modules/modfile.c
type mp_obj_fdfile_t (line 47) | typedef struct _mp_obj_fdfile_t {
function STATIC (line 53) | STATIC void check_fd_is_open(const mp_obj_fdfile_t *o) {
function STATIC (line 65) | STATIC void fdfile_print(const mp_print_t *print, mp_obj_t self_in, mp_p...
function STATIC (line 71) | STATIC mp_uint_t fdfile_read(mp_obj_t o_in, void *buf, mp_uint_t size, i...
function STATIC (line 82) | STATIC mp_uint_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t ...
function STATIC (line 107) | STATIC mp_uint_t fdfile_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_...
function STATIC (line 133) | STATIC mp_obj_t fdfile_close(mp_obj_t self_in) {
function STATIC (line 143) | STATIC mp_obj_t fdfile___exit__(size_t n_args, const mp_obj_t *args) {
function STATIC (line 149) | STATIC mp_obj_t fdfile_fileno(mp_obj_t self_in) {
function STATIC (line 166) | STATIC mp_obj_t fdfile_open(const mp_obj_type_t *type, mp_arg_val_t *arg...
function STATIC (line 217) | STATIC mp_obj_t fdfile_make_new(const mp_obj_type_t *type, size_t n_args...
function mp_obj_t (line 278) | mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *...
FILE: port/modules/modnetwork_wlan.c
type netdev (line 46) | struct netdev
type wlan_if_obj_t (line 48) | typedef struct _wlan_if_obj_t {
function STATIC (line 66) | STATIC void error_check(bool status, const char *msg) {
function STATIC (line 77) | STATIC void require_if(mp_obj_t wlan_if, int if_no) {
function STATIC (line 84) | STATIC mp_obj_t get_wlan(size_t n_args, const mp_obj_t *args) {
function STATIC (line 96) | STATIC mp_obj_t wlan_active(size_t n_args, const mp_obj_t *args) {
function STATIC (line 139) | STATIC mp_obj_t wlan_connect(size_t n_args, const mp_obj_t *pos_args, mp...
function STATIC (line 175) | STATIC mp_obj_t wlan_disconnect(mp_obj_t self_in) {
function STATIC (line 182) | STATIC mp_obj_t wlan_status(size_t n_args, const mp_obj_t *args) {
type rt_semaphore (line 216) | struct rt_semaphore
type rt_wlan_scan_result (line 217) | struct rt_wlan_scan_result
function wlan_scan_report_hander (line 219) | static void wlan_scan_report_hander(int event,struct rt_wlan_buff *buff,...
function wlan_scan_done_hander (line 252) | static void wlan_scan_done_hander(int event,struct rt_wlan_buff *buff,vo...
type rt_wlan_scan_result (line 258) | struct rt_wlan_scan_result
function rt_wlan_scan_result_clean (line 284) | void rt_wlan_scan_result_clean(void)
function wlan_station_scan (line 296) | void wlan_station_scan(void)
function STATIC (line 372) | STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
function STATIC (line 389) | STATIC mp_obj_t wlan_isconnected(mp_obj_t self_in) {
function STATIC (line 404) | STATIC mp_obj_t wlan_ifconfig(size_t n_args, const mp_obj_t *args) {
function STATIC (line 470) | STATIC mp_obj_t wlan_config(size_t n_args, const mp_obj_t *args, mp_map_...
FILE: port/modules/modpyb.c
function STATIC (line 49) | STATIC mp_obj_t pyb_elapsed_millis(mp_obj_t start) {
function STATIC (line 66) | STATIC mp_obj_t pyb_elapsed_micros(mp_obj_t start) {
FILE: port/modules/modrtthread.c
function rt_bool_t (line 35) | rt_bool_t rt_is_preempt_thread(void) {
function STATIC (line 43) | STATIC mp_obj_t mod_is_preempt_thread(void) {
function STATIC (line 48) | STATIC mp_obj_t mod_current_tid(void) {
function STATIC (line 53) | STATIC mp_obj_t mod_stacks_analyze(void) {
function STATIC (line 65) | STATIC mp_obj_t mod_list_device(void) {
FILE: port/modules/moduos_file.c
function mp_obj_t (line 39) | mp_obj_t mp_posix_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_...
function mp_obj_t (line 45) | mp_obj_t mp_posix_umount(mp_obj_t mnt_in) {
function mp_obj_t (line 51) | mp_obj_t mp_posix_mkfs(size_t n_args, const mp_obj_t *args) {
function mp_obj_t (line 74) | mp_obj_t mp_posix_chdir(mp_obj_t path_in) {
function mp_obj_t (line 83) | mp_obj_t mp_posix_getcwd(void) {
type dfs_fd (line 91) | struct dfs_fd
type dirent (line 92) | struct dirent
function mp_obj_t (line 93) | mp_obj_t mp_posix_listdir(size_t n_args, const mp_obj_t *args) {
function mp_obj_t (line 174) | mp_obj_t mp_posix_mkdir(mp_obj_t path_in) {
function mp_obj_t (line 184) | mp_obj_t mp_posix_remove(uint n_args, const mp_obj_t *arg) {
function mp_obj_t (line 200) | mp_obj_t mp_posix_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) {
function mp_obj_t (line 211) | mp_obj_t mp_posix_rmdir(uint n_args, const mp_obj_t *arg) {
function mp_obj_t (line 227) | mp_obj_t mp_posix_stat(mp_obj_t path_in) {
function calc_crc32 (line 249) | static uint32_t calc_crc32(const char* pathname)
function mp_obj_t (line 289) | mp_obj_t mp_posix_file_crc32(mp_obj_t path_in) {
function mp_import_stat_t (line 303) | mp_import_stat_t mp_posix_import_stat(const char *path) {
FILE: port/modules/modusocket.c
type socket_obj_t (line 55) | typedef struct _socket_obj_t {
function NORETURN (line 69) | NORETURN static void exception_from_errno(int _errno) {
function check_for_exceptions (line 77) | static inline void check_for_exceptions(void) {
function _socket_getaddrinfo2 (line 81) | static int _socket_getaddrinfo2(const mp_obj_t host, const mp_obj_t port...
function _socket_getaddrinfo (line 109) | int _socket_getaddrinfo(const mp_obj_t addrtuple, struct addrinfo **resp) {
function STATIC (line 117) | STATIC mp_obj_t socket_bind(const mp_obj_t arg0, const mp_obj_t arg1) {
function STATIC (line 128) | STATIC mp_obj_t socket_listen(const mp_obj_t arg0, const mp_obj_t arg1) {
function STATIC (line 137) | STATIC mp_obj_t socket_accept(const mp_obj_t arg0) {
function STATIC (line 175) | STATIC mp_obj_t socket_connect(const mp_obj_t arg0, const mp_obj_t arg1) {
function STATIC (line 191) | STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) {
function STATIC (line 232) | STATIC void _socket_settimeout(socket_obj_t *sock, uint64_t timeout_ms) {
function STATIC (line 248) | STATIC mp_obj_t socket_settimeout(const mp_obj_t arg0, const mp_obj_t ar...
function STATIC (line 256) | STATIC mp_obj_t socket_setblocking(const mp_obj_t arg0, const mp_obj_t a...
function STATIC (line 267) | STATIC mp_uint_t _socket_read_data(mp_obj_t self_in, void *buf, size_t s...
function mp_obj_t (line 301) | mp_obj_t _socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in,
function STATIC (line 317) | STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
function STATIC (line 322) | STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) {
function STATIC (line 337) | STATIC int _socket_send(socket_obj_t *sock, const char *data, size_t dat...
function STATIC (line 351) | STATIC mp_obj_t socket_send(const mp_obj_t arg0, const mp_obj_t arg1) {
function STATIC (line 360) | STATIC mp_obj_t socket_sendall(const mp_obj_t arg0, const mp_obj_t arg1) {
function STATIC (line 372) | STATIC mp_obj_t socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj...
function STATIC (line 400) | STATIC mp_obj_t socket_fileno(const mp_obj_t arg0) {
function STATIC (line 406) | STATIC mp_obj_t socket_makefile(size_t n_args, const mp_obj_t *args) {
function STATIC (line 412) | STATIC mp_uint_t socket_stream_read(mp_obj_t self_in, void *buf, mp_uint...
function STATIC (line 416) | STATIC mp_uint_t socket_stream_write(mp_obj_t self_in, const void *buf, ...
function STATIC (line 430) | STATIC mp_uint_t socket_stream_ioctl(mp_obj_t self_in, mp_uint_t request...
function STATIC (line 509) | STATIC mp_obj_t get_socket(size_t n_args, const mp_obj_t *args) {
function STATIC (line 539) | STATIC mp_obj_t mod_usocket_getaddrinfo(uint n_args, const mp_obj_t *arg) {
FILE: port/modules/modutils.c
function mp_calc_crc32 (line 85) | uint32_t mp_calc_crc32(uint32_t crc, const void *buf, size_t len)
function mp_hex_to_str (line 99) | void mp_hex_to_str(char *pbDest, char *pbSrc, int nLen)
FILE: port/modules/modutime.c
function STATIC (line 40) | STATIC mp_obj_t mod_time_time(void) {
function STATIC (line 52) | STATIC mp_obj_t mod_time_localtime(size_t n_args, const mp_obj_t *args) {
function STATIC (line 91) | STATIC mp_obj_t time_mktime(mp_obj_t tuple) {
FILE: port/modules/user/moduserfunc.c
function STATIC (line 29) | STATIC mp_obj_t add(
FILE: port/mpconfigport.h
type mp_int_t (line 350) | typedef intptr_t mp_int_t;
type mp_uint_t (line 351) | typedef uintptr_t mp_uint_t;
type mp_off_t (line 353) | typedef long mp_off_t;
type _mp_obj_module_t (line 375) | struct _mp_obj_module_t
type _mp_obj_module_t (line 376) | struct _mp_obj_module_t
type _mp_obj_module_t (line 377) | struct _mp_obj_module_t
type _mp_obj_module_t (line 378) | struct _mp_obj_module_t
type _mp_obj_module_t (line 379) | struct _mp_obj_module_t
type _mp_obj_module_t (line 380) | struct _mp_obj_module_t
type _mp_obj_module_t (line 381) | struct _mp_obj_module_t
type _mp_obj_module_t (line 382) | struct _mp_obj_module_t
type _mp_obj_fun_builtin_fixed_t (line 383) | struct _mp_obj_fun_builtin_fixed_t
type _mp_obj_module_t (line 384) | struct _mp_obj_module_t
type _mp_obj_module_t (line 385) | struct _mp_obj_module_t
type _mp_obj_module_t (line 386) | struct _mp_obj_module_t
FILE: port/mpgetcharport.c
type rt_ringbuffer (line 38) | struct rt_ringbuffer
function rt_err_t (line 41) | static rt_err_t getchar_rx_ind(rt_device_t dev, rt_size_t size) {
function mp_getchar_init (line 61) | void mp_getchar_init(void) {
function mp_getchar_deinit (line 81) | void mp_getchar_deinit(void) {
function mp_getchar (line 96) | int mp_getchar(void) {
FILE: port/mphalport.c
function mp_hal_stdin_rx_chr (line 50) | int mp_hal_stdin_rx_chr(void) {
function mp_hal_stdout_tx_strn (line 64) | void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
function mp_hal_stdout_tx_strn_stream (line 72) | void mp_hal_stdout_tx_strn_stream(const char *str, size_t len) {
function mp_uint_t (line 80) | mp_uint_t mp_hal_ticks_us(void) {
function mp_uint_t (line 84) | mp_uint_t mp_hal_ticks_ms(void) {
function mp_uint_t (line 88) | mp_uint_t mp_hal_ticks_cpu(void) {
function mp_hal_delay_us (line 92) | void mp_hal_delay_us(mp_uint_t us) {
function mp_hal_delay_ms (line 105) | void mp_hal_delay_ms(mp_uint_t ms) {
FILE: port/mpputsnport.c
type rt_device (line 31) | struct rt_device
function mp_putsn (line 34) | void mp_putsn(const char *str, size_t len) {
function mp_putsn_stream (line 40) | void mp_putsn_stream(const char *str, size_t len) {
function mp_putsn_init (line 50) | void mp_putsn_init(void) {
function mp_putsn_deinit (line 73) | void mp_putsn_deinit(void) {
FILE: port/mpthreadport.c
type thread_t (line 46) | typedef struct _thread_t {
function mp_thread_init (line 66) | void mp_thread_init(void *stack, uint32_t stack_len) {
function mp_thread_gc_others (line 80) | void mp_thread_gc_others(void) {
function mp_state_thread_t (line 100) | mp_state_thread_t *mp_thread_get_state(void) {
function mp_thread_set_state (line 104) | void mp_thread_set_state(mp_state_thread_t *state) {
function mp_thread_start (line 108) | void mp_thread_start(void) {
function mp_thread_create_ex (line 119) | void mp_thread_create_ex(void *(*entry)(void*), void *arg, size_t *stack...
function mp_thread_create (line 162) | void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_si...
function mp_thread_finish (line 177) | void mp_thread_finish(void) {
function mp_thread_mutex_init (line 202) | void mp_thread_mutex_init(mp_thread_mutex_t *mutex) {
function mp_thread_mutex_lock (line 214) | int mp_thread_mutex_lock(mp_thread_mutex_t *mutex, int wait) {
function mp_thread_mutex_unlock (line 218) | void mp_thread_mutex_unlock(mp_thread_mutex_t *mutex) {
function mp_thread_deinit (line 222) | void mp_thread_deinit(void) {
FILE: port/mpthreadport.h
type mp_thread_mutex_t (line 32) | typedef struct _mp_thread_mutex_t {
FILE: port/mpy_main.c
function do_str (line 52) | void do_str(const char *src, mp_parse_input_kind_t input_kind) {
function mp_sys_resource_bak (line 69) | static int mp_sys_resource_bak(struct dfs_fdtable **table_bak)
function mp_sys_resource_gc (line 110) | static void mp_sys_resource_gc(struct dfs_fdtable *fd_table_bak)
function mpy_main (line 137) | void mpy_main(const char *filename) {
function mp_import_stat_t (line 251) | mp_import_stat_t mp_import_stat(const char *path) {
function NORETURN (line 256) | NORETURN void nlr_jump_fail(void *val) {
function MP_WEAK (line 262) | MP_WEAK __assert_func(const char *file, int line, const char *func, cons...
function DEBUG_printf (line 270) | int DEBUG_printf(const char *format, ...)
function mp_lexer_t (line 286) | mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
function python (line 293) | static void python(uint8_t argc, char **argv) {
FILE: port/native/native_module.c
function native_module_show (line 52) | void native_module_show(const char *str) {
function native_module_add (line 55) | RTM_EXPORT(native_module_show)
FILE: py/argcheck.c
function mp_arg_check_num_sig (line 32) | void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) {
function mp_arg_parse_all (line 79) | void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, ...
function mp_arg_parse_all_kw_array (line 134) | void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t...
function NORETURN (line 140) | NORETURN void mp_arg_error_terse_mismatch(void) {
function NORETURN (line 145) | NORETURN void mp_arg_error_unimpl_kw(void) {
FILE: py/asmarm.c
function asm_arm_end_pass (line 41) | void asm_arm_end_pass(asm_arm_t *as) {
function STATIC (line 61) | STATIC void emit(asm_arm_t *as, uint op) {
function STATIC (line 69) | STATIC void emit_al(asm_arm_t *as, uint op) {
function STATIC (line 74) | STATIC uint asm_arm_op_push(uint reglist) {
function STATIC (line 79) | STATIC uint asm_arm_op_pop(uint reglist) {
function STATIC (line 84) | STATIC uint asm_arm_op_mov_reg(uint rd, uint rn) {
function STATIC (line 89) | STATIC uint asm_arm_op_mov_imm(uint rd, uint imm) {
function STATIC (line 94) | STATIC uint asm_arm_op_mvn_imm(uint rd, uint imm) {
function STATIC (line 99) | STATIC uint asm_arm_op_add_imm(uint rd, uint rn, uint imm) {
function STATIC (line 104) | STATIC uint asm_arm_op_add_reg(uint rd, uint rn, uint rm) {
function STATIC (line 109) | STATIC uint asm_arm_op_sub_imm(uint rd, uint rn, uint imm) {
function STATIC (line 114) | STATIC uint asm_arm_op_sub_reg(uint rd, uint rn, uint rm) {
function STATIC (line 119) | STATIC uint asm_arm_op_mul_reg(uint rd, uint rm, uint rs) {
function STATIC (line 125) | STATIC uint asm_arm_op_and_reg(uint rd, uint rn, uint rm) {
function STATIC (line 130) | STATIC uint asm_arm_op_eor_reg(uint rd, uint rn, uint rm) {
function STATIC (line 135) | STATIC uint asm_arm_op_orr_reg(uint rd, uint rn, uint rm) {
function asm_arm_bkpt (line 140) | void asm_arm_bkpt(asm_arm_t *as) {
function asm_arm_entry (line 156) | void asm_arm_entry(asm_arm_t *as, int num_locals) {
function asm_arm_exit (line 184) | void asm_arm_exit(asm_arm_t *as) {
function asm_arm_push (line 192) | void asm_arm_push(asm_arm_t *as, uint reglist) {
function asm_arm_pop (line 196) | void asm_arm_pop(asm_arm_t *as, uint reglist) {
function asm_arm_mov_reg_reg (line 200) | void asm_arm_mov_reg_reg(asm_arm_t *as, uint reg_dest, uint reg_src) {
function asm_arm_mov_reg_i32 (line 204) | size_t asm_arm_mov_reg_i32(asm_arm_t *as, uint rd, int imm) {
function asm_arm_mov_reg_i32_optimised (line 213) | void asm_arm_mov_reg_i32_optimised(asm_arm_t *as, uint rd, int imm) {
function asm_arm_mov_local_reg (line 225) | void asm_arm_mov_local_reg(asm_arm_t *as, int local_num, uint rd) {
function asm_arm_mov_reg_local (line 230) | void asm_arm_mov_reg_local(asm_arm_t *as, uint rd, int local_num) {
function asm_arm_cmp_reg_i8 (line 235) | void asm_arm_cmp_reg_i8(asm_arm_t *as, uint rd, int imm) {
function asm_arm_cmp_reg_reg (line 240) | void asm_arm_cmp_reg_reg(asm_arm_t *as, uint rd, uint rn) {
function asm_arm_setcc_reg (line 245) | void asm_arm_setcc_reg(asm_arm_t *as, uint rd, uint cond) {
function asm_arm_add_reg_reg_reg (line 250) | void asm_arm_add_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
function asm_arm_sub_reg_reg_reg (line 255) | void asm_arm_sub_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
function asm_arm_mul_reg_reg_reg (line 260) | void asm_arm_mul_reg_reg_reg(asm_arm_t *as, uint rd, uint rs, uint rm) {
function asm_arm_and_reg_reg_reg (line 266) | void asm_arm_and_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
function asm_arm_eor_reg_reg_reg (line 271) | void asm_arm_eor_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
function asm_arm_orr_reg_reg_reg (line 276) | void asm_arm_orr_reg_reg_reg(asm_arm_t *as, uint rd, uint rn, uint rm) {
function asm_arm_mov_reg_local_addr (line 281) | void asm_arm_mov_reg_local_addr(asm_arm_t *as, uint rd, int local_num) {
function asm_arm_mov_reg_pcrel (line 286) | void asm_arm_mov_reg_pcrel(asm_arm_t *as, uint reg_dest, uint label) {
function asm_arm_lsl_reg_reg (line 301) | void asm_arm_lsl_reg_reg(asm_arm_t *as, uint rd, uint rs) {
function asm_arm_lsr_reg_reg (line 306) | void asm_arm_lsr_reg_reg(asm_arm_t *as, uint rd, uint rs) {
function asm_arm_asr_reg_reg (line 311) | void asm_arm_asr_reg_reg(asm_arm_t *as, uint rd, uint rs) {
function asm_arm_ldr_reg_reg (line 316) | void asm_arm_ldr_reg_reg(asm_arm_t *as, uint rd, uint rn, uint byte_offs...
function asm_arm_ldrh_reg_reg (line 321) | void asm_arm_ldrh_reg_reg(asm_arm_t *as, uint rd, uint rn) {
function asm_arm_ldrb_reg_reg (line 326) | void asm_arm_ldrb_reg_reg(asm_arm_t *as, uint rd, uint rn) {
function asm_arm_str_reg_reg (line 331) | void asm_arm_str_reg_reg(asm_arm_t *as, uint rd, uint rm, uint byte_offs...
function asm_arm_strh_reg_reg (line 336) | void asm_arm_strh_reg_reg(asm_arm_t *as, uint rd, uint rm) {
function asm_arm_strb_reg_reg (line 341) | void asm_arm_strb_reg_reg(asm_arm_t *as, uint rd, uint rm) {
function asm_arm_str_reg_reg_reg (line 346) | void asm_arm_str_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) {
function asm_arm_strh_reg_reg_reg (line 351) | void asm_arm_strh_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) {
function asm_arm_strb_reg_reg_reg (line 357) | void asm_arm_strb_reg_reg_reg(asm_arm_t *as, uint rd, uint rm, uint rn) {
function asm_arm_bcc_label (line 362) | void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label) {
function asm_arm_b_label (line 376) | void asm_arm_b_label(asm_arm_t *as, uint label) {
function asm_arm_bl_ind (line 380) | void asm_arm_bl_ind(asm_arm_t *as, uint fun_id, uint reg_temp) {
function asm_arm_bx_reg (line 387) | void asm_arm_bx_reg(asm_arm_t *as, uint reg_src) {
FILE: py/asmarm.h
type asm_arm_t (line 69) | typedef struct _asm_arm_t {
FILE: py/asmbase.c
function mp_asm_base_init (line 36) | void mp_asm_base_init(mp_asm_base_t *as, size_t max_num_labels) {
function mp_asm_base_deinit (line 41) | void mp_asm_base_deinit(mp_asm_base_t *as, bool free_code) {
function mp_asm_base_start_pass (line 48) | void mp_asm_base_start_pass(mp_asm_base_t *as, int pass) {
function mp_asm_base_label_assign (line 74) | void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label) {
function mp_asm_base_align (line 87) | void mp_asm_base_align(mp_asm_base_t *as, unsigned int align) {
function mp_asm_base_data (line 92) | void mp_asm_base_data(mp_asm_base_t *as, unsigned int bytesize, uintptr_...
FILE: py/asmbase.h
type mp_asm_base_t (line 35) | typedef struct _mp_asm_base_t {
function mp_asm_base_get_code_pos (line 53) | static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) {
function mp_asm_base_get_code_size (line 57) | static inline size_t mp_asm_base_get_code_size(mp_asm_base_t *as) {
FILE: py/asmthumb.c
function byte (line 59) | static inline byte *asm_thumb_get_cur_to_write_bytes(asm_thumb_t *as, in...
function asm_thumb_end_pass (line 63) | void asm_thumb_end_pass(asm_thumb_t *as) {
function asm_thumb_entry (line 120) | void asm_thumb_entry(asm_thumb_t *as, int num_locals) {
function asm_thumb_exit (line 184) | void asm_thumb_exit(asm_thumb_t *as) {
function STATIC (line 195) | STATIC mp_uint_t get_label_dest(asm_thumb_t *as, uint label) {
function asm_thumb_op16 (line 200) | void asm_thumb_op16(asm_thumb_t *as, uint op) {
function asm_thumb_op32 (line 209) | void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2) {
function asm_thumb_format_4 (line 222) | void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rl...
function asm_thumb_mov_reg_reg (line 228) | void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src) {
function asm_thumb_mov_reg_i16 (line 245) | size_t asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest...
function asm_thumb_b_n_label (line 255) | bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) {
function asm_thumb_bcc_nw_label (line 269) | bool asm_thumb_bcc_nw_label(asm_thumb_t *as, int cond, uint label, bool ...
function asm_thumb_bl_label (line 285) | bool asm_thumb_bl_label(asm_thumb_t *as, uint label) {
function asm_thumb_mov_reg_i32 (line 293) | size_t asm_thumb_mov_reg_i32(asm_thumb_t *as, uint reg_dest, mp_uint_t i...
function asm_thumb_mov_reg_i32_optimised (line 305) | void asm_thumb_mov_reg_i32_optimised(asm_thumb_t *as, uint reg_dest, int...
function asm_thumb_mov_local_reg (line 318) | void asm_thumb_mov_local_reg(asm_thumb_t *as, int local_num, uint rlo_sr...
function asm_thumb_mov_reg_local (line 325) | void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_n...
function asm_thumb_mov_reg_local_addr (line 334) | void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int lo...
function asm_thumb_mov_reg_pcrel (line 341) | void asm_thumb_mov_reg_pcrel(asm_thumb_t *as, uint rlo_dest, uint label) {
function asm_thumb_ldr_reg_reg_i12 (line 350) | static inline void asm_thumb_ldr_reg_reg_i12(asm_thumb_t *as, uint reg_d...
function asm_thumb_ldr_reg_reg_i12_optimised (line 354) | void asm_thumb_ldr_reg_reg_i12_optimised(asm_thumb_t *as, uint reg_dest,...
function asm_thumb_b_label (line 366) | void asm_thumb_b_label(asm_thumb_t *as, uint label) {
function asm_thumb_bcc_label (line 385) | void asm_thumb_bcc_label(asm_thumb_t *as, int cond, uint label) {
function asm_thumb_bl_ind (line 407) | void asm_thumb_bl_ind(asm_thumb_t *as, uint fun_id, uint reg_temp) {
FILE: py/asmthumb.h
type asm_thumb_t (line 67) | typedef struct _asm_thumb_t {
function asm_thumb_it_cc (line 105) | static inline void asm_thumb_it_cc(asm_thumb_t *as, uint cc, uint mask) {
function asm_thumb_format_1 (line 118) | static inline void asm_thumb_format_1(asm_thumb_t *as, uint op, uint rlo...
function asm_thumb_format_2 (line 134) | static inline void asm_thumb_format_2(asm_thumb_t *as, uint op, uint rlo...
function asm_thumb_add_rlo_rlo_rlo (line 140) | static inline void asm_thumb_add_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_d...
function asm_thumb_add_rlo_rlo_i3 (line 143) | static inline void asm_thumb_add_rlo_rlo_i3(asm_thumb_t *as, uint rlo_de...
function asm_thumb_sub_rlo_rlo_rlo (line 146) | static inline void asm_thumb_sub_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_d...
function asm_thumb_sub_rlo_rlo_i3 (line 149) | static inline void asm_thumb_sub_rlo_rlo_i3(asm_thumb_t *as, uint rlo_de...
function asm_thumb_format_3 (line 163) | static inline void asm_thumb_format_3(asm_thumb_t *as, uint op, uint rlo...
function asm_thumb_mov_rlo_i8 (line 168) | static inline void asm_thumb_mov_rlo_i8(asm_thumb_t *as, uint rlo, int i...
function asm_thumb_cmp_rlo_i8 (line 171) | static inline void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i...
function asm_thumb_add_rlo_i8 (line 174) | static inline void asm_thumb_add_rlo_i8(asm_thumb_t *as, uint rlo, int i...
function asm_thumb_sub_rlo_i8 (line 177) | static inline void asm_thumb_sub_rlo_i8(asm_thumb_t *as, uint rlo, int i...
function asm_thumb_cmp_rlo_rlo (line 202) | static inline void asm_thumb_cmp_rlo_rlo(asm_thumb_t *as, uint rlo_dest,...
function asm_thumb_format_5 (line 215) | static inline void asm_thumb_format_5(asm_thumb_t *as, uint op, uint r_d...
function asm_thumb_add_reg_reg (line 219) | static inline void asm_thumb_add_reg_reg(asm_thumb_t *as, uint r_dest, u...
function asm_thumb_bx_reg (line 222) | static inline void asm_thumb_bx_reg(asm_thumb_t *as, uint r_src) {
function asm_thumb_format_9_10 (line 244) | static inline void asm_thumb_format_9_10(asm_thumb_t *as, uint op, uint ...
function asm_thumb_str_rlo_rlo_i5 (line 248) | static inline void asm_thumb_str_rlo_rlo_i5(asm_thumb_t *as, uint rlo_sr...
function asm_thumb_strb_rlo_rlo_i5 (line 251) | static inline void asm_thumb_strb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_s...
function asm_thumb_strh_rlo_rlo_i5 (line 254) | static inline void asm_thumb_strh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_s...
function asm_thumb_ldr_rlo_rlo_i5 (line 257) | static inline void asm_thumb_ldr_rlo_rlo_i5(asm_thumb_t *as, uint rlo_de...
function asm_thumb_ldrb_rlo_rlo_i5 (line 260) | static inline void asm_thumb_ldrb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_d...
function asm_thumb_ldrh_rlo_rlo_i5 (line 263) | static inline void asm_thumb_ldrh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_d...
FILE: py/asmx64.c
function byte (line 122) | static inline byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int n) {
function STATIC (line 126) | STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
function STATIC (line 133) | STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
function STATIC (line 141) | STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b...
function STATIC (line 150) | STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
function STATIC (line 160) | STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
function STATIC (line 186) | STATIC void asm_x64_write_r64_disp(asm_x64_t *as, int r64, int disp_r64,...
function STATIC (line 207) | STATIC void asm_x64_generic_r64_r64(asm_x64_t *as, int dest_r64, int src...
function asm_x64_nop (line 211) | void asm_x64_nop(asm_x64_t *as) {
function asm_x64_push_r64 (line 215) | void asm_x64_push_r64(asm_x64_t *as, int src_r64) {
function asm_x64_pop_r64 (line 238) | void asm_x64_pop_r64(asm_x64_t *as, int dest_r64) {
function STATIC (line 246) | STATIC void asm_x64_ret(asm_x64_t *as) {
function asm_x64_mov_r64_r64 (line 250) | void asm_x64_mov_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
function asm_x64_mov_r8_to_mem8 (line 254) | void asm_x64_mov_r8_to_mem8(asm_x64_t *as, int src_r64, int dest_r64, in...
function asm_x64_mov_r16_to_mem16 (line 263) | void asm_x64_mov_r16_to_mem16(asm_x64_t *as, int src_r64, int dest_r64, ...
function asm_x64_mov_r32_to_mem32 (line 272) | void asm_x64_mov_r32_to_mem32(asm_x64_t *as, int src_r64, int dest_r64, ...
function asm_x64_mov_r64_to_mem64 (line 281) | void asm_x64_mov_r64_to_mem64(asm_x64_t *as, int src_r64, int dest_r64, ...
function asm_x64_mov_mem8_to_r64zx (line 287) | void asm_x64_mov_mem8_to_r64zx(asm_x64_t *as, int src_r64, int src_disp,...
function asm_x64_mov_mem16_to_r64zx (line 297) | void asm_x64_mov_mem16_to_r64zx(asm_x64_t *as, int src_r64, int src_disp...
function asm_x64_mov_mem32_to_r64zx (line 307) | void asm_x64_mov_mem32_to_r64zx(asm_x64_t *as, int src_r64, int src_disp...
function asm_x64_mov_mem64_to_r64 (line 317) | void asm_x64_mov_mem64_to_r64(asm_x64_t *as, int src_r64, int src_disp, ...
function STATIC (line 323) | STATIC void asm_x64_lea_disp_to_r64(asm_x64_t *as, int src_r64, int src_...
function asm_x64_mov_i32_to_r64 (line 338) | size_t asm_x64_mov_i32_to_r64(asm_x64_t *as, int src_i32, int dest_r64) {
function asm_x64_mov_i64_to_r64 (line 350) | void asm_x64_mov_i64_to_r64(asm_x64_t *as, int64_t src_i64, int dest_r64) {
function asm_x64_mov_i64_to_r64_optimised (line 359) | void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, in...
function asm_x64_and_r64_r64 (line 370) | void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
function asm_x64_or_r64_r64 (line 374) | void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
function asm_x64_xor_r64_r64 (line 378) | void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
function asm_x64_shl_r64_cl (line 382) | void asm_x64_shl_r64_cl(asm_x64_t *as, int dest_r64) {
function asm_x64_shr_r64_cl (line 386) | void asm_x64_shr_r64_cl(asm_x64_t *as, int dest_r64) {
function asm_x64_sar_r64_cl (line 390) | void asm_x64_sar_r64_cl(asm_x64_t *as, int dest_r64) {
function asm_x64_add_r64_r64 (line 394) | void asm_x64_add_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
function asm_x64_sub_r64_r64 (line 398) | void asm_x64_sub_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
function asm_x64_mul_r64_r64 (line 402) | void asm_x64_mul_r64_r64(asm_x64_t *as, int dest_r64, int src_r64) {
function STATIC (line 422) | STATIC void asm_x64_sub_r64_i32(asm_x64_t *as, int dest_r64, int src_i32) {
function asm_x64_cmp_r64_with_r64 (line 452) | void asm_x64_cmp_r64_with_r64(asm_x64_t *as, int src_r64_a, int src_r64_...
function asm_x64_test_r8_with_r8 (line 468) | void asm_x64_test_r8_with_r8(asm_x64_t *as, int src_r64_a, int src_r64_b) {
function asm_x64_test_r64_with_r64 (line 474) | void asm_x64_test_r64_with_r64(asm_x64_t *as, int src_r64_a, int src_r64...
function asm_x64_setcc_r8 (line 478) | void asm_x64_setcc_r8(asm_x64_t *as, int jcc_type, int dest_r8) {
function asm_x64_jmp_reg (line 483) | void asm_x64_jmp_reg(asm_x64_t *as, int src_r64) {
function STATIC (line 488) | STATIC mp_uint_t get_label_dest(asm_x64_t *as, mp_uint_t label) {
function asm_x64_jmp_label (line 493) | void asm_x64_jmp_label(asm_x64_t *as, mp_uint_t label) {
function asm_x64_jcc_label (line 515) | void asm_x64_jcc_label(asm_x64_t *as, int jcc_type, mp_uint_t label) {
function asm_x64_entry (line 537) | void asm_x64_entry(asm_x64_t *as, int num_locals) {
function asm_x64_exit (line 548) | void asm_x64_exit(asm_x64_t *as) {
function STATIC (line 568) | STATIC int asm_x64_local_offset_from_rsp(asm_x64_t *as, int local_num) {
function asm_x64_mov_local_to_r64 (line 574) | void asm_x64_mov_local_to_r64(asm_x64_t *as, int src_local_num, int dest...
function asm_x64_mov_r64_to_local (line 578) | void asm_x64_mov_r64_to_local(asm_x64_t *as, int src_r64, int dest_local...
function asm_x64_mov_local_addr_to_r64 (line 582) | void asm_x64_mov_local_addr_to_r64(asm_x64_t *as, int local_num, int des...
function asm_x64_mov_reg_pcrel (line 591) | void asm_x64_mov_reg_pcrel(asm_x64_t *as, int dest_r64, mp_uint_t label) {
function asm_x64_call_ind (line 631) | void asm_x64_call_ind(asm_x64_t *as, size_t fun_id, int temp_r64) {
FILE: py/asmx64.h
type asm_x64_t (line 76) | typedef struct _asm_x64_t {
function asm_x64_end_pass (line 81) | static inline void asm_x64_end_pass(asm_x64_t *as) {
FILE: py/asmx86.c
function STATIC (line 106) | STATIC void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
function STATIC (line 113) | STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
function STATIC (line 121) | STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b...
function STATIC (line 130) | STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) {
function STATIC (line 140) | STATIC void asm_x86_write_r32_disp(asm_x86_t *as, int r32, int disp_r32,...
function STATIC (line 161) | STATIC void asm_x86_generic_r32_r32(asm_x86_t *as, int dest_r32, int src...
function STATIC (line 166) | STATIC void asm_x86_nop(asm_x86_t *as) {
function STATIC (line 171) | STATIC void asm_x86_push_r32(asm_x86_t *as, int src_r32) {
function asm_x86_push_i32 (line 176) | void asm_x86_push_i32(asm_x86_t *as, int src_i32) {
function asm_x86_push_disp (line 181) | void asm_x86_push_disp(asm_x86_t *as, int src_r32, int src_offset) {
function STATIC (line 187) | STATIC void asm_x86_pop_r32(asm_x86_t *as, int dest_r32) {
function STATIC (line 191) | STATIC void asm_x86_ret(asm_x86_t *as) {
function asm_x86_mov_r32_r32 (line 195) | void asm_x86_mov_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
function asm_x86_mov_r8_to_mem8 (line 199) | void asm_x86_mov_r8_to_mem8(asm_x86_t *as, int src_r32, int dest_r32, in...
function asm_x86_mov_r16_to_mem16 (line 204) | void asm_x86_mov_r16_to_mem16(asm_x86_t *as, int src_r32, int dest_r32, ...
function asm_x86_mov_r32_to_mem32 (line 209) | void asm_x86_mov_r32_to_mem32(asm_x86_t *as, int src_r32, int dest_r32, ...
function asm_x86_mov_mem8_to_r32zx (line 214) | void asm_x86_mov_mem8_to_r32zx(asm_x86_t *as, int src_r32, int src_disp,...
function asm_x86_mov_mem16_to_r32zx (line 219) | void asm_x86_mov_mem16_to_r32zx(asm_x86_t *as, int src_r32, int src_disp...
function asm_x86_mov_mem32_to_r32 (line 224) | void asm_x86_mov_mem32_to_r32(asm_x86_t *as, int src_r32, int src_disp, ...
function STATIC (line 229) | STATIC void asm_x86_lea_disp_to_r32(asm_x86_t *as, int src_r32, int src_...
function asm_x86_mov_i8_to_r8 (line 235) | void asm_x86_mov_i8_to_r8(asm_x86_t *as, int src_i8, int dest_r32) {
function asm_x86_mov_i32_to_r32 (line 240) | size_t asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r...
function asm_x86_and_r32_r32 (line 247) | void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
function asm_x86_or_r32_r32 (line 251) | void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
function asm_x86_xor_r32_r32 (line 255) | void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
function asm_x86_shl_r32_cl (line 259) | void asm_x86_shl_r32_cl(asm_x86_t *as, int dest_r32) {
function asm_x86_shr_r32_cl (line 263) | void asm_x86_shr_r32_cl(asm_x86_t *as, int dest_r32) {
function asm_x86_sar_r32_cl (line 267) | void asm_x86_sar_r32_cl(asm_x86_t *as, int dest_r32) {
function asm_x86_add_r32_r32 (line 271) | void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
function STATIC (line 275) | STATIC void asm_x86_add_i32_to_r32(asm_x86_t *as, int src_i32, int dest_...
function asm_x86_sub_r32_r32 (line 285) | void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
function STATIC (line 289) | STATIC void asm_x86_sub_r32_i32(asm_x86_t *as, int dest_r32, int src_i32) {
function asm_x86_mul_r32_r32 (line 301) | void asm_x86_mul_r32_r32(asm_x86_t *as, int dest_r32, int src_r32) {
function asm_x86_shl_r32_by_imm (line 308) | void asm_x86_shl_r32_by_imm(asm_x86_t *as, int r32, int imm) {
function asm_x86_shr_r32_by_imm (line 313) | void asm_x86_shr_r32_by_imm(asm_x86_t *as, int r32, int imm) {
function asm_x86_sar_r32_by_imm (line 318) | void asm_x86_sar_r32_by_imm(asm_x86_t *as, int r32, int imm) {
function asm_x86_cmp_r32_with_r32 (line 324) | void asm_x86_cmp_r32_with_r32(asm_x86_t *as, int src_r32_a, int src_r32_...
function asm_x86_cmp_i32_with_r32 (line 329) | void asm_x86_cmp_i32_with_r32(asm_x86_t *as, int src_i32, int src_r32) {
function asm_x86_test_r8_with_r8 (line 340) | void asm_x86_test_r8_with_r8(asm_x86_t *as, int src_r32_a, int src_r32_b) {
function asm_x86_test_r32_with_r32 (line 344) | void asm_x86_test_r32_with_r32(asm_x86_t *as, int src_r32_a, int src_r32...
function asm_x86_setcc_r8 (line 348) | void asm_x86_setcc_r8(asm_x86_t *as, mp_uint_t jcc_type, int dest_r8) {
function asm_x86_jmp_reg (line 352) | void asm_x86_jmp_reg(asm_x86_t *as, int src_r32) {
function STATIC (line 356) | STATIC mp_uint_t get_label_dest(asm_x86_t *as, mp_uint_t label) {
function asm_x86_jmp_label (line 361) | void asm_x86_jmp_label(asm_x86_t *as, mp_uint_t label) {
function asm_x86_jcc_label (line 383) | void asm_x86_jcc_label(asm_x86_t *as, mp_uint_t jcc_type, mp_uint_t labe...
function asm_x86_entry (line 405) | void asm_x86_entry(asm_x86_t *as, int num_locals) {
function asm_x86_exit (line 416) | void asm_x86_exit(asm_x86_t *as) {
function STATIC (line 425) | STATIC int asm_x86_arg_offset_from_esp(asm_x86_t *as, size_t arg_num) {
function asm_x86_push_arg (line 431) | void asm_x86_push_arg(asm_x86_t *as, int src_arg_num) {
function asm_x86_mov_arg_to_r32 (line 436) | void asm_x86_mov_arg_to_r32(asm_x86_t *as, int src_arg_num, int dest_r32) {
function asm_x86_mov_r32_to_arg (line 441) | void asm_x86_mov_r32_to_arg(asm_x86_t *as, int src_r32, int dest_arg_num) {
function STATIC (line 457) | STATIC int asm_x86_local_offset_from_esp(asm_x86_t *as, int local_num) {
function asm_x86_mov_local_to_r32 (line 463) | void asm_x86_mov_local_to_r32(asm_x86_t *as, int src_local_num, int dest...
function asm_x86_mov_r32_to_local (line 467) | void asm_x86_mov_r32_to_local(asm_x86_t *as, int src_r32, int dest_local...
function asm_x86_mov_local_addr_to_r32 (line 471) | void asm_x86_mov_local_addr_to_r32(asm_x86_t *as, int local_num, int des...
function asm_x86_mov_reg_pcrel (line 480) | void asm_x86_mov_reg_pcrel(asm_x86_t *as, int dest_r32, mp_uint_t label) {
function asm_x86_push_local (line 492) | void asm_x86_push_local(asm_x86_t *as, int local_num) {
function asm_x86_push_local_addr (line 496) | void asm_x86_push_local_addr(asm_x86_t *as, int local_num, int temp_r32) {
function asm_x86_call_ind (line 503) | void asm_x86_call_ind(asm_x86_t *as, size_t fun_id, mp_uint_t n_args, in...
FILE: py/asmx86.h
type asm_x86_t (line 78) | typedef struct _asm_x86_t {
function asm_x86_end_pass (line 83) | static inline void asm_x86_end_pass(asm_x86_t *as) {
FILE: py/asmxtensa.c
function asm_xtensa_end_pass (line 41) | void asm_xtensa_end_pass(asm_xtensa_t *as) {
function asm_xtensa_entry (line 64) | void asm_xtensa_entry(asm_xtensa_t *as, int num_locals) {
function asm_xtensa_exit (line 86) | void asm_xtensa_exit(asm_xtensa_t *as) {
function asm_xtensa_entry_win (line 104) | void asm_xtensa_entry_win(asm_xtensa_t *as, int num_locals) {
function asm_xtensa_exit_win (line 115) | void asm_xtensa_exit_win(asm_xtensa_t *as) {
function STATIC (line 120) | STATIC uint32_t get_label_dest(asm_xtensa_t *as, uint label) {
function asm_xtensa_op16 (line 125) | void asm_xtensa_op16(asm_xtensa_t *as, uint16_t op) {
function asm_xtensa_op24 (line 133) | void asm_xtensa_op24(asm_xtensa_t *as, uint32_t op) {
function asm_xtensa_j_label (line 142) | void asm_xtensa_j_label(asm_xtensa_t *as, uint label) {
function asm_xtensa_bccz_reg_label (line 149) | void asm_xtensa_bccz_reg_label(asm_xtensa_t *as, uint cond, uint reg, ui...
function asm_xtensa_bcc_reg_reg_label (line 158) | void asm_xtensa_bcc_reg_reg_label(asm_xtensa_t *as, uint cond, uint reg1...
function asm_xtensa_setcc_reg_reg_reg (line 168) | void asm_xtensa_setcc_reg_reg_reg(asm_xtensa_t *as, uint cond, uint reg_...
function asm_xtensa_mov_reg_i32 (line 174) | size_t asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t ...
function asm_xtensa_mov_reg_i32_optimised (line 187) | void asm_xtensa_mov_reg_i32_optimised(asm_xtensa_t *as, uint reg_dest, u...
function asm_xtensa_mov_local_reg (line 195) | void asm_xtensa_mov_local_reg(asm_xtensa_t *as, int local_num, uint reg_...
function asm_xtensa_mov_reg_local (line 199) | void asm_xtensa_mov_reg_local(asm_xtensa_t *as, uint reg_dest, int local...
function asm_xtensa_mov_reg_local_addr (line 203) | void asm_xtensa_mov_reg_local_addr(asm_xtensa_t *as, uint reg_dest, int ...
function asm_xtensa_mov_reg_pcrel (line 213) | void asm_xtensa_mov_reg_pcrel(asm_xtensa_t *as, uint reg_dest, uint labe...
function asm_xtensa_call_ind (line 235) | void asm_xtensa_call_ind(asm_xtensa_t *as, uint idx) {
function asm_xtensa_call_ind_win (line 244) | void asm_xtensa_call_ind_win(asm_xtensa_t *as, uint idx) {
FILE: py/asmxtensa.h
type asm_xtensa_t (line 113) | typedef struct _asm_xtensa_t {
function asm_xtensa_op_entry (line 134) | static inline void asm_xtensa_op_entry(asm_xtensa_t *as, uint reg_src, i...
function asm_xtensa_op_add_n (line 138) | static inline void asm_xtensa_op_add_n(asm_xtensa_t *as, uint reg_dest, ...
function asm_xtensa_op_addi (line 142) | static inline void asm_xtensa_op_addi(asm_xtensa_t *as, uint reg_dest, u...
function asm_xtensa_op_and (line 146) | static inline void asm_xtensa_op_and(asm_xtensa_t *as, uint reg_dest, ui...
function asm_xtensa_op_bcc (line 150) | static inline void asm_xtensa_op_bcc(asm_xtensa_t *as, uint cond, uint r...
function asm_xtensa_op_bccz (line 154) | static inline void asm_xtensa_op_bccz(asm_xtensa_t *as, uint cond, uint ...
function asm_xtensa_op_call0 (line 158) | static inline void asm_xtensa_op_call0(asm_xtensa_t *as, int32_t rel18) {
function asm_xtensa_op_callx0 (line 162) | static inline void asm_xtensa_op_callx0(asm_xtensa_t *as, uint reg) {
function asm_xtensa_op_callx8 (line 166) | static inline void asm_xtensa_op_callx8(asm_xtensa_t *as, uint reg) {
function asm_xtensa_op_j (line 170) | static inline void asm_xtensa_op_j(asm_xtensa_t *as, int32_t rel18) {
function asm_xtensa_op_jx (line 174) | static inline void asm_xtensa_op_jx(asm_xtensa_t *as, uint reg) {
function asm_xtensa_op_l8ui (line 178) | static inline void asm_xtensa_op_l8ui(asm_xtensa_t *as, uint reg_dest, u...
function asm_xtensa_op_l16ui (line 182) | static inline void asm_xtensa_op_l16ui(asm_xtensa_t *as, uint reg_dest, ...
function asm_xtensa_op_l32i (line 186) | static inline void asm_xtensa_op_l32i(asm_xtensa_t *as, uint reg_dest, u...
function asm_xtensa_op_l32i_n (line 190) | static inline void asm_xtensa_op_l32i_n(asm_xtensa_t *as, uint reg_dest,...
function asm_xtensa_op_l32r (line 194) | static inline void asm_xtensa_op_l32r(asm_xtensa_t *as, uint reg_dest, u...
function asm_xtensa_op_mov_n (line 198) | static inline void asm_xtensa_op_mov_n(asm_xtensa_t *as, uint reg_dest, ...
function asm_xtensa_op_movi (line 202) | static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, i...
function asm_xtensa_op_movi_n (line 206) | static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest,...
function asm_xtensa_op_mull (line 210) | static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, u...
function asm_xtensa_op_or (line 214) | static inline void asm_xtensa_op_or(asm_xtensa_t *as, uint reg_dest, uin...
function asm_xtensa_op_ret_n (line 218) | static inline void asm_xtensa_op_ret_n(asm_xtensa_t *as) {
function asm_xtensa_op_retw_n (line 222) | static inline void asm_xtensa_op_retw_n(asm_xtensa_t *as) {
function asm_xtensa_op_s8i (line 226) | static inline void asm_xtensa_op_s8i(asm_xtensa_t *as, uint reg_src, uin...
function asm_xtensa_op_s16i (line 230) | static inline void asm_xtensa_op_s16i(asm_xtensa_t *as, uint reg_src, ui...
function asm_xtensa_op_s32i (line 234) | static inline void asm_xtensa_op_s32i(asm_xtensa_t *as, uint reg_src, ui...
function asm_xtensa_op_s32i_n (line 238) | static inline void asm_xtensa_op_s32i_n(asm_xtensa_t *as, uint reg_src, ...
function asm_xtensa_op_sll (line 242) | static inline void asm_xtensa_op_sll(asm_xtensa_t *as, uint reg_dest, ui...
function asm_xtensa_op_srl (line 246) | static inline void asm_xtensa_op_srl(asm_xtensa_t *as, uint reg_dest, ui...
function asm_xtensa_op_sra (line 250) | static inline void asm_xtensa_op_sra(asm_xtensa_t *as, uint reg_dest, ui...
function asm_xtensa_op_ssl (line 254) | static inline void asm_xtensa_op_ssl(asm_xtensa_t *as, uint reg_src) {
function asm_xtensa_op_ssr (line 258) | static inline void asm_xtensa_op_ssr(asm_xtensa_t *as, uint reg_src) {
function asm_xtensa_op_sub (line 262) | static inline void asm_xtensa_op_sub(asm_xtensa_t *as, uint reg_dest, ui...
function asm_xtensa_op_xor (line 266) | static inline void asm_xtensa_op_xor(asm_xtensa_t *as, uint reg_dest, ui...
FILE: py/bc.c
function mp_uint_t (line 45) | mp_uint_t mp_decode_uint(const byte **ptr) {
function mp_uint_t (line 63) | mp_uint_t mp_decode_uint_value(const byte *ptr) {
function byte (line 69) | const byte *mp_decode_uint_skip(const byte *ptr) {
function fun_pos_args_mismatch (line 77) | void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t g...
function STATIC (line 96) | STATIC void dump_args(const mp_obj_t *a, size_t sz) {
function mp_setup_code_state (line 112) | void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, siz...
function uint (line 313) | uint mp_opcode_format(const byte *ip, size_t *opcode_size, bool count_va...
FILE: py/bc.h
type mp_bytecode_prelude_t (line 175) | typedef struct _mp_bytecode_prelude_t {
type mp_exc_stack_t (line 189) | typedef struct _mp_exc_stack_t {
type mp_code_state_t (line 198) | typedef struct _mp_code_state_t {
function mp_bytecode_get_source_line (line 246) | static inline size_t mp_bytecode_get_source_line(const byte *line_info, ...
FILE: py/binary.c
function mp_binary_get_size (line 45) | size_t mp_binary_get_size(char struct_type, char val_type, size_t *palig...
function mp_obj_t (line 147) | mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
function mp_binary_get_int (line 196) | long long mp_binary_get_int(size_t size, bool is_signed, bool big_endian...
function mp_obj_t (line 219) | mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base...
function mp_binary_set_int (line 269) | void mp_binary_set_int(size_t val_sz, bool big_endian, byte *dest, mp_ui...
function mp_binary_set_val (line 288) | void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in,...
function mp_binary_set_val_array (line 358) | void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_ob...
function mp_binary_set_val_array_from_int (line 385) | void mp_binary_set_val_array_from_int(char typecode, void *p, size_t ind...
FILE: py/builtinevex.c
type mp_obj_code_t (line 36) | typedef struct _mp_obj_code_t {
function STATIC (line 46) | STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals...
function STATIC (line 76) | STATIC mp_obj_t mp_builtin_compile(size_t n_args, const mp_obj_t *args) {
function STATIC (line 117) | STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp...
function STATIC (line 156) | STATIC mp_obj_t mp_builtin_eval(size_t n_args, const mp_obj_t *args) {
function STATIC (line 161) | STATIC mp_obj_t mp_builtin_exec(size_t n_args, const mp_obj_t *args) {
function STATIC (line 169) | STATIC mp_obj_t mp_builtin_execfile(size_t n_args, const mp_obj_t *args) {
FILE: py/builtinhelp.c
function STATIC (line 50) | STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t va...
function STATIC (line 59) | STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) {
function STATIC (line 68) | STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) {
function STATIC (line 78) | STATIC void mp_help_print_modules(void) {
function STATIC (line 129) | STATIC void mp_help_print_obj(const mp_obj_t obj) {
function STATIC (line 164) | STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
FILE: py/builtinimport.c
function mp_obj_is_package (line 51) | bool mp_obj_is_package(mp_obj_t module) {
function STATIC (line 59) | STATIC mp_import_stat_t mp_import_stat_any(const char *path) {
function STATIC (line 69) | STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) {
function STATIC (line 86) | STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) {
function STATIC (line 98) | STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, v...
function STATIC (line 133) | STATIC void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex) {
function STATIC (line 146) | STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_...
function STATIC (line 182) | STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {
function STATIC (line 235) | STATIC void chop_component(const char *start, const char **end) {
function mp_obj_t (line 246) | mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
function mp_obj_t (line 478) | mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
FILE: py/compile.c
type compiler_t (line 158) | typedef struct _compiler_t {
function STATIC (line 193) | STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
function STATIC (line 200) | STATIC void compile_syntax_error(compiler_t *comp, mp_parse_node_t pn, m...
function STATIC (line 213) | STATIC uint comp_next_label(compiler_t *comp) {
function STATIC (line 218) | STATIC void reserve_labels_for_native(compiler_t *comp, int n) {
function STATIC (line 227) | STATIC void compile_increase_except_level(compiler_t *comp, uint label, ...
function STATIC (line 235) | STATIC void compile_decrease_except_level(compiler_t *comp) {
function STATIC (line 242) | STATIC scope_t *scope_new_and_link(compiler_t *comp, scope_kind_t kind, ...
function STATIC (line 260) | STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn...
function STATIC (line 272) | STATIC void compile_generic_all_nodes(compiler_t *comp, mp_parse_node_st...
function STATIC (line 284) | STATIC void compile_load_id(compiler_t *comp, qstr qst) {
function STATIC (line 296) | STATIC void compile_store_id(compiler_t *comp, qstr qst) {
function STATIC (line 308) | STATIC void compile_delete_id(compiler_t *comp, qstr qst) {
function STATIC (line 320) | STATIC void c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_...
function STATIC (line 336) | STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct...
function STATIC (line 341) | STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if...
type assign_kind_t (line 403) | typedef enum { ASSIGN_STORE, ASSIGN_AUG_LOAD, ASSIGN_AUG_STORE } assign_...
function STATIC (line 406) | STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 456) | STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, ...
function STATIC (line 496) | STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t...
function STATIC (line 604) | STATIC void close_over_variables_etc(compiler_t *comp, scope_t *this_sco...
function STATIC (line 646) | STATIC void compile_funcdef_lambdef_param(compiler_t *comp, mp_parse_nod...
function STATIC (line 737) | STATIC void compile_funcdef_lambdef(compiler_t *comp, scope_t *scope, mp...
function STATIC (line 773) | STATIC qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struc...
function STATIC (line 793) | STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_stru...
function STATIC (line 874) | STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *...
function STATIC (line 942) | STATIC void compile_funcdef(compiler_t *comp, mp_parse_node_struct_t *pn...
function STATIC (line 948) | STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) {
function STATIC (line 1025) | STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *p...
function STATIC (line 1029) | STATIC void compile_break_cont_stmt(compiler_t *comp, mp_parse_node_stru...
function STATIC (line 1043) | STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t...
function STATIC (line 1071) | STATIC void compile_yield_stmt(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 1076) | STATIC void compile_raise_stmt(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 1096) | STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q...
function STATIC (line 1152) | STATIC void compile_dotted_as_name(compiler_t *comp, mp_parse_node_t pn) {
function STATIC (line 1160) | STATIC void compile_import_name(compiler_t *comp, mp_parse_node_struct_t...
function STATIC (line 1164) | STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t...
function STATIC (line 1252) | STATIC void compile_declare_global(compiler_t *comp, mp_parse_node_t pn,...
function STATIC (line 1266) | STATIC void compile_declare_nonlocal(compiler_t *comp, mp_parse_node_t p...
function STATIC (line 1278) | STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node...
function STATIC (line 1301) | STATIC void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t...
function STATIC (line 1319) | STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pn...
function STATIC (line 1396) | STATIC void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 1434) | STATIC void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_...
function STATIC (line 1516) | STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *p...
function STATIC (line 1598) | STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body...
function STATIC (line 1693) | STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_bod...
function STATIC (line 1713) | STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *p...
function STATIC (line 1740) | STATIC void compile_with_stmt_helper(compiler_t *comp, size_t n, mp_pars...
function STATIC (line 1767) | STATIC void compile_with_stmt(compiler_t *comp, mp_parse_node_struct_t *...
function STATIC (line 1777) | STATIC void compile_yield_from(compiler_t *comp) {
function STATIC (line 1785) | STATIC void compile_await_object_method(compiler_t *comp, qstr method) {
function STATIC (line 1791) | STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struc...
function STATIC (line 1843) | STATIC void compile_async_with_stmt_helper(compiler_t *comp, size_t n, m...
function STATIC (line 1955) | STATIC void compile_async_with_stmt(compiler_t *comp, mp_parse_node_stru...
function STATIC (line 1965) | STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 1984) | STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *...
function STATIC (line 2099) | STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_...
function STATIC (line 2114) | STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pn...
function STATIC (line 2130) | STATIC void compile_namedexpr_helper(compiler_t *comp, mp_parse_node_t p...
function STATIC (line 2145) | STATIC void compile_namedexpr(compiler_t *comp, mp_parse_node_struct_t *...
function STATIC (line 2150) | STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t...
function STATIC (line 2163) | STATIC void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 2168) | STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 2221) | STATIC void compile_star_expr(compiler_t *comp, mp_parse_node_struct_t *...
function STATIC (line 2225) | STATIC void compile_binary_op(compiler_t *comp, mp_parse_node_struct_t *...
function STATIC (line 2237) | STATIC void compile_term(compiler_t *comp, mp_parse_node_struct_t *pns) {
function STATIC (line 2248) | STATIC void compile_factor_2(compiler_t *comp, mp_parse_node_struct_t *p...
function STATIC (line 2261) | STATIC void compile_atom_expr_normal(compiler_t *comp, mp_parse_node_str...
function STATIC (line 2357) | STATIC void compile_power(compiler_t *comp, mp_parse_node_struct_t *pns) {
function STATIC (line 2362) | STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node...
function STATIC (line 2455) | STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct...
function STATIC (line 2480) | STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 2512) | STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_...
function STATIC (line 2551) | STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_st...
function STATIC (line 2653) | STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 2657) | STATIC void compile_trailer_paren(compiler_t *comp, mp_parse_node_struct...
function STATIC (line 2661) | STATIC void compile_trailer_bracket(compiler_t *comp, mp_parse_node_stru...
function STATIC (line 2667) | STATIC void compile_trailer_period(compiler_t *comp, mp_parse_node_struc...
function STATIC (line 2673) | STATIC void compile_subscript(compiler_t *comp, mp_parse_node_struct_t *...
function STATIC (line 2728) | STATIC void compile_dictorsetmaker_item(compiler_t *comp, mp_parse_node_...
function STATIC (line 2734) | STATIC void compile_classdef(compiler_t *comp, mp_parse_node_struct_t *p...
function STATIC (line 2740) | STATIC void compile_yield_expr(compiler_t *comp, mp_parse_node_struct_t ...
function STATIC (line 2761) | STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_stru...
function STATIC (line 2771) | STATIC mp_obj_t get_const_object(mp_parse_node_struct_t *pns) {
function STATIC (line 2780) | STATIC void compile_const_object(compiler_t *comp, mp_parse_node_struct_...
function STATIC (line 2877) | STATIC void compile_scope_func_lambda_param(compiler_t *comp, mp_parse_n...
function STATIC (line 2964) | STATIC void compile_scope_func_param(compiler_t *comp, mp_parse_node_t p...
function STATIC (line 2968) | STATIC void compile_scope_lambda_param(compiler_t *comp, mp_parse_node_t...
function STATIC (line 2972) | STATIC void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_stru...
function STATIC (line 3011) | STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
function STATIC (line 3056) | STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t ...
function STATIC (line 3221) | STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, p...
function STATIC (line 3394) | STATIC void scope_compute_things(scope_t *scope) {
function mp_raw_code_t (line 3490) | mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr ...
function mp_obj_t (line 3660) | mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, bool ...
FILE: py/dynruntime.h
function m_free_dyn (line 61) | static inline void m_free_dyn(void *ptr) {
function mp_obj_t (line 126) | static inline mp_obj_t mp_obj_new_str_of_type_dyn(const mp_obj_type_t *t...
function mp_obj_t (line 134) | static inline mp_obj_t mp_obj_cast_to_native_base_dyn(mp_obj_t self_in, ...
function mp_obj_t (line 158) | static inline mp_obj_t mp_obj_len_dyn(mp_obj_t o) {
function mp_obj_t (line 222) | static inline mp_obj_t mp_obj_new_exception_arg1_dyn(const mp_obj_type_t...
function NORETURN (line 227) | static NORETURN inline void mp_raise_dyn(mp_obj_t o) {
function mp_raise_OSError_dyn (line 233) | static inline void mp_raise_OSError_dyn(int er) {
FILE: py/emit.h
type pass_kind_t (line 42) | typedef enum {
type emit_t (line 93) | typedef struct _emit_t emit_t;
type mp_emit_method_table_id_ops_t (line 95) | typedef struct _mp_emit_method_table_id_ops_t {
type emit_method_table_t (line 100) | typedef struct _emit_method_table_t {
function mp_emit_common_get_id_for_load (line 164) | static inline void mp_emit_common_get_id_for_load(scope_t *scope, qstr q...
type emit_inline_asm_t (line 258) | typedef struct _emit_inline_asm_t emit_inline_asm_t;
type emit_inline_asm_method_table_t (line 260) | typedef struct _emit_inline_asm_method_table_t {
FILE: py/emitbc.c
type _emit_t (line 42) | struct _emit_t {
function emit_t (line 78) | emit_t *emit_bc_new(void) {
function emit_bc_set_max_num_labels (line 83) | void emit_bc_set_max_num_labels(emit_t *emit, mp_uint_t max_num_labels) {
function emit_bc_free (line 88) | void emit_bc_free(emit_t *emit) {
type byte (line 93) | typedef byte *(*emit_allocator_t)(emit_t *emit, int nbytes);
function STATIC (line 95) | STATIC void emit_write_uint(emit_t *emit, emit_allocator_t allocator, mp...
function STATIC (line 112) | STATIC byte *emit_get_cur_to_write_code_info(emit_t *emit, int num_bytes...
function STATIC (line 124) | STATIC void emit_write_code_info_byte(emit_t *emit, byte val) {
function STATIC (line 128) | STATIC void emit_write_code_info_qstr(emit_t *emit, qstr qst) {
function STATIC (line 140) | STATIC void emit_write_code_info_bytes_lines(emit_t *emit, mp_uint_t byt...
function STATIC (line 169) | STATIC byte *emit_get_cur_to_write_bytecode(emit_t *emit, int num_bytes_...
function STATIC (line 181) | STATIC void emit_write_bytecode_raw_byte(emit_t *emit, byte b1) {
function STATIC (line 186) | STATIC void emit_write_bytecode_byte(emit_t *emit, int stack_adj, byte b...
function STATIC (line 193) | STATIC void emit_write_bytecode_byte_int(emit_t *emit, int stack_adj, by...
function STATIC (line 219) | STATIC void emit_write_bytecode_byte_uint(emit_t *emit, int stack_adj, b...
function STATIC (line 225) | STATIC void emit_write_bytecode_byte_const(emit_t *emit, int stack_adj, ...
function STATIC (line 233) | STATIC void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, b...
function STATIC (line 246) | STATIC void emit_write_bytecode_byte_obj(emit_t *emit, int stack_adj, by...
function STATIC (line 262) | STATIC void emit_write_bytecode_byte_raw_code(emit_t *emit, int stack_ad...
function STATIC (line 282) | STATIC void emit_write_bytecode_byte_unsigned_label(emit_t *emit, int st...
function STATIC (line 297) | STATIC void emit_write_bytecode_byte_signed_label(emit_t *emit, int stac...
function mp_emit_bc_start_pass (line 311) | void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scop...
function mp_emit_bc_end_pass (line 391) | void mp_emit_bc_end_pass(emit_t *emit) {
function mp_emit_bc_last_emit_was_return_value (line 453) | bool mp_emit_bc_last_emit_was_return_value(emit_t *emit) {
function mp_emit_bc_adjust_stack_size (line 457) | void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta) {
function mp_emit_bc_set_source_line (line 469) | void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t source_line) {
function mp_emit_bc_label_assign (line 488) | void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) {
function mp_emit_bc_import (line 504) | void mp_emit_bc_import(emit_t *emit, qstr qst, int kind) {
function mp_emit_bc_load_const_tok (line 515) | void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
function mp_emit_bc_load_const_small_int (line 525) | void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) {
function mp_emit_bc_load_const_str (line 535) | void mp_emit_bc_load_const_str(emit_t *emit, qstr qst) {
function mp_emit_bc_load_const_obj (line 539) | void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj) {
function mp_emit_bc_load_null (line 543) | void mp_emit_bc_load_null(emit_t *emit) {
function mp_emit_bc_load_local (line 547) | void mp_emit_bc_load_local(emit_t *emit, qstr qst, mp_uint_t local_num, ...
function mp_emit_bc_load_global (line 558) | void mp_emit_bc_load_global(emit_t *emit, qstr qst, int kind) {
function mp_emit_bc_load_method (line 568) | void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super) {
function mp_emit_bc_load_build_class (line 573) | void mp_emit_bc_load_build_class(emit_t *emit) {
function mp_emit_bc_subscr (line 577) | void mp_emit_bc_subscr(emit_t *emit, int kind) {
function mp_emit_bc_attr (line 589) | void mp_emit_bc_attr(emit_t *emit, qstr qst, int kind) {
function mp_emit_bc_store_local (line 604) | void mp_emit_bc_store_local(emit_t *emit, qstr qst, mp_uint_t local_num,...
function mp_emit_bc_store_global (line 615) | void mp_emit_bc_store_global(emit_t *emit, qstr qst, int kind) {
function mp_emit_bc_delete_local (line 621) | void mp_emit_bc_delete_local(emit_t *emit, qstr qst, mp_uint_t local_num...
function mp_emit_bc_delete_global (line 628) | void mp_emit_bc_delete_global(emit_t *emit, qstr qst, int kind) {
function mp_emit_bc_dup_top (line 634) | void mp_emit_bc_dup_top(emit_t *emit) {
function mp_emit_bc_dup_top_two (line 638) | void mp_emit_bc_dup_top_two(emit_t *emit) {
function mp_emit_bc_pop_top (line 642) | void mp_emit_bc_pop_top(emit_t *emit) {
function mp_emit_bc_rot_two (line 646) | void mp_emit_bc_rot_two(emit_t *emit) {
function mp_emit_bc_rot_three (line 650) | void mp_emit_bc_rot_three(emit_t *emit) {
function mp_emit_bc_jump (line 654) | void mp_emit_bc_jump(emit_t *emit, mp_uint_t label) {
function mp_emit_bc_pop_jump_if (line 658) | void mp_emit_bc_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label) {
function mp_emit_bc_jump_if_or_pop (line 666) | void mp_emit_bc_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label) {
function mp_emit_bc_unwind_jump (line 674) | void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t exc...
function mp_emit_bc_setup_block (line 691) | void mp_emit_bc_setup_block(emit_t *emit, mp_uint_t label, int kind) {
function mp_emit_bc_with_cleanup (line 701) | void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label) {
function mp_emit_bc_end_finally (line 710) | void mp_emit_bc_end_finally(emit_t *emit) {
function mp_emit_bc_get_iter (line 714) | void mp_emit_bc_get_iter(emit_t *emit, bool use_stack) {
function mp_emit_bc_for_iter (line 719) | void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label) {
function mp_emit_bc_for_iter_end (line 723) | void mp_emit_bc_for_iter_end(emit_t *emit) {
function mp_emit_bc_pop_except_jump (line 727) | void mp_emit_bc_pop_except_jump(emit_t *emit, mp_uint_t label, bool with...
function mp_emit_bc_unary_op (line 732) | void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op) {
function mp_emit_bc_binary_op (line 736) | void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op) {
function mp_emit_bc_build (line 751) | void mp_emit_bc_build(emit_t *emit, mp_uint_t n_args, int kind) {
function mp_emit_bc_store_map (line 761) | void mp_emit_bc_store_map(emit_t *emit) {
function mp_emit_bc_store_comp (line 765) | void mp_emit_bc_store_comp(emit_t *emit, scope_kind_t kind, mp_uint_t co...
function mp_emit_bc_unpack_sequence (line 782) | void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
function mp_emit_bc_unpack_ex (line 786) | void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_ri...
function mp_emit_bc_make_function (line 790) | void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_...
function mp_emit_bc_make_closure (line 798) | void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_c...
function STATIC (line 811) | STATIC void emit_bc_call_function_method_helper(emit_t *emit, int stack_...
function mp_emit_bc_call_function (line 821) | void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_u...
function mp_emit_bc_call_method (line 825) | void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uin...
function mp_emit_bc_return_value (line 829) | void mp_emit_bc_return_value(emit_t *emit) {
function mp_emit_bc_raise_varargs (line 834) | void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args) {
function mp_emit_bc_yield (line 841) | void mp_emit_bc_yield(emit_t *emit, int kind) {
function mp_emit_bc_start_except_handler (line 847) | void mp_emit_bc_start_except_handler(emit_t *emit) {
function mp_emit_bc_end_except_handler (line 851) | void mp_emit_bc_end_except_handler(emit_t *emit) {
FILE: py/emitcommon.c
function mp_emit_common_get_id_for_modification (line 33) | void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst) {
function mp_emit_common_id_op (line 42) | void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_op...
FILE: py/emitglue.c
function mp_raw_code_t (line 53) | mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
function mp_emit_glue_assign_bytecode (line 62) | void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
function mp_emit_glue_assign_native (line 101) | void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t ki...
function mp_obj_t (line 148) | mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_...
function mp_obj_t (line 196) | mp_obj_t mp_make_closure_from_raw_code(const mp_raw_code_t *rc, mp_uint_...
FILE: py/emitglue.h
type mp_raw_code_kind_t (line 43) | typedef enum {
type mp_qstr_link_entry_t (line 52) | typedef struct _mp_qstr_link_entry_t {
type mp_raw_code_t (line 57) | typedef struct _mp_raw_code_t {
FILE: py/emitinlinethumb.c
type _emit_inline_asm_t (line 54) | struct _emit_inline_asm_t {
function STATIC (line 62) | STATIC void emit_inline_thumb_error_msg(emit_inline_asm_t *emit, mp_rom_...
function STATIC (line 66) | STATIC void emit_inline_thumb_error_exc(emit_inline_asm_t *emit, mp_obj_...
function emit_inline_asm_t (line 70) | emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels) {
function emit_inline_thumb_free (line 79) | void emit_inline_thumb_free(emit_inline_asm_t *emit) {
function STATIC (line 85) | STATIC void emit_inline_thumb_start_pass(emit_inline_asm_t *emit, pass_k...
function STATIC (line 95) | STATIC void emit_inline_thumb_end_pass(emit_inline_asm_t *emit, mp_uint_...
function STATIC (line 100) | STATIC mp_uint_t emit_inline_thumb_count_params(emit_inline_asm_t *emit,...
function STATIC (line 119) | STATIC bool emit_inline_thumb_label(emit_inline_asm_t *emit, mp_uint_t l...
type reg_name_t (line 134) | typedef struct _reg_name_t { byte reg;
type special_reg_name_t (line 162) | typedef struct _special_reg_name_t { byte reg;
function STATIC (line 172) | STATIC const char *get_arg_str(mp_parse_node_t pn) {
function STATIC (line 181) | STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp...
function STATIC (line 205) | STATIC mp_uint_t get_arg_special_reg(emit_inline_asm_t *emit, const char...
function STATIC (line 220) | STATIC mp_uint_t get_arg_vfpreg(emit_inline_asm_t *emit, const char *op,...
function STATIC (line 248) | STATIC mp_uint_t get_arg_reglist(emit_inline_asm_t *emit, const char *op...
function STATIC (line 300) | STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_pa...
function STATIC (line 314) | STATIC bool get_arg_addr(emit_inline_asm_t *emit, const char *op, mp_par...
function STATIC (line 336) | STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_par...
type cc_name_t (line 354) | typedef struct _cc_name_t { byte cc;
type format_4_op_t (line 374) | typedef struct _format_4_op_t { byte op;
type format_9_10_op_t (line 398) | typedef struct _format_9_10_op_t { uint16_t op;
type format_vfp_op_t (line 414) | typedef struct _format_vfp_op_t { byte op;
function STATIC (line 428) | STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_ui...
FILE: py/emitinlinextensa.c
type _emit_inline_asm_t (line 38) | struct _emit_inline_asm_t {
function STATIC (line 46) | STATIC void emit_inline_xtensa_error_msg(emit_inline_asm_t *emit, mp_rom...
function STATIC (line 50) | STATIC void emit_inline_xtensa_error_exc(emit_inline_asm_t *emit, mp_obj...
function emit_inline_asm_t (line 54) | emit_inline_asm_t *emit_inline_xtensa_new(mp_uint_t max_num_labels) {
function emit_inline_xtensa_free (line 63) | void emit_inline_xtensa_free(emit_inline_asm_t *emit) {
function STATIC (line 69) | STATIC void emit_inline_xtensa_start_pass(emit_inline_asm_t *emit, pass_...
function STATIC (line 79) | STATIC void emit_inline_xtensa_end_pass(emit_inline_asm_t *emit, mp_uint...
function STATIC (line 84) | STATIC mp_uint_t emit_inline_xtensa_count_params(emit_inline_asm_t *emit...
function STATIC (line 103) | STATIC bool emit_inline_xtensa_label(emit_inline_asm_t *emit, mp_uint_t ...
type reg_name_t (line 118) | typedef struct _reg_name_t { byte reg;
function STATIC (line 142) | STATIC const char *get_arg_str(mp_parse_node_t pn) {
function STATIC (line 151) | STATIC mp_uint_t get_arg_reg(emit_inline_asm_t *emit, const char *op, mp...
function STATIC (line 168) | STATIC uint32_t get_arg_i(emit_inline_asm_t *emit, const char *op, mp_pa...
function STATIC (line 182) | STATIC int get_arg_label(emit_inline_asm_t *emit, const char *op, mp_par...
type opcode_table_3arg_t (line 204) | typedef struct _opcode_table_3arg_t {
function STATIC (line 245) | STATIC void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_u...
FILE: py/emitnative.c
type stack_info_kind_t (line 140) | typedef enum {
type vtype_kind_t (line 148) | typedef enum {
function STATIC (line 164) | STATIC qstr vtype_to_qstr(vtype_kind_t vtype) {
type stack_info_t (line 188) | typedef struct _stack_info_t {
type exc_stack_entry_t (line 200) | typedef struct _exc_stack_entry_t {
type _emit_t (line 207) | struct _emit_t {
function emit_t (line 257) | emit_t *EXPORT_FUN(new)(mp_obj_t * error_slot, uint *label_slot, mp_uint...
function STATIC (line 281) | STATIC void emit_native_mov_reg_const(emit_t *emit, int reg_dest, int co...
function STATIC (line 285) | STATIC void emit_native_mov_state_reg(emit_t *emit, int local_num, int r...
function STATIC (line 293) | STATIC void emit_native_mov_reg_state(emit_t *emit, int reg_dest, int lo...
function STATIC (line 301) | STATIC void emit_native_mov_reg_state_addr(emit_t *emit, int reg_dest, i...
function STATIC (line 310) | STATIC void emit_native_mov_reg_qstr(emit_t *emit, int arg_reg, qstr qst) {
function STATIC (line 323) | STATIC void emit_native_mov_reg_qstr_obj(emit_t *emit, int reg_dest, qst...
function STATIC (line 342) | STATIC void emit_native_start_pass(emit_t *emit, pass_kind_t pass, scope...
function emit_native_write_code_info_byte (line 627) | static inline void emit_native_write_code_info_byte(emit_t *emit, byte v...
function STATIC (line 631) | STATIC void emit_native_end_pass(emit_t *emit) {
function STATIC (line 727) | STATIC bool emit_native_last_emit_was_return_value(emit_t *emit) {
function STATIC (line 731) | STATIC void ensure_extra_stack(emit_t *emit, size_t delta) {
function STATIC (line 739) | STATIC void adjust_stack(emit_t *emit, mp_int_t stack_size_delta) {
function STATIC (line 756) | STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
function STATIC (line 780) | STATIC void emit_native_set_source_line(emit_t *emit, mp_uint_t source_l...
function STATIC (line 786) | STATIC void emit_native_pre(emit_t *emit) {
function STATIC (line 791) | STATIC stack_info_t *peek_stack(emit_t *emit, mp_uint_t depth) {
function STATIC (line 796) | STATIC vtype_kind_t peek_vtype(emit_t *emit, mp_uint_t depth) {
function STATIC (line 807) | STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack...
function STATIC (line 820) | STATIC void need_reg_all(emit_t *emit) {
function STATIC (line 830) | STATIC vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const...
function STATIC (line 850) | STATIC void need_stack_settled(emit_t *emit) {
function STATIC (line 872) | STATIC void emit_access_stack(emit_t *emit, int pos, vtype_kind_t *vtype...
function STATIC (line 895) | STATIC void emit_fold_stack_top(emit_t *emit, int reg_dest) {
function STATIC (line 909) | STATIC void emit_pre_pop_reg_flexible(emit_t *emit, vtype_kind_t *vtype,...
function STATIC (line 922) | STATIC void emit_pre_pop_discard(emit_t *emit) {
function STATIC (line 927) | STATIC void emit_pre_pop_reg(emit_t *emit, vtype_kind_t *vtype, int reg_...
function STATIC (line 933) | STATIC void emit_pre_pop_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int...
function STATIC (line 938) | STATIC void emit_pre_pop_reg_reg_reg(emit_t *emit, vtype_kind_t *vtypea,...
function STATIC (line 944) | STATIC void emit_post(emit_t *emit) {
function STATIC (line 948) | STATIC void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) {
function STATIC (line 953) | STATIC void emit_post_push_reg(emit_t *emit, vtype_kind_t vtype, int reg) {
function STATIC (line 962) | STATIC void emit_post_push_imm(emit_t *emit, vtype_kind_t vtype, mp_int_...
function STATIC (line 971) | STATIC void emit_post_push_reg_reg(emit_t *emit, vtype_kind_t vtypea, in...
function STATIC (line 976) | STATIC void emit_post_push_reg_reg_reg(emit_t *emit, vtype_kind_t vtypea...
function STATIC (line 982) | STATIC void emit_post_push_reg_reg_reg_reg(emit_t *emit, vtype_kind_t vt...
function STATIC (line 989) | STATIC void emit_call(emit_t *emit, mp_fun_kind_t fun_kind) {
function STATIC (line 994) | STATIC void emit_call_with_imm_arg(emit_t *emit, mp_fun_kind_t fun_kind,...
function STATIC (line 1000) | STATIC void emit_call_with_2_imm_args(emit_t *emit, mp_fun_kind_t fun_ki...
function STATIC (line 1007) | STATIC void emit_call_with_qstr_arg(emit_t *emit, mp_fun_kind_t fun_kind...
function STATIC (line 1017) | STATIC void emit_get_stack_pointer_to_reg_for_pop(emit_t *emit, mp_uint_...
function STATIC (line 1054) | STATIC void emit_get_stack_pointer_to_reg_for_push(emit_t *emit, mp_uint...
function STATIC (line 1065) | STATIC void emit_native_push_exc_stack(emit_t *emit, uint label, bool is...
function STATIC (line 1082) | STATIC void emit_native_leave_exc_stack(emit_t *emit, bool start_of_hand...
function STATIC (line 1108) | STATIC exc_stack_entry_t *emit_native_pop_exc_stack(emit_t *emit) {
function STATIC (line 1115) | STATIC void emit_load_reg_with_ptr(emit_t *emit, int reg, mp_uint_t ptr,...
function STATIC (line 1128) | STATIC void emit_load_reg_with_object(emit_t *emit, int reg, mp_obj_t ob...
function STATIC (line 1134) | STATIC void emit_load_reg_with_raw_code(emit_t *emit, int reg, mp_raw_co...
function STATIC (line 1140) | STATIC void emit_native_label_assign(emit_t *emit, mp_uint_t l) {
function STATIC (line 1168) | STATIC void emit_native_global_exc_entry(emit_t *emit) {
function STATIC (line 1277) | STATIC void emit_native_global_exc_exit(emit_t *emit) {
function STATIC (line 1312) | STATIC void emit_native_import_name(emit_t *emit, qstr qst) {
function STATIC (line 1331) | STATIC void emit_native_import_from(emit_t *emit, qstr qst) {
function STATIC (line 1341) | STATIC void emit_native_import_star(emit_t *emit) {
function STATIC (line 1350) | STATIC void emit_native_import(emit_t *emit, qstr qst, int kind) {
function STATIC (line 1360) | STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
function STATIC (line 1378) | STATIC void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) {
function STATIC (line 1384) | STATIC void emit_native_load_const_str(emit_t *emit, qstr qst) {
function STATIC (line 1401) | STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj) {
function STATIC (line 1409) | STATIC void emit_native_load_null(emit_t *emit) {
function STATIC (line 1414) | STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t loca...
function STATIC (line 1430) | STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t loc...
function STATIC (line 1442) | STATIC void emit_native_load_local(emit_t *emit, qstr qst, mp_uint_t loc...
function STATIC (line 1450) | STATIC void emit_native_load_global(emit_t *emit, qstr qst, int kind) {
function STATIC (line 1471) | STATIC void emit_native_load_attr(emit_t *emit, qstr qst) {
function STATIC (line 1483) | STATIC void emit_native_load_method(emit_t *emit, qstr qst, bool is_supe...
function STATIC (line 1497) | STATIC void emit_native_load_build_class(emit_t *emit) {
function STATIC (line 1503) | STATIC void emit_native_load_subscr(emit_t *emit) {
function STATIC (line 1638) | STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t loc...
function STATIC (line 1660) | STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t lo...
function STATIC (line 1674) | STATIC void emit_native_store_local(emit_t *emit, qstr qst, mp_uint_t lo...
function STATIC (line 1682) | STATIC void emit_native_store_global(emit_t *emit, qstr qst, int kind) {
function STATIC (line 1704) | STATIC void emit_native_store_attr(emit_t *emit, qstr qst) {
function STATIC (line 1713) | STATIC void emit_native_store_subscr(emit_t *emit) {
function STATIC (line 1890) | STATIC void emit_native_delete_local(emit_t *emit, qstr qst, mp_uint_t l...
function STATIC (line 1902) | STATIC void emit_native_delete_global(emit_t *emit, qstr qst, int kind) {
function STATIC (line 1910) | STATIC void emit_native_delete_attr(emit_t *emit, qstr qst) {
function STATIC (line 1919) | STATIC void emit_native_delete_subscr(emit_t *emit) {
function STATIC (line 1927) | STATIC void emit_native_subscr(emit_t *emit, int kind) {
function STATIC (line 1937) | STATIC void emit_native_attr(emit_t *emit, qstr qst, int kind) {
function STATIC (line 1947) | STATIC void emit_native_dup_top(emit_t *emit) {
function STATIC (line 1955) | STATIC void emit_native_dup_top_two(emit_t *emit) {
function STATIC (line 1961) | STATIC void emit_native_pop_top(emit_t *emit) {
function STATIC (line 1967) | STATIC void emit_native_rot_two(emit_t *emit) {
function STATIC (line 1974) | STATIC void emit_native_rot_three(emit_t *emit) {
function STATIC (line 1981) | STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) {
function STATIC (line 1990) | STATIC void emit_native_jump_helper(emit_t *emit, bool cond, mp_uint_t l...
function STATIC (line 2027) | STATIC void emit_native_pop_jump_if(emit_t *emit, bool cond, mp_uint_t l...
function STATIC (line 2032) | STATIC void emit_native_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_...
function STATIC (line 2037) | STATIC void emit_native_unwind_jump(emit_t *emit, mp_uint_t label, mp_ui...
function STATIC (line 2080) | STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
function STATIC (line 2119) | STATIC void emit_native_setup_block(emit_t *emit, mp_uint_t label, int k...
function STATIC (line 2131) | STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
function STATIC (line 2198) | STATIC void emit_native_end_finally(emit_t *emit) {
function STATIC (line 2224) | STATIC void emit_native_get_iter(emit_t *emit, bool use_stack) {
function STATIC (line 2242) | STATIC void emit_native_for_iter(emit_t *emit, mp_uint_t label) {
function STATIC (line 2257) | STATIC void emit_native_for_iter_end(emit_t *emit) {
function STATIC (line 2264) | STATIC void emit_native_pop_except_jump(emit_t *emit, mp_uint_t label, b...
function STATIC (line 2275) | STATIC void emit_native_unary_op(emit_t *emit, mp_unary_op_t op) {
function STATIC (line 2288) | STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
function STATIC (line 2532) | STATIC void emit_native_build(emit_t *emit, mp_uint_t n_args, int kind) {
function STATIC (line 2553) | STATIC void emit_native_store_map(emit_t *emit) {
function STATIC (line 2564) | STATIC void emit_native_build_slice(emit_t *emit, mp_uint_t n_args) {
function STATIC (line 2585) | STATIC void emit_native_store_comp(emit_t *emit, scope_kind_t kind, mp_u...
function STATIC (line 2614) | STATIC void emit_native_unpack_sequence(emit_t *emit, mp_uint_t n_args) {
function STATIC (line 2623) | STATIC void emit_native_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uin...
function STATIC (line 2632) | STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_u...
function STATIC (line 2651) | STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_ui...
function STATIC (line 2665) | STATIC void emit_native_call_function(emit_t *emit, mp_uint_t n_position...
function STATIC (line 2720) | STATIC void emit_native_call_method(emit_t *emit, mp_uint_t n_positional...
function STATIC (line 2733) | STATIC void emit_native_return_value(emit_t *emit) {
function STATIC (line 2788) | STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
function STATIC (line 2800) | STATIC void emit_native_yield(emit_t *emit, int kind) {
function STATIC (line 2883) | STATIC void emit_native_start_except_handler(emit_t *emit) {
function STATIC (line 2892) | STATIC void emit_native_end_except_handler(emit_t *emit) {
FILE: py/formatfloat.c
function fp_signbit (line 71) | static inline int fp_signbit(float x) {
function fp_iszero (line 77) | static inline int fp_iszero(float x) {
function fp_isless1 (line 81) | static inline int fp_isless1(float x) {
function mp_format_float (line 114) | int mp_format_float(FPTYPE f, char *buf, size_t buf_size, char fmt, int ...
FILE: py/frozenmod.c
function STATIC (line 63) | STATIC mp_lexer_t *mp_lexer_frozen_str(const char *str, size_t len) {
function STATIC (line 85) | STATIC const mp_raw_code_t *mp_find_frozen_mpy(const char *str, size_t l...
function STATIC (line 101) | STATIC mp_import_stat_t mp_frozen_stat_helper(const char *name, const ch...
function mp_import_stat_t (line 118) | mp_import_stat_t mp_frozen_stat(const char *str) {
function mp_find_frozen_module (line 138) | int mp_find_frozen_module(const char *str, size_t len, void **data) {
FILE: py/gc.c
function gc_init (line 109) | void gc_init(void *start, void *end) {
function gc_lock (line 176) | void gc_lock(void) {
function gc_unlock (line 182) | void gc_unlock(void) {
function gc_is_locked (line 188) | bool gc_is_locked(void) {
function STATIC (line 211) | STATIC void gc_mark_subtree(size_t block) {
function STATIC (line 251) | STATIC void gc_deal_with_stack_overflow(void) {
function STATIC (line 265) | STATIC void gc_sweep(void) {
function gc_collect_start (line 321) | void gc_collect_start(void) {
function gc_collect_root (line 344) | void gc_collect_root(void **ptrs, size_t len) {
function gc_collect_end (line 359) | void gc_collect_end(void) {
function gc_sweep_all (line 367) | void gc_sweep_all(void) {
function gc_info (line 374) | void gc_info(gc_info_t *info) {
function gc_free (line 575) | void gc_free(void *ptr) {
function gc_nbytes (line 616) | size_t gc_nbytes(const void *ptr) {
function gc_dump_info (line 800) | void gc_dump_info(void) {
function gc_dump_alloc_table (line 809) | void gc_dump_alloc_table(void) {
function gc_test (line 940) | void gc_test(void) {
FILE: py/gc.h
type gc_info_t (line 60) | typedef struct _gc_info_t {
FILE: py/lexer.c
function STATIC (line 45) | STATIC bool is_end(mp_lexer_t *lex) {
function STATIC (line 49) | STATIC bool is_physical_newline(mp_lexer_t *lex) {
function STATIC (line 53) | STATIC bool is_char(mp_lexer_t *lex, byte c) {
function STATIC (line 57) | STATIC bool is_char_or(mp_lexer_t *lex, byte c1, byte c2) {
function STATIC (line 61) | STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) {
function STATIC (line 65) | STATIC bool is_char_following(mp_lexer_t *lex, byte c) {
function STATIC (line 69) | STATIC bool is_char_following_or(mp_lexer_t *lex, byte c1, byte c2) {
function STATIC (line 73) | STATIC bool is_char_following_following_or(mp_lexer_t *lex, byte c1, byt...
function STATIC (line 77) | STATIC bool is_char_and(mp_lexer_t *lex, byte c1, byte c2) {
function STATIC (line 81) | STATIC bool is_whitespace(mp_lexer_t *lex) {
function STATIC (line 85) | STATIC bool is_letter(mp_lexer_t *lex) {
function STATIC (line 89) | STATIC bool is_digit(mp_lexer_t *lex) {
function STATIC (line 93) | STATIC bool is_following_digit(mp_lexer_t *lex) {
function STATIC (line 97) | STATIC bool is_following_base_char(mp_lexer_t *lex) {
function STATIC (line 102) | STATIC bool is_following_odigit(mp_lexer_t *lex) {
function STATIC (line 106) | STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
function STATIC (line 114) | STATIC bool is_head_of_identifier(mp_lexer_t *lex) {
function STATIC (line 118) | STATIC bool is_tail_of_identifier(mp_lexer_t *lex) {
function STATIC (line 122) | STATIC void next_char(mp_lexer_t *lex) {
function STATIC (line 154) | STATIC void indent_push(mp_lexer_t *lex, size_t indent) {
function STATIC (line 162) | STATIC size_t indent_top(mp_lexer_t *lex) {
function STATIC (line 166) | STATIC void indent_pop(mp_lexer_t *lex) {
function STATIC (line 261) | STATIC bool get_hex(mp_lexer_t *lex, size_t num_digits, mp_uint_t *resul...
function STATIC (line 275) | STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw) {
function STATIC (line 425) | STATIC bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) {
function mp_lexer_to_next (line 453) | void mp_lexer_to_next(mp_lexer_t *lex) {
function mp_lexer_t (line 693) | mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) {
function mp_lexer_t (line 729) | mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, si...
function mp_lexer_t (line 737) | mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
function mp_lexer_t (line 745) | mp_lexer_t *mp_lexer_new_from_fd(qstr filename, int fd, bool close_fd) {
function mp_lexer_free (line 755) | void mp_lexer_free(mp_lexer_t *lex) {
function mp_lexer_show_token (line 767) | void mp_lexer_show_token(const mp_lexer_t *lex) {
FILE: py/lexer.h
type mp_token_kind_t (line 41) | typedef enum _mp_token_kind_t {
type mp_lexer_t (line 156) | typedef struct _mp_lexer_t {
type mp_import_stat_t (line 188) | typedef enum {
FILE: py/makecompresseddata.py
function check_non_ascii (line 14) | def check_non_ascii(msg):
function space_compression (line 28) | def space_compression(error_strings):
function word_compression (line 45) | def word_compression(error_strings):
function huffman_compression (line 83) | def huffman_compression(error_strings):
function ngram_compression (line 111) | def ngram_compression(error_strings):
function main (line 146) | def main(collected_path, fn):
FILE: py/makemoduledefs.py
function find_c_file (line 19) | def find_c_file(obj_file, vpath):
function find_module_registrations (line 38) | def find_module_registrations(c_file):
function generate_module_table_header (line 54) | def generate_module_table_header(modules):
function main (line 91) | def main():
FILE: py/makeqstrdata.py
function compute_hash (line 226) | def compute_hash(qstr, bytes_hash):
function qstr_escape (line 234) | def qstr_escape(qst):
function parse_input_headers (line 246) | def parse_input_headers(infiles):
function make_bytes (line 320) | def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
function print_qstr_data (line 342) | def print_qstr_data(qcfgs, qstrs):
function do_work (line 363) | def do_work(infiles):
FILE: py/makeqstrdefs.py
function preprocess (line 24) | def preprocess():
function write_out (line 49) | def write_out(fname, output):
function process_file (line 57) | def process_file(f):
function cat_together (line 92) | def cat_together():
class Args (line 138) | class Args:
FILE: py/makeversionhdr.py
function get_version_info_from_git (line 15) | def get_version_info_from_git():
function get_version_info_from_docs_conf (line 65) | def get_version_info_from_docs_conf():
function make_version_header (line 75) | def make_version_header(filename):
FILE: py/malloc.c
function STATIC (line 72) | STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
function m_free (line 196) | void m_free(void *ptr)
function m_get_total_bytes_allocated (line 211) | size_t m_get_total_bytes_allocated(void) {
function m_get_current_bytes_allocated (line 215) | size_t m_get_current_bytes_allocated(void) {
function m_get_peak_bytes_allocated (line 219) | size_t m_get_peak_bytes_allocated(void) {
FILE: py/map.c
function STATIC (line 54) | STATIC size_t get_hash_alloc_greater_or_equal_to(size_t x) {
function mp_map_init (line 68) | void mp_map_init(mp_map_t *map, size_t n) {
function mp_map_init_fixed_table (line 82) | void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *ta...
function mp_map_deinit (line 92) | void mp_map_deinit(mp_map_t *map) {
function mp_map_clear (line 99) | void mp_map_clear(mp_map_t *map) {
function STATIC (line 110) | STATIC void mp_map_rehash(mp_map_t *map) {
function mp_map_elem_t (line 135) | mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_looku...
function mp_set_init (line 293) | void mp_set_init(mp_set_t *set, size_t n) {
function STATIC (line 299) | STATIC void mp_set_rehash(mp_set_t *set) {
function mp_obj_t (line 313) | mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind...
function mp_obj_t (line 386) | mp_obj_t mp_set_remove_first(mp_set_t *set) {
function mp_set_clear (line 404) | void mp_set_clear(mp_set_t *set) {
function mp_map_dump (line 414) | void mp_map_dump(mp_map_t *map) {
FILE: py/misc.h
type byte (line 37) | typedef unsigned char byte;
type uint (line 38) | typedef unsigned int uint;
type unichar (line 120) | typedef uint32_t unichar;
type uint (line 124) | typedef uint unichar;
function unichar (line 132) | static inline unichar utf8_get_char(const byte *s) {
function byte (line 135) | static inline const byte *utf8_next_char(const byte *s) {
function utf8_charlen (line 138) | static inline size_t utf8_charlen(const byte *str, size_t len) {
type vstr_t (line 161) | typedef struct _vstr_t {
type _mp_print_t (line 174) | struct _mp_print_t
type _mp_print_t (line 175) | struct _mp_print_t
function vstr_reset (line 179) | static inline void vstr_reset(vstr_t *vstr) {
function vstr_len (line 185) | static inline size_t vstr_len(vstr_t *vstr) {
type mp_float_uint_t (line 231) | typedef uint64_t mp_float_uint_t;
type mp_float_uint_t (line 235) | typedef uint32_t mp_float_uint_t;
type mp_float_union_t (line 240) | typedef union _mp_float_union_t {
FILE: py/modbuiltins.c
type _mp_dummy_t (line 43) | struct _mp_dummy_t
function STATIC (line 49) | STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t...
function STATIC (line 91) | STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
function STATIC (line 96) | STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
function STATIC (line 109) | STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
function STATIC (line 122) | STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
function STATIC (line 128) | STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
function STATIC (line 137) | STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
function STATIC (line 176) | STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
function STATIC (line 209) | STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
function STATIC (line 214) | STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
function STATIC (line 220) | STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
function STATIC (line 240) | STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
function STATIC (line 259) | STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
function STATIC (line 266) | STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, ...
function STATIC (line 308) | STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_m...
function STATIC (line 313) | STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_m...
function STATIC (line 321) | STATIC mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) {
function STATIC (line 336) | STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
function STATIC (line 347) | STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
function STATIC (line 357) | STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
function STATIC (line 384) | STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
function STATIC (line 400) | STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *pos_args...
function STATIC (line 451) | STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
function STATIC (line 465) | STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
function STATIC (line 474) | STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
function STATIC (line 526) | STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
function STATIC (line 546) | STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, m...
function mp_obj_t (line 558) | static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp...
function STATIC (line 577) | STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args) {
function STATIC (line 586) | STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_...
function STATIC (line 593) | STATIC mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
function STATIC (line 599) | STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
function STATIC (line 607) | STATIC mp_obj_t mp_builtin_globals(void) {
function STATIC (line 612) | STATIC mp_obj_t mp_builtin_locals(void) {
FILE: py/modcmath.c
function STATIC (line 34) | STATIC mp_obj_t mp_cmath_phase(mp_obj_t z_obj) {
function STATIC (line 42) | STATIC mp_obj_t mp_cmath_polar(mp_obj_t z_obj) {
function STATIC (line 54) | STATIC mp_obj_t mp_cmath_rect(mp_obj_t r_obj, mp_obj_t phi_obj) {
function STATIC (line 62) | STATIC mp_obj_t mp_cmath_exp(mp_obj_t z_obj) {
function STATIC (line 72) | STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
function STATIC (line 81) | STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
function STATIC (line 90) | STATIC mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
function STATIC (line 100) | STATIC mp_obj_t mp_cmath_cos(mp_obj_t z_obj) {
function STATIC (line 108) | STATIC mp_obj_t mp_cmath_sin(mp_obj_t z_obj) {
FILE: py/modgc.c
function STATIC (line 34) | STATIC mp_obj_t py_gc_collect(void) {
function STATIC (line 45) | STATIC mp_obj_t gc_disable(void) {
function STATIC (line 52) | STATIC mp_obj_t gc_enable(void) {
function STATIC (line 58) | STATIC mp_obj_t gc_isenabled(void) {
function STATIC (line 64) | STATIC mp_obj_t gc_mem_free(void) {
function STATIC (line 72) | STATIC mp_obj_t gc_mem_alloc(void) {
function STATIC (line 80) | STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
FILE: py/modio.c
function STATIC (line 49) | STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args...
function STATIC (line 57) | STATIC mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t si...
function STATIC (line 75) | STATIC mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, in...
function STATIC (line 79) | STATIC mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t s...
function STATIC (line 83) | STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t...
type mp_obj_bufwriter_t (line 113) | typedef struct _mp_obj_bufwriter_t {
function STATIC (line 121) | STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_a...
function STATIC (line 132) | STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_u...
function STATIC (line 168) | STATIC mp_obj_t bufwriter_flush(mp_obj_t self_in) {
function STATIC (line 208) | STATIC mp_obj_t resource_stream(mp_obj_t package_in, mp_obj_t path_in) {
FILE: py/modmath.c
function math_error (line 40) | void math_error(void) {
function STATIC (line 44) | STATIC mp_obj_t math_generic_1(mp_obj_t x_obj, mp_float_t (*f)(mp_float_...
function STATIC (line 53) | STATIC mp_obj_t math_generic_2(mp_obj_t x_obj, mp_obj_t y_obj, mp_float_...
function mp_float_t (line 93) | mp_float_t MICROPY_FLOAT_C_FUN(log2)(mp_float_t x) {
function mp_float_t (line 102) | mp_float_t pow_func(mp_float_t x, mp_float_t y) {
function mp_float_t (line 150) | mp_float_t atan2_func(mp_float_t x, mp_float_t y) {
function mp_float_t (line 163) | mp_float_t MICROPY_FLOAT_C_FUN(copysign_func)(mp_float_t x, mp_float_t y) {
function mp_float_t (line 168) | mp_float_t MICROPY_FLOAT_C_FUN(fabs_func)(mp_float_t x) {
function mp_float_t (line 176) | mp_float_t fmod_func(mp_float_t x, mp_float_t y) {
function STATIC (line 206) | STATIC mp_obj_t mp_math_isclose(size_t n_args, const mp_obj_t *pos_args,...
function STATIC (line 244) | STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) {
function STATIC (line 267) | STATIC mp_obj_t mp_math_frexp(mp_obj_t x_obj) {
function STATIC (line 278) | STATIC mp_obj_t mp_math_modf(mp_obj_t x_obj) {
function STATIC (line 297) | STATIC mp_obj_t mp_math_radians(mp_obj_t x_obj) {
function STATIC (line 303) | STATIC mp_obj_t mp_math_degrees(mp_obj_t x_obj) {
function STATIC (line 313) | STATIC mp_obj_t mp_math_factorial_inner(mp_uint_t start, mp_uint_t end) {
function STATIC (line 331) | STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
function STATIC (line 345) | STATIC mp_obj_t mp_math_factorial(mp_obj_t x_obj) {
FILE: py/modmicropython.c
function STATIC (line 39) | STATIC mp_obj_t mp_micropython_opt_level(size_t n_args, const mp_obj_t *...
function STATIC (line 53) | STATIC mp_obj_t mp_micropython_mem_total(void) {
function STATIC (line 58) | STATIC mp_obj_t mp_micropython_mem_current(void) {
function STATIC (line 63) | STATIC mp_obj_t mp_micropython_mem_peak(void) {
function mp_obj_t (line 69) | mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
function STATIC (line 94) | STATIC mp_obj_t mp_micropython_qstr_info(size_t n_args, const mp_obj_t *...
function STATIC (line 111) | STATIC mp_obj_t mp_micropython_stack_use(void) {
function STATIC (line 118) | STATIC mp_obj_t mp_micropython_pystack_use(void) {
function STATIC (line 125) | STATIC mp_obj_t mp_micropython_heap_lock(void) {
function STATIC (line 131) | STATIC mp_obj_t mp_micropython_heap_unlock(void) {
function STATIC (line 138) | STATIC mp_obj_t mp_micropython_heap_locked(void) {
function STATIC (line 150) | STATIC mp_obj_t mp_micropython_kbd_intr(mp_obj_t int_chr_in) {
function STATIC (line 158) | STATIC mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
FILE: py/modstruct.c
function STATIC (line 55) | STATIC char get_fmt_type(const char **fmt) {
function STATIC (line 74) | STATIC mp_uint_t get_fmt_num(const char **p) {
function STATIC (line 85) | STATIC size_t calc_size_items(const char *fmt, size_t *total_sz) {
function STATIC (line 113) | STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
function STATIC (line 121) | STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
function STATIC (line 179) | STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n...
function STATIC (line 215) | STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
function STATIC (line 227) | STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
FILE: py/modsys.c
type _mp_dummy_t (line 47) | struct _mp_dummy_t
type _mp_dummy_t (line 48) | struct _mp_dummy_t
type _mp_dummy_t (line 49) | struct _mp_dummy_t
function STATIC (line 88) | STATIC MP_DEFINE_ATTRTUPLE(
function STATIC (line 123) | STATIC mp_obj_t mp_sys_print_exception(size_t n_args, const mp_obj_t *ar...
function STATIC (line 143) | STATIC mp_obj_t mp_sys_exc_info(void) {
function STATIC (line 163) | STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
function STATIC (line 171) | STATIC mp_obj_t mp_sys_atexit(mp_obj_t obj) {
function STATIC (line 181) | STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) {
FILE: py/modthread.c
type mp_obj_thread_lock_t (line 50) | typedef struct _mp_obj_thread_lock_t {
function STATIC (line 56) | STATIC mp_obj_thread_lock_t *mp_obj_new_thread_lock(void) {
function STATIC (line 64) | STATIC mp_obj_t thread_lock_acquire(size_t n_args, const mp_obj_t *args) {
function STATIC (line 85) | STATIC mp_obj_t thread_lock_release(mp_obj_t self_in) {
function STATIC (line 98) | STATIC mp_obj_t thread_lock_locked(mp_obj_t self_in) {
function STATIC (line 104) | STATIC mp_obj_t thread_lock___exit__(size_t n_args, const mp_obj_t *args) {
function STATIC (line 131) | STATIC mp_obj_t mod_thread_get_ident(void) {
function STATIC (line 136) | STATIC mp_obj_t mod_thread_stack_size(size_t n_args, const mp_obj_t *arg...
type thread_entry_args_t (line 147) | typedef struct _thread_entry_args_t {
function STATIC (line 157) | STATIC void *thread_entry(void *args_in) {
function STATIC (line 218) | STATIC mp_obj_t mod_thread_start_new_thread(size_t n_args, const mp_obj_...
function STATIC (line 273) | STATIC mp_obj_t mod_thread_exit(void) {
function STATIC (line 278) | STATIC mp_obj_t mod_thread_allocate_lock(void) {
FILE: py/moduerrno.c
function qstr (line 102) | qstr mp_errno_to_str(mp_obj_t errno_val) {
FILE: py/mpconfig.h
type mp_longint_impl_t (line 641) | typedef long long mp_longint_impl_t;
type mp_float_t (line 694) | typedef float mp_float_t;
type mp_float_t (line 699) | typedef double mp_float_t;
FILE: py/mpprint.c
function STATIC (line 46) | STATIC void plat_print_strn(void *env, const char *str, size_t len) {
function mp_print_str (line 53) | int mp_print_str(const mp_print_t *print, const char *str) {
function mp_print_strn (line 61) | int mp_print_strn(const mp_print_t *print, const char *str, size_t len, ...
function STATIC (line 130) | STATIC int mp_print_int(const mp_print_t *print, mp_uint_t x, int sgn, i...
function mp_print_mp_int (line 204) | int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int b...
function mp_print_float (line 343) | int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int ...
function mp_printf (line 379) | int mp_printf(const mp_print_t *print, const char *fmt, ...) {
function mp_vprintf (line 387) | int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
FILE: py/mpprint.h
type mp_print_t (line 50) | typedef struct _mp_print_t {
FILE: py/mpstate.h
type mp_dynamic_compiler_t (line 45) | typedef struct mp_dynamic_compiler_t {
type mp_sched_item_t (line 60) | typedef struct _mp_sched_item_t {
type mp_state_mem_t (line 66) | typedef struct _mp_state_mem_t {
type mp_state_vm_t (line 109) | typedef struct _mp_state_vm_t {
type mp_state_thread_t (line 242) | typedef struct _mp_state_thread_t {
type mp_state_ctx_t (line 276) | typedef struct _mp_state_ctx_t {
FILE: py/mpthread.h
type _mp_state_thread_t (line 33) | struct _mp_state_thread_t
type _mp_state_thread_t (line 41) | struct _mp_state_thread_t
type _mp_state_thread_t (line 42) | struct _mp_state_thread_t
FILE: py/mpz.c
function STATIC (line 52) | STATIC size_t mpn_remove_trailing_zeros(mpz_dig_t *oidig, mpz_dig_t *idi...
function STATIC (line 62) | STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *...
function STATIC (line 88) | STATIC size_t mpn_shl(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_...
function STATIC (line 127) | STATIC size_t mpn_shr(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_...
function STATIC (line 159) | STATIC size_t mpn_add(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jle...
function STATIC (line 189) | STATIC size_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jle...
function STATIC (line 217) | STATIC size_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_...
function STATIC (line 238) | STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t...
function STATIC (line 269) | STATIC size_t mpn_or(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen...
function STATIC (line 299) | STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t ...
function STATIC (line 329) | STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t ...
function STATIC (line 361) | STATIC size_t mpn_xor(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jle...
function STATIC (line 388) | STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t...
function STATIC (line 413) | STATIC size_t mpn_mul_dig_add_dig(mpz_dig_t *idig, size_t ilen, mpz_dig_...
function STATIC (line 435) | STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz...
function STATIC (line 466) | STATIC void mpn_div(mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t...
function mpz_init_zero (line 630) | void mpz_init_zero(mpz_t *z) {
function mpz_init_from_int (line 638) | void mpz_init_from_int(mpz_t *z, mp_int_t val) {
function mpz_init_fixed_from_int (line 643) | void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t alloc, mp_...
function mpz_deinit (line 652) | void mpz_deinit(mpz_t *z) {
function mpz_t (line 661) | mpz_t *mpz_zero(void) {
function mpz_t (line 667) | mpz_t *mpz_from_int(mp_int_t val) {
function mpz_t (line 673) | mpz_t *mpz_from_ll(long long val, bool is_signed) {
function mpz_t (line 680) | mpz_t *mpz_from_float(mp_float_t val) {
function mpz_t (line 687) | mpz_t *mpz_from_str(const char *str, size_t len, bool neg, unsigned int ...
function STATIC (line 694) | STATIC void mpz_free(mpz_t *z) {
function STATIC (line 701) | STATIC void mpz_need_dig(mpz_t *z, size_t need) {
function STATIC (line 715) | STATIC mpz_t *mpz_clone(const mpz_t *src) {
function mpz_set (line 730) | void mpz_set(mpz_t *dest, const mpz_t *src) {
function mpz_set_from_int (line 737) | void mpz_set_from_int(mpz_t *z, mp_int_t val) {
function mpz_set_from_ll (line 761) | void mpz_set_from_ll(mpz_t *z, long long val, bool is_signed) {
function mpz_set_from_float (line 781) | void mpz_set_from_float(mpz_t *z, mp_float_t src) {
function mpz_set_from_str (line 839) | size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg,...
function mpz_set_from_bytes (line 875) | void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byt...
function mpz_is_pos (line 911) | bool mpz_is_pos(const mpz_t *z) {
function mpz_is_odd (line 915) | bool mpz_is_odd(const mpz_t *z) {
function mpz_is_even (line 919) | bool mpz_is_even(const mpz_t *z) {
function mpz_cmp (line 924) | int mpz_cmp(const mpz_t *z1, const mpz_t *z2) {
function mp_int_t (line 943) | mp_int_t mpz_cmp_sml_int(const mpz_t *z, mp_int_t sml_int) {
function mpz_t (line 997) | mpz_t *mpz_abs(const mpz_t *z) {
function mpz_t (line 1006) | mpz_t *mpz_neg(const mpz_t *z) {
function mpz_t (line 1016) | mpz_t *mpz_add(const mpz_t *lhs, const mpz_t *rhs) {
function mpz_t (line 1025) | mpz_t *mpz_sub(const mpz_t *lhs, const mpz_t *rhs) {
function mpz_t (line 1034) | mpz_t *mpz_mul(const mpz_t *lhs, const mpz_t *rhs) {
function mpz_t (line 1043) | mpz_t *mpz_pow(const mpz_t *lhs, const mpz_t *rhs) {
function mpz_divmod (line 1054) | void mpz_divmod(const mpz_t *lhs, const mpz_t *rhs, mpz_t **quo, mpz_t *...
function mpz_abs_inpl (line 1064) | void mpz_abs_inpl(mpz_t *dest, const mpz_t *z) {
function mpz_neg_inpl (line 1074) | void mpz_neg_inpl(mpz_t *dest, const mpz_t *z) {
function mpz_not_inpl (line 1084) | void mpz_not_inpl(mpz_t *dest, const mpz_t *z) {
function mpz_shl_inpl (line 1108) | void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) {
function mpz_shr_inpl (line 1121) | void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs) {
function mpz_add_inpl (line 1159) | void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
function mpz_sub_inpl (line 1180) | void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
function mpz_and_inpl (line 1208) | void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
function mpz_or_inpl (line 1242) | void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
function mpz_xor_inpl (line 1276) | void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
function mpz_mul_inpl (line 1314) | void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
function mpz_pow_inpl (line 1346) | void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
function mpz_pow3_inpl (line 1380) | void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, cons...
function mpz_t (line 1424) | mpz_t *mpz_gcd(const mpz_t *z1, const mpz_t *z2) {
function mpz_t (line 1482) | mpz_t *mpz_lcm(const mpz_t *z1, const mpz_t *z2) {
function mpz_divmod_inpl (line 1505) | void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs,...
function mpz_t (line 1533) | mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs) {
function mpz_t (line 1545) | mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs) {
function mp_int_t (line 1556) | mp_int_t mpz_hash(const mpz_t *z) {
function mpz_as_int_checked (line 1571) | bool mpz_as_int_checked(const mpz_t *i, mp_int_t *value) {
function mpz_as_uint_checked (line 1591) | bool mpz_as_uint_checked(const mpz_t *i, mp_uint_t *value) {
function mpz_as_bytes (line 1613) | void mpz_as_bytes(const mpz_t *z, bool big_endian, size_t len, byte *buf) {
function mp_float_t (line 1647) | mp_float_t mpz_as_float(const mpz_t *i) {
function mpz_as_str_inpl (line 1675) | size_t mpz_as_str_inpl(const mpz_t *i, unsigned int base, const char *pr...
FILE: py/mpz.h
type mpz_dig_t (line 59) | typedef uint32_t mpz_dig_t;
type mpz_dbl_dig_t (line 60) | typedef uint64_t mpz_dbl_dig_t;
type mpz_dbl_dig_signed_t (line 61) | typedef int64_t mpz_dbl_dig_signed_t;
type mpz_dig_t (line 64) | typedef uint16_t mpz_dig_t;
type mpz_dbl_dig_t (line 65) | typedef uint32_t mpz_dbl_dig_t;
type mpz_dbl_dig_signed_t (line 66) | typedef int32_t mpz_dbl_dig_signed_t;
type mpz_dig_t (line 69) | typedef uint8_t mpz_dig_t;
type mpz_dbl_dig_t (line 70) | typedef uint16_t mpz_dbl_dig_t;
type mpz_dbl_dig_signed_t (line 71) | typedef int16_t mpz_dbl_dig_signed_t;
type mpz_dig_t (line 74) | typedef uint8_t mpz_dig_t;
type mpz_dbl_dig_t (line 75) | typedef uint8_t mpz_dbl_dig_t;
type mpz_dbl_dig_signed_t (line 76) | typedef int8_t mpz_dbl_dig_signed_t;
type mpz_t (line 93) | typedef struct _mpz_t {
function mpz_is_zero (line 118) | static inline bool mpz_is_zero(const mpz_t *z) {
function mpz_is_neg (line 121) | static inline bool mpz_is_neg(const mpz_t *z) {
function mpz_max_num_bits (line 141) | static inline size_t mpz_max_num_bits(const mpz_t *z) {
FILE: py/nativeglue.c
function mp_native_type_from_qstr (line 45) | int mp_native_type_from_qstr(qstr qst) {
function mp_uint_t (line 69) | mp_uint_t mp_native_from_obj(mp_obj_t obj, mp_uint_t type) {
function mp_obj_t (line 96) | mp_obj_t mp_native_to_obj(mp_uint_t val, mp_uint_t type) {
function mp_obj_t (line 118) | mp_obj_t mp_obj_new_set(size_t n_args, mp_obj_t *items) {
function mp_obj_set_store (line 124) | void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item) {
function mp_obj_t (line 132) | mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t oste...
function STATIC (line 140) | STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
function STATIC (line 156) | STATIC mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_a...
function STATIC (line 162) | STATIC void mp_native_raise(mp_obj_t o) {
function STATIC (line 169) | STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
function STATIC (line 184) | STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
function STATIC (line 194) | STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_o...
function STATIC (line 232) | STATIC mp_obj_t mp_obj_new_float_from_f(float f) {
function STATIC (line 237) | STATIC mp_obj_t mp_obj_new_float_from_d(double d) {
function STATIC (line 242) | STATIC float mp_obj_get_float_to_f(mp_obj_t o) {
function STATIC (line 247) | STATIC double mp_obj_get_float_to_d(mp_obj_t o) {
FILE: py/nativeglue.h
type mp_fun_kind_t (line 34) | typedef enum {
type mp_fun_table_t (line 88) | typedef struct _mp_fun_table_t {
FILE: py/nlr.c
function nlr_push_tail (line 40) | unsigned int nlr_push_tail(nlr_buf_t *nlr) {
function nlr_pop (line 48) | void nlr_pop(void) {
FILE: py/nlr.h
type nlr_buf_t (line 94) | typedef struct _nlr_buf_t nlr_buf_t;
type _nlr_buf_t (line 95) | struct _nlr_buf_t {
FILE: py/nlrpowerpc.c
function nlr_push (line 35) | unsigned int nlr_push(nlr_buf_t *nlr) {
function NORETURN (line 79) | NORETURN void nlr_jump(void *val) {
FILE: py/nlrsetjmp.c
function nlr_jump (line 31) | void nlr_jump(void *val) {
FILE: py/nlrthumb.c
function nlr_push (line 39) | __attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) {
function NORETURN (line 95) | NORETURN void nlr_jump(void *val) {
FILE: py/nlrx64.c
function NORETURN (line 85) | NORETURN void nlr_jump(void *val) {
FILE: py/nlrx86.c
function nlr_push (line 56) | __attribute__((naked))
function NORETURN (line 81) | NORETURN void nlr_jump(void *val) {
FILE: py/nlrxtensa.c
function nlr_push (line 39) | unsigned int nlr_push(nlr_buf_t *nlr) {
function NORETURN (line 58) | NORETURN void nlr_jump(void *val) {
FILE: py/obj.c
function mp_obj_type_t (line 40) | const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
function mp_obj_print_helper (line 102) | void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_prin...
function mp_obj_print (line 119) | void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind) {
function mp_obj_print_exception (line 124) | void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
function mp_obj_is_true (line 151) | bool mp_obj_is_true(mp_obj_t arg) {
function mp_obj_is_callable (line 184) | bool mp_obj_is_callable(mp_obj_t o_in) {
function mp_obj_t (line 205) | mp_obj_t mp_obj_equal_not_equal(mp_binary_op_t op, mp_obj_t o1, mp_obj_t...
function mp_obj_equal (line 286) | bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) {
function mp_int_t (line 290) | mp_int_t mp_obj_get_int(mp_const_obj_t arg) {
function mp_int_t (line 308) | mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg) {
function mp_obj_get_int_maybe (line 319) | bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value) {
function mp_obj_get_float_maybe (line 335) | bool mp_obj_get_float_maybe(mp_obj_t arg, mp_float_t *value) {
function mp_float_t (line 358) | mp_float_t mp_obj_get_float(mp_obj_t arg) {
function mp_obj_get_complex_maybe (line 374) | bool mp_obj_get_complex_maybe(mp_obj_t arg, mp_float_t *real, mp_float_t...
function mp_obj_get_complex (line 400) | void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
function mp_obj_get_array (line 414) | void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items) {
function mp_obj_get_array_fixed_n (line 430) | void mp_obj_get_array_fixed_n(mp_obj_t o, size_t len, mp_obj_t **items) {
function mp_get_index (line 444) | size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t inde...
function mp_obj_t (line 481) | mp_obj_t mp_obj_id(mp_obj_t o_in) {
function mp_obj_t (line 500) | mp_obj_t mp_obj_len(mp_obj_t o_in) {
function mp_obj_t (line 534) | mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
function mp_obj_t (line 569) | mp_obj_t mp_identity(mp_obj_t self) {
function mp_obj_t (line 574) | mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf) {
function mp_get_buffer (line 579) | bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t fl...
function mp_get_buffer_raise (line 591) | void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uin...
function mp_obj_t (line 597) | mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
FILE: py/obj.h
type mp_obj_t (line 41) | typedef uint64_t mp_obj_t;
type mp_const_obj_t (line 42) | typedef uint64_t mp_const_obj_t;
type mp_obj_type_t (line 50) | typedef struct _mp_obj_type_t mp_obj_type_t;
type _mp_obj_base_t (line 54) | struct _mp_obj_base_t {
type mp_obj_base_t (line 57) | typedef struct _mp_obj_base_t mp_obj_base_t;
function mp_obj_is_small_int (line 86) | static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
function mp_obj_is_qstr (line 92) | static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
function mp_obj_is_immediate_obj (line 98) | static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
type _mp_obj_float_t (line 107) | struct _mp_obj_float_t
type _mp_obj_float_t (line 108) | struct _mp_obj_float_t
function mp_obj_is_obj (line 115) | static inline bool mp_obj_is_obj(mp_const_obj_t o) {
function mp_obj_is_small_int (line 121) | static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
function mp_obj_is_qstr (line 127) | static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
function mp_obj_is_immediate_obj (line 133) | static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
type _mp_obj_float_t (line 142) | struct _mp_obj_float_t
type _mp_obj_float_t (line 143) | struct _mp_obj_float_t
function mp_obj_is_obj (line 150) | static inline bool mp_obj_is_obj(mp_const_obj_t o) {
function mp_obj_is_small_int (line 156) | static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
function mp_obj_is_float (line 166) | static inline bool mp_obj_is_float(mp_const_obj_t o) {
function mp_float_t (line 169) | static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
function mp_obj_t (line 176) | static inline mp_obj_t mp_obj_new_float(mp_float_t f) {
function mp_obj_is_qstr (line 185) | static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
function mp_obj_is_immediate_obj (line 191) | static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
function mp_obj_is_obj (line 197) | static inline bool mp_obj_is_obj(mp_const_obj_t o) {
function mp_obj_is_small_int (line 203) | static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
function mp_obj_is_qstr (line 209) | static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
function mp_obj_is_immediate_obj (line 215) | static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
function mp_obj_is_float (line 230) | static inline bool mp_obj_is_float(mp_const_obj_t o) {
function mp_float_t (line 233) | static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
function mp_obj_t (line 240) | static inline mp_obj_t mp_obj_new_float(mp_float_t f) {
function mp_obj_is_obj (line 249) | static inline bool mp_obj_is_obj(mp_const_obj_t o) {
type mp_rom_obj_t (line 256) | typedef union _mp_rom_obj_t { uint64_t u64;
type mp_const_obj_t (line 306) | typedef mp_const_obj_t mp_rom_obj_t;
type mp_map_elem_t (line 398) | typedef struct _mp_map_elem_t {
type mp_rom_map_elem_t (line 403) | typedef struct _mp_rom_map_elem_t {
type mp_map_t (line 408) | typedef struct _mp_map_t {
type mp_map_lookup_kind_t (line 418) | typedef enum _mp_map_lookup_kind_t {
function mp_map_slot_is_filled (line 425) | static inline bool mp_map_slot_is_filled(const mp_map_t *map, size_t pos) {
type mp_set_t (line 441) | typedef struct _mp_set_t {
function mp_set_slot_is_filled (line 447) | static inline bool mp_set_slot_is_filled(const mp_set_t *set, size_t pos) {
type mp_obj_t (line 458) | typedef mp_obj_t (*mp_fun_0_t)(void);
type mp_obj_t (line 459) | typedef mp_obj_t (*mp_fun_1_t)(mp_obj_t);
type mp_obj_t (line 460) | typedef mp_obj_t (*mp_fun_2_t)(mp_obj_t, mp_obj_t);
type mp_obj_t (line 461) | typedef mp_obj_t (*mp_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t);
type mp_obj_t (line 462) | typedef mp_obj_t (*mp_fun_var_t)(size_t n, const mp_obj_t *);
type mp_obj_t (line 465) | typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *);
type mp_print_kind_t (line 484) | typedef enum {
type mp_obj_iter_buf_t (line 493) | typedef struct _mp_obj_iter_buf_t {
type mp_obj_t (line 503) | typedef mp_obj_t (*mp_make_new_fun_t)(const mp_obj_type_t *type, size_t ...
type mp_obj_t (line 504) | typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_...
type mp_obj_t (line 505) | typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t);
type mp_obj_t (line 506) | typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_o...
type mp_obj_t (line 508) | typedef mp_obj_t (*mp_subscr_fun_t)(mp_obj_t self_in, mp_obj_t index, mp...
type mp_obj_t (line 509) | typedef mp_obj_t (*mp_getiter_fun_t)(mp_obj_t self_in, mp_obj_iter_buf_t...
type mp_buffer_info_t (line 512) | typedef struct _mp_buffer_info_t {
type mp_buffer_p_t (line 520) | typedef struct _mp_buffer_p_t {
type _mp_obj_type_t (line 526) | struct _mp_obj_type_t {
type _mp_obj_none_t (line 681) | struct _mp_obj_none_t
type _mp_obj_bool_t (line 682) | struct _mp_obj_bool_t
type _mp_obj_bool_t (line 683) | struct _mp_obj_bool_t
type _mp_obj_str_t (li
Condensed preview — 405 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,612K chars).
[
{
"path": ".gitignore",
"chars": 23,
"preview": "/.vscode/settings.json\n"
},
{
"path": "LICENSE",
"chars": 1089,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2013, 2014 Damien P. George\n\nPermission is hereby granted, free of charge, to any p"
},
{
"path": "README.md",
"chars": 3621,
"preview": "# MicroPython\n\n[中文页](README_ZH.md) | English\n\n## 1. Introduction\n\nThis is a port of `MicroPython` on RT-Thread, which ca"
},
{
"path": "README_ZH.md",
"chars": 2195,
"preview": "# MicroPython\n\n中文页 | [English](README.md)\n\n## 1、介绍\n\n这是一个在 RT-Thread 上的 `MicroPython` 移植,可以运行在 **RT-Thread 3.0** 版本以上。通过该"
},
{
"path": "SConscript",
"chars": 1001,
"preview": "from building import *\nimport rtconfig\n\n# get current directory\ncwd = GetCurrentDir()\n# The set of source files asso"
},
{
"path": "docs/external_c_modules.md",
"chars": 1813,
"preview": "# 为 MicroPython 扩展 C 模块\n\n当使用原生 MicroPython 进行开发时,你可能会遇到这样一些限制,比如官方没有实现自己想要的功能,或者你觉得这些实现不符合自己的工作需求。此时,添加自己的 C 模块到 MicroPy"
},
{
"path": "docs/firmware-develop.md",
"chars": 3154,
"preview": "## MicroPython 固件开发指南\n\n如果手上没有官方支持固件的开发板,就需要自己来动手制作 MicroPython 固件了。由于 RT-Thread 官方提供了 [MicroPython 软件包](https://github.c"
},
{
"path": "docs/introduction.md",
"chars": 2181,
"preview": "# MicroPython 入门必读\n\n本文档将初步介绍 MicroPython 的基本概念,RT-Thread MicroPython 的特性与优势,以及可以被用在哪些领域。\n\n## 主要特性\n\n- MicroPython 是 Pytho"
},
{
"path": "docs/micropython-ide.md",
"chars": 680,
"preview": "# MicroPython IDE\n\nRT-Thread 为广大开发者提供了 VSCode 最好用的 MicroPython 插件 来帮助大家使用 MicroPython 来开发应用程序。该插件为 MicroPython 开发提供了功能强大"
},
{
"path": "docs/micropython-librarys.md",
"chars": 1876,
"preview": "# MicroPython 库\n\n### MicroPython 标准库\n\n- [`Builtin functions and exceptions`](std-librarys/builtins.md) – 内置函数与异常\n- [`cma"
},
{
"path": "docs/micropython-mpy.md",
"chars": 448,
"preview": "# MicroPython .mpy 文件详解\n\nMicroPython 定义了 `.mpy` 文件的概念,该文件是一种二进制容器文件格式,在其中包含了预编译的 Python 代码,这种类型的文件可以像普通的 `.py` 模块一样被导入到 "
},
{
"path": "docs/micropython_for_pandora_iot_board.md",
"chars": 3446,
"preview": "# MicroPython for Pandora IoT Board\n\n\n\n[**IoT Board 潘多拉**](https://item.taobao.com/ite"
},
{
"path": "docs/micropython_for_sparrow_one_board.md",
"chars": 2184,
"preview": "# MicroPython for sparrow one board\n\n\n\n[**麻雀一号开发板**](https://item.taobao.com"
},
{
"path": "docs/micropython_for_w601_iot_board.md",
"chars": 3320,
"preview": "# MicroPython for W601 IoT Board\n\n\n\n[**W601 IoT Board**](https://item.taobao.com/"
},
{
"path": "docs/spec-librarys/machine/ADC.md",
"chars": 1207,
"preview": "## machine.ADC\n\n**machine.ADC** 类是 machine 模块下的一个硬件类,用于指定 ADC 设备的配置和控制,提供对 ADC 设备的操作方法。\n\n- ADC(Analog-to-Digital Convert"
},
{
"path": "docs/spec-librarys/machine/I2C.md",
"chars": 3941,
"preview": "## machine.I2C\n\n**machine.I2C** 类是 `machine` 模块下面的一个硬件类,用于对 `I2C` 的配置和控制,提供对 `I2C` 设备的操作方法。\n\n- `I2C` 是一种用于设备间通信的两线协议。在物理"
},
{
"path": "docs/spec-librarys/machine/LCD.md",
"chars": 2097,
"preview": "## machine.LCD\n\n**machine.LCD** 类是 machine 模块下面的一个硬件类,用于对 LCD 的配置和控制,提供对 LCD 设备的操作方法。\n\nIoT board 板载一块 1.3 寸,分辨率为 `240*24"
},
{
"path": "docs/spec-librarys/machine/PWM.md",
"chars": 1656,
"preview": "## machine.PWM\n\n**machine.PWM** 类是 machine 模块下的一个硬件类,用于指定 PWM 设备的配置和控制,提供对 PWM 设备的操作方法。\n\n- PWM (Pulse Width Modulation,脉"
},
{
"path": "docs/spec-librarys/machine/Pin.md",
"chars": 2674,
"preview": "## machine.Pin\n\n**machine.Pin** 类是 machine 模块下面的一个硬件类,用于对引脚的配置和控制,提供对 `Pin` 设备的操作方法。\n\n`Pin` 对象用于控制输入/输出引脚(也称为 `GPIO`)。`P"
},
{
"path": "docs/spec-librarys/machine/RTC.md",
"chars": 1189,
"preview": "## machine.RTC\n\n**machine.RTC** 类是 machine 模块下面的一个硬件类,用于对指定 RTC 设备的配置和控制,提供对 RTC 设备的操作方法。\n\n- RTC(Real-Time Clock )实时时钟可以"
},
{
"path": "docs/spec-librarys/machine/SPI.md",
"chars": 2608,
"preview": "## machine.SPI\n\n**machine.SPI** 类是 machine 模块下面的一个硬件类,用于对 SPI 的配置和控制,提供对 SPI 设备的操作方法。\n\n- `SPI` 是一个由主机驱动的同步串行协议。在物理层,总线有三"
},
{
"path": "docs/spec-librarys/machine/Timer.md",
"chars": 2217,
"preview": "## machine.Timer\n\n**machine.Timer** 类是 machine 模块下的一个硬件类,用于 Timer 设备的配置和控制,提供对 Timer 设备的操作方法。\n\n- Timer(硬件定时器),是一种用于处理周期性"
},
{
"path": "docs/spec-librarys/machine/UART.md",
"chars": 1639,
"preview": "## machine.UART\n\n**machine.UART** 类是 machine 模块下面的一个硬件类,用于对 UART 的配置和控制,提供对 UART 设备的操作方法。\n\n`UART` 实现了标准的 `uart/usart` 双工"
},
{
"path": "docs/spec-librarys/machine/WDT.md",
"chars": 1105,
"preview": "## machine.WDT\n\n**machine.WDT** 类是 machine 模块下的一个硬件类,用于 WDT 设备的配置和控制,提供对 WDT 设备的操作方法。\n\n如下为 WDT 设备基本介绍:\n\n- WDT(WatchDog T"
},
{
"path": "docs/spec-librarys/machine.md",
"chars": 1141,
"preview": "## **machine** – 与硬件相关的功能\n\n**machine** 模块包含与特定开发板上的硬件相关的特定函数。 在这个模块中的大多数功能允许实现直接和不受限制地访问和控制系统上的硬件块(如CPU,定时器,总线等)。如果使用不当,"
},
{
"path": "docs/spec-librarys/micropython.md",
"chars": 5852,
"preview": "\n# micropython – 内部功能访问与控制模块\n\n## Functions\n\n### micropython.const(expr)\nUsed to declare that the expression is a constan"
},
{
"path": "docs/spec-librarys/network/wlan.md",
"chars": 2592,
"preview": "## class WLAN – 控制内置的 WiFi 网络接口\n\n该类为 WiFi 网络处理器提供一个驱动程序。使用示例:\n\n```python\nimport network\n# enable station interface and c"
},
{
"path": "docs/spec-librarys/network.md",
"chars": 221,
"preview": "## network – 网络配置\n\n此模块提供网络驱动程序和路由配置。特定硬件的网络驱动程序在此模块中可用,用于配置硬件网络接口。然后,配置接口提供的网络服务可以通过 `usocket` 模块使用。\n\n### 专用的网络类配置\n\n下面具体"
},
{
"path": "docs/spec-librarys/rtthread.md",
"chars": 379,
"preview": "## **rtthread** – 系统相关函数\n\n**rtthread** 模块提供了与 RT-Thread 操作系统相关的功能,如查看栈使用情况等。\n\n### 函数\n\n#### rtthread.current_tid() \n返回当前"
},
{
"path": "docs/std-librarys/_thread.md",
"chars": 507,
"preview": "## _thread – 多线程支持\n\n`_thread` 模块提供了用于处理多线程的基本方法——多个控制线程共享它们的全局数据空间。为了实现同步,提供了简单的锁(也称为互斥锁或二进制信号量)。\n\n### 示例\n\n```python\nimp"
},
{
"path": "docs/std-librarys/builtins.md",
"chars": 1934,
"preview": "# Builtin functions and exceptions\n\n所有的内饰函数和异常类型都在下面描述。\n\n## 函数和类型\n\n- abs()\n- all()\n- any()\n- bin()\n- **class** bool\n- **"
},
{
"path": "docs/std-librarys/cmath.md",
"chars": 678,
"preview": "## **cmath** – 复数运算函数功能\n\n`cmath` 模块提供了一些用于复数运算的函数。这个模块中的函数接受整数、浮点数或复数作为参数。他们还将接受任何有复数或浮点方法的 Python 对象:这些方法分别用于将对象转换成复数或浮"
},
{
"path": "docs/std-librarys/gc.md",
"chars": 343,
"preview": "## **gc** – 控制垃圾回收\n\n**gc** 模块提供了垃圾收集器的控制接口。\n\n### 函数\n\n#### **gc.enable**() \n允许自动回收内存碎片。 \n\n#### **gc.disable**() \n禁止自动回收"
},
{
"path": "docs/std-librarys/math.md",
"chars": 3635,
"preview": "## **math** – 数学函数\n\n**math** 模块提供了对 C 标准定义的数学函数的访问。\n\n> 注意:本模块需要带有硬件 FPU,精度是32位,这个模块需要浮点功能支持。\n\n### 常数\n\n#### **math.e** \n"
},
{
"path": "docs/std-librarys/rtthread.md",
"chars": 1000,
"preview": "## **rtthread** – 系统相关函数\n\n**rtthread** 模块提供了与 RT-Thread 操作系统相关的功能,如查看栈使用情况等。\n\n### 函数\n\n#### rtthread.current_tid() \n返回当前"
},
{
"path": "docs/std-librarys/sys.md",
"chars": 1223,
"preview": "## **sys** – 系统特有功能函数\n\n**sys** 模块提供系统特有的功能。\n\n### 函数\n\n#### **sys.exit**(retval=0) \n 终止当前程序给定的退出代码。 函数会抛出 `SystemExit` 异"
},
{
"path": "docs/std-librarys/uarray.md",
"chars": 956,
"preview": "## **array** – 数字数据数组\n\n**array** 模块定义了一个对象类型,它可以简洁地表示基本值的数组:字符、整数、浮点数。支持代码格式: b, B, h, H, i, I, l, L, q, Q, f, d (最后2个需"
},
{
"path": "docs/std-librarys/ubinascii.md",
"chars": 914,
"preview": "## **ubinascii** – 二进制/ ASCII转换\n\n`ubinascii` 模块包含许多在二进制和各种 ascii 编码的二进制表示之间转换的方法。\n\n### 函数\n\n#### **ubinascii.hexlify**(da"
},
{
"path": "docs/std-librarys/ucollections.md",
"chars": 1041,
"preview": "## **ucollections** – 集合与容器类型\n\n**ucollections** 模块实现了专门的容器数据类型,它提供了 Python 的通用内置容器的替代方案,包括了字典、列表、集合和元组。\n\n### 类\n\n#### **u"
},
{
"path": "docs/std-librarys/uctypes.md",
"chars": 1700,
"preview": "## **uctypes** – 以结构化的方式访问二进制数据\n\nuctypes 模块用来访问二进制数据结构,它提供 C 兼容的数据类型。\n\n### 常量\n- uctypes.LITTLE_ENDIAN — 小端压缩结构。\n- uctype"
},
{
"path": "docs/std-librarys/uerrno.md",
"chars": 465,
"preview": "## **uerrno** – 系统错误码模块\n\n`uerrno` 模块提供了标准的 errno 系统符号,每个符号都有对应的整数值。\n\n### 示例\n\n```python\ntry:\n uos.mkdir(\"my_dir\")\nexce"
},
{
"path": "docs/std-librarys/uhashlib.md",
"chars": 799,
"preview": "## **uhashlib** – 哈希算法\n\n`uhashlib` 模块实现了二进制数据哈希算法。\n\n### 算法功能\n\n#### **SHA256** \n当代的散列算法(SHA2系列),它适用于密码安全的目的。被包含在 MicroPyt"
},
{
"path": "docs/std-librarys/uheapq.md",
"chars": 330,
"preview": "## **uheapq** – 堆排序算法\n\n`uheapq` 模块提供了堆排序相关算法,堆队列是一个列表,它的元素以特定的方式存储。\n\n### 函数\n\n#### **uheapq.heappush**(heap, item) \n将对象压"
},
{
"path": "docs/std-librarys/uio.md",
"chars": 764,
"preview": "## **uio** – 输入/输出流\n\n**uio** 模块包含流类型 (类似文件) 对象和帮助函数。\n\n### 函数\n\n#### **uio.open**(name, mode='r', \\*\\*kwargs)\n\n打开一个文件,关联到内"
},
{
"path": "docs/std-librarys/ujson.md",
"chars": 858,
"preview": "## **ujson** – JSON编码与解码\n\n`ujson` 模块提供 Python 对象到 JSON(JavaScript Object Notation) 数据格式的转换。\n\n### 函数\n\n#### **ujson.dumps*"
},
{
"path": "docs/std-librarys/uos.md",
"chars": 963,
"preview": "## **uos** – 基本的操作系统服务\n\n`uos` 模块包含了对文件系统的访问操作,是对应 CPython 模块的一个子集。\n\n### 函数\n\n#### **uos.chdir**(path) \n更改当前目录。\n\n#### **u"
},
{
"path": "docs/std-librarys/urandom.md",
"chars": 2255,
"preview": "## **urandom** - 随机数生成模块\n\n`urandom` 模块实现了伪随机数生成器。\n\n### 函数 \n\n#### **urandom.choice**(obj) \n\n随机生成对象 obj 中的元数。\n\n```\nobj:元数"
},
{
"path": "docs/std-librarys/ure.md",
"chars": 830,
"preview": "## **ure** – 正则表达式\n\n`ure` 模块用于测试字符串的某个模式,执行正则表达式操作。\n\n### 匹配字符集\n\n\n#### 匹配任意字符\n ``'.'``\n\n#### 匹配字符集合,支持单个字符和一个范围\n ``'[]'"
},
{
"path": "docs/std-librarys/uselect.md",
"chars": 1779,
"preview": "## **uselect** – 等待流事件\n\n`uselect` 模块提供了等待数据流的事件功能。\n\n### 常数\n\n#### **select.POLLIN** - 读取可用数据 \n\n#### **select.POLLOUT** -"
},
{
"path": "docs/std-librarys/usocket.md",
"chars": 3752,
"preview": "## **usocket** – 套接字模块\n\n`usocket` 模块提供对BSD套接字接口的访问。 \n\n### 常数\n\n#### 地址簇\n- socket.AF_INET =2 — TCP/IP – IPv4\n- socket.AF_I"
},
{
"path": "docs/std-librarys/ussl.md",
"chars": 1985,
"preview": "# ussl – SSL/TLS 模块\n\nThis module implements a subset of the corresponding* [`CPython`](http://docs.micropython.org/en/la"
},
{
"path": "docs/std-librarys/ustruct.md",
"chars": 1427,
"preview": "## **ustruct** – 打包和解包原始数据类型\n\n**ustruct** 模块在 Python 值和以 Python 字节对象表示的 C 结构之间执行转换。\n\n- 支持 size/byte 的前缀: @, <, >, !.\n- 支"
},
{
"path": "docs/std-librarys/utime.md",
"chars": 3626,
"preview": "## **utime** – 时间相关函数\n\n**utime** 模块提供获取当前时间和日期、测量时间间隔和延迟的功能。\n\n**初始时刻**: `Unix` 使用 `POSIX` 系统标准,从 1970-01-01 00:00:00 `UT"
},
{
"path": "docs/std-librarys/uzlib.md",
"chars": 236,
"preview": "## **uzlib** – zlib 解压缩\n\n`uzlib` 模块实现了使用 DEFLATE 算法解压缩二进制数据 (常用的 zlib 库和 gzip 文档)。目前不支持压缩。\n\n### 函数\n\n#### **uzlib.decompr"
},
{
"path": "docs/tools-mpy-cross.md",
"chars": 1387,
"preview": "# 生成并运行 .mpy 文件\n\nPython 工程中,.py 文件可以被编译成 .pyc 字节码文件。使用这类预先编译好的二进制文件的优势是一定程度上能够保护源代码,同时可以提高程序的加载速度。在 micropython 中同样地提供了类"
},
{
"path": "drivers/bus/qspi.h",
"chars": 2223,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "drivers/bus/softqspi.c",
"chars": 7296,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "drivers/bus/softspi.c",
"chars": 3929,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "drivers/bus/spi.h",
"chars": 2050,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/axtls-include/config.h",
"chars": 3217,
"preview": "/*\n * Automatically generated header file: don't edit\n */\n\n#define HAVE_DOT_CONFIG 1\n#define CONFIG_PLATFORM_LINUX 1\n#un"
},
{
"path": "extmod/axtls-include/version.h",
"chars": 40,
"preview": "#define AXTLS_VERSION \"(no version)\"\n"
},
{
"path": "extmod/crypto-algorithms/sha256.c",
"chars": 5378,
"preview": "/*********************************************************************\n* Source: https://github.com/B-Con/crypto-alg"
},
{
"path": "extmod/crypto-algorithms/sha256.h",
"chars": 1343,
"preview": "/*********************************************************************\n* Source: https://github.com/B-Con/crypto-alg"
},
{
"path": "extmod/lwip-include/arch/cc.h",
"chars": 907,
"preview": "#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H\n#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_CC_H\n\n#include "
},
{
"path": "extmod/lwip-include/arch/perf.h",
"chars": 263,
"preview": "#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H\n#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_ARCH_PERF_H\n\n#defi"
},
{
"path": "extmod/lwip-include/lwipopts.h",
"chars": 995,
"preview": "#ifndef MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H\n#define MICROPY_INCLUDED_EXTMOD_LWIP_INCLUDE_LWIPOPTS_H\n\n#includ"
},
{
"path": "extmod/machine_i2c.c",
"chars": 25081,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_i2c.h",
"chars": 2836,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_mem.c",
"chars": 4204,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_mem.h",
"chars": 1960,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_pinbase.c",
"chars": 2931,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_pinbase.h",
"chars": 1448,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_pulse.c",
"chars": 2461,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_pulse.h",
"chars": 1576,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_signal.c",
"chars": 6231,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_signal.h",
"chars": 1444,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_spi.c",
"chars": 12068,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/machine_spi.h",
"chars": 2405,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/misc.h",
"chars": 1911,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modbtree.c",
"chars": 13039,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modframebuf.c",
"chars": 21707,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modonewire.c",
"chars": 5789,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modubinascii.c",
"chars": 8350,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modubinascii.h",
"chars": 1981,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/moducryptolib.c",
"chars": 12401,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/moductypes.c",
"chars": 30020,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/moduhashlib.c",
"chars": 12491,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/moduheapq.c",
"chars": 4567,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modujson.c",
"chars": 11035,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modurandom.c",
"chars": 8096,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modure.c",
"chars": 16185,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/moduselect.c",
"chars": 13790,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modussl_axtls.c",
"chars": 11348,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modussl_mbedtls.c",
"chars": 14826,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modutimeq.c",
"chars": 7884,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/moduwebsocket.c",
"chars": 11143,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/moduwebsocket.h",
"chars": 273,
"preview": "#ifndef MICROPY_INCLUDED_EXTMOD_MODUWEBSOCKET_H\n#define MICROPY_INCLUDED_EXTMOD_MODUWEBSOCKET_H\n\n#define FRAME_OPCODE_MA"
},
{
"path": "extmod/moduzlib.c",
"chars": 7396,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modwebrepl.c",
"chars": 12542,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modwebsocket.c",
"chars": 11128,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/modwebsocket.h",
"chars": 270,
"preview": "#ifndef MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H\n#define MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H\n\n#define FRAME_OPCODE_MASK"
},
{
"path": "extmod/re1.5/charclass.c",
"chars": 868,
"preview": "#include \"re1.5.h\"\n\nint _re1_5_classmatch(const char *pc, const char *sp)\n{\n // pc points to \"cnt\" byte after opcode\n"
},
{
"path": "extmod/re1.5/compilecode.c",
"chars": 5906,
"preview": "// Copyright 2014 Paul Sokolovsky.\n// Use of this source code is governed by a BSD-style\n// license that can be found in"
},
{
"path": "extmod/re1.5/dumpcode.c",
"chars": 2413,
"preview": "// Copyright 2014 Paul Sokolovsky.\n// Use of this source code is governed by a BSD-style\n// license that can be found in"
},
{
"path": "extmod/re1.5/re1.5.h",
"chars": 2783,
"preview": "// Copyright 2007-2009 Russ Cox. All Rights Reserved.\n// Copyright 2014 Paul Sokolovsky.\n// Use of this source code is "
},
{
"path": "extmod/re1.5/recursiveloop.c",
"chars": 1804,
"preview": "// Copyright 2007-2009 Russ Cox. All Rights Reserved.\n// Use of this source code is governed by a BSD-style\n// license "
},
{
"path": "extmod/uos_dupterm.c",
"chars": 6835,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/utime_mphal.c",
"chars": 3928,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/utime_mphal.h",
"chars": 1840,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/uzlib/adler32.c",
"chars": 2243,
"preview": "/*\n * Adler-32 checksum\n *\n * Copyright (c) 2003 by Joergen Ibsen / Jibz\n * All Rights Reserved\n *\n * http://www.ibsenso"
},
{
"path": "extmod/uzlib/crc32.c",
"chars": 1952,
"preview": "/*\n * CRC32 checksum\n *\n * Copyright (c) 1998-2003 by Joergen Ibsen / Jibz\n * All Rights Reserved\n *\n * http://www.ibsen"
},
{
"path": "extmod/uzlib/defl_static.h",
"chars": 1509,
"preview": "/*\n * Copyright (c) uzlib authors\n *\n * This software is provided 'as-is', without any express\n * or implied warranty. "
},
{
"path": "extmod/uzlib/tinf.h",
"chars": 163,
"preview": "/* Compatibility header for the original tinf lib/older versions of uzlib.\n Note: may be removed in the future, please"
},
{
"path": "extmod/uzlib/tinf_compat.h",
"chars": 359,
"preview": "/* This header contains compatibility defines for the original tinf API\n and uzlib 2.x and below API. These defines ar"
},
{
"path": "extmod/uzlib/tinfgzip.c",
"chars": 2833,
"preview": "/*\n * uzlib - tiny deflate/inflate library (deflate, gzip, zlib)\n *\n * Copyright (c) 2003 by Joergen Ibsen / Jibz\n * A"
},
{
"path": "extmod/uzlib/tinflate.c",
"chars": 17423,
"preview": "/*\n * uzlib - tiny deflate/inflate library (deflate, gzip, zlib)\n *\n * Copyright (c) 2003 by Joergen Ibsen / Jibz\n * A"
},
{
"path": "extmod/uzlib/tinfzlib.c",
"chars": 1800,
"preview": "/*\n * uzlib - tiny deflate/inflate library (deflate, gzip, zlib)\n *\n * Copyright (c) 2003 by Joergen Ibsen / Jibz\n * A"
},
{
"path": "extmod/uzlib/uzlib.h",
"chars": 4733,
"preview": "/*\n * uzlib - tiny deflate/inflate library (deflate, gzip, zlib)\n *\n * Copyright (c) 2003 by Joergen Ibsen / Jibz\n * A"
},
{
"path": "extmod/uzlib/uzlib_conf.h",
"chars": 562,
"preview": "/*\n * uzlib - tiny deflate/inflate library (deflate, gzip, zlib)\n *\n * Copyright (c) 2014-2018 by Paul Sokolovsky\n */\n"
},
{
"path": "extmod/vfs.c",
"chars": 18911,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs.h",
"chars": 5226,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs_fat.c",
"chars": 15390,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs_fat.h",
"chars": 1800,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs_fat_diskio.c",
"chars": 5652,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * Original template for this file comes "
},
{
"path": "extmod/vfs_fat_file.c",
"chars": 10090,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs_posix.c",
"chars": 13034,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs_posix.h",
"chars": 1653,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs_posix_file.c",
"chars": 9095,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/vfs_reader.c",
"chars": 3035,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/virtpin.c",
"chars": 1684,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/virtpin.h",
"chars": 1893,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "extmod/webrepl/manifest.py",
"chars": 72,
"preview": "freeze('.', ('webrepl.py', 'webrepl_setup.py', 'websocket_helper.py',))\n"
},
{
"path": "extmod/webrepl/webrepl.py",
"chars": 2184,
"preview": "# This module should be imported from REPL, not run from command line.\nimport socket\nimport uos\nimport network\nimport uw"
},
{
"path": "extmod/webrepl/webrepl_setup.py",
"chars": 2748,
"preview": "import sys\n#import uos as os\nimport os\nimport machine\n\nRC = \"./boot.py\"\nCONFIG = \"./webrepl_cfg.py\"\n\ndef input_choice(pr"
},
{
"path": "extmod/webrepl/websocket_helper.py",
"chars": 1624,
"preview": "import sys\ntry:\n import ubinascii as binascii\nexcept:\n import binascii\ntry:\n import uhashlib as hashlib\nexcept:"
},
{
"path": "lib/mp-readline/readline.c",
"chars": 15704,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/mp-readline/readline.h",
"chars": 1894,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/netutils/netutils.c",
"chars": 3609,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/netutils/netutils.h",
"chars": 2506,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/oofatfs/diskio.h",
"chars": 2926,
"preview": "/* This file is part of ooFatFs, a customised version of FatFs\n * See https://github.com/micropython/oofatfs for details"
},
{
"path": "lib/oofatfs/ff.c",
"chars": 226045,
"preview": "/* This file is part of ooFatFs, a customised version of FatFs\n * See https://github.com/micropython/oofatfs for details"
},
{
"path": "lib/oofatfs/ff.h",
"chars": 15070,
"preview": "/* This file is part of ooFatFs, a customised version of FatFs\n * See https://github.com/micropython/oofatfs for details"
},
{
"path": "lib/oofatfs/ffconf.h",
"chars": 12904,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * Original file from:\n * FatFs - FAT fil"
},
{
"path": "lib/oofatfs/option/ccsbcs.c",
"chars": 26174,
"preview": "/*------------------------------------------------------------------------*/\n/* Unicode - Local code bidirectional conve"
},
{
"path": "lib/oofatfs/option/unicode.c",
"chars": 400,
"preview": "#include \"../ff.h\"\n\n#if _USE_LFN != 0\n\n#if _CODE_PAGE == 932 /* Japanese Shift_JIS */\n#include \"cc932.c\"\n#elif _CODE_P"
},
{
"path": "lib/timeutils/timeutils.c",
"chars": 6658,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/timeutils/timeutils.h",
"chars": 2374,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/gchelper.h",
"chars": 1770,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/gchelper_m0.s",
"chars": 1991,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/gchelper_m3.s",
"chars": 1894,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/interrupt_char.c",
"chars": 1409,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/interrupt_char.h",
"chars": 1459,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/mpirq.c",
"chars": 5252,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/mpirq.h",
"chars": 3022,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/printf.c",
"chars": 4130,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/pyexec.c",
"chars": 20288,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/pyexec.h",
"chars": 2299,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "lib/utils/stdout_helpers.c",
"chars": 675,
"preview": "#include <string.h>\n#include <unistd.h>\n#include \"py/mpconfig.h\"\n#include \"py/mphal.h\"\n\n/*\n * Extra stdout functions\n * "
},
{
"path": "lib/utils/sys_stdio_mphal.c",
"chars": 6199,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/frozen_mpy.c",
"chars": 4397,
"preview": "#include \"py/mpconfig.h\"\n#include \"py/objint.h\"\n#include \"py/objstr.h\"\n#include \"py/emitglue.h\"\n#include \"py/nativeglue."
},
{
"path": "port/gccollect.c",
"chars": 1675,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/genhdr/gen_qstr.py",
"chars": 3298,
"preview": "#\n# This file is part of the MicroPython project, http://micropython.org/\n#\n# The MIT License (MIT)\n#\n# Copyright (c) 20"
},
{
"path": "port/genhdr/moduledefs.h",
"chars": 0,
"preview": ""
},
{
"path": "port/genhdr/mpversion.h",
"chars": 171,
"preview": "// This file was generated by py/makeversionhdr.py\n#define MICROPY_GIT_TAG \"v1.13-148-ged7ddd4\"\n#define MICROPY_GIT_HASH"
},
{
"path": "port/genhdr/qstrdefs.generated.h",
"chars": 44761,
"preview": "// This file was automatically generated by makeqstrdata.py\n\nQDEF(MP_QSTRnull, (const byte*)\"\\x00\\x00\" \"\")\nQDEF(MP_QSTR_"
},
{
"path": "port/modules/machine/machine_adc.c",
"chars": 5340,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_adc.h",
"chars": 1452,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_hw_i2c.c",
"chars": 13594,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_hw_spi.c",
"chars": 4823,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_lcd.c",
"chars": 12222,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_lcd.h",
"chars": 1405,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_pin.c",
"chars": 11847,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_pwm.c",
"chars": 9606,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_pwm.h",
"chars": 1452,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_rtc.c",
"chars": 5603,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_rtc.h",
"chars": 1452,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_timer.c",
"chars": 9561,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_timer.h",
"chars": 1461,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_uart.c",
"chars": 10642,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_uart.h",
"chars": 1443,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_wdt.c",
"chars": 4879,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/machine_wdt.h",
"chars": 1453,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/modmachine.c",
"chars": 8805,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/machine/modmachine.h",
"chars": 2049,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modffi.c",
"chars": 16856,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modfile.c",
"chars": 9514,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modnetwork.c",
"chars": 2063,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modnetwork.h",
"chars": 1653,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modnetwork_wlan.c",
"chars": 22399,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modpyb.c",
"chars": 6620,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modrtthread.c",
"chars": 3859,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/moduos.c",
"chars": 5224,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/moduos_file.c",
"chars": 9842,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/moduos_file.h",
"chars": 3243,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modusocket.c",
"chars": 21905,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modutils.c",
"chars": 5405,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/modutime.c",
"chars": 5120,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/modules/user/moduserfunc.c",
"chars": 2068,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/mpconfigport.h",
"chars": 19845,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
},
{
"path": "port/mpgetcharport.c",
"chars": 3216,
"preview": "/*\n * This file is part of the MicroPython project, http://micropython.org/\n *\n * The MIT License (MIT)\n *\n * Copyright "
}
]
// ... and 205 more files (download for full content)
About this extraction
This page contains the full source code of the RT-Thread-packages/micropython GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 405 files (3.3 MB), approximately 877.8k tokens, and a symbol index with 2966 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.