Skip to content

Commit fd83a09

Browse files
authored
Merge pull request adafruit#8214 from MakerClassCZ/picopad
Add PicoPad support
2 parents 8de3467 + 58d6c3a commit fd83a09

File tree

6 files changed

+276
-0
lines changed

6 files changed

+276
-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/displayio/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+
displayio_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, 0x68, // 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+
displayio_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 = &displayio_fourwire_type;
73+
common_hal_displayio_fourwire_construct(bus,
74+
spi,
75+
&pin_GPIO17, // TFT_DC Command or data
76+
&pin_GPIO21, // TFT_CS Chip select
77+
&pin_GPIO20, // TFT_RST Reset
78+
60000000, // Baudrate
79+
0, // Polarity
80+
0); // Phase
81+
82+
displayio_display_obj_t *display = &allocate_display()->display;
83+
display->base.type = &displayio_display_type;
84+
common_hal_displayio_display_construct(display,
85+
bus,
86+
320, // Width
87+
240, // Height
88+
0, // column start
89+
0, // 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+
&pin_GPIO16, // 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+
50000); // backlight pwm frequency
112+
}
113+
114+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
firmware_size = 1532k;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#define MICROPY_HW_BOARD_NAME "Pajenicko PicoPad"
2+
#define MICROPY_HW_MCU_NAME "rp2040"
3+
4+
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_PULL (1)
5+
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_DRIVE_MODE (1)
6+
7+
#define MICROPY_HW_LED_STATUS (&pin_CYW0)
8+
9+
#define DEFAULT_UART_BUS_TX (&pin_GPIO0)
10+
#define DEFAULT_UART_BUS_RX (&pin_GPIO1)
11+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO0)
12+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO1)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
USB_VID = 0x2E8A
2+
USB_PID = 0x1063
3+
4+
USB_PRODUCT = "PicoPad"
5+
USB_MANUFACTURER = "Pajenicko s.r.o."
6+
7+
CHIP_VARIANT = RP2040
8+
CHIP_FAMILY = rp2
9+
10+
EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ"
11+
12+
CIRCUITPY_KEYPAD = 1
13+
CIRCUITPY_STAGE = 1
14+
CIRCUITPY_AUDIOIO = 1
15+
16+
CIRCUITPY__EVE = 1
17+
18+
CIRCUITPY_CYW43 = 1
19+
CIRCUITPY_SSL = 1
20+
CIRCUITPY_SSL_MBEDTLS = 1
21+
CIRCUITPY_HASHLIB = 1
22+
CIRCUITPY_WEB_WORKFLOW = 1
23+
CIRCUITPY_MDNS = 1
24+
CIRCUITPY_SOCKETPOOL = 1
25+
CIRCUITPY_WIFI = 1
26+
27+
CIRCUITPY_PICODVI = 1
28+
29+
# Pimoroni PicoSystem peripherals are compatible, we can use of existing ugame.py
30+
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/picosystem
31+
32+
CFLAGS += -DCYW43_PIN_WL_HOST_WAKE=24 -DCYW43_PIN_WL_REG_ON=23 -DCYW43_WL_GPIO_COUNT=3 -DCYW43_WL_GPIO_LED_PIN=0
33+
# Must be accompanied by a linker script change
34+
CFLAGS += -DCIRCUITPY_FIRMWARE_SIZE='(1536 * 1024)'
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: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
// Default RPi Pico Pins
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+
{MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3)},
11+
{MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4)},
12+
{MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5)},
13+
{MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6)},
14+
{MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7)},
15+
{MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8)},
16+
{MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9)},
17+
{MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10)},
18+
{MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11)},
19+
{MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12)},
20+
{MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13)},
21+
{MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14)},
22+
{MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15)},
23+
{MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16)},
24+
{MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17)},
25+
{MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18)},
26+
{MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19)},
27+
{MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20)},
28+
{MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21)},
29+
{MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22)},
30+
{MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26)},
31+
{MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27)},
32+
{MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28)},
33+
34+
// PicoPad external connector
35+
/*
36+
┌──────┐
37+
GND -│1 2│- GND
38+
3V3 -│3 4│- VBAT
39+
D5/A2 -│5 6│- ADC_VREF
40+
D4/A1 -│7 8│- AGND
41+
D3/TX/SDA -│9 10│- D0/A0
42+
D2/RX/SCL -│11 12│- D1
43+
└──────┘
44+
*/
45+
46+
{MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO26)},
47+
{MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO14)},
48+
{MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO1)},
49+
{MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO0)},
50+
{MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO27)},
51+
{MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO28)},
52+
53+
{MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26)},
54+
{MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27)},
55+
{MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28)},
56+
57+
// PicoPad LCD
58+
{MP_ROM_QSTR(MP_QSTR_LCD_RESET), MP_ROM_PTR(&pin_GPIO20)},
59+
{MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO21)},
60+
{MP_ROM_QSTR(MP_QSTR_LCD_SCLK), MP_ROM_PTR(&pin_GPIO18)},
61+
{MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO19)},
62+
{MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO17)},
63+
{MP_ROM_QSTR(MP_QSTR_LCD_BL), MP_ROM_PTR(&pin_GPIO16)},
64+
65+
// PicoPad Audio
66+
{MP_ROM_QSTR(MP_QSTR_AUDIO), MP_ROM_PTR(&pin_GPIO15)},
67+
68+
// PicoPad USR LED (yellow)
69+
{MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO22)},
70+
71+
// PicoPad Buttons
72+
{MP_ROM_QSTR(MP_QSTR_SW_X), MP_ROM_PTR(&pin_GPIO9)},
73+
{MP_ROM_QSTR(MP_QSTR_SW_Y), MP_ROM_PTR(&pin_GPIO8)},
74+
{MP_ROM_QSTR(MP_QSTR_SW_A), MP_ROM_PTR(&pin_GPIO7)},
75+
{MP_ROM_QSTR(MP_QSTR_SW_B), MP_ROM_PTR(&pin_GPIO6)},
76+
77+
{MP_ROM_QSTR(MP_QSTR_SW_DOWN), MP_ROM_PTR(&pin_GPIO5)},
78+
{MP_ROM_QSTR(MP_QSTR_SW_RIGHT), MP_ROM_PTR(&pin_GPIO2)},
79+
{MP_ROM_QSTR(MP_QSTR_SW_LEFT), MP_ROM_PTR(&pin_GPIO3)},
80+
{MP_ROM_QSTR(MP_QSTR_SW_UP), MP_ROM_PTR(&pin_GPIO4)},
81+
82+
// PicoPad SD Card
83+
{MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO13)},
84+
{MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO10)},
85+
{MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO11)},
86+
{MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO12)},
87+
88+
// PicoPad Battery
89+
{MP_ROM_QSTR(MP_QSTR_BAT_SENSE), MP_ROM_PTR(&pin_GPIO29)},
90+
91+
// PicoPad UART0
92+
{MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0)},
93+
{MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1)},
94+
95+
// PicoPad I2C0
96+
{MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO0)},
97+
{MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO1)},
98+
99+
// PicoPad I2C1
100+
{MP_ROM_QSTR(MP_QSTR_SDA_ALT), MP_ROM_PTR(&pin_GPIO14)},
101+
{MP_ROM_QSTR(MP_QSTR_SCL_ALT), MP_ROM_PTR(&pin_GPIO27)},
102+
103+
104+
{MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj)},
105+
{MP_ROM_QSTR(MP_QSTR_I2C_ALT), MP_ROM_PTR(&board_i2c_obj)},
106+
{MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj)},
107+
108+
{MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_CYW1)},
109+
{MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_CYW0)},
110+
{MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_CYW2)},
111+
{MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
112+
};
113+
114+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy