Skip to content

Commit

Permalink
Merge pull request #147 from sieren/m5stack-core2
Browse files Browse the repository at this point in the history
Add M5Stack Core2 Support
  • Loading branch information
sieren committed Feb 7, 2021
2 parents f69260b + ca1a342 commit 5664f82
Show file tree
Hide file tree
Showing 177 changed files with 249,000 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
url = https://github.com/me-no-dev/AsyncTCP.git
[submodule "main/libraries/TFT_eSPI"]
path = main/libraries/TFT_eSPI
url = https://github.com/Bodmer/TFT_eSPI.git
url = https://github.com/Bodmer/TFT_eSPI.git
25 changes: 25 additions & 0 deletions components/m5stackcore2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

set(COMPONENT_SRCDIRS
"M5Core2/src"
"M5Core2/src/utility"
)

set(COMPONENT_ADD_INCLUDEDIRS
"M5Core2/src"
"M5Core2/src/utility"
)

set(COMPONENT_REQUIRES
"arduino-esp32"
)

register_component()

target_compile_definitions(${COMPONENT_TARGET} PUBLIC -DESP32)
target_compile_definitions(${COMPONENT_TARGET} PUBLIC -DM5Stack_M5Core2)
# target_compile_definitions(${COMPONENT_TARGET} PUBLIC -DTFT_eSPI_TOUCH_EMULATION)

target_compile_options(${COMPONENT_TARGET} PRIVATE -fno-rtti)
target_compile_options(${COMPONENT_TARGET} PRIVATE -Wno-maybe-uninitialized)
target_compile_options(${COMPONENT_TARGET} PUBLIC -Wno-missing-field-initializers)

17 changes: 17 additions & 0 deletions components/m5stackcore2/M5Core2/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

# This is a clang-format config file. Run command below with this file in
# one of the parent directories.
#
# clang-format -style=file -i <filename> (.cpp or .h)
#
# ( -i = in-place editing, without it formatted source goes to stdout )
#
# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Language: Cpp
BasedOnStyle: Google
ReflowComments: false
SortIncludes: false
PointerAlignment: Left
...
5 changes: 5 additions & 0 deletions components/m5stackcore2/M5Core2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

examples/.DS_Store
examples/Basics/.DS_Store
.development
examples/Touch/.DS_Store
21 changes: 21 additions & 0 deletions components/m5stackcore2/M5Core2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 M5Stack

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.
121 changes: 121 additions & 0 deletions components/m5stackcore2/M5Core2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# M5Core2 Library

English | [中文](README_cn.md)

<img src="https://docs.m5stack.com/assets/img/product_pics/core/core2/core2_01.webp" alt="M5Core2_P1" width="350" height="350">


<img src="https://docs.m5stack.com/assets/img/product_pics/core/core2/core2_02.webp" alt="M5Core2_P2" width="350" height="350">

## Description

**M5Core2** is the second generation core device in the M5Stack development kit series, which further enhances the functions of the original generation of cores.

The MCU is an ESP32 model D0WDQ6-V3 and has dual core Xtensa® 32-bit 240Mhz LX6 processors that can be controlled separately. WiFi and Bluetooth are supported as standard and it includes an on board 16MB Flash and 8MB PSRAM, USB TYPE-C interface for charging, downloading of programs and serial communication, a 2.0-inch integrated capacitive touch screen, and a built-in vibration motor.

M5Core2 also features a built-in RTC module which can provide accurate timing. The power supply is managed by an AXP192 power management chip, which can effectively control the power consumption of the base and a built-in green LED power indicator helps to notify the user of battery level. The battery capacity has been upgraded to 390mAh, which can power the core for much longer than the previous model.

The M5Core2 retains the SD card slot and speakers. However, in order to ensure higher quality sound output, the I2S digital audio interface power amplifier chip is used to effectively prevent signal distortion. There are independent power and reset buttons on the left side and bottom of the base.

The 3 icons on the front of the screen are capacitive buttons which are programmable. There is a small expansion board on the back of the base with a 6-axis IMU sensor and microphone.

