Skip to content

Commit 8f6eac9

Browse files
author
brentru
committed
add defs for pyportal titano
1 parent 47a0b7c commit 8f6eac9

File tree

5 files changed

+251
-1
lines changed

5 files changed

+251
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
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:
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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-module/displayio/__init__.h"
32+
#include "shared-module/displayio/mipi_constants.h"
33+
34+
#include "tick.h"
35+
36+
#define DELAY 0x80
37+
38+
uint8_t display_init_sequence[] = {
39+
0xEF, 3, 0x03, 0x80, 0x02,
40+
0xCF, 3, 0x00, 0xC1, 0x30,
41+
0xED, 4, 0x64, 0x03, 0x12, 0x81,
42+
0xE8, 3, 0x85, 0x00, 0x78,
43+
0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02,
44+
0xF7, 1, 0x20,
45+
0xEA, 2, 0x00, 0x00,
46+
0xc0, 1, 0x23, // Power control VRH[5:0]
47+
0xc1, 1, 0x10, // Power control SAP[2:0];BT[3:0]
48+
0xc5, 2, 0x3e, 0x28, // VCM control
49+
0xc7, 1, 0x86, // VCM control2
50+
0x36, 1, 0xa8, // Memory Access Control
51+
0x37, 1, 0x00, // Vertical scroll zero
52+
0x3a, 1, 0x55, // COLMOD: Pixel Format Set
53+
0xb1, 2, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors)
54+
0xb6, 3, 0x08, 0xa2, 0x27, // Display Function Control
55+
0xF2, 1, 0x00, // 3Gamma Function Disable
56+
0x26, 1, 0x01, // Gamma curve selected
57+
0xe0, 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma
58+
0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00,
59+
0xe1, 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma
60+
0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F,
61+
0x11, DELAY, 120, // Exit Sleep
62+
0x29, DELAY, 120, // Display on
63+
};
64+
65+
void board_init(void) {
66+
displayio_parallelbus_obj_t* bus = &displays[0].parallel_bus;
67+
bus->base.type = &displayio_parallelbus_type;
68+
common_hal_displayio_parallelbus_construct(bus,
69+
&pin_PA16, // Data0
70+
&pin_PB05, // Command or data
71+
&pin_PB06, // Chip select
72+
&pin_PB09, // Write
73+
&pin_PB04, // Read
74+
&pin_PA00); // Reset
75+
76+
displayio_display_obj_t* display = &displays[0].display;
77+
display->base.type = &displayio_display_type;
78+
common_hal_displayio_display_construct(display,
79+
bus,
80+
320, // Width
81+
240, // Height
82+
0, // column start
83+
0, // row start
84+
0, // rotation
85+
16, // Color depth
86+
false, // grayscale
87+
false, // pixels_in_byte_share_row (unused for depths > 8)
88+
1, // bytes per cell. Only valid for depths < 8
89+
false, // reverse_pixels_in_byte. Only valid for depths < 8
90+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
91+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
92+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
93+
0x37, // Set vertical scroll command
94+
display_init_sequence,
95+
sizeof(display_init_sequence),
96+
&pin_PB31, // Backlight pin
97+
NO_BRIGHTNESS_COMMAND,
98+
1.0f, // brightness (ignored)
99+
true, // auto_brightness
100+
false, // single_byte_bounds
101+
false); // data_as_commands
102+
}
103+
104+
bool board_requests_safe_mode(void) {
105+
return false;
106+
}
107+
108+
void reset_board(void) {
109+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
// This is for Rev B
7+
8+
#define MICROPY_HW_LED_STATUS (&pin_PA27)
9+
10+
#define MICROPY_HW_NEOPIXEL (&pin_PB22)
11+
12+
// These are pins not to reset.
13+
// QSPI Data pins
14+
#define MICROPY_PORT_A ( PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11 )
15+
// QSPI CS, and QSPI SCK
16+
#define MICROPY_PORT_B ( PORT_PB10 | PORT_PB11 | PORT_PB22 )
17+
#define MICROPY_PORT_C ( 0 )
18+
#define MICROPY_PORT_D (0)
19+
20+
#define AUTORESET_DELAY_MS 500
21+
22+
// If you change this, then make sure to update the linker scripts as well to
23+
// make sure you don't overwrite code
24+
#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
25+
26+
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
27+
28+
#define DEFAULT_I2C_BUS_SCL (&pin_PB03)
29+
#define DEFAULT_I2C_BUS_SDA (&pin_PB02)
30+
31+
#define DEFAULT_SPI_BUS_SCK (&pin_PA13)
32+
#define DEFAULT_SPI_BUS_MOSI (&pin_PA12)
33+
#define DEFAULT_SPI_BUS_MISO (&pin_PA14)
34+
35+
#define DEFAULT_UART_BUS_RX (&pin_PB13)
36+
#define DEFAULT_UART_BUS_TX (&pin_PB12)
37+
38+
// USB is always used internally so skip the pin objects for it.
39+
#define IGNORE_PIN_PA24 1
40+
#define IGNORE_PIN_PA25 1
Lines changed: 16 additions & 0 deletions
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
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
84+
};
85+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

0 commit comments

Comments
 (0)