开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
master
review
master
分支 (2)
master
review
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
master
review
microPython
/
docs
/
library
/
esp32.rst
microPython
/
docs
/
library
/
esp32.rst
esp32.rst 10.56 KB
一键复制 编辑 原始数据 按行查看 历史
chenchi 提交于 2021年06月03日 16:44 +08:00 . first commit
.. currentmodule:: esp32

:mod:`esp32` --- functionality specific to the ESP32

.. module:: esp32
 :synopsis: functionality specific to the ESP32

The esp32 module contains functions and classes specifically aimed at controlling ESP32 modules.

Functions

.. function:: wake_on_touch(wake)

 Configure whether or not a touch will wake the device from sleep.
 *wake* should be a boolean value.

.. function:: wake_on_ext0(pin, level)

 Configure how EXT0 wakes the device from sleep. *pin* can be ``None``
 or a valid Pin object. *level* should be ``esp32.WAKEUP_ALL_LOW`` or
 ``esp32.WAKEUP_ANY_HIGH``.

.. function:: wake_on_ext1(pins, level)

 Configure how EXT1 wakes the device from sleep. *pins* can be ``None``
 or a tuple/list of valid Pin objects. *level* should be ``esp32.WAKEUP_ALL_LOW``
 or ``esp32.WAKEUP_ANY_HIGH``.

.. function:: raw_temperature()

 Read the raw value of the internal temperature sensor, returning an integer.

.. function:: hall_sensor()

 Read the raw value of the internal Hall sensor, returning an integer.

.. function:: idf_heap_info(capabilities)

 Returns information about the ESP-IDF heap memory regions. One of them contains
 the MicroPython heap and the others are used by ESP-IDF, e.g., for network
 buffers and other data. This data is useful to get a sense of how much memory
 is available to ESP-IDF and the networking stack in particular. It may shed
 some light on situations where ESP-IDF operations fail due to allocation failures.
 The information returned is *not* useful to troubleshoot Python allocation failures,
 use `micropython.mem_info()` instead.

 The capabilities parameter corresponds to ESP-IDF's ``MALLOC_CAP_XXX`` values but the
 two most useful ones are predefined as `esp32.HEAP_DATA` for data heap regions and
 `esp32.HEAP_EXEC` for executable regions as used by the native code emitter.

 The return value is a list of 4-tuples, where each 4-tuple corresponds to one heap
 and contains: the total bytes, the free bytes, the largest free block, and
 the minimum free seen over time.

 Example after booting::

 >>> import esp32; esp32.idf_heap_info(esp32.HEAP_DATA)
 [(240, 0, 0, 0), (7288, 0, 0, 0), (16648, 4, 4, 4), (79912, 35712, 35512, 35108),
 (15072, 15036, 15036, 15036), (113840, 0, 0, 0)]

Flash partitions

This class gives access to the partitions in the device's flash memory and includes methods to enable over-the-air (OTA) updates.

Create an object representing a partition. id can be a string which is the label of the partition to retrieve, or one of the constants: BOOT or RUNNING.

.. classmethod:: Partition.find(type=TYPE_APP, subtype=0xff, label=None)

 Find a partition specified by *type*, *subtype* and *label*. Returns a
 (possibly empty) list of Partition objects. Note: ``subtype=0xff`` matches any subtype
 and ``label=None`` matches any label.

.. method:: Partition.info()

 Returns a 6-tuple ``(type, subtype, addr, size, label, encrypted)``.

.. method:: Partition.readblocks(block_num, buf)
 Partition.readblocks(block_num, buf, offset)
.. method:: Partition.writeblocks(block_num, buf)
 Partition.writeblocks(block_num, buf, offset)
.. method:: Partition.ioctl(cmd, arg)

 These methods implement the simple and :ref:`extended
 <block-device-interface>` block protocol defined by
 :class:`uos.AbstractBlockDev`.

.. method:: Partition.set_boot()

 Sets the partition as the boot partition.

