Skip to content

Commit b2c7e14

Browse files
authored
Merge pull request #8836 from supcik/picomo
Add support for the PicoMo board
2 parents b18665a + af38ea2 commit b2c7e14

File tree

5 files changed

+244
-0
lines changed

5 files changed

+244
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
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+
#include "mpconfigboard.h"
29+
#include "shared-bindings/busio/SPI.h"
30+
#include "shared-bindings/fourwire/FourWire.h"
31+
#include "shared-module/displayio/__init__.h"
32+
#include "shared-module/displayio/mipi_constants.h"
33+
#include "supervisor/shared/board.h"
34+
35+
fourwire_fourwire_obj_t board_display_obj;
36+
37+
#define DELAY 0x80
38+
39+
uint8_t display_init_sequence[] = {
40+
0x01, 0 | DELAY, 150, // SWRESET
41+
42+
0x36, 1, 0x04, // MADCTL
43+
0x35, 1, 0x00, // TEON
44+
0xB2, 5, 0x0c, 0x0c, 0x00, 0x33, 0x33, // FRMCTR2
45+
0x3A, 1, 0x05, // COLMOD
46+
0xB7, 1, 0x14, // GCTRL
47+
0xBB, 1, 0x37, // VCOMS
48+
0xC0, 1, 0x2c, // LCMCTRL
49+
0xC2, 1, 0x01, // VDVVRHEN
50+
0xC3, 1, 0x12, // VRHS
51+
0xC4, 1, 0x20, // VDVS
52+
0xD0, 2, 0xa4, 0xa1, // PWRCTRL1
53+
0xC6, 1, 0x0f, // FRCTRL2
54+
0xE0, 14, 0xd0, 0x04, 0x0d, 0x11, 0x13, 0x2b, 0x3f, 0x54, 0x4c, 0x18, 0x0d, 0x0b, 0x1f, 0x23, // GMCTRP1
55+
0xE1, 14, 0xd0, 0x04, 0x0c, 0x11, 0x13, 0x2c, 0x3f, 0x44, 0x51, 0x2f, 0x1f, 0x1f, 0x20, 0x23, // GMCTRN1
56+
0x21, 0, // INVON
57+
58+
0x11, 0 | DELAY, 255, // SLPOUT
59+
0x29, 0 | DELAY, 100, // DISPON
60+
61+
0x2a, 4, 0x00, 0, 0x00, 0xfe, // CASET
62+
0x2b, 4, 0x00, 0, 0x00, 0xfe, // RASET
63+
0x2c, 0, // RAMWR
64+
};
65+
66+
void board_init(void) {
67+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
68+
busio_spi_obj_t *spi = &bus->inline_bus;
69+
common_hal_busio_spi_construct(spi, &pin_GPIO18, &pin_GPIO19, NULL, false);
70+
common_hal_busio_spi_never_reset(spi);
71+
72+
bus->base.type = &fourwire_fourwire_type;
73+
common_hal_fourwire_fourwire_construct(bus,
74+
spi,
75+
&pin_GPIO16, // TFT_DC Command or data
76+
&pin_GPIO17, // TFT_CS Chip select
77+
NULL, // TFT_RST Reset
78+
62500000, // Baudrate
79+
0, // Polarity
80+
0); // Phase
81+
82+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
83+
display->base.type = &busdisplay_busdisplay_type;
84+
common_hal_busdisplay_busdisplay_construct(display,
85+
bus,
86+
240, // Width
87+
280, // Height
88+
0, // column start
89+
20, // row start
90+
0, // rotation
91+
16, // Color depth
92+
false, // Grayscale
93+
false, // pixels in a byte share a row. Only valid for depths < 8
94+
1, // bytes per cell. Only valid for depths < 8
95+
false, // reverse_pixels_in_byte. Only valid for depths < 8
96+
true, // reverse_bytes_in_word
97+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
98+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
99+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
100+
display_init_sequence,
101+
sizeof(display_init_sequence),
102+
NULL, // no backlight pin
103+
NO_BRIGHTNESS_COMMAND,
104+
1.0f, // brightness
105+
false, // single_byte_bounds
106+
false, // data_as_commands
107+
true, // auto_refresh
108+
60, // native_frames_per_second
109+
true, // backlight_on_high
110+
false, // SH1107_addressing
111+
0); // backlight pwm frequency
112+
}
113+
114+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#define MICROPY_HW_BOARD_NAME "HEIA-FR Picomo V2"
2+
#define MICROPY_HW_MCU_NAME "rp2040"
3+
4+
#define CIRCUITPY_RGB_STATUS_R (&pin_GPIO10)
5+
#define CIRCUITPY_RGB_STATUS_G (&pin_GPIO9)
6+
#define CIRCUITPY_RGB_STATUS_B (&pin_GPIO8)
7+
8+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO21)
9+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO20)
10+
11+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18)
12+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
USB_VID = 0x2E8A
2+
USB_PID = 0x107D
3+
4+
USB_PRODUCT = "Picomo V2"
5+
USB_MANUFACTURER = "HEIA-FR"
6+
7+
CHIP_VARIANT = RP2040
8+
CHIP_FAMILY = rp2
9+
10+
EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ"
11+
12+
CIRCUITPY__EVE = 1
13+
14+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
15+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ST7789
16+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Shapes
17+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text
18+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ProgressBar
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Put board-specific pico-sdk definitions here. This file must exist.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
{ MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) },
8+
{ MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) },
9+
{ MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) },
10+
11+
{ MP_ROM_QSTR(MP_QSTR_SW_UP), MP_ROM_PTR(&pin_GPIO3) },
12+
{ MP_ROM_QSTR(MP_QSTR_S1), MP_ROM_PTR(&pin_GPIO3) },
13+
{ MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) },
14+
15+
{ MP_ROM_QSTR(MP_QSTR_SW_MID), MP_ROM_PTR(&pin_GPIO4) },
16+
{ MP_ROM_QSTR(MP_QSTR_S5), MP_ROM_PTR(&pin_GPIO4) },
17+
{ MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) },
18+
19+
{ MP_ROM_QSTR(MP_QSTR_SW_DOWN), MP_ROM_PTR(&pin_GPIO5) },
20+
{ MP_ROM_QSTR(MP_QSTR_S2), MP_ROM_PTR(&pin_GPIO5) },
21+
{ MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) },
22+
23+
{ MP_ROM_QSTR(MP_QSTR_SW_TOPR), MP_ROM_PTR(&pin_GPIO6) },
24+
{ MP_ROM_QSTR(MP_QSTR_BOOTSEL), MP_ROM_PTR(&pin_GPIO6) },
25+
{ MP_ROM_QSTR(MP_QSTR_S7), MP_ROM_PTR(&pin_GPIO6) },
26+
{ MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) },
27+
28+
{ MP_ROM_QSTR(MP_QSTR_SW_RIGHT), MP_ROM_PTR(&pin_GPIO7) },
29+
{ MP_ROM_QSTR(MP_QSTR_S4), MP_ROM_PTR(&pin_GPIO7) },
30+
{ MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) },
31+
32+
{ MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_GPIO8) },
33+
{ MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) },
34+
35+
{ MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_GPIO9) },
36+
{ MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) },
37+
38+
{ MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_GPIO10) },
39+
{ MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) },
40+
41+
{ MP_ROM_QSTR(MP_QSTR_BUZZER), MP_ROM_PTR(&pin_GPIO11) },
42+
{ MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) },
43+
44+
{ MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) },
45+
{ MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) },
46+
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) },
47+
{ MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) },
48+
49+
{ MP_ROM_QSTR(MP_QSTR_DISP_DC), MP_ROM_PTR(&pin_GPIO16) },
50+
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) },
51+
52+
{ MP_ROM_QSTR(MP_QSTR_DISP_CS), MP_ROM_PTR(&pin_GPIO17) },
53+
{ MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) },
54+
55+
{ MP_ROM_QSTR(MP_QSTR_DISP_SCL), MP_ROM_PTR(&pin_GPIO18) },
56+
{ MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) },
57+
58+
{ MP_ROM_QSTR(MP_QSTR_DISP_SDA), MP_ROM_PTR(&pin_GPIO19) },
59+
{ MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) },
60+
61+
{ MP_ROM_QSTR(MP_QSTR_TEMP_SDA), MP_ROM_PTR(&pin_GPIO20) },
62+
{ MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) },
63+
64+
{ MP_ROM_QSTR(MP_QSTR_TEMP_SCL), MP_ROM_PTR(&pin_GPIO21) },
65+
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
66+
67+
{ MP_ROM_QSTR(MP_QSTR_SW_LEFT), MP_ROM_PTR(&pin_GPIO22) },
68+
{ MP_ROM_QSTR(MP_QSTR_S3), MP_ROM_PTR(&pin_GPIO22) },
69+
{ MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) },
70+
71+
{ MP_ROM_QSTR(MP_QSTR_SW_TOPL), MP_ROM_PTR(&pin_GPIO23) },
72+
{ MP_ROM_QSTR(MP_QSTR_S6), MP_ROM_PTR(&pin_GPIO23) },
73+
{ MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) },
74+
75+
{ MP_ROM_QSTR(MP_QSTR_USB_OVCUR), MP_ROM_PTR(&pin_GPIO24) },
76+
{ MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) },
77+
78+
{ MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) },
79+
80+
{ MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) },
81+
{ MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) },
82+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) },
83+
84+
{ MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) },
85+
{ MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) },
86+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) },
87+
88+
{ MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) },
89+
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) },
90+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) },
91+
92+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) },
93+
{ MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) },
94+
95+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
96+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
97+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
98+
};
99+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)