Skip to content

Commit 9993a99

Browse files
committed
Add initial Monster M4SK build
1 parent 2497cbe commit 9993a99

7 files changed

Lines changed: 203 additions & 2 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ env:
3535
- TRAVIS_BOARDS="itsybitsy_m0_express metro_m0_express pirkey_m0 pyruler trinket_m0 trinket_m0_haxpress arduino_mkr1300 arduino_mkrzero arduino_zero bast_pro_mini_m0 catwan_usbstick datum_distance datum_imu datum_weather" TRAVIS_SDK=arm
3636
- TRAVIS_BOARDS="escornabot_makech meowmeow pewpew10 robohatmm1_m0 snekboard sparkfun_lumidrive sparkfun_redboard_turbo sparkfun_samd21_dev sparkfun_samd21_mini uchip ugame10" TRAVIS_SDK=arm
3737
# Adafruit SAMD51 (M4) + Other SAMD51
38-
- TRAVIS_BOARDS="feather_m4_express grandcentral_m4_express itsybitsy_m4_express metro_m4_airlift_lite metro_m4_express pybadge pybadge_airlift pygamer pygamer_advance" TRAVIS_SDK=arm
38+
- TRAVIS_BOARDS="feather_m4_express grandcentral_m4_express itsybitsy_m4_express metro_m4_airlift_lite metro_m4_express pybadge pybadge_airlift pygamer pygamer_advance monster_m4sk" TRAVIS_SDK=arm
3939
- TRAVIS_BOARDS="pyportal pyportal_titano trellis_m4_express capablerobot_usbhub cp32-m4 datalore_ip_m4 datum_light kicksat-sprite mini_sam_m4 robohatmm1_m4 sam32" TRAVIS_SDK=arm
4040

4141

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
#include "shared-bindings/busio/SPI.h"
31+
#include "shared-bindings/displayio/FourWire.h"
32+
#include "shared-module/displayio/__init__.h"
33+
#include "shared-module/displayio/mipi_constants.h"
34+
#include "tick.h"
35+
36+
displayio_fourwire_obj_t board_display_obj;
37+
38+
#define DELAY 0x80
39+
40+
uint8_t display_init_sequence[] = {
41+
0x01, 0 | DELAY, 150, // SWRESET
42+
0x11, 0 | DELAY, 255, // SLPOUT
43+
0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order.
44+
0x3a, 1, 0x55, // COLMOD - 16bit color
45+
0x38, 0, // Idle mode off
46+
0x21, 0, // _INVON
47+
0x13, 0, // _NORON
48+
0x29, 0 | DELAY, 255 // _DISPON
49+
};
50+
51+
void board_init(void) {
52+
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
53+
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL);
54+
common_hal_busio_spi_never_reset(spi);
55+
56+
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
57+
bus->base.type = &displayio_fourwire_type;
58+
common_hal_displayio_fourwire_construct(bus,
59+
spi,
60+
&pin_PA07, // TFT_DC Command or data
61+
&pin_PA06, // TFT_CS Chip select
62+
&pin_PA04, // TFT_RST Reset
63+
60000000);
64+
65+
displayio_display_obj_t* display = &displays[0].display;
66+
display->base.type = &displayio_display_type;
67+
common_hal_displayio_display_construct(display,
68+
bus,
69+
240, // Width (after rotation)
70+
240, // Height (after rotation)
71+
0, // column start
72+
0, // row start
73+
180, // rotation
74+
16, // Color depth
75+
false, // Grayscale
76+
false, // pixels in a byte share a row. Only valid for depths < 8
77+
1, // bytes per cell. Only valid for depths < 8
78+
false, // reverse_pixels_in_byte. Only valid for depths < 8
79+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
80+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
81+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
82+
0x37, // set vertical scroll command
83+
display_init_sequence,
84+
sizeof(display_init_sequence),
85+
&pin_PA23, // backlight pin
86+
NO_BRIGHTNESS_COMMAND,
87+
1.0f, // brightness (ignored)
88+
true, // auto_brightness
89+
false, // single_byte_bounds
90+
false, // data_as_commands
91+
true, // auto_refresh
92+
60); // native_frames_per_second
93+
}
94+
95+
bool board_requests_safe_mode(void) {
96+
return false;
97+
}
98+
99+
void reset_board(void) {
100+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#define MICROPY_HW_BOARD_NAME "Adafruit Monster M4SK"
2+
#define MICROPY_HW_MCU_NAME "samd51j19"
3+
4+
#define CIRCUITPY_MCU_FAMILY samd51
5+
6+
#define MICROPY_HW_LED_STATUS (&pin_PA27)
7+
8+
// These are pins not to reset.
9+
// QSPI Data pins
10+
#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11)
11+
// DotStar pins, QSPI CS, and QSPI SCK
12+
#define MICROPY_PORT_B (PORT_PB10 | PORT_PB11)
13+
#define MICROPY_PORT_C (0)
14+
#define MICROPY_PORT_D (0)
15+
16+
#define AUTORESET_DELAY_MS 500
17+
18+
// If you change this, then make sure to update the linker scripts as well to
19+
// make sure you don't overwrite code
20+
#define CIRCUITPY_INTERNAL_NVM_SIZE 8192
21+
22+
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
23+
24+
#define DEFAULT_I2C_BUS_SCL (&pin_PA01)
25+
#define DEFAULT_I2C_BUS_SDA (&pin_PA00)
26+
27+
// USB is always used internally so skip the pin objects for it.
28+
#define IGNORE_PIN_PA24 1
29+
#define IGNORE_PIN_PA25 1
30+
31+
#define CIRCUITPY_FS_NAME "MONSTERM4SK"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
LD_FILE = boards/samd51x19-bootloader-external-flash.ld
2+
USB_VID = 0x239A
3+
USB_PID = 0x8048
4+
USB_PRODUCT = "Monster M4SK"
5+
USB_MANUFACTURER = "Adafruit Industries LLC"
6+
7+
CHIP_VARIANT = SAMD51J19A
8+
CHIP_FAMILY = samd51
9+
10+
QSPI_FLASH_FILESYSTEM = 1
11+
EXTERNAL_FLASH_DEVICE_COUNT = 1
12+
EXTERNAL_FLASH_DEVICES = GD25Q64C
13+
LONGINT_IMPL = MPZ
14+
15+
CIRCUITPY_AUDIOIO = 1
16+
CIRCUITPY_DISPLAYIO = 1
17+
# No touch on SAMD51 yet
18+
CIRCUITPY_TOUCHIO = 0
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
#include "boards/board.h"
4+
#include "shared-module/displayio/__init__.h"
5+
6+
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
7+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_PA02) },
8+
{ MP_OBJ_NEW_QSTR(MP_QSTR_HEADPHONE_LEFT), MP_ROM_PTR(&pin_PA02) },
9+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
10+
{ MP_OBJ_NEW_QSTR(MP_QSTR_HEADPHONE_RIGHT), MP_ROM_PTR(&pin_PA05) },
11+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) },
12+
13+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB03) },
14+
{ MP_OBJ_NEW_QSTR(MP_QSTR_NOSE), MP_ROM_PTR(&pin_PB03) },
15+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB02) },
16+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA27) },
17+
18+
// I2C
19+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA00) },
20+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA01) },
21+
22+
{ MP_OBJ_NEW_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_PA22) },
23+
24+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_PA14) },
25+
26+
{ MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_PA16) },
27+
{ MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_PA17) },
28+
29+
// Right TFT control pins
30+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RIGHT_TFT_LITE), MP_ROM_PTR(&pin_PA23) },
31+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RIGHT_TFT_MOSI), MP_ROM_PTR(&pin_PA12) },
32+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RIGHT_TFT_SCK), MP_ROM_PTR(&pin_PA13) },
33+
{ MP_OBJ_NEW_QSTR(MP_QSTR_RIGHT_TFT_RST), MP_ROM_PTR(&pin_PA04) },
34+
{ MP_ROM_QSTR(MP_QSTR_RIGHT_TFT_CS), MP_ROM_PTR(&pin_PA06) },
35+
{ MP_ROM_QSTR(MP_QSTR_RIGHT_TFT_DC), MP_ROM_PTR(&pin_PA07) },
36+
37+
// Left TFT control pins. Some pins are attached through the SeeSaw chip.
38+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LEFT_TFT_MOSI), MP_ROM_PTR(&pin_PB02) },
39+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LEFT_TFT_SCK), MP_ROM_PTR(&pin_PB03) },
40+
{ MP_ROM_QSTR(MP_QSTR_LEFT_TFT_CS), MP_ROM_PTR(&pin_PB23) },
41+
{ MP_ROM_QSTR(MP_QSTR_LEFT_TFT_DC), MP_ROM_PTR(&pin_PB22) },
42+
43+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
44+
45+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
46+
{ MP_ROM_QSTR(MP_QSTR_RIGHT_DISPLAY), MP_ROM_PTR(&displays[0].display)}
47+
};
48+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

py/circuitpy_mpconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,4 +657,8 @@ void run_background_tasks(void);
657657
#define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000
658658
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
659659

660+
#ifndef CIRCUITPY_FS_NAME
661+
#define CIRCUITPY_FS_NAME "CIRCUITPY"
662+
#endif
663+
660664
#endif // __INCLUDED_MPCONFIG_CIRCUITPY_H

supervisor/shared/filesystem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void filesystem_init(bool create_allowed, bool force_create) {
9191
}
9292

9393
// set label
94-
f_setlabel(&vfs_fat->fatfs, "CIRCUITPY");
94+
f_setlabel(&vfs_fat->fatfs, CIRCUITPY_FS_NAME);
9595

9696
// inhibit file indexing on MacOS
9797
f_mkdir(&vfs_fat->fatfs, "/.fseventsd");

0 commit comments

Comments
 (0)