Skip to content

Commit 5602618

Browse files
authored
Merge pull request adafruit#9896 from relic-se/waveshare-rp2350
Add Waveshare RP2350 Boards
2 parents 2d2fa28 + b9ae1a7 commit 5602618

40 files changed

+1089
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
9+
10+
#include "mpconfigboard.h"
11+
#include "shared-module/displayio/__init__.h"
12+
#include "shared-module/displayio/mipi_constants.h"
13+
#include "shared-bindings/board/__init__.h"
14+
15+
#define DELAY 0x80
16+
17+
18+
// display init sequence according to https://github.com/adafruit/Adafruit_CircuitPython_ST7789
19+
uint8_t display_init_sequence[] = {
20+
0x01, 0 | DELAY, 0x96, // _SWRESET and Delay 150ms
21+
0x11, 0 | DELAY, 0xFF, // _SLPOUT and Delay 500ms
22+
0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms
23+
0x36, 0x01, 0x08, // _MADCTL
24+
0x21, 0 | DELAY, 0x0A, // _INVON Hack and Delay 10ms
25+
0x13, 0 | DELAY, 0x0A, // _NORON and Delay 10ms
26+
0x36, 0x01, 0xC0, // _MADCTL
27+
0x29, 0 | DELAY, 0xFF, // _DISPON and Delay 500ms
28+
};
29+
30+
static void display_init(void) {
31+
32+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
33+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
34+
35+
bus->base.type = &fourwire_fourwire_type;
36+
37+
common_hal_fourwire_fourwire_construct(
38+
bus,
39+
spi,
40+
&pin_GPIO8, // TFT_DC
41+
&pin_GPIO9, // TFT_CS
42+
&pin_GPIO12, // TFT_RST
43+
50000000, // Baudrate
44+
0, // Polarity
45+
0 // Phase
46+
47+
);
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+
240, // Width
56+
135, // Height
57+
53, // column start
58+
40, // row start
59+
270, // rotation
60+
16, // Color depth
61+
false, // Grayscale
62+
false, // Pixels in a byte share a row
63+
1, // bytes per cell
64+
false, // reverse_pixels_in_byte
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+
&pin_GPIO25, // 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+
1000 // backlight pwm frequency
81+
);
82+
}
83+
84+
void board_init(void) {
85+
display_init();
86+
}
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) 2019 Scott Shawcroft for Adafruit Industries
4+
// SPDX-FileCopyrightText: Copyright (c) 2024 Cooper Dalrymple
5+
//
6+
// SPDX-License-Identifier: MIT
7+
8+
#pragma once
9+
10+
// Micropython setup
11+
#define MICROPY_HW_BOARD_NAME "Waveshare RP2350-GEEK"
12+
#define MICROPY_HW_MCU_NAME "rp2350"
13+
14+
#define CIRCUITPY_BOARD_I2C (1)
15+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO29, .sda = &pin_GPIO28}}
16+
17+
#define CIRCUITPY_BOARD_SPI (2)
18+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO10, .mosi = &pin_GPIO11}, \
19+
{.clock = &pin_GPIO18, .mosi = &pin_GPIO19, .miso = &pin_GPIO20}}
20+
21+
#define CIRCUITPY_BOARD_UART (1)
22+
#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO4, .rx = &pin_GPIO5}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
USB_VID = 0x2E8A
2+
USB_PID = 0x10B6
3+
USB_PRODUCT = "RP2350-GEEK"
4+
USB_MANUFACTURER = "Waveshare Electronics"
5+
6+
CHIP_VARIANT = RP2350
7+
CHIP_PACKAGE = A
8+
CHIP_FAMILY = rp2
9+
10+
EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ"
11+
12+
CIRCUITPY__EVE = 1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Put board-specific pico-sdk definitions here. This file must exist.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
#include "shared-module/displayio/__init__.h"
9+
10+
CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1)
11+
static const mp_rom_map_elem_t board_module_globals_table[] = {
12+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
13+
14+
// 2-3 DEBUG
15+
{ MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) },
16+
{ MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) },
17+
// 4-5 UART
18+
{ MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) },
19+
{ MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) },
20+
// 8-12 LCD
21+
{ MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) },
22+
{ MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) },
23+
{ MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) },
24+
{ MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) },
25+
{ MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) },
26+
// 16-17 I2C
27+
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) },
28+
{ MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) },
29+
// 18-23 SD Card
30+
{ MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) },
31+
{ MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) },
32+
{ MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) },
33+
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
34+
{ MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) },
35+
{ MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) },
36+
// 25 LCD Backlight
37+
{ MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) },
38+
// 28-29 I2C
39+
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) },
40+
{ MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29) },
41+
42+
// UART
43+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO4) },
44+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO5) },
45+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
46+
47+
// I2C
48+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO29) },
49+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO28) },
50+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
51+
52+
// SPI SD Card
53+
{ MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO18)},
54+
{ MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO19)},
55+
{ MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO20)},
56+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO23)},
57+
{ MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) },
58+
59+
// SDIO SD Card
60+
{ MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_GPIO18)},
61+
{ MP_ROM_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_GPIO19)},
62+
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_GPIO20)},
63+
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_GPIO21)},
64+
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_GPIO22)},
65+
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_GPIO23)},
66+
67+
// LCD
68+
{ MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO8) },
69+
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO9) },
70+
{ MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO10) },
71+
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO11) },
72+
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO12) },
73+
{ MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO25) },
74+
{ MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_spi_obj) },
75+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
76+
77+
};
78+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-module/displayio/__init__.h"
10+
#include "shared-module/displayio/mipi_constants.h"
11+
12+
#define DELAY 0x80
13+
14+
15+
// display init sequence according to Adafruit_CircuitPython_ST7735R
16+
// https://github.com/adafruit/Adafruit_CircuitPython_ST7735R
17+
uint8_t display_init_sequence[] = {
18+
// sw reset
19+
0x01, 0 | DELAY, 0x96,
20+
// SLPOUT and Delay
21+
0x11, 0 | DELAY, 0xFF,
22+
0xB1, 0x03, 0x01, 0x2C, 0x2D, // _FRMCTR1
23+
0xB3, 0x06, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D, // _FRMCTR3
24+
0xB4, 0x01, 0x07, // _INVCTR line inversion
25+
0xC0, 0x03, 0xA2, 0x02, 0x84, // _PWCTR1 GVDD = 4.7V, 1.0uA
26+
0xC1, 0x01, 0xC5, // _PWCTR2 VGH=14.7V, VGL=-7.35V
27+
0xC2, 0x02, 0x0A, 0x00, // _PWCTR3 Opamp current small, Boost frequency
28+
0xC3, 0x02, 0x8A, 0x2A,
29+
0xC4, 0x02, 0x8A, 0xEE,
30+
0xC5, 0x01, 0x0E, // _VMCTR1 VCOMH = 4V, VOML = -1.1V
31+
0x20, 0x00, // _INVOFF
32+
0x36, 0x01, 0x18, // _MADCTL bottom to top refresh
33+
// 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie,
34+
// fix on VTL
35+
0x3A, 0x01, 0x05, // COLMOD - 16bit color
36+
0xE0, 0x10, 0x02, 0x1C, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2D, 0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10, // _GMCTRP1 Gamma
37+
0xE1, 0x10, 0x03, 0x1D, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D, 0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10, // _GMCTRN1
38+
0x13, 0 | DELAY, 0x0A, // _NORON
39+
0x29, 0 | DELAY, 0x64, // _DISPON
40+
// 0x36, 0x01, 0xC0, // _MADCTL Default rotation plus BGR encoding
41+
0x36, 0x01, 0xC8, // _MADCTL Default rotation plus RGB encoding
42+
0x21, 0x00, // _INVON
43+
};
44+
45+
static void display_init(void) {
46+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
47+
busio_spi_obj_t *spi = &bus->inline_bus;
48+
common_hal_busio_spi_construct(
49+
spi,
50+
&pin_GPIO10, // CLK
51+
&pin_GPIO11, // MOSI
52+
NULL, // MISO not connected
53+
false // Not half-duplex
54+
);
55+
56+
common_hal_busio_spi_never_reset(spi);
57+
58+
bus->base.type = &fourwire_fourwire_type;
59+
60+
common_hal_fourwire_fourwire_construct(
61+
bus,
62+
spi,
63+
&pin_GPIO8, // DC
64+
&pin_GPIO9, // CS
65+
&pin_GPIO12, // RST
66+
40000000, // baudrate
67+
0, // polarity
68+
0 // phase
69+
);
70+
71+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
72+
display->base.type = &busdisplay_busdisplay_type;
73+
common_hal_busdisplay_busdisplay_construct(
74+
display,
75+
bus,
76+
160, // width (after rotation)
77+
80, // height (after rotation)
78+
26, // column start
79+
1, // row start
80+
90, // rotation
81+
16, // color depth
82+
false, // grayscale
83+
false, // pixels in a byte share a row. Only valid for depths < 8
84+
1, // bytes per cell. Only valid for depths < 8
85+
false, // reverse_pixels_in_byte. Only valid for depths < 8
86+
true, // reverse_pixels_in_word
87+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
88+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
89+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
90+
display_init_sequence,
91+
sizeof(display_init_sequence),
92+
&pin_GPIO25, // backlight pin
93+
NO_BRIGHTNESS_COMMAND,
94+
1.0f, // brightness
95+
false, // single_byte_bounds
96+
false, // data_as_commands
97+
true, // auto_refresh
98+
60, // native_frames_per_second
99+
true, // backlight_on_high
100+
false, // SH1107_addressing
101+
50000 // backlight pwm frequency
102+
);
103+
}
104+
105+
void board_init(void) {
106+
// Display
107+
display_init();
108+
}
109+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
// SPDX-FileCopyrightText: Copyright (c) 2024 Cooper Dalrymple
5+
//
6+
// SPDX-License-Identifier: MIT
7+
8+
#pragma once
9+
10+
#define MICROPY_HW_BOARD_NAME "Waveshare RP2350-LCD-0.96"
11+
#define MICROPY_HW_MCU_NAME "rp2350"
12+
13+
#define CIRCUITPY_BOARD_I2C (1)
14+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO21, .sda = &pin_GPIO20}}
15+
16+
#define CIRCUITPY_BOARD_SPI (1)
17+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO18, .mosi = &pin_GPIO19, .miso = &pin_GPIO16}}
18+
19+
#define CIRCUITPY_BOARD_UART (1)
20+
#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO0, .rx = &pin_GPIO1}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
USB_VID = 0x2E8A
2+
USB_PID = 0x10B7
3+
USB_PRODUCT = "Waveshare RP2350-LCD-0.96"
4+
USB_MANUFACTURER = "Waveshare Electronics"
5+
6+
CHIP_VARIANT = RP2350
7+
CHIP_PACKAGE = A
8+
CHIP_FAMILY = rp2
9+
10+
EXTERNAL_FLASH_DEVICES = "P25Q32SH"
11+
12+
CIRCUITPY__EVE = 1
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Put board-specific pico-sdk definitions here. This file must exist.

0 commit comments

Comments
 (0)