Skip to content

Commit 583392a

Browse files
authored
Merge pull request micropython#2046 from brentru/add-pyportal-titano
Add PyPortal Titano
2 parents 49cb72d + 5a8846d commit 583392a

File tree

5 files changed

+279
-1
lines changed

5 files changed

+279
-1
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
- TRAVIS_BOARDS="metro_m0_express metro_m4_express metro_m4_airlift_lite pirkey_m0 trellis_m4_express trinket_m0 sparkfun_lumidrive sparkfun_redboard_turbo bast_pro_mini_m0 datum_distance pyruler" TRAVIS_SDK=arm
2626
- TRAVIS_BOARDS="cp32-m4 feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow sam32 uchip escornabot_makech pygamer_advance datum_imu snekboard" TRAVIS_SDK=arm
2727
- TRAVIS_BOARDS="feather_m0_supersized feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300 arduino_mkrzero pewpew10 kicksat-sprite ugame10 robohatmm1_m0 robohatmm1_m4 datum_light" TRAVIS_SDK=arm
28-
- TRAVIS_BOARDS="datalore_ip_m4 circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick pyportal sparkfun_samd21_mini sparkfun_samd21_dev pybadge pybadge_airlift datum_weather" TRAVIS_SDK=arm
28+
- TRAVIS_BOARDS="datalore_ip_m4 circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick pyportal sparkfun_samd21_mini sparkfun_samd21_dev pybadge pybadge_airlift datum_weather pyportal_titano" TRAVIS_SDK=arm
2929

