Skip to content

Commit a230171

Browse files
committed
shield: m5stack_cardputer: initial support
Added initial support for the M5Stack Cardputer shield for M5 Stamp S3. The following features are supported: - uSD - st7789 LCD - Analog input from VBAT - I2C on the grove connector Signed-off-by: Sahaj Sarup <[email protected]>
1 parent 70f55bc commit a230171

File tree

5 files changed

+282
-0
lines changed

5 files changed

+282
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) 2025 Linaro Limited
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SHIELD_M5STACK_CARDPUTER
5+
6+
if ADC
7+
8+
config ADC_ESP32
9+
default y
10+
11+
endif # ADC
12+
13+
config INPUT
14+
default y
15+
16+
if DISK_DRIVERS
17+
18+
config DISK_DRIVER_SDMMC
19+
default y
20+
21+
endif # DISK_DRIVERS
22+
23+
if DISPLAY
24+
25+
choice ST7789V_PIXEL_FORMAT
26+
default ST7789V_RGB565
27+
endchoice
28+
29+
if LVGL
30+
31+
config LV_Z_BITS_PER_PIXEL
32+
default 16
33+
34+
choice LV_COLOR_DEPTH
35+
default LV_COLOR_DEPTH_16
36+
endchoice
37+
38+
configdefault LV_COLOR_16_SWAP
39+
default y
40+
41+
endif # LVGL
42+
43+
endif # DISPLAY
44+
45+
endif # SHIELD_M5STACK_CARDPUTER
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2025 Linaro Limited
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SHIELD_M5STACK_CARDPUTER
5+
def_bool $(shields_list_contains,m5stack_cardputer)
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
.. _m5stack_cardputer:
2+
3+
M5Stack-Cardputer base shield
4+
####################################
5+
6+
Overview
7+
********
8+
9+
`M5Stack-Cardputer`_ is a card-sized portable computer that is perfect for engineers.
10+
At the heart of Cardputer is the M5StampS3, a mini development board based on the ESP32-S3
11+
chip.
12+
13+
The 56-key keyboard and 1.14" TFT screen allow users to easily enter and view
14+
information. The on-board SPM1423 digital MEMS microphone and built-in speaker
15+
enable voice operations such as recording, wake-up and audio playback. The
16+
infrared emitter allows infrared control interaction with external devices such
17+
as TVs or air conditioners. And Cardputer offers a HY2.0-4P interface for
18+
expanding I2C sensors such as temperature and humidity sensors, light sensors
19+
and pressure sensors. It also includes a Micro SD card slot for expanding storage.
20+
21+
The device is powered by an internal 120mAh+1400mAh (in the base) lithium
22+
battery solution.
23+
24+
.. figure:: img/m5stack_cardputer.webp
25+
:align: center
26+
:alt: M5Stack-Cardputer
27+
:width: 400 px
28+
29+
M5Stack-Cardputer
30+
31+
.. note::
32+
The NS4186 I2S Codec, SPM1423 microphone, IR LED and Keyboard functionality is not implemented yet.
33+
34+
Pins Assignments
35+
================
36+
37+
+-------------------+---------------+
38+
| ESP32-S3 GPIO Pin | Function |
39+
+===================+======+========+
40+
| 0 | User Button |
41+
+-------------------+---------------+
42+
| 1 | I2C SCL |
43+
+-------------------+---------------+
44+
| 2 | I2C SDA |
45+
+-------------------+---------------+
46+
| 10 | VBAT Voltage |
47+
+-------------------+---------------+
48+
| 33 | LCD RST |
49+
+-------------------+---------------+
50+
| 34 | LCD RS/DC |
51+
+-------------------+---------------+
52+
| 35 | LCD MOSI |
53+
+-------------------+---------------+
54+
| 36 | LCD SCLK |
55+
+-------------------+---------------+
56+
| 37 | LCD CS |
57+
+-------------------+---------------+
58+
| 38 | LCD Backlight |
59+
+-------------------+---------------+
60+
| 39 | uSD MISO |
61+
+-------------------+---------------+
62+
| 40 | uSD SCLK |
63+
+-------------------+---------------+
64+
| 12 | uSD CS |
65+
+-------------------+---------------+
66+
| 14 | uSD MOSI |
67+
+-------------------+---------------+
68+
69+
70+
Programming
71+
***********
72+
73+
Set ``--shield m5stack_cardputer`` when you invoke ``west build``.
74+
For example:
75+
76+
.. zephyr-app-commands::
77+
:zephyr-app: samples/drivers/display
78+
:board: m5stack_stamps3/esp32s3/procpu
79+
:shield: m5stack_cardputer
80+
:goals: build
81+
82+
References
83+
**********
84+
85+
.. target-notes::
86+
87+
.. _M5Stack-Cardputer:
88+
https://docs.m5stack.com/en/core/Cardputer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* Copyright (c) 2025 Linaro Limited
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
zephyr,user {
9+
io-channels = <&adc0 9>;
10+
};
11+
12+
aliases {
13+
/delete-property/ led-strip;
14+
};
15+
16+
chosen {
17+
zephyr,display = &st7789v;
18+
};
19+
20+
mipi_dbi {
21+
compatible = "zephyr,mipi-dbi-spi";
22+
spi-dev = <&spi2>;
23+
dc-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
24+
reset-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
25+
write-only;
26+
#address-cells = <1>;
27+
#size-cells = <0>;
28+
29+
st7789v: st7789v@0 {
30+
compatible = "sitronix,st7789v";
31+
reg = <0>;
32+
mipi-max-frequency = <20000000>;
33+
34+
width = <135>;
35+
height = <240>;
36+
x-offset = <53>;
37+
y-offset = <40>;
38+
39+
vcom = <0x28>;
40+
gctrl = <0x35>;
41+
vrhs = <0x10>;
42+
vdvs = <0x20>;
43+
mdac = <0x00>;
44+
gamma = <0x01>;
45+
colmod = <0x55>;
46+
lcm = <0x2c>;
47+
porch-param = [0c 0c 00 33 33];
48+
cmd2en-param = [5a 69 02 00];
49+
pwctrl1-param = [a4 a1];
50+
pvgam-param = [d0 00 02 07 0a 28 32 44 42 06 0e 12 14 17];
51+
nvgam-param = [d0 00 02 07 0a 28 31 54 47 0e 1c 17 1b 1e];
52+
ram-param = [00 F0];
53+
rgb-param = [40 02 14];
54+
mipi-mode = "MIPI_DBI_MODE_SPI_4WIRE";
55+
};
56+
};
57+
};
58+
59+
/delete-node/ &status_rgb_led;
60+
61+
&pinctrl {
62+
63+
spim2_default: spim2_default {
64+
group1 {
65+
pinmux = <SPIM2_SCLK_GPIO36>,
66+
<SPIM2_CSEL_GPIO37>;
67+
};
68+
group2 {
69+
pinmux = <SPIM2_MOSI_GPIO35>;
70+
output-low;
71+
};
72+
};
73+
74+
spim3_default: spim3_default {
75+
group1 {
76+
pinmux = <SPIM3_SCLK_GPIO40>,
77+
<SPIM3_MISO_GPIO39>;
78+
};
79+
group2 {
80+
pinmux = <SPIM3_MOSI_GPIO14>;
81+
output-low;
82+
};
83+
};
84+
85+
i2c1_default: i2c1_default {
86+
group1 {
87+
pinmux = <I2C1_SDA_GPIO1>,
88+
<I2C1_SCL_GPIO2>;
89+
bias-pull-up;
90+
drive-open-drain;
91+
output-high;
92+
};
93+
};
94+
};
95+
96+
97+
&adc0 {
98+
status = "okay";
99+
#address-cells = <1>;
100+
#size-cells = <0>;
101+
102+
channel@9 {
103+
reg = <9>;
104+
zephyr,gain = "ADC_GAIN_1_4";
105+
zephyr,reference = "ADC_REF_INTERNAL";
106+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
107+
zephyr,resolution = <12>;
108+
};
109+
};
110+
111+
112+
&spi3 {
113+
status = "okay";
114+
#address-cells = <1>;
115+
#size-cells = <0>;
116+
status = "okay";
117+
pinctrl-0 = <&spim3_default>;
118+
pinctrl-names = "default";
119+
clock-frequency = <25000000>;
120+
cs-gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; /* TF-CARD */
121+
122+
sd0: sd@0 {
123+
compatible = "zephyr,sdhc-spi-slot";
124+
reg = <0>;
125+
status = "okay";
126+
spi-max-frequency = <25000000>;
127+
mmc {
128+
compatible = "zephyr,sdmmc-disk";
129+
disk-name = "SD";
130+
status = "okay";
131+
};
132+
133+
};
134+
};
135+
136+
&gpio1 {
137+
status = "okay";
138+
139+
lcd-backlight {
140+
gpio-hog;
141+
gpios = <6 GPIO_ACTIVE_HIGH>;
142+
output-high;
143+
};
144+
};

0 commit comments

Comments
 (0)