Skip to content

Commit 4c6ef4e

Browse files
authored
Merge pull request #10114 from tannewt/fruit_jam_usb
Improve Fruit Jam
2 parents e8de36a + b14672c commit 4c6ef4e

File tree

26 files changed

+365
-60
lines changed

26 files changed

+365
-60
lines changed

.gitmodules

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@
345345
url = https://github.com/adafruit/Adafruit_CircuitPython_Wave.git
346346
[submodule "ports/raspberrypi/lib/Pico-PIO-USB"]
347347
path = ports/raspberrypi/lib/Pico-PIO-USB
348-
url = https://github.com/adafruit/Pico-PIO-USB.git
348+
url = https://github.com/tannewt/Pico-PIO-USB.git
349+
branch = better_timeouts
349350
[submodule "lib/micropython-lib"]
350351
path = lib/micropython-lib
351352
url = https://github.com/micropython/micropython-lib.git

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,30 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(BASEOPTS)
4040
# the i18n builder cannot share the environment and doctrees with the others
4141
I18NSPHINXOPTS = $(BASEOPTS)
4242

43-
TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/analog ports/cxd56 ports/espressif ports/mimxrt10xx ports/nordic ports/raspberrypi ports/renode ports/stm py shared-bindings shared-module supervisor
43+
TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/analog ports/cxd56 ports/espressif ports/mimxrt10xx ports/nordic ports/raspberrypi ports/renode ports/stm ports/zephyr-cp py shared-bindings shared-module supervisor
4444
# Paths to exclude from TRANSLATE_SOURCES
4545
# Each must be preceded by "-path"; if any wildcards, enclose in quotes.
4646
# Separate by "-o" (Find's "or" operand)
4747
TRANSLATE_SOURCES_EXC = -path "ports/*/build-*" \
4848
-o -path "ports/*/build" \
49+
-o -path ports/analog/msdk \
4950
-o -path ports/atmel-samd/asf4 \
5051
-o -path ports/cxd56/spresense-exported-sdk \
52+
-o -path ports/espressif/esp-camera \
5153
-o -path ports/espressif/esp-idf \
54+
-o -path ports/espressif/esp-protocols \
5255
-o -path ports/mimxrt10xx/sdk \
56+
-o -path ports/nordic/bluetooth \
57+
-o -path ports/nordic/nrfx \
58+
-o -path ports/raspberrypi/lib \
5359
-o -path ports/raspberrypi/sdk \
60+
-o -path ports/stm/peripherals \
5461
-o -path ports/stm/st_driver \
55-
-o -path lib/tinyusb \
56-
-o -path lib/lwip \
62+
-o -path ports/zephyr-cp/bootloader \
63+
-o -path ports/zephyr-cp/modules \
64+
-o -path ports/zephyr-cp/tools \
65+
-o -path ports/zephyr-cp/zephyr \
66+
-o -path lib \
5767
-o -path extmod/ulab/circuitpython \
5868
-o -path extmod/ulab/micropython \
5969

lib/tinyusb

Submodule tinyusb updated 105 files

locale/circuitpython.pot

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ msgstr ""
102102
msgid "%q failure: %d"
103103
msgstr ""
104104

105-
#: py/argcheck.c
105+
#: py/argcheck.c shared-module/audiofilters/Filter.c
106106
msgid "%q in %q must be of type %q, not %q"
107107
msgstr ""
108108

@@ -187,10 +187,6 @@ msgstr ""
187187
msgid "%q must be >= %d"
188188
msgstr ""
189189

190-
#: shared-module/audiofilters/Filter.c
191-
msgid "%q must be a %q object, %q, or %q"
192-
msgstr ""
193-
194190
#: shared-bindings/analogbufio/BufferedIn.c
195191
msgid "%q must be a bytearray or array of type 'H' or 'B'"
196192
msgstr ""
@@ -218,6 +214,7 @@ msgstr ""
218214
#: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c
219215
#: shared-bindings/bitmapfilter/__init__.c shared-bindings/canio/CAN.c
220216
#: shared-bindings/digitalio/Pull.c shared-bindings/supervisor/__init__.c
217+
#: shared-module/audiofilters/Filter.c shared-module/displayio/__init__.c
221218
#: shared-module/synthio/Biquad.c shared-module/synthio/Synthesizer.c
222219
msgid "%q must be of type %q or %q, not %q"
223220
msgstr ""
@@ -542,7 +539,6 @@ msgstr ""
542539
#: ports/nordic/common-hal/pulseio/PulseIn.c
543540
#: ports/nordic/peripherals/nrf/timers.c
544541
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
545-
#: ports/stm/peripherals/timers.c
546542
msgid "All timers in use"
547543
msgstr ""
548544

@@ -568,6 +564,7 @@ msgstr ""
568564

569565
#: ports/espressif/common-hal/wifi/Radio.c
570566
#: ports/raspberrypi/common-hal/wifi/Radio.c
567+
#: ports/zephyr-cp/common-hal/wifi/Radio.c
571568
msgid "Already scanning for wifi networks"
572569
msgstr ""
573570

@@ -875,10 +872,6 @@ msgstr ""
875872
msgid "Data 0 pin must be byte aligned"
876873
msgstr ""
877874

878-
#: shared-module/audiocore/WaveFile.c
879-
msgid "Data chunk must follow fmt chunk"
880-
msgstr ""
881-
882875
#: shared-module/jpegio/JpegDecoder.c
883876
msgid "Data format error (may be broken data)"
884877
msgstr ""
@@ -1042,6 +1035,10 @@ msgstr ""
10421035
msgid "Failed to release mutex, err 0x%04x"
10431036
msgstr ""
10441037

1038+
#: ports/zephyr-cp/common-hal/wifi/Radio.c
1039+
msgid "Failed to set hostname"
1040+
msgstr ""
1041+
10451042
#: ports/espressif/common-hal/audioio/AudioOut.c
10461043
msgid "Failed to start async audio"
10471044
msgstr ""
@@ -1193,6 +1190,7 @@ msgid "Insufficient stream input buffer"
11931190
msgstr ""
11941191

11951192
#: ports/espressif/common-hal/wifi/Radio.c
1193+
#: ports/zephyr-cp/common-hal/wifi/Radio.c
11961194
msgid "Interface must be started"
11971195
msgstr ""
11981196

@@ -1312,6 +1310,7 @@ msgid "Invalid hex password"
13121310
msgstr ""
13131311

13141312
#: ports/espressif/common-hal/wifi/Radio.c
1313+
#: ports/zephyr-cp/common-hal/wifi/Radio.c
13151314
msgid "Invalid multicast MAC address"
13161315
msgstr ""
13171316

@@ -1414,7 +1413,8 @@ msgstr ""
14141413
msgid "Mount point directory missing"
14151414
msgstr ""
14161415

1417-
#: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c
1416+
#: ports/zephyr-cp/bindings/zephyr_serial/UART.c shared-bindings/busio/UART.c
1417+
#: shared-bindings/displayio/Group.c
14181418
msgid "Must be a %q subclass."
14191419
msgstr ""
14201420

@@ -1653,13 +1653,6 @@ msgstr ""
16531653
msgid "Only int or string supported for ip"
16541654
msgstr ""
16551655

1656-
#: shared-module/displayio/OnDiskBitmap.c
1657-
#, c-format
1658-
msgid ""
1659-
"Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: "
1660-
"%d bpp given"
1661-
msgstr ""
1662-
16631656
#: ports/espressif/common-hal/alarm/touch/TouchAlarm.c
16641657
msgid "Only one %q can be set in deep sleep."
16651658
msgstr ""
@@ -1710,6 +1703,7 @@ msgstr ""
17101703

17111704
#: ports/espressif/common-hal/socketpool/Socket.c
17121705
#: ports/raspberrypi/common-hal/socketpool/Socket.c
1706+
#: ports/zephyr-cp/common-hal/socketpool/Socket.c
17131707
msgid "Out of sockets"
17141708
msgstr ""
17151709

@@ -1986,6 +1980,7 @@ msgstr ""
19861980

19871981
#: ports/espressif/common-hal/socketpool/SocketPool.c
19881982
#: ports/raspberrypi/common-hal/socketpool/SocketPool.c
1983+
#: ports/zephyr-cp/common-hal/socketpool/SocketPool.c
19891984
msgid "SocketPool can only be used with wifi.radio"
19901985
msgstr ""
19911986

@@ -2025,8 +2020,7 @@ msgstr ""
20252020
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
20262021
msgstr ""
20272022

2028-
#: shared-module/audiodelays/Echo.c shared-module/audiofilters/Distortion.c
2029-
#: shared-module/audiofilters/Filter.c shared-module/audiomixer/MixerVoice.c
2023+
#: shared-module/audiocore/__init__.c
20302024
msgid "The sample's %q does not match"
20312025
msgstr ""
20322026

@@ -2291,6 +2285,7 @@ msgid "Unsupported hash algorithm"
22912285
msgstr ""
22922286

22932287
#: ports/espressif/common-hal/socketpool/Socket.c
2288+
#: ports/zephyr-cp/common-hal/socketpool/Socket.c
22942289
msgid "Unsupported socket type"
22952290
msgstr ""
22962291