## PinMap

**LCD & TF card**

LCD :320x240
TF card Maximum size 16GB

<table>
<tr><td>ESP32 Chip</td><td>GPIO38</td><td>GPIO23</td><td>GPIO18</td><td>GPIO5</td><td>GPIO15</td><td></td><td> </td><td> </td></tr>
<tr><td>AXP192 Chip</td><td> </td><td> </td><td> </td><td> </td><td> </td><td>AXP_IO4</td><td>AXP_DC3</td><td>AXP_LDO2</td></tr>
<tr><td>ILI9342C</td><td>MISO</td><td>MOSI</td><td>SCK</td><td>CS</td><td>DC</td><td>RST</td><td>BL</td><td>PWR</td></tr>
</table>

<table>
<tr><td>ESP32 Chip</td><td>GPIO38</td><td>GPIO23</td><td>GPIO18</td><td>GPIO4</td></tr>
<tr><td>TF Card</td><td>MISO</td><td>MOSI</td><td>SCK</td><td>CS</td></tr>
</table>

**CAP.TOUCH**

<table>
<tr><td>ESP32 chip</td><td>GPIO21</td><td>GPIO22</td><td>GPIO39</td></tr>
<tr><td>AXP192</td><td></td><td></td><td></td><td>AXP_IO4</td></tr>
<tr><td>FT6336U</td><td>SDA</td><td>SCL</td><td>INT</td><td>RST</td></tr>
</table>

**Mic & NS4168**

<table>
<tr><td>ESP32 Chip</td><td>GPIO12</td><td>GPIO0</td><td>GPIO2</td><td>AXP_IO2</td><td>GPIO34</td></tr>
<tr><td>NS4168</td><td>BCLK</td><td>LRCK</td><td>DATA</td><td>SPK_EN</td> </td></tr>
<tr><td>Mic</td><td></td><td>CLK</td><td></td><td></td><td>DATA</td></tr>
</table>

**AXP Power Indicator Light & Vibration motor**

<table>
<tr><td>AXP192</td><td>AXP_IO1</td><td>AXP_LDO3</td></tr>
<tr><td>Green LED</td><td>Vcc</td><td></td></tr>
<tr><td>Vibration motor</td><td></td><td>Vcc</td></tr>
</table>

**RTC**

<table>
<tr><td>ESP32 Chip</td><td>GPIO21</td><td>GPIO22</td><td></td></tr>
<tr><td>AXP192</td><td></td><td></td><td>AXP_PWR</td></tr>
<tr><td>BM8563</td><td>SDA</td><td>SCL</td><td>INT</td></tr>
</table>

**IMU(3-axis gyroscope & 3-axis accelerometer)**

<table>
<tr><td>ESP32 Chip</td><td>GPIO21</td><td>GPIO22</td></tr>
<tr><td>MPU6886</td><td>SDA</td><td>SCL</td></tr>
</table>

**USB to serial chip**

<table>
<tr><td>ESP32 Chip</td><td>GPIO1</td><td>GPIO3</td></tr>
<tr><td>CP2104</td><td>RXD</td><td>TXD</td></tr>
</table>


**Internal I2C connection**

<table>
<tr><td>ESP32 Chip</td><td>GPIO21</td><td>GPIO22</td></tr>
<tr><td>MPU6886</td><td>SDA</td><td>SCL</td></tr>
<tr><td>AXP192</td><td>SDA</td><td>SCL</td></tr>
<tr><td>BM8563</td><td>SDA</td><td>SCL</td></tr>
<tr><td>FT6336U</td><td>SDA</td><td>SCL</td></tr>
</table>


## M5Core2 M-BUS Schematic diagram

<img class="pic" src="https://docs.m5stack.com/assets/img/product_pics/core/core2/core2_mbus.webp" width = "50%">

## M5PORT EXPLAIN

