8000 Merge pull request #10106 from SeanTheITGuy/spotpear_esp32c3_lcd_1_69 · adafruit/circuitpython@e5c2902 · GitHub
[go: up one dir, main page]

Skip to content

Commit e5c2902

Browse files
authored
Merge pull request #10106 from SeanTheITGuy/spotpear_esp32c3_lcd_1_69
Support for spotpear 1.69 esp32c3 device
2 parents 2ec0d04 + 48d06b9 commit e5c2902

File tree

5 files changed

+180
-0
lines changed

5 files changed

+180
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/busio/SPI.h"
10+
#include "shared-bindings/fourwire/FourWire.h"
11+
#include "shared-bindings/microcontroller/Pin.h"
12+
#include "shared-module/displayio/__init__.h"
13+
#include "shared-module/displayio/mipi_constants.h"
14+
#include "shared-bindings/board/__init__.h"
15+
16+
17+
#define DELAY 0x80
18+
19+
// display init sequence according to ST7789
20+
uint8_t display_init_sequence[] = {
21+
0x01, 0 | DELAY, 0x96, // _SWRESET and Delay 150ms
22+
0x11, 0 | DELAY, 0xff, // _SLPOUT and Delay 500ms
23+
0x3A, 1 | DELAY, 0x55, 0x0a, // _COLMOD and Delay 10ms
24+
0x36, 0x01, 0x08, // _MADCTL
25+
0x21, 0x80, 0x0A, // _INVON Hack and Delay 10ms
26+
0x13, 0x80, 0x0A, // _NORON and Delay 10ms
27+
0x29, 0 | DELAY, 0xff // _DISPON and Delay 500ms
28+
};
29+
30+
31+
void board_init(void) {
32+
33+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
34+
busio_spi_obj_t *spi = &bus->inline_bus;
35+
common_hal_busio_spi_construct(spi, &pin_GPIO5, &pin_GPIO6, NULL, false);
36+
common_hal_busio_spi_never_reset(spi);
37+
bus->base.type = &fourwire_fourwire_type;
38+
39+
common_hal_fourwire_fourwire_construct(
40+
bus,
41+
spi,
42+
&pin_GPIO2, // DC
43+
&pin_GPIO3, // CS
44+
&pin_GPIO10, // RST
45+
40000000, // baudrate
46+
0, // polarity
47+
0 // phase
48+
);
49+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
50+
display->base.type = &busdisplay_busdisplay_type;
51+
52+
common_hal_busdisplay_busdisplay_construct(
53+
display,
54+
bus,
55+
280, // width (after rotation)
56+
240, // height (after rotation)
57+
0, // column start
58+
20, // row start
59+
270, // rotation
60+
16, // color depth
61+
false, // grayscale
62+
false, // pixels in a byte share a row. Only valid for depths < 8
63+
1, // bytes per cell. Only valid for depths < 8
64+
false, // reverse_pixels_in_byte. Only valid for depths < 8
65+
true, // reverse_pixels_in_word
66+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
67+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
68+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
69+
display_init_sequence,
70+
sizeof(display_init_sequence),
71+
NULL, // backlight pin
72+
NO_BRIGHTNESS_COMMAND,
73+
1.0f, // brightness
74+
false, // single_byte_bounds
75+
false, // data_as_commands
76+
true, // auto_refresh
77+
60, // native_frames_per_second
78+
true, // backlight_on_high
79+
false, // SH1107_addressing
80+
200 // backlight pwm frequency
81+
);
82+
}
83+
84+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2023 Neradoc
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Board setup
10+
#define MICROPY_HW_BOARD_NAME "Spotpear ESP32C3 LCD 1.69"
11+
#define MICROPY_HW_MCU_NAME "ESP32-C3FH4"
12+
13+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9)
14+
15+
#define CIRCUITPY_BOARD_I2C (1)
16+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO7, .sda = &pin_GPIO11}}
17+
18+
#define CIRCUITPY_BOARD_SPI (1)
19+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO5, .mosi = &pin_GPIO6, .miso = &pin_GPIO4}}
20+
21+
#define CIRCUITPY_BOARD_UART (1)
22+
#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO21, .rx = &pin_GPIO20}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CIRCUITPY_CREATOR_ID = 0x18760000
2+
CIRCUITPY_CREATION_ID = 0x00DD0002
3+
4+
IDF_TARGET = esp32c3
5+
6+
CIRCUITPY_ESP_FLASH_MODE = qio
7+
CIRCUITPY_ESP_FLASH_FREQ = 80m
8+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
9+
10+
CIRCUITPY_ESP_USB_SERIAL_JTAG = 1
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2023 CDarius
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
#include "shared-module/displayio/__init__.h"
9+
10+
static const mp_rom_map_elem_t board_module_globals_table[] = {
11+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
12+
13+
// buttons
14+
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO9) },
15+
{ MP_ROM_QSTR(MP_QSTR_BUTTON0), MP_ROM_PTR(&pin_GPIO9) },
16+
17+
// buzzer
18+
{ MP_ROM_QSTR(MP_QSTR_BUZZER), MP_ROM_PTR(&pin_GPIO1) },
19+
20+
// SPI
21+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO5) },
22+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO4) },
23+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO6) },
24+
25+
// LCD
26+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO2) },
27+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO3) },
28+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO8) },
29+
30+
// I2C
31+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO7) },
32+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO11) },
33+
34+
// Touch
35+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO9) },
36+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_RST), MP_ROM_PTR(&pin_GPIO10) },
37+
38+
// UART (on unpopulated header)
39+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) },
40+
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
41+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) },
42+
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
43+
44+
// Objects
45+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
46+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
47+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
48+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
49+
};
50+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Espressif IoT Development Framework Configuration
3+
#
4+
#
5+
# Component config
6+
#
7+
#
8+
# LWIP
9+
#
10+
# end of LWIP
11+
12+
# end of Component config
13+
14+
# end of Espressif IoT Development Framework Configuration

0 commit comments

Comments
 (0)
0