@@ -2578,7 +2573,8 @@ msgstr ""
25782573
msgid "bits must be 32 or less"
25792574
msgstr ""
25802575

2581-
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Distortion.c
2576+
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiodelays/PitchShift.c
2577+
#: shared-bindings/audiofilters/Distortion.c
25822578
#: shared-bindings/audiofilters/Filter.c shared-bindings/audiomixer/Mixer.c
25832579
msgid "bits_per_sample must be 8 or 16"
25842580
msgstr ""
@@ -4361,6 +4357,7 @@ msgstr ""
43614357

43624358
#: ports/espressif/common-hal/wifi/Radio.c
43634359
#: ports/raspberrypi/common-hal/wifi/Radio.c
4360+
#: ports/zephyr-cp/common-hal/wifi/Radio.c
43644361
msgid "wifi is not enabled"
43654362
msgstr ""
43664363

ports/raspberrypi/boards/adafruit_fruit_jam/board.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
#include "common-hal/microcontroller/Pin.h"
88
#include "hardware/gpio.h"
9+
#include "py/mphal.h"
910
#include "shared-bindings/usb_host/Port.h"
1011
#include "supervisor/board.h"
1112

13+
#include "common-hal/picodvi/__init__.h"
14+
1215
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
1316

17+
#define I2S_RESET_PIN_NUMBER 22
1418

1519
#if defined(DEFAULT_USB_HOST_5V_POWER)
1620
bool board_reset_pin_number(uint8_t pin_number) {
@@ -25,12 +29,29 @@ bool board_reset_pin_number(uint8_t pin_number) {
2529

2630
return true;
2731
}
32+
// Set I2S out of reset.
33+
if (pin_number == I2S_RESET_PIN_NUMBER) {
34+
gpio_put(pin_number, 1);
35+
gpio_set_dir(pin_number, GPIO_OUT);
36+
gpio_set_function(pin_number, GPIO_FUNC_SIO);
37+
38+
return true;
39+
}
2840
return false;
2941
}
3042
#endif
3143

32-
#if defined(DEFAULT_USB_HOST_DATA_PLUS)
3344
void board_init(void) {
45+
// Reset the DAC to put it in a known state.
46+
gpio_put(I2S_RESET_PIN_NUMBER, 0);
47+
gpio_set_dir(I2S_RESET_PIN_NUMBER, GPIO_OUT);
48+
gpio_set_function(I2S_RESET_PIN_NUMBER, GPIO_FUNC_SIO);
49+
mp_hal_delay_us(1);
50+
board_reset_pin_number(I2S_RESET_PIN_NUMBER);
51+
52+
#if defined(DEFAULT_USB_HOST_DATA_PLUS)
3453
common_hal_usb_host_port_construct(DEFAULT_USB_HOST_DATA_PLUS, DEFAULT_USB_HOST_DATA_MINUS);
54+
#endif
55+
56+
picodvi_autoconstruct();
3557
}
36-
#endif

ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,18 @@
2121
#define DEFAULT_USB_HOST_DATA_MINUS (&pin_GPIO2)
2222
#define DEFAULT_USB_HOST_5V_POWER (&pin_GPIO11)
2323

24+
#define DEFAULT_DVI_BUS_CLK_DN (&pin_GPIO12)
25+
#define DEFAULT_DVI_BUS_CLK_DP (&pin_GPIO13)
26+
#define DEFAULT_DVI_BUS_RED_DN (&pin_GPIO14)
27+
#define DEFAULT_DVI_BUS_RED_DP (&pin_GPIO15)
28+
#define DEFAULT_DVI_BUS_GREEN_DN (&pin_GPIO16)
29+
#define DEFAULT_DVI_BUS_GREEN_DP (&pin_GPIO17)
30+
#define DEFAULT_DVI_BUS_BLUE_DN (&pin_GPIO18)
31+
#define DEFAULT_DVI_BUS_BLUE_DP (&pin_GPIO19)
32+
2433
#define CIRCUITPY_PSRAM_CHIP_SELECT (&pin_GPIO47)
34+
35+
// #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO44)
36+
// #define CIRCUITPY_CONSOLE_UART_RX (&pin_GPIO45)
37+
38+
// #define CIRCUITPY_DEBUG_TINYUSB 0

ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ CHIP_PACKAGE = B
88
CHIP_FAMILY = rp2
99

1010
EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ"
11+
12+
# CIRCUITPY_DISPLAY_FONT = $(TOP)/tools/fonts/unifont-16.0.02-all.bdf
13+
# CIRCUITPY_FONT_EXTRA_CHARACTERS = "🖮🖱️"

ports/raspberrypi/boards/adafruit_fruit_jam/pins.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
1515
{ MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO44) },
1616
{ MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO45) },
1717

