10000 Merge pull request #7962 from tannewt/inky_frame_5_7 · tannewt/circuitpython@827eaeb · GitHub
[go: up one dir, main page]

Skip to content

Commit 827eaeb

Browse files
authored
Merge pull request micropython#7962 from tannewt/inky_frame_5_7
Add Pimoroni Inky Frame 5.7
2 parents ca01200 + cbfb2d0 commit 827eaeb

File tree

9 files changed

+224
-14
lines changed

9 files changed

+224
-14
lines changed

main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,10 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) {
666666
#endif
667667
{
668668
// Refresh the ePaper display if we have one. That way it'll show an error message.
669+
// Skip if we're about to autoreload. Otherwise we may delay when user code can update
670+
// the display.
669671
#if CIRCUITPY_DISPLAYIO
670-
if (time_to_epaper_refresh > 0) {
672+
if (time_to_epaper_refresh > 0 && !autoreload_pending()) {
671673
time_to_epaper_refresh = maybe_refresh_epaperdisplay();
672674
}
673675

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+
29+
#include "mpconfigboard.h"
30+
#include "shared-bindings/busio/SPI.h"
31+
#include "shared-bindings/displayio/FourWire.h"
32+
#include "shared-bindings/microcontroller/Pin.h"
33+
#include "shared-module/displayio/__init__.h"
34+
#include "shared-bindings/board/__init__.h"
35+
#include "supervisor/shared/board.h"
36+
37+
#define DELAY 0x80
38+
39+
// This is an SPD1656 control chip. The display is a 5.7" ACeP EInk.
40+
41+
const uint8_t display_start_sequence[] = {
42+
0x01, 4, 0x37, 0x00, 0x23, 0x23, // power setting
43+
0x00, 2, 0xef, 0x08, // panel setting (PSR)
44+
0x03, 1, 0x00, // PFS
45+
0x06, 3, 0xc7, 0xc7, 0x1d, // booster
46+
0x30, 1, 0x3c, // PLL setting
47+
0x41, 1, 0x00, // TSE
48+
0x50, 1, 0x37, // vcom and data interval setting
49+
0x60, 1, 0x22, // tcon setting
50+
0x61, 4, 0x02, 0x58, 0x01, 0xc0, // tres
51+
0xe3, 1, 0xaa, // PWS
52+
0x04, DELAY | 0, 0xc8, // VCM DC and delay 200ms
53+
};
54+
55+
const uint8_t display_stop_sequence[] = {
56+
0x02, 1, 0x00, // power off
57+
0x07, 1, 0xa5 // deep sleep
58+
};
59+
60+
const uint8_t refresh_sequence[] = {
61+
0x12, 0x00
62+
};
63+
64+
void board_init(void) {
65+
displayio_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
66+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
67+
68+
bus->base.type = &displayio_fourwire_type;
69+
common_hal_displayio_fourwire_construct(bus,
70+
spi,
71+
&pin_GPIO28, // EPD_DC Command or data
72+
&pin_GPIO17, // EPD_CS Chip select
73+
&pin_GPIO27, // EPD_RST Reset
74+
1000000, // Baudrate
75+
0, // Polarity
76+
0); // Phase
77+
78+
displayio_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
79+
display->base.type = &displayio_epaperdisplay_type;
80+
common_hal_displayio_epaperdisplay_construct(
81+
display,
82+
bus,
83+
display_start_sequence, sizeof(display_start_sequence),
84+
1.0, // start up time
85+
display_stop_sequence, sizeof(display_stop_sequence),
86+
600, // width
87+
448, // height
88+
640, // ram_width
89+
480, // ram_height
90+
0, // colstart
91+
0, // rowstart
92+
180, // rotation
93+
NO_COMMAND, // set_column_window_command
94+
NO_COMMAND, // set_row_window_command
95+
NO_COMMAND, // set_current_column_command
96+
NO_COMMAND, // set_current_row_command
97+
0x10, // write_black_ram_command
98+
false, // black_bits_inverted
99+
NO_COMMAND, // write_color_ram_command
100+
false, // color_bits_inverted
101+
0x000000, // highlight_color
102+
refresh_sequence, sizeof(refresh_sequence),
103+
28.0, // refresh_time
104+
NULL, // busy_pin
105+
false, // busy_state
106+
30.0, // seconds_per_frame
107+
false, // always_toggle_chip_select
108+
false, // grayscale
109+
true, // acep
110+
false, // two_byte_sequence_length
111+
false); // address_little_endian
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#define MICROPY_HW_BOARD_NAME "Pimoroni Inky Frame 5.7"
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_GPIO6)
8+
9+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4)
10+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO5)
11+
12+
#define DEFAULT_UART_BUS_TX (&pin_GPIO0)
13+
#define DEFAULT_UART_BUS_RX (&pin_GPIO1)
14+
15+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18)
16+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19)
17+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO16)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
USB_VID = 0x2E8A
2+
USB_PID = 0x1018
3+
USB_PRODUCT = "Inky Frame 5.7"
4+
USB_MANUFACTURER = "Pimoroni"
5+
6+
CHIP_VARIANT = RP2040
7+
CHIP_FAMILY = rp2
8+
9+
EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ"
10+
11+
CIRCUITPY__EVE = 1
12+
13+
CIRCUITPY_CYW43 = 1
14+
CIRCUITPY_SSL = 1
15+
CIRCUITPY_SSL_MBEDTLS = 1
16+
CIRCUITPY_HASHLIB = 1
17+
CIRCUITPY_WEB_WORKFLOW = 1
18+
CIRCUITPY_MDNS = 1
19+
CIRCUITPY_SOCKETPOOL = 1
20+
CIRCUITPY_WIFI = 1
21+
22+
CFLAGS += -DCYW43_PIN_WL_HOST_WAKE=24 -DCYW43_PIN_WL_REG_ON=23 -DCYW43_WL_GPIO_COUNT=3 -DCYW43_WL_GPIO_LED_PIN=0
23+
# Must be accompanied by a linker script change
24+
CFLAGS += -DCIRCUITPY_FIRMWARE_SIZE='(1536 * 1024)'
25+
26+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
#include "supervisor/board.h"
4+
#include "shared-module/displayio/__init__.h"
5+
6+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
7+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
8+
9+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) },
10+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) },
11+
{ MP_ROM_QSTR(MP_QSTR_HOLD_SYS_EN), MP_ROM_PTR(&pin_GPIO2) },
12+
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_GPIO3) },
13+
14+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) },
15+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) },
16+
17+
{ MP_ROM_QSTR(MP_QSTR_LED_ACT), MP_ROM_PTR(&pin_GPIO6) },
18+
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO6) },
19+
{ MP_ROM_QSTR(MP_QSTR_LED_CONN), MP_ROM_PTR(&pin_GPIO7) },
20+
{ MP_ROM_QSTR(MP_QSTR_SWITCH_CLK), MP_ROM_PTR(&pin_GPIO8) },
21+
{ MP_ROM_QSTR(MP_QSTR_SWITCH_LATCH), MP_ROM_PTR(&pin_GPIO9) },
22+
{ MP_ROM_QSTR(MP_QSTR_SWITCH_OUT), MP_ROM_PTR(&pin_GPIO10) },
23+
{ MP_ROM_QSTR(MP_QSTR_LED_A), MP_ROM_PTR(&pin_GPIO11) },
24+
{ MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_GPIO12) },
25+
{ MP_ROM_QSTR(MP_QSTR_LED_C), MP_ROM_PTR(&pin_GPIO13) },
26+
{ MP_ROM_QSTR(MP_QSTR_LED_D), MP_ROM_PTR(&pin_GPIO14) },
27+
{ MP_ROM_QSTR(MP_QSTR_LED_E), MP_ROM_PTR(&pin_GPIO15) },
28+
29+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO16) },
30+
{ MP_ROM_QSTR(MP_QSTR_INKY_CS), MP_ROM_PTR(&pin_GPIO17) },
31+
{ MP_ROM_QSTR(MP_QSTR_SCLK), MP_ROM_PTR(&pin_GPIO18) },
32+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO19) },
33+
{ MP_ROM_QSTR(MP_QSTR_SD_DAT1), MP_ROM_PTR(&pin_GPIO20) },
34+
{ MP_ROM_QSTR(MP_QSTR_SD_DAT2), MP_ROM_PTR(&pin_GPIO21) },
35+
{ MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO22) },
36+
37+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) },
38+
39+
{ MP_ROM_QSTR( 10000 MP_QSTR_INKY_RES), MP_ROM_PTR(&pin_GPIO27) },
40+
{ MP_ROM_QSTR(MP_QSTR_INKY_DC), MP_ROM_PTR(&pin_GPIO28) },
41+
42+
{ MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_CYW1) },
43+
{ MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_CYW2) },
44+
45+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
46+
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
47+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
48+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
49+
50+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)},
51+
};
52+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/raspberrypi/supervisor/port.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,23 @@ safe_mode_t port_init(void) {
104104
_binary_info();
105105
// Set brown out.
106106

107+
// Load from the XIP memory space that doesn't cache. That way we don't
108+
// evict anything else. The code we're loading is linked to the RAM address
109+
// anyway.
110+
size_t nocache = 0x03000000;
111+
107112
// Copy all of the "tightly coupled memory" code and data to run from RAM.
108113
// This lets us use the 16k cache for dynamically used data and code.
109114
// We must do this before we try and call any of its code or load the data.
115+
uint32_t *itcm_flash_copy = (uint32_t *)(((size_t)&_ld_itcm_flash_copy) | nocache);
110116
for (uint32_t i = 0; i < ((size_t)&_ld_itcm_size) / 4; i++) {
111-
(&_ld_itcm_destination)[i] = (&_ld_itcm_flash_copy)[i];
112-
// Now zero it out to evict the line from the XIP cache. Without this,
113-
// it'll stay in the XIP cache anyway.
114-
(&_ld_itcm_flash_copy)[i] = 0x0;
117+
(&_ld_itcm_destination)[i] = itcm_flash_copy[i];
115118
}
116119

117120
// Copy all of the data to run from DTCM.
121+
uint32_t *dtcm_flash_copy = (uint32_t *)(((size_t)&_ld_dtcm_data_flash_copy) | nocache);
118122
for (uint32_t i = 0; i < ((size_t)&_ld_dtcm_data_size) / 4; i++) {
119-
(&_ld_dtcm_data_destination)[i] = (&_ld_dtcm_data_flash_copy)[i];
120-
// Now zero it out to evict the line from the XIP cache. Without this,
121-
// it'll stay in the XIP cache anyway.
122-
(&_ld_dtcm_data_flash_copy)[i] = 0x0;
123+
(&_ld_dtcm_data_destination)[i] = dtcm_flash_copy[i];
123124
}
124125

125126
// Clear DTCM bss.

tools/cortex-m-fault-gdb.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ def _armv6m_fault(self):
4545
print("vtor", hex(vtor))
4646

4747
icsr = self._read(ICSR)
48-
if (icsr & (1 << 23)) != 0:
49-
print("No preempted exceptions")
50-
else:
51-
print("Another exception was preempted")
5248
vectactive = icsr & 0x1FF
53-
print(hex(icsr), vectactive)
49+
print("icsr", hex(icsr), vectactive)
5450
if vectactive != 0:
5551
if vectactive in EXCEPTIONS:
5652
vectactive = EXCEPTIONS[vectactive]

0 commit comments

Comments
 (0)
0