.. method:: Partition.get_next_update()

 Gets the next update partition after this one, and returns a new Partition object.
 Typical usage is ``Partition(Partition.RUNNING).get_next_update()``
 which returns the next partition to update given the current running one.

.. classmethod:: Partition.mark_app_valid_cancel_rollback()

 Signals that the current boot is considered successful.
 Calling ``mark_app_valid_cancel_rollback`` is required on the first boot of a new
 partition to avoid an automatic rollback at the next boot.
 This uses the ESP-IDF "app rollback" feature with "CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE"
 and an ``OSError(-261)`` is raised if called on firmware that doesn't have the
 feature enabled.
 It is OK to call ``mark_app_valid_cancel_rollback`` on every boot and it is not
 necessary when booting firmare that was loaded using esptool.

Constants

.. data:: Partition.BOOT
 Partition.RUNNING

 Used in the `Partition` constructor to fetch various partitions: ``BOOT`` is the
 partition that will be booted at the next reset and ``RUNNING`` is the currently
 running partition.

.. data:: Partition.TYPE_APP
 Partition.TYPE_DATA

 Used in `Partition.find` to specify the partition type: ``APP`` is for bootable
 firmware partitions (typically labelled ``factory``, ``ota_0``, ``ota_1``), and
 ``DATA`` is for other partitions, e.g. ``nvs``, ``otadata``, ``phy_init``, ``vfs``.

.. data:: HEAP_DATA
 HEAP_EXEC

 Used in `idf_heap_info`.

RMT

The RMT (Remote Control) module, specific to the ESP32, was originally designed to send and receive infrared remote control signals. However, due to a flexible design and very accurate (as low as 12.5ns) pulse generation, it can also be used to transmit or receive many other types of digital signals:

import esp32
from machine import Pin

r = esp32.RMT(0, pin=Pin(18), clock_div=8)
r # RMT(channel=0, pin=18, source_freq=80000000, clock_div=8)

# To use carrier frequency
r = esp32.RMT(0, pin=Pin(18), clock_div=8, carrier_freq=38000)
r # RMT(channel=0, pin=18, source_freq=80000000, clock_div=8, carrier_freq=38000, carrier_duty_percent=50)

# The channel resolution is 100ns (1/(source_freq/clock_div)).
r.write_pulses((1, 20, 2, 40), start=0) # Send 0 for 100ns, 1 for 2000ns, 0 for 200ns, 1 for 4000ns

The input to the RMT module is an 80MHz clock (in the future it may be able to configure the input clock but, for now, it's fixed). clock_div divides the clock input which determines the resolution of the RMT channel. The numbers specificed in write_pulses are multiplied by the resolution to define the pulses.

clock_div is an 8-bit divider (0-255) and each pulse can be defined by multiplying the resolution by a 15-bit (0-32,768) number. There are eight channels (0-7) and each can have a different clock divider.

To enable the carrier frequency feature of the esp32 hardware, specify the carrier_freq as something like 38000, a typical IR carrier frequency.

So, in the example above, the 80MHz clock is divided by 8. Thus the resolution is (1/(80Mhz/8)) 100ns. Since the start level is 0 and toggles with each number, the bitstream is 0101 with durations of [100ns, 2000ns, 100ns, 4000ns].

For more details see Espressif's Ultra-Low-Power co-processor

This class provides access to the Ultra-Low-Power co-processor.

.. method:: ULP.set_wakeup_period(period_index, period_us)

 Set the wake-up period.

.. method:: ULP.load_binary(load_addr, program_binary)

 Load a *program_binary* into the ULP at the given *load_addr*.

.. method:: ULP.run(entry_point)

 Start the ULP running at the given *entry_point*.


Constants

.. data:: esp32.WAKEUP_ALL_LOW
 esp32.WAKEUP_ANY_HIGH

 Selects the wake level for pins.
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

HeliosSDK microPython组件
暂无标签
MIT
使用 MIT 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quecpython/microPython.git
git@gitee.com:quecpython/microPython.git
quecpython
microPython
microPython
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /