首页 > 编程知识 正文

M5StackESP32学习笔记12 Fire的ESP32 Pin Mapping,esp8266学习笔记

时间:2023-05-03 22:35:34 阅读:276375 作者:3476

      M5Stack的核心是一颗ESP32芯片,用esptool.py工具read_mac的结果是:

(esptool) zz-MacBook-Air:~ zz$ esptool.py --port /dev/tty.SLAB_USBtoUART read_macesptool.py v2.6Serial port /dev/tty.SLAB_USBtoUARTConnecting........_Detecting chip type... ESP32Chip is ESP32D0WDQ6 (revision 1)Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None

看起来它的核心模块类似于 ESP32-WROVER。

官方说明书大概说明了其GPIO和功能接口的对应关系。


为了更清晰的了解Pin Mapping,我花了点时间,研究了一下其芯片引脚和外部功能电路的对应关系。

研究成果见下面的表格:

GPIO6-11 已用于连接模组上集成的 SPI flash,GPIO16-17 已用于连接模组上集成的 PSRAM。

可以看出,用户可以自由使用的GPIO有 2、5、12、13、26、35、36,其中26、36引出到了Port B(GPIO 36只能作为INPUT)。

值得注意的是,从表格中可以看出,GPIO 16和GPIO 17 被用来连接SPIRAM,如果试图使用这两个GPIO,会引起错误。

>>> pin = machine.Pin(17, machine.Pin.IN)Traceback (most recent call last): File "<stdin>", line 1, in <module>ValueError: Pins 16&17 cannot be used if SPIRAM is used>>>

但是M5Stack的Port C接口连接到了GPIO 16和17,这就意味着如果MicroPython固件编译时打开了SPIRAM的支持,以后就不可以使用Port C(UART)了。这样看起来就损失掉了一个UART口,不过MicroPython似乎可以指定其他GPIO作为UART的TX和RX,也就不是什么大问题了。 比如用对应Port B的GPIO 26(I/O)做TX,和GPIO 36(I)做RX。
s = machine.UART(2, tx=26, rx=36)
https://github.com/m5stack/M5Stack_MicroPython#uart

I2C是在GPIO 21和22上,在Port A接口没有连接的时候,我的Fire上挂了2个设备。

>>> i2c = machine.I2C(freq=400000, sda=21, scl=22)>>> i2c.scan()[104, 117]>>> hex(104)'0x68'>>> hex(117)'0x75'

0x68是MPU9250,0x75是IP5306(可以读取电量)。

>>> i2c.readfrom_mem(117, 0x78, 1)b'x00'

返回的数据表示电量是100%。

参考资料:
https://www.espressif.com/sites/default/files/documentation/esp32-wrover_datasheet_en.pdf
https://www.espressif.com/sites/default/files/documentation/esp32-wrover-b_datasheet_cn.pdf
https://blog.csdn.net/qq_27114397/article/details/82316994
https://github.com/m5stack/M5Stack_MicroPython#gpio
https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards.html

欢迎交流。

极速赛车稳赚4码machine.I2C(freq=400000, sda=21, scl=22)>>> i2c.scan()[104, 117]>>> hex(104)'0x68'>>> hex(117)'0x75'

0x68是MPU9250,0x75是IP5306(可以读取电量)。

>>> i2c.readfrom_mem(117, 0x78, 1)b'x00'

返回的数据表示电量是100%。

参考资料:
https://www.espressif.com/sites/default/files/documentation/esp32-wrover_datasheet_en.pdf
https://www.espressif.com/sites/default/files/documentation/esp32-wrover-b_datasheet_cn.pdf
https://blog.csdn.net/qq_27114397/article/details/82316994
https://github.com/m5stack/M5Stack_MicroPython#gpio
https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/modules-and-boards.html

欢迎交流。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。