Skip to content

Commit d24518e

Browse files
author
Martin Kiepfer
committed
shield: m5stack_m5dial: Add support for m5dial shield
M5Dial is an IoT development board based on m5stack_stamps3. It features an LCD screen, touch interface, a rotary button, an RTC and a piezo beeper. Signed-off-by: Martin Kiepfer <[email protected]>
1 parent e90c58a commit d24518e

File tree

5 files changed

+374
-0
lines changed

5 files changed

+374
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# M5Stack M5Dial shield configuration
2+
# Copyright (c) 2023 Martin Kiepfer <[email protected]>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
if SHIELD_M5STACK_M5DIAL
6+
7+
config INPUT
8+
default y
9+
10+
config INPUT_FT5336_INTERRUPT
11+
default y if INPUT
12+
13+
config LV_COLOR_16_SWAP
14+
default y if LVGL
15+
16+
config PWM
17+
default y
18+
19+
config REGULATOR
20+
default y
21+
22+
endif # SHIELD_M5STACK_M5DIAL
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# M5Stack M5Dial board configuration
2+
3+
# Copyright (c) 2023 Martin Kiepfer <[email protected]>
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
config SHIELD_M5STACK_M5DIAL
7+
def_bool $(shields_list_contains,m5stack_m5dial)
53.2 KB
Loading
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
.. _m5stack_m5dial:
2+
3+
M5Stack M5Dial
4+
##############
5+
6+
Overview
7+
********
8+
9+
M5Dial is an ESP32-based development board from M5Stack.
10+
The device features an embedded ``m5stack_stamps3`` module that runs
11+
the ESP32-S3 microcontroller.
12+
13+
.. figure:: img/m5stack_m5dial.webp
14+
:align: center
15+
:alt: M5Stack M5Dial
16+
17+
M5Stack M5Dial
18+
19+
Key components
20+
==============
21+
22+
The Zephyr ``m5stack_m5dial`` shield configuration supports the following key components:
23+
24+
+------------------------+-----------------------------------------------------------------------+------------+
25+
| Key Component | Description | Status |
26+
+========================+=======================================================================+============+
27+
| LCD IPS round display | 240x240 pixel display features GC9A01A display controller interfaced | supported |
28+
| (240x240 pixel) | via SPI | |
29+
+------------------------+-----------------------------------------------------------------------+------------+
30+
| WS1850S NFC | Wisesun NFC reader IC interfaced via I2C. | todo |
31+
+------------------------+-----------------------------------------------------------------------+------------+
32+
| RTC8563 RTC | Real-Time clock interfaced via I2C. | supported |
33+
+------------------------+-----------------------------------------------------------------------+------------+
34+
| Rotary encoder | Round rotary button (``INPUT_KEY_LEFT`` and ``INPUT_KEY_RIGHT`` | supported |
35+
| | events). | |
36+
+------------------------+-----------------------------------------------------------------------+------------+
37+
| Reset button | Directly interconnected to EN signal of StampS3 module. | supported |
38+
+------------------------+-----------------------------------------------------------------------+------------+
39+
| User-button | Custom user button. | supported |
40+
+------------------------+-----------------------------------------------------------------------+------------+
41+
| Builtin Beeper/Buzzer | PWM controller beeper, properly operating between 200Hz and 2kHz | supported |
42+
+------------------------+-----------------------------------------------------------------------+------------+
43+
44+
M5Stack M5Dial features 2 external grove ports (A and B)
45+
46+
Grove header A
47+
---------------
48+
49+
Functionality is accessible via ``grove_headerA``
50+
51+
+-----+----------------------------+---------------------------+
52+
| Pin | ``m5stack_stamps3_header`` | Function |
53+
+=====+============================+===========================+
54+
| 1 | 16 | I2C-SCL (``groveA_i2c```) |
55+
+-----+----------------------------+---------------------------+
56+
| 2 | 14 | I2C-SDL (``groveA_i2c``) |
57+
+-----+----------------------------+---------------------------+
58+
| 3 | | 5V-Output |
59+
+-----+----------------------------+---------------------------+
60+
| 4 | | GND |
61+
+-----+----------------------------+---------------------------+
62+
63+
64+
Grove header B
65+
---------------
66+
67+
Functionality is accessible via ``grove_headerB``
68+
69+
+-----+----------------------------+-----------+
70+
| Pin | ``m5stack_stamps3_header`` | Function |
71+
+=====+============================+===========+
72+
| 1 | 0 | In |
73+
+-----+----------------------------+-----------+
74+
| 2 | 1 | Out |
75+
+-----+----------------------------+-----------+
76+
| 3 | | 5V-Output |
77+
+-----+----------------------------+-----------+
78+
| 4 | | GND |
79+
+-----+----------------------------+-----------+
80+
81+
82+
Battery-Support
83+
---------------
84+
85+
Although ``m5stack_m5dial`` does not natively come with a battery, it features
86+
support for connecting a battery to it. The battery connector is underneath the
87+
StampS3 module.
88+
89+
To keep the module running on the battery only, without an external supply, an
90+
internal power-hold signal must be activated. This can be controlled via regulator
91+
``battery_hold``, which is activated by default.
92+
93+
Pin Mapping
94+
===========
95+
96+
M5Dial is utilizing the :dtcompatible:`m5stack,stamps3-header` header.
97+
Following table shows the pin mapping, the interconnection to the
98+
M5Stack-StampS3 module and its according function.
99+
100+
+----------+--------------------------------+---------+-----------+-----------------------------------+
101+
| StampS3 | stamps3-header | M5Dial | M5Dial | Description |
102+
| pin | | pin | signal | |
103+
+----------+--------------------------------+---------+-----------+-----------------------------------+
104+
| M1-1 | ``m5stack_stamps3_header:0`` | J2.1 | GI | Grove-B In |
105+
+----------+--------------------------------+---------+-----------+-----------------------------------+
106+
| M1-2 | ``m5stack_stamps3_header:1`` | J2-2 | GO | Grove-B Out |
107+
+----------+--------------------------------+---------+-----------+-----------------------------------+
108+
| M1-3 | ``m5stack_stamps3_clkout0:2`` | | Beep | Beeper |
109+
+----------+--------------------------------+---------+-----------+-----------------------------------+
110+
| M1-4 | ``m5stack_stamps3_header:3`` | | LCD_RS | LCD Cmd/Data |
111+
+----------+--------------------------------+---------+-----------+-----------------------------------+
112+
| M1-5 | ``m5stack_stamps3_spilcd`` | | LCD_MOSI | LCD SPI-MOSI |
113+
+----------+--------------------------------+---------+-----------+-----------------------------------+
114+
| M1-6 | ``m5stack_stamps3_spilcd`` | | LCD_SCK | LCD SPI-CLK |
115+
+----------+--------------------------------+---------+-----------+-----------------------------------+
116+
| M1-7 | ``m5stack_stamps3_spilcd`` | | LCD_CS | LCD SPI-CS |
117+
+----------+--------------------------------+---------+-----------+-----------------------------------+
118+
| M1-8 | ``m5stack_stamps3_header:7`` | | LCD_RESET | LCD Reset (active-low) |
119+
+----------+--------------------------------+---------+-----------+-----------------------------------+
120+
| M1-9 | ``m5stack_stamps3_clkout0:0`` | | LCD_BL | LCD Backlight |
121+
| | | | | (PWM controlled MOSFET) |
122+
+----------+--------------------------------+---------+-----------+-----------------------------------+
123+
| M1-10 | ``m5stack_stamps3_header:9`` | | RC522_INT | NFC Interrupt |
124+
+----------+--------------------------------+---------+-----------+-----------------------------------+
125+
| M1-11 | **GND** | Ground |
126+
+----------+--------------------------------+---------+-----------+-----------------------------------+
127+
| M1-12 | ``m5stack_stamps3_i2c1`` | | TP_SDA | Internal I2C-SDA |
128+
| | | | | (Touch, NFC and RTC) |
129+
+----------+--------------------------------+---------+-----------+-----------------------------------+
130+
| M1-13 | **VIN_5V** | 5V Input voltage |
131+
| | | (via USB-C connector of StampS3) |
132+
+----------+--------------------------------+---------+-----------+-----------------------------------+
133+
| M1-14 | ``m5stack_stamps3_i2c1`` | | TP_SCL | Internal I2C-SCL |
134+
| | | | | (Touch, NFC and RTC) |
135+
+----------+--------------------------------+---------+-----------+-----------------------------------+
136+
| M1-15 | ``m5stack_stamps3_i2c0`` | J3-2 | SDA | Grove-A I2C-SDA |
137+
+----------+--------------------------------+---------+-----------+-----------------------------------+
138+
| M1-16 | ``m5stack_stamps3_header:15`` | | TP_INT | Touch Interrupt |
139+
+----------+--------------------------------+---------+-----------+-----------------------------------+
140+
| M1-17 | ``m5stack_stamps3_i2c0`` | J3-1 | SCL | Grove-A I2C-SCL |
141+
+----------+--------------------------------+---------+-----------+-----------------------------------+
142+
| M1-18 | **GND** | Ground |
143+
+----------+--------------------------------+---------+-----------+-----------------------------------+
144+
| M1-19 | | | MTCK | |
145+
+----------+--------------------------------+---------+-----------+-----------------------------------+
146+
| M1-20 | | | Boot | |
147+
+----------+--------------------------------+---------+-----------+-----------------------------------+
148+
| M1-21 | ``m5stack_stamps3_header:20`` | | B | Rotary left key |
149+
+----------+--------------------------------+---------+-----------+-----------------------------------+
150+
| M1-22 | | | EN | Enable signal for 3V3 |
151+
+----------+--------------------------------+---------+-----------+-----------------------------------+
152+
| M1-23 | ``m5stack_stamps3_header:22`` | | A | Rotary right key |
153+
+----------+--------------------------------+---------+-----------+-----------------------------------+
154+
| M1-24 | | | RX | |
155+
+----------+--------------------------------+---------+-----------+-----------------------------------+
156+
| M1-25 | ``m5stack_stamps3_header:24`` | | WAKE | User-Button |
157+
+----------+--------------------------------+---------+-----------+-----------------------------------+
158+
| M1-26 | | | TX | |
159+
+----------+--------------------------------+---------+-----------+-----------------------------------+
160+
| M1-27 | ``m5stack_stamps3_header:26`` | | HOLD | Battery-hold signal |
161+
+----------+--------------------------------+---------+-----------+-----------------------------------+
162+
| M1-28 | **3_3V** | 3.3V main output |
163+
| | | (via StampS3 DCDC) |
164+
+----------+--------------------------------+---------+-----------+-----------------------------------+
165+
166+
Start Application Development
167+
*****************************
168+
169+
Before powering up your M5Stack M5Dial, please make sure that the board is in good
170+
condition with no obvious signs of damage.
171+
172+
Building & Flashing
173+
===================
174+
175+
M5Dial is based on ``m5stack_stamps3``.
176+
You may build and flash applications for M5Stack StampS3 as usual (see
177+
:ref:`build_an_application` and :ref:`application_run` for more details), and
178+
include this shield as an overlay.
179+
180+
A good first example to test is :zephyr:code-sample:`lvgl`:
181+
.. zephyr-app-commands::
182+
:zephyr-app: samples/subsys/display/lvgl
183+
:board: m5stack_stamps3
184+
:shield: m5stack_m5dial
185+
:goals: build flash
186+
187+
The baud rate of 921600bps is set by default. If experiencing issues when flashing,
188+
try using different values by using ``--esp-baud-rate <BAUD>`` option during
189+
``west flash`` (e.g. ``west flash --esp-baud-rate 115200``).
190+
191+
.. note::
192+
Because there currently is missing automatic PWM control or an external backlight
193+
driver, the display backlight be default is disabled. You may need to enable it
194+
in your application or by using the PWM shell.
195+
196+
Debugging
197+
---------
198+
199+
M5Stack M5Dial debugging is not supported due to pinout limitations.
200+
201+
Related Documents
202+
*****************
203+
204+
- `M5Stack M5Dial schematic <https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/products/core/M5Dial/Sch_M5Dial.pdf>`_
205+
- `M5Stack M5Dial documentation <https://docs.m5stack.com/en/core/M5Dial>`_
206+
- `ESP32S3 Datasheet <https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf>`_
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* Copyright (c) 2023 Martin Kiepfer <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <zephyr/dt-bindings/pwm/pwm.h>
7+
#include <zephyr/dt-bindings/display/panel.h>
8+
#include <zephyr/dt-bindings/input/input-event-codes.h>
9+
#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
10+
11+
/ {
12+
chosen {
13+
zephyr,display = &gc9x01x_lcd;
14+
zephyr,display-backlight = &backlight_pwm;
15+
zephyr,rtc = &pfc8563_rtc;
16+
};
17+
18+
aliases {
19+
sw0 = &user_button_1; /* overwrite StampS3 user button */
20+
};
21+
22+
gpio_keys {
23+
compatible = "gpio-keys";
24+
25+
user_button_1: button_1 {
26+
label = "User button 1";
27+
gpios = <&m5stack_stamps3_header 24 GPIO_ACTIVE_LOW>;
28+
zephyr,code = <INPUT_KEY_0>;
29+
};
30+
31+
rotary_left: rotary_left {
32+
label = "rotary left";
33+
gpios = <&m5stack_stamps3_header 20 GPIO_ACTIVE_LOW>;
34+
zephyr,code = <INPUT_KEY_LEFT>;
35+
};
36+
37+
rotary_right: rotary_right {
38+
label = "rotary right";
39+
gpios = <&m5stack_stamps3_header 22 GPIO_ACTIVE_LOW>;
40+
zephyr,code = <INPUT_KEY_RIGHT>;
41+
};
42+
};
43+
44+
mipi_dbi_gc9x01x_240x240 {
45+
compatible = "zephyr,mipi-dbi-spi";
46+
spi-dev = <&m5stack_stamps3_spilcd>;
47+
dc-gpios = <&m5stack_stamps3_header 3 GPIO_ACTIVE_HIGH>;
48+
reset-gpios = <&m5stack_stamps3_header 7 GPIO_ACTIVE_LOW>;
49+
write-only;
50+
#address-cells = <1>;
51+
#size-cells = <0>;
52+
53+
gc9x01x_lcd: gc9x01x_lcd@0 {
54+
compatible = "galaxycore,gc9x01x";
55+
reg = <0>;
56+
mipi-max-frequency = <100000000>;
57+
display-inversion;
58+
pixel-format = <PANEL_PIXEL_FORMAT_RGB_565>;
59+
60+
width = <240>;
61+
height = <240>;
62+
63+
mipi-mode = <MIPI_DBI_MODE_SPI_4WIRE>;
64+
};
65+
};
66+
67+
backlight_pwm: backlight_pwm {
68+
status = "okay";
69+
compatible = "pwm-clock";
70+
#clock-cells = <1>;
71+
pwms = <&m5stack_stamps3_clkout0 0 PWM_MSEC(5) PWM_POLARITY_NORMAL>;
72+
};
73+
74+
beeper_pwm: beeper_pwm {
75+
status = "okay";
76+
compatible = "pwm-clock";
77+
#clock-cells = <1>;
78+
pwms = <&m5stack_stamps3_clkout0 2 PWM_USEC(1500) PWM_POLARITY_NORMAL>;
79+
};
80+
81+
battery_hold {
82+
compatible = "regulator-fixed";
83+
regulator-name = "battery_hold";
84+
enable-gpios = <&m5stack_stamps3_header 26 GPIO_ACTIVE_HIGH>;
85+
regulator-boot-on;
86+
};
87+
88+
grove_headerA: grove_headerA {
89+
compatible = "grove-header";
90+
#gpio-cells = <2>;
91+
gpio-map-mask = <0xffffffff 0xffffffc0>;
92+
gpio-map-pass-thru = <0 0x3f>;
93+
gpio-map = <0 0 &m5stack_stamps3_header 16 0>,
94+
<1 0 &m5stack_stamps3_header 14 0>;
95+
};
96+
97+
grove_headerB: grove_headerB {
98+
compatible = "grove-header";
99+
#gpio-cells = <2>;
100+
gpio-map-mask = <0xffffffff 0xffffffc0>;
101+
gpio-map-pass-thru = <0 0x3f>;
102+
gpio-map = <0 0 &m5stack_stamps3_header 0 0>,
103+
<1 0 &m5stack_stamps3_header 1 0>;
104+
};
105+
106+
lvgl_pointer {
107+
compatible = "zephyr,lvgl-pointer-input";
108+
input = <&ft5267_touch>;
109+
swap-xy;
110+
};
111+
112+
};
113+
&m5stack_stamps3_clkout0 {
114+
status = "okay";
115+
116+
};
117+
118+
&m5stack_stamps3_i2c1 {
119+
status = "okay";
120+
121+
ft5267_touch: ft3267@38 {
122+
compatible = "focaltech,ft5336";
123+
reg = <0x38>;
124+
int-gpios = <&m5stack_stamps3_header 15 0>;
125+
};
126+
127+
pfc8563_rtc: pfc8563@51 {
128+
compatible = "nxp,pcf8563";
129+
reg = <0x51>;
130+
status = "okay";
131+
};
132+
};
133+
134+
&m5stack_stamps3_spilcd {
135+
status = "okay";
136+
dma-enabled;
137+
};
138+
139+
groveA_i2c: &m5stack_stamps3_i2c0 {};

0 commit comments

Comments
 (0)