<table>
<thead>
<th>PORT</th>
<th>PIN</th>
<th>Note:</th>
</thead>
<tbody>
<tr>
<td>PORT-A(Red)</td>
<td>G32/33</td>
<td>I2C</td>
</tr>
</tbody>
</table>

## More Information

[Product docs](https://docs.m5stack.com/#/en/core/core2)
113 changes: 113 additions & 0 deletions components/m5stackcore2/M5Core2/README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# M5Core2 Library

中文 | [English](README_cn.md)

<img src="https://docs.m5stack.com/assets/img/product_pics/core/core2/core2_01.webp" alt="M5Core2_P1" width="350" height="350">


<img src="https://docs.m5stack.com/assets/img/product_pics/core/core2/core2_02.webp" alt="M5Core2_P2" width="350" height="350">


## 描述

**M5Core2** 是M5Stack开发套件系列中第二代主机,在原有一代主机基础上对功能进一步加强,硬件功能更加齐全。主控ESP32型号为D0WDQ6-V3,具有两个可以单独控制的 Xtensa® 32-bit LX6 处理器,主频高达240Mhz,支持WiFi与蓝牙功能,板载16MB Flash与8MB PSRAM,可通过TYPE-C接口下载程序,强劲的配置满足复杂应用的资源开销。正面搭载一块2.0寸一体化电容式触摸屏,为用户带来更流畅的人机交互体验。机身内置震动马达,可提供触觉回馈和震动提醒功能。内建的RTC模块可提供精准计时功能。电源部分搭载AXP192电源管理芯片可有效控制机身功耗,内置绿色电源指示灯,配备390mAh电池,续航时间更持久。同时机身内配备了SD卡槽与扬声器,为了保证获得更高质量的声音效果,采用I2S数字音频接口的功放芯片,能有效防止信号失真。在机身的左侧和底部配有独立的电源按键与重启(RST)按键,屏幕正面的3个圆点属于触摸屏的一部分,可通过编写程序设置热区映射为3个虚拟按键。机身背部有一块扩展小板,板上带有6轴IMU传感器与麦克风。

## 管脚映射

**LCD 屏幕 & TF Card**

LCD 像素:320x240
TF 卡最大支持 16GB

<table>
<tr><td>ESP32 Chip</td><td>GPIO38</td><td>GPIO23</td><td>GPIO18</td><td>GPIO5</td><td>GPIO15</td><td></td><td> </td><td> </td></tr>
<tr><td>AXP192 Chip</td><td> </td><td> </td><td> </td><td> </td><td> </td><td>AXP_IO4</td><td>AXP_DC3</td><td>AXP_LDO2</td></tr>
<tr><td>ILI9342C</td><td>MISO</td><td>MOSI</td><td>SCK</td><td>CS</td><td>DC</td><td>RST</td><td>BL</td><td>PWR</td></tr>
</table>

<table>
<tr><td>ESP32 Chip</td><td>GPIO38</td><td>GPIO23</td><td>GPIO18</td><td>GPIO4</td></tr>
<tr><td>TF Card</td><td>MISO</td><td>MOSI</td><td>SCK</td><td>CS</td></tr>
</table>

**CAP.TOUCH触摸屏**

<table>
<tr><td>ESP32 chip</td><td>GPIO21</td><td>GPIO22</td><td>GPIO39</td></tr>
<tr><td>AXP192</td><td></td><td></td><td></td><td>AXP_IO4</td></tr>
<tr><td>FT6336U</td><td>SDA</td><td>SCL</td><td>INT</td><td>RST</td></tr>
</table>

**麦克风 & NS4168功放**

<table>
<tr><td>ESP32 Chip</td><td>GPIO12</td><td>GPIO0</td><td>GPIO2</td><td>AXP_IO2</td><td>GPIO34</td></tr>
<tr><td>NS4168</td><td>BCLK</td><td>LRCK</td><td>DATA</td><td>SPK_EN</td> </td></tr>
<tr><td>Mic</td><td></td><td>CLK</td><td></td><td></td><td>DATA</td></tr>
</table>

**AXP电源指示灯 & 震动马达**

<table>
<tr><td>AXP192</td><td>AXP_IO1</td><td>AXP_LDO3</td></tr>
<tr><td>Green LED</td><td>Vcc</td><td></td></tr>
<tr><td>Vibration motor</td><td></td><td>Vcc</td></tr>
</table>

**RTC**

<table>
<tr><td>ESP32 Chip</td><td>GPIO21</td><td>GPIO22</td><td></td></tr>
<tr><td>AXP192</td><td></td><td></td><td>AXP_PWR</td></tr>
<tr><td>BM8563</td><td>SDA</td><td>SCL</td><td>INT</td></tr>
</table>

**IMU(3轴陀螺仪+3轴加速计)**

<table>
<tr><td>ESP32 Chip</td><td>GPIO21</td><td>GPIO22</td></tr>
<tr><td>MPU6886</td><td>SDA</td><td>SCL</td></tr>
</table>

**USB转串口下载**

<table>
<tr><td>ESP32 Chip</td><td>GPIO1</td><td>GPIO3</td></tr>
<tr><td>CP2104</td><td>RXD</td><td>TXD</td></tr>
</table>


**内部I2C连接**

<table>
<tr><td>ESP32 Chip</td><td>GPIO21</td><td>GPIO22</td></tr>
<tr><td>MPU6886</td><td>SDA</td><td>SCL</td></tr>
<tr><td>AXP192</td><td>SDA</td><td>SCL</td></tr>
<tr><td>BM8563</td><td>SDA</td><td>SCL</td></tr>
<tr><td>FT6336U</td><td>SDA</td><td>SCL</td></tr>
</table>

## M5Core2 M-BUS示意图

<img class="pic" src="https://docs.m5stack.com/assets/img/product_pics/core/core2/core2_mbus.webp" width = "50%">

## M5Core2 端口说明

<table>
<thead>
<th>PORT</th>
<th>PIN</th>
<th>备注:</th>
</thead>
<tbody>
<tr>
<td>PORT-A(红色)</td>
<td>G32/33</td>
<td>I2C</td>
</tr>
</tbody>
</table>

## 更多信息

[产品文档](https://docs.m5stack.com/#/zh_CN/core/core2)
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <M5Core2.h>

float accX = 0.0F;
float accY = 0.0F;
float accZ = 0.0F;

float gyroX = 0.0F;
float gyroY = 0.0F;
float gyroZ = 0.0F;

float pitch = 0.0F;
float roll = 0.0F;
float yaw = 0.0F;

float temp = 0.0F;

// the setup routine runs once when M5Stack starts up
void setup(){

// Initialize the M5Stack object
M5.begin();

M5.IMU.Init();

M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextColor(GREEN , BLACK);
M5.Lcd.setTextSize(2);
}

// the loop routine runs over and over again forever
void loop() {
// put your main code here, to run repeatedly:
M5.IMU.getGyroData(&gyroX,&gyroY,&gyroZ);
M5.IMU.getAccelData(&accX,&accY,&accZ);
M5.IMU.getAhrsData(&pitch,&roll,&yaw);
M5.IMU.getTempData(&temp);

M5.Lcd.setCursor(0, 20);
M5.Lcd.printf("%6.2f %6.2f %6.2f ", gyroX, gyroY, gyroZ);
M5.Lcd.setCursor(220, 42);
M5.Lcd.print(" o/s");
M5.Lcd.setCursor(0, 65);
M5.Lcd.printf(" %5.2f %5.2f %5.2f ", accX, accY, accZ);
M5.Lcd.setCursor(220, 87);
M5.Lcd.print(" G");
M5.Lcd.setCursor(0, 110);
M5.Lcd.printf(" %5.2f %5.2f %5.2f ", pitch, roll, yaw);
M5.Lcd.setCursor(220, 132);
M5.Lcd.print(" degree");
M5.Lcd.setCursor(0, 155);
M5.Lcd.printf("Temperature : %.2f C", temp);

delay(1);
}
Loading

0 comments on commit 5664f82

Please sign in to comment.