Skip to content

Commit 37d8075

Browse files
author
Jozsef Kiraly
committed
port: Add M5Stack M5Paper board target
1 parent d0f313c commit 37d8075

File tree

5 files changed

+281
-0
lines changed

5 files changed

+281
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 fonix232
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "supervisor/board.h"
28+
29+
#include "mpconfigboard.h"
30+
#include "shared-bindings/busio/SPI.h"
31+
#include "shared-bindings/displayio/FourWire.h"
32+
#include "shared-bindings/microcontroller/Pin.h"
33+
#include "shared-module/displayio/__init__.h"
34+
#include "shared-bindings/board/__init__.h"
35+
36+
37+
const uint8_t display_start_sequence[] = { };
38+
39+
const uint8_t display_stop_sequence[] = { };
40+
41+
const uint8_t display_refresh_sequence[] = { };
42+
43+
44+
void board_init(void) {
45+
46+
// TODO: Investigate how to initialise display
47+
48+
// // Set up the SPI object used to control the display
49+
// busio_spi_obj_t *spi = common_hal_board_create_spi(0);
50+
// common_hal_busio_spi_never_reset(spi);
51+
52+
// // Set up the DisplayIO pin object
53+
// displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
54+
// bus->base.type = &displayio_fourwire_type;
55+
// common_hal_displayio_fourwire_construct(bus,
56+
// spi,
57+
// &pin_GPIO20, // EPD_DC Command or data
58+
// &pin_GPIO15, // EPD_CS Chip select
59+
// &pin_GPIO23, // EPD_RST Reset
60+
// 1200000, // Baudrate
61+
// 0, // Polarity
62+
// 0); // Phase
63+
64+
// displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
65+
// display->base.type = &displayio_epaperdisplay_type;
66+
67+
// common_hal_displayio_epaperdisplay_construct(
68+
// display,
69+
// bus,
70+
// display_start_sequence, sizeof(display_start_sequence),
71+
// 1.0, // start up time
72+
// display_stop_sequence, sizeof(display_stop_sequence),
73+
// 540, // width
74+
// 960, // height
75+
// 540, // ram_width
76+
// 960, // ram_height
77+
// 0, // colstart
78+
// 0, // rowstart
79+
// 90, // rotation
80+
// NO_COMMAND, // set_column_window_command
81+
// NO_COMMAND, // set_row_window_command
82+
// NO_COMMAND, // set_current_column_command
83+
// NO_COMMAND, // set_current_row_command
84+
// NO_COMMAND, // write_black_ram_command
85+
// false, // black_bits_inverted
86+
// NO_COMMAND, // write_color_ram_command
87+
// false, // color_bits_inverted
88+
// 0x000000, // highlight_color
89+
// refresh_sequence, sizeof(refresh_sequence),
90+
// 28.0, // refresh_time
91+
// &pin_GPIO27, // busy_pin
92+
// false, // busy_state
93+
// 30.0, // seconds_per_frame
94+
// false, // always_toggle_chip_select
95+
// false, // grayscale
96+
// true, // acep
97+
// false, // two_byte_sequence_length
98+
// false // address_little_endian
99+
// );
100+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2023 fonix232
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
// Micropython setup
28+
29+
#define MICROPY_HW_BOARD_NAME "M5Stack M5Paper"
30+
#define MICROPY_HW_MCU_NAME "ESP32"
31+
32+
#define CIRCUITPY_BOARD_I2C (2)
33+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO22, .sda = &pin_GPIO21}, \
34+
{.scl = &pin_GPIO32, .sda = &pin_GPIO25}}
35+
36+
#define CIRCUITPY_BOARD_SPI (1)
37+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO14, .mosi = &pin_GPIO12, .miso = &pin_GPIO13}}
38+
39+
// GPIO16 & GPIO17 are used for PSRAM
40+
// #define CIRCUITPY_BOARD_UART (1)
41+
// #define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO17, .rx = &pin_GPIO16}}
42+
43+
// For entering safe mode
44+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39)
45+
46+
// Explanation of how a user got into safe mode
47+
#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button DOWN at start up.")
48+
49+
// UART pins attached to the USB-serial converter chip
50+
#define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1)
51+
#define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO3)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CIRCUITPY_CREATOR_ID = 0x10151015
2+
CIRCUITPY_CREATION_ID = 0x0032000B
3+
4+
IDF_TARGET = esp32
5+
6+
CIRCUITPY_ESP_FLASH_MODE = qio
7+
CIRCUITPY_ESP_FLASH_FREQ = 80m
8+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
9+
CIRCUITPY_ESPCAMERA = 0
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "shared-bindings/board/__init__.h"
2+
#include "shared-module/displayio/__init__.h"
3+
4+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
5+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
6+
7+
// Power MAIN
8+
{ MP_ROM_QSTR(MP_QSTR_POWER_MAIN),MP_ROM_PTR(&pin_GPIO2) },
9+
10+
// sd card
11+
{ MP_ROM_QSTR(MP_QSTR_SD_CS),MP_ROM_PTR(&pin_GPIO4) },
12+
13+
// Power EXT
14+
{ MP_ROM_QSTR(MP_QSTR_SD_CS),MP_ROM_PTR(&pin_GPIO5) },
15+
16+
// SPI Internal
17+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO12) },
18+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO13) },
19+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO14) },
20+
21+
// IT8951
22+
{ MP_ROM_QSTR(MP_QSTR_IT8951_CS), MP_ROM_PTR(&pin_GPIO15) },
23+
{ MP_ROM_QSTR(MP_QSTR_IT8951_RESET), MP_ROM_PTR(&pin_GPIO23) },
24+
{ MP_ROM_QSTR(MP_QSTR_IT8951_BUSY), MP_ROM_PTR(&pin_GPIO27) },
25+
26+
// Port C
27+
{ MP_ROM_QSTR(MP_QSTR_PORTC_RX), MP_ROM_PTR(&pin_GPIO18) },
28+
{ MP_ROM_QSTR(MP_QSTR_PORTC_TX), MP_ROM_PTR(&pin_GPIO19) },
29+
30+
// I2C
31+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO21) },
32+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO22) },
33+
34+
// EPD Power
35+
{ MP_ROM_QSTR(MP_QSTR_IT8951_POWER), MP_ROM_PTR(&pin_GPIO23) },
36+
37+
// Port A
38+
{ MP_ROM_QSTR(MP_QSTR_PORTA_SDA), MP_ROM_PTR(&pin_GPIO25) },
39+
{ MP_ROM_QSTR(MP_QSTR_PORTA_SCL), MP_ROM_PTR(&pin_GPIO32) },
40+
41+
// Port B
42+
{ MP_ROM_QSTR(MP_QSTR_PORTB_IN), MP_ROM_PTR(&pin_GPIO26) },
43+
{ MP_ROM_QSTR(MP_QSTR_PORTB_OUT), MP_ROM_PTR(&pin_GPIO33) },
44+
45+
// Battery voltage
46+
{ MP_ROM_QSTR(MP_QSTR_BATTERY_VOLTAGE), MP_ROM_PTR(&pin_GPIO35) },
47+
48+
// Touch
49+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO36) },
50+
51+
// buttons
52+
{ MP_ROM_QSTR(MP_QSTR_BTN_UP), MP_ROM_PTR(&pin_GPIO37) },
53+
{ MP_ROM_QSTR(MP_QSTR_BTN_CENTER), MP_ROM_PTR(&pin_GPIO38) },
54+
{ MP_ROM_QSTR(MP_QSTR_BTN_DOWN), MP_ROM_PTR(&pin_GPIO39) },
55+
56+
57+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
58+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
59+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
60+
61+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
62+
};
63+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
CONFIG_ESP32_ECO3_CACHE_LOCK_FIX=y
2+
CONFIG_ESP32_SPIRAM_SUPPORT=y
3+
CONFIG_ESP32_REV_MIN_3=y
4+
5+
#
6+
# SPI RAM config
7+
#
8+
CONFIG_SPIRAM_TYPE_AUTO=y
9+
# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set
10+
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
11+
#CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
12+
CONFIG_SPIRAM_SIZE=8388608
13+
# end of SPI RAM config
14+
15+
#
16+
# PSRAM clock and cs IO for ESP32
17+
#
18+
CONFIG_D0WD_PSRAM_CLK_IO=17
19+
CONFIG_D0WD_PSRAM_CS_IO=16
20+
# end of PSRAM clock and cs IO for ESP32
21+
22+
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
23+
# CONFIG_SPIRAM_RODATA is not set
24+
CONFIG_SPIRAM_SPEED_80M=y
25+
# CONFIG_SPIRAM_SPEED_40M is not set
26+
# CONFIG_SPIRAM_SPEED_26M is not set
27+
# CONFIG_SPIRAM_SPEED_20M is not set
28+
CONFIG_SPIRAM=y
29+
CONFIG_SPIRAM_BOOT_INIT=y
30+
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
31+
CONFIG_SPIRAM_USE_MEMMAP=y
32+
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
33+
# CONFIG_SPIRAM_USE_MALLOC is not set
34+
CONFIG_SPIRAM_MEMTEST=y
35+
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
36+
#
37+
# LWIP
38+
#
39+
CONFIG_LWIP_LOCAL_HOSTNAME="M5StaskCoreFire"
40+
# end of LWIP
41+
42+
# Uncomment (remove ###) to send ESP_LOG output to TX/RX pins
43+
### #
44+
### # ESP System Settings
45+
### #
46+
### CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y
47+
### # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set
48+
### CONFIG_ESP_CONSOLE_UART_CUSTOM=y
49+
### CONFIG_ESP_CONSOLE_NONE is not set
50+
### CONFIG_ESP_CONSOLE_UART=y
51+
### CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_0=y
52+
### # CONFIG_ESP_CONSOLE_UART_CUSTOM_NUM_1 is not set
53+
### CONFIG_ESP_CONSOLE_UART_NUM=0
54+
### CONFIG_ESP_CONSOLE_UART_TX_GPIO=17
55+
### CONFIG_ESP_CONSOLE_UART_RX_GPIO=16
56+
### CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
57+
### # CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set
58+
### # end of ESP System Settings

0 commit comments

Comments
 (0)