18-
// On-board switch reverses D0 and D1 connections to RX and TX.
19-
2018
{ MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
2119
{ MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },
2220
{ MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },

ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
271271
// streaming support.
272272
self->framebuffer = (uint32_t *)port_malloc(framebuffer_size * sizeof(uint32_t), true);
273273
if (self->framebuffer == NULL || ((size_t)self->framebuffer & 0xf0000000) == 0x10000000) {
274+
if (self->framebuffer != NULL) {
275+
// Return the memory in PSRAM.
276+
port_free(self->framebuffer);
277+
self->framebuffer = NULL;
278+
}
274279
m_malloc_fail(framebuffer_size * sizeof(uint32_t));
275280
return;
276281
}

ports/raspberrypi/common-hal/picodvi/__init__.c

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "supervisor/port_heap.h"
1818

1919
#if defined(DEFAULT_DVI_BUS_CLK_DP)
20-
static bool picodvi_autoconstruct_enabled(void) {
20+
static bool picodvi_autoconstruct_enabled(mp_int_t *default_width, mp_int_t *default_height) {
2121
char buf[sizeof("detect")];
2222
buf[0] = 0;
2323

@@ -42,6 +42,48 @@ static bool picodvi_autoconstruct_enabled(void) {
4242
return false;
4343
}
4444
bool probed = common_hal_busio_i2c_probe(i2c, 0x50);
45+
if (probed) {
46+
uint8_t edid[128];
47+
uint8_t out[1] = {0};
48+
common_hal_busio_i2c_write_read(i2c, 0x50, out, 1, edid, sizeof(edid));
49+
bool edid_ok = true;
50+
if (edid[0] != 0x00 || edid[1] != 0xFF || edid[2] != 0xFF || edid[3] != 0xFF || edid[4] != 0xFF || edid[5] != 0xFF || edid[6] != 0xFF || edid[7] != 0x00) {
51+
edid_ok = false;
52+
}
53+
uint8_t checksum = 0;
54+
for (size_t i = 0; i < sizeof(edid); i++) {
55+
checksum += edid[i];
56+
}
57+
if (checksum != 0) {
58+
edid_ok = false;
59+
}
60+
61+
if (edid_ok) {
62+
uint8_t established_timings = edid[35];
63+
if ((established_timings & 0xa0) == 0) {
64+
// Check that 720x400@70Hz or 640x480@60Hz is supported. If not
65+
// and we read EDID ok, then don't autostart.
66+
probed = false;
67+
} else {
68+
size_t offset = 54;
69+
uint16_t preferred_pixel_clock = edid[offset] | (edid[offset + 1] << 8);
70+
if (preferred_pixel_clock != 0) {
71+
size_t preferred_width = ((edid[offset + 4] & 0xf0) << 4) | edid[offset + 2];
72+
size_t preferred_height = ((edid[offset + 7] & 0xf0) << 4) | edid[offset + 5];
73+
// Use 720x400 on 1080p, 4k and 8k displays.
74+
if ((established_timings & 0x80) != 0 &&
75+
preferred_width % 1920 == 0 &&
76+
preferred_height % 1080 == 0) {
77+
*default_width = 720 / 2;
78+
*default_height = 400 / 2;
79+
} else {
80+
*default_width = 640 / 2;
81+
*default_height = 480 / 2;
82+
}
83+
}
84+
}
85+
}
86+
}
4587
common_hal_busio_i2c_unlock(i2c);
4688
return probed;
4789
}
@@ -53,11 +95,13 @@ void picodvi_autoconstruct(void) {
5395
return;
5496
}
5597

56-
if (!picodvi_autoconstruct_enabled()) {
98+
mp_int_t default_width = 320;
99+
mp_int_t default_height = 240;
100+
if (!picodvi_autoconstruct_enabled(&default_width, &default_height)) {
57101
return;
58102
}
59103

60-
mp_int_t width = 320;
104+
mp_int_t width = default_width;
61105
mp_int_t height = 0;
62106
mp_int_t color_depth = 16;
63107
mp_int_t rotation = 0;
@@ -75,6 +119,9 @@ void picodvi_autoconstruct(void) {
75119
case 320:
76120
height = 240;
77121
break;
122+
case 360:
123+
height = 200;
124+
break;
78125
}
79126
}
80127

@@ -85,8 +132,8 @@ void picodvi_autoconstruct(void) {
85132

86133
if (!common_hal_picodvi_framebuffer_preflight(width, height, color_depth)) {
87134
// invalid configuration, set back to default
88-
width = 320;
89-
height = 240;
135+
width = default_width;
136+
height = default_height;
90137
color_depth = 16;
91138
}
92139

0 commit comments

Comments
 (0)