3030
addons:
3131
artifacts:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 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 "boards/board.h"
28+
#include "mpconfigboard.h"
29+
#include "hal/include/hal_gpio.h"
30+
31+
#include "shared-bindings/busio/SPI.h"
32+
#include "shared-bindings/displayio/FourWire.h"
33+
34+
#include "shared-module/displayio/__init__.h"
35+
#include "shared-module/displayio/mipi_constants.h"
36+
37+
#include "tick.h"
38+
39+
#define DELAY 0x80
40+
41+
uint8_t display_init_sequence[] = {
42+
0x01, DELAY, 100/5, // Soft reset, then delay 10 ms
43+
0xB9, 3, 0xFF, 0x83, 0x57, // Extension command set
44+
0xFF, DELAY, 500/5,
45+
0xB3, 4, 0x80, 0x00, 0x06, 0x06, // 0x80 enables SDO pin (0x00 disables)
46+
0xB6, 2, 0x01, 0x25, // -1.52V
47+
0xB0, 1, 0x68, // Normal mode 70Hz, Idle mode 55 Hz
48+
0xCC, 1, 0x05,
49+
0xB1, 6,
50+
0x00, // Not deep standby
51+
0x15, // BT
52+
0x1C, // VSPR
53+
0x1C, // VSNR
54+
0x83, // AP
55+
0xAA, // FS
56+
0xC0, 6,
57+
0x50, // OPON normal
58+
0x50, // OPON idle
59+
0x01, // STBA
60+
0x3C, // STBA
61+
0x1E, // STBA
62+
0x08, // GEN
63+
0xB4, 7,
64+
0x02, // NW 0x02
65+
0x40, // RTN
66+
0x00, // DIV
67+
0x2A, // DUM
68+
0x2A, // DUM
69+
0x0D, // GDON
70+
0x78, // GDOFF
71+
0xE0, 34,
72+
0x02, 0x0A, 0x11, 0x1d, 0x23, 0x35, 0x41, 0x4b, 0x4b,
73+
0x42, 0x3A, 0x27, 0x1B, 0x08, 0x09, 0x03, 0x02, 0x0A,
74+
0x11, 0x1d, 0x23, 0x35, 0x41, 0x4b, 0x4b, 0x42, 0x3A,
75+
0x27, 0x1B, 0x08, 0x09, 0x03, 0x00, 0x01,
76+
0x3a, 1, 0x55,
77+
0x36, 1, 0x00,
78+
0x11, DELAY, 150/5, // Exit Sleep, then delay 150 ms
79+
0x29, DELAY, 50/5
80+
};
81+
82+
void board_init(void) {
83+
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
84+
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, &pin_PA14);
85+
common_hal_busio_spi_never_reset(spi);
86+
87+
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
88+
bus->base.type = &displayio_fourwire_type;
89+
common_hal_displayio_fourwire_construct(bus,
90+
spi,
91+
&pin_PB05, // TFT_DC Command or data
92+
&pin_PB06, // TFT_CS Chip select
93+
&pin_PA00, // TFT_RST Reset
94+
24000000);
95+
96+
displayio_display_obj_t* display = &displays[0].display;
97+
display->base.type = &displayio_display_type;
98+
common_hal_displayio_display_construct(display,
99+
bus,
100+
480, // Width
101+
320, // Height
102+
0, // column start
103+
0, // row start
104+
270, // rotation
105+
16, // Color depth
106+
false, // grayscale
107+
false, // pixels_in_byte_share_row (unused for depths > 8)
108+
1, // bytes per cell. Only valid for depths < 8
109+
false, // reverse_pixels_in_byte. Only valid for depths < 8
110+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
111+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
112+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
113+
0x37, // Set vertical scroll command
114+
display_init_sequence,
115+
sizeof(display_init_sequence),
116+
&pin_PB31, // Backlight pin
117+
NO_BRIGHTNESS_COMMAND,
118+
1.0f, // brightness (ignored)
119+
true, // auto_brightness
120+
false, // single_byte_bounds
121+
false); // data_as_commands
122+
}
123+
124+
bool board_requests_safe_mode(void) {
125+
return false;
126+
}
127+
128+
void reset_board(void) {
129+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#define MICROPY_HW_BOARD_NAME "Adafruit PyPortal Titano"
2+
#define MICROPY_HW_MCU_NAME "samd51j20"
3+
4+
#define CIRCUITPY_MCU_FAMILY samd51
5+
6+
7+
#define MICROPY_HW_LED_STATUS (&pin_PA27)
8+
9+
#define MICROPY_HW_NEOPIXEL (&pin_PB22)
10+
11+
// These are pins not to reset.
12+
// QSPI Data pins
13+
#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 )
14+
// QSPI CS, and QSPI SCK
15+
#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 )
16+
#define MICROPY_PORT_C ( 0 )
17+
#define MICROPY_PORT_D (0)
18+
19+
#define AUTORESET_DELAY_MS 500
20+
21+
// If you change this, then make sure to update the linker scripts as well to
22+
// make sure you don't overwrite code
23+
#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
24+
25+
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
26+
27+
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
28+
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
29+
30+
#define DEFAULT_SPI_BUS_SCK (&pin_PA13)
31+
#define DEFAULT_SPI_BUS_MOSI (&pin_PA12)
32+
#define DEFAULT_SPI_BUS_MISO (&pin_PA14)
33+
34+
#define DEFAULT_UART_BUS_RX (&pin_PB13)
35+
#define DEFAULT_UART_BUS_TX (&pin_PB12)
36+
37+
// USB is always used internally so skip the pin objects for it.
38+
#define IGNORE_PIN_PA24 1
39+
#define IGNORE_PIN_PA25 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
LD_FILE = boards/samd51x20-bootloader-external-flash.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x8054
4+
USB_PRODUCT = "PyPortal Titano"
5+
USB_MANUFACTURER = "Adafruit Industries LLC"
6+
7+
CHIP_VARIANT = SAMD51J20A
8+
CHIP_FAMILY = samd51
9+
10+
QSPI_FLASH_FILESYSTEM = 1
11+
EXTERNAL_FLASH_DEVICE_COUNT = 2
12+
EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C"
13+
LONGINT_IMPL = MPZ
14+
15+
# No touch on SAMD51 yet
16+
CIRCUITPY_TOUCHIO = 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
#include "boards/board.h"
4+
#include "shared-module/displayio/__init__.h"
5+
6+
// This mapping only includes functional names because pins broken
7+
// out on connectors are labeled with their MCU name available from
8+
// microcontroller.pin.
9+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
10+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_PA02) },
11+
{ MP_OBJ_NEW_QSTR(MP_QSTR_AUDIO_OUT), MP_ROM_PTR(&pin_PA02) },
12+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, // analog out/in
13+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_PA27) },
14+
15+
// Light sensor
16+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_PA07) },
17+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA07) },
18+
19+
// STEMMA connectors
20+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA04) },
21+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) },
22+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA05) },
23+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) },
24+
25+
// Indicator LED
26+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PB23) },
27+
{ MP_OBJ_NEW_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_PB23) },
28+
29+
{ MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL),MP_ROM_PTR(&pin_PB22) },
30+
31+
// LCD pins
32+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_PA00) },
33+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_RD), MP_ROM_PTR(&pin_PB04) },
34+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_RS), MP_ROM_PTR(&pin_PB05) },
35+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_PB06) },
36+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_TE), MP_ROM_PTR(&pin_PB07) },
37+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_WR), MP_ROM_PTR(&pin_PB09) },
38+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_PB09) },
39+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_PB31) },
40+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA0), MP_ROM_PTR(&pin_PA16) },
41+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA1), MP_ROM_PTR(&pin_PA17) },
42+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA2), MP_ROM_PTR(&pin_PA18) },
43+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA3), MP_ROM_PTR(&pin_PA19) },
44+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA4), MP_ROM_PTR(&pin_PA20) },
45+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA5), MP_ROM_PTR(&pin_PA21) },
46+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA6), MP_ROM_PTR(&pin_PA22) },
47+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LCD_DATA7), MP_ROM_PTR(&pin_PA23) },
48+
49+
// Touch pins
50+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TOUCH_YD), MP_ROM_PTR(&pin_PB00) },
51+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TOUCH_XL), MP_ROM_PTR(&pin_PB01) },
52+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TOUCH_YU), MP_ROM_PTR(&pin_PA06) },
53+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TOUCH_XR), MP_ROM_PTR(&pin_PB08) },
54+
55+
// ESP control
56+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_CS), MP_ROM_PTR(&pin_PB14) },
57+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_GPIO0), MP_ROM_PTR(&pin_PB15) },
58+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_BUSY), MP_ROM_PTR(&pin_PB16) },
59+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RESET), MP_ROM_PTR(&pin_PB17) },
60+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ESP_RTS), MP_ROM_PTR(&pin_PA15) },
61+
62+
// UART
63+
{ MP_OBJ_NEW_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB12) },
64+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB13) },
65+
66+
// SPI
67+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MOSI),MP_ROM_PTR(&pin_PA12) },
68+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCK),MP_ROM_PTR(&pin_PA13) },
69+
{ MP_OBJ_NEW_QSTR(MP_QSTR_MISO),MP_ROM_PTR(&pin_PA14) },
70+
71+
// I2C
72+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_PB02) },
73+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_PB03) },
74+
75+
// SD Card
76+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_CS),MP_ROM_PTR(&pin_PB30) },
77+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_CARD_DETECT),MP_ROM_PTR(&pin_PA01) },
78+
79+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
80+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
81+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
82+
83+
// TFT control pins
84+
{MP_OBJ_NEW_QSTR(MP_QSTR_TFT_LITE), MP_ROM_PTR(&pin_PB31)},
85+
{MP_OBJ_NEW_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_PA12)},
86+
{MP_OBJ_NEW_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_PA13)},
87+
{MP_OBJ_NEW_QSTR(MP_QSTR_TFT_MISO), MP_ROM_PTR(&pin_PA14)},
88+
{MP_OBJ_NEW_QSTR(MP_QSTR_TFT_RST), MP_ROM_PTR(&pin_PA00)},
89+
{MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_PB06)},
90+
{MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_PB05)},
91+
92+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
93+
};
94+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

0 commit comments

Comments
 (0)