Skip to content

Commit acc102f

Browse files
committed
Rev A Fruit Jam definition
This is experimental and will change as the hardware does.
1 parent 457edc3 commit acc102f

File tree

12 files changed

+386
-82
lines changed

12 files changed

+386
-82
lines changed

ports/raspberrypi/bindings/picodvi/Framebuffer.c

+10-9
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
//| * 4 - Each nibble is a pixels in RGB format. The fourth bit is ignored. (RP2350 only)
5656
//| * 8 - Each byte is a pixels in RGB332 format.
5757
//| * 16 - Each two bytes are a pixel in RGB565 format.
58+
//| * 32 - Each four bytes are a pixel in RGB888 format. The top byte is ignored.
5859
//|
5960
//| Output resolution support varies between the RP2040 and RP2350.
6061
//|
@@ -63,17 +64,17 @@
6364
//| full resolution. Color framebuffers must be half resolution (320x240
6465
//| or 400x240) and pixels will be duplicated to create the signal.
6566
//|
66-
//| On RP2350, output resolution is always 640x480. Monochrome
67+
//| On RP2350, output resolution is either 640x480 or 720x400. Monochrome
6768
//| framebuffers (color_depth=1 or 2) must be full resolution. 4-bit
68-
//| color must also be full resolution. 8-bit color can be half or full
69-
//| resolution. 16-bit color must be half resolution due to RAM
70-
//| limitations.
69+
//| color must also be full resolution. 8-bit color can be quarter, half
70+
//| or full resolution. 16-bit color and 32-bit color must be quarter or
71+
//| half resolution due to internal RAM limitations.
7172
//|
7273
//| A Framebuffer is often used in conjunction with a
7374
//| `framebufferio.FramebufferDisplay`.
7475
//|
75-
//| :param int width: the width of the target display signal. Only 320, 400, 640 or 800 is currently supported depending on color_depth and chip set.
76-
//| :param int height: the height of the target display signal. Only 240 or 480 is currently supported depending on color_depth and chip set.
76+
//| :param int width: the width of the source framebuffer. Support varies with chipset.
77+
//| :param int height: the height of the source framebuffer. Support varies with chipset.
7778
//| :param ~microcontroller.Pin clk_dp: the positive clock signal pin
7879
//| :param ~microcontroller.Pin clk_dn: the negative clock signal pin
7980
//| :param ~microcontroller.Pin red_dp: the positive red signal pin
@@ -83,7 +84,7 @@
8384
//| :param ~microcontroller.Pin blue_dp: the positive blue signal pin
8485
//| :param ~microcontroller.Pin blue_dn: the negative blue signal pin
8586
//| :param int color_depth: the color depth of the framebuffer in bits. 1, 2 for grayscale
86-
//| and 4 (RP2350 only), 8 or 16 for color
87+
//| and 4 (RP2350 only), 8 or 16 for color, 32 for color (RP2350 only)
8788
//| """
8889
//|
8990

@@ -114,7 +115,7 @@ static mp_obj_t picodvi_framebuffer_make_new(const mp_obj_type_t *type, size_t n
114115
mp_uint_t width = (mp_uint_t)mp_arg_validate_int_min(args[ARG_width].u_int, 0, MP_QSTR_width);
115116
mp_uint_t height = (mp_uint_t)mp_arg_validate_int_min(args[ARG_height].u_int, 0, MP_QSTR_height);
116117
mp_uint_t color_depth = args[ARG_color_depth].u_int;
117-
if (color_depth != 1 && color_depth != 2 && color_depth != 4 && color_depth != 8 && color_depth != 16) {
118+
if (color_depth != 1 && color_depth != 2 && color_depth != 4 && color_depth != 8 && color_depth != 16 && color_depth != 32) {
118119
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_color_depth);
119120
}
120121
common_hal_picodvi_framebuffer_construct(self,
@@ -221,7 +222,7 @@ static int picodvi_framebuffer_get_bytes_per_cell_proto(mp_obj_t self_in) {
221222
}
222223

223224
static int picodvi_framebuffer_get_native_frames_per_second_proto(mp_obj_t self_in) {
224-
return 60;
225+
return common_hal_picodvi_framebuffer_get_native_frames_per_second(self_in);
225226
}
226227

227228
static bool picodvi_framebuffer_get_pixels_in_byte_share_row_proto(mp_obj_t self_in) {

ports/raspberrypi/bindings/picodvi/Framebuffer.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ int common_hal_picodvi_framebuffer_get_width(picodvi_framebuffer_obj_t *self);
2929
int common_hal_picodvi_framebuffer_get_height(picodvi_framebuffer_obj_t *self);
3030
int common_hal_picodvi_framebuffer_get_row_stride(picodvi_framebuffer_obj_t *self);
3131
int common_hal_picodvi_framebuffer_get_color_depth(picodvi_framebuffer_obj_t *self);
32+
int common_hal_picodvi_framebuffer_get_native_frames_per_second(picodvi_framebuffer_obj_t *self);
3233
bool common_hal_picodvi_framebuffer_get_grayscale(picodvi_framebuffer_obj_t *self);
3334
mp_int_t common_hal_picodvi_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "common-hal/microcontroller/Pin.h"
8+
#include "hardware/gpio.h"
9+
#include "shared-bindings/usb_host/Port.h"
10+
#include "supervisor/board.h"
11+
12+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
13+
14+
15+
#if defined(DEFAULT_USB_HOST_5V_POWER)
16+
bool board_reset_pin_number(uint8_t pin_number) {
17+
if (pin_number == DEFAULT_USB_HOST_5V_POWER->number) {
18+
// doing this (rather than gpio_init) in this specific order ensures no
19+
// glitch if pin was already configured as a high output. gpio_init() temporarily
20+
// configures the pin as an input, so the power enable value would potentially
21+
// glitch.
22+
gpio_put(pin_number, 1);
23+
gpio_set_dir(pin_number, GPIO_OUT);
24+
gpio_set_function(pin_number, GPIO_FUNC_SIO);
25+
26+
return true;
27+
}
28+
return false;
29+
}
30+
#endif
31+
32+
#if defined(DEFAULT_USB_HOST_DATA_PLUS)
33+
void board_init(void) {
34+
common_hal_usb_host_port_construct(DEFAULT_USB_HOST_DATA_PLUS, DEFAULT_USB_HOST_DATA_MINUS);
35+
}
36+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#define MICROPY_HW_BOARD_NAME "Adafruit Fruit Jam"
8+
#define MICROPY_HW_MCU_NAME "rp2350b"
9+
10+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO32)
11+
#define MICROPY_HW_NEOPIXEL_COUNT (5)
12+
13+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO21)
14+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO20)
15+
16+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO30)
17+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO31)
18+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO28)
19+
20+
#define DEFAULT_USB_HOST_DATA_PLUS (&pin_GPIO1)
21+
#define DEFAULT_USB_HOST_DATA_MINUS (&pin_GPIO2)
22+
#define DEFAULT_USB_HOST_5V_POWER (&pin_GPIO11)
23+
24+
#define CIRCUITPY_PSRAM_CHIP_SELECT (&pin_GPIO47)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x816C
3+
USB_PRODUCT = "Fruit Jam"
4+
USB_MANUFACTURER = "Adafruit"
5+
6+
CHIP_VARIANT = RP2350
7+
CHIP_PACKAGE = B
8+
CHIP_FAMILY = rp2
9+
10+
EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
// Put board-specific pico-sdk definitions here. This file must exist.
8+
9+
// Allow extra time for xosc to start.
10+
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
9+
static const mp_rom_map_elem_t board_module_globals_table[] = {
10+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
11+
12+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO41) },
13+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO42) },
14+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO43) },
15+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO44) },
16+
{ MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO45) },
17+
18+
// On-board switch reverses D0 and D1 connections to RX and TX.
19+
20+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
21+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },
22+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
23+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) },
24+
{ MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
25+
26+
{ MP_OBJ_NEW_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO29) },
27+
28+
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
29+
{ MP_OBJ_NEW_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) },
30+
31+
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO4) },
32+
33+
{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_GPIO5) },
34+
35+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO20) },
36+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO21) },
37+
38+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO30) },
39+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO31) },
40+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO28) },
41+
42+
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO46) },
43+
44+
{ MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO32) },
45+
46+
{ MP_ROM_QSTR(MP_QSTR_CKN), MP_ROM_PTR(&pin_GPIO12) },
47+
{ MP_ROM_QSTR(MP_QSTR_CKP), MP_ROM_PTR(&pin_GPIO13) },
48+
{ MP_ROM_QSTR(MP_QSTR_D0N), MP_ROM_PTR(&pin_GPIO14) },
49+
{ MP_ROM_QSTR(MP_QSTR_D0P), MP_ROM_PTR(&pin_GPIO15) },
50+
{ MP_ROM_QSTR(MP_QSTR_D1N), MP_ROM_PTR(&pin_GPIO16) },
51+
{ MP_ROM_QSTR(MP_QSTR_D1P), MP_ROM_PTR(&pin_GPIO17) },
52+
{ MP_ROM_QSTR(MP_QSTR_D2N), MP_ROM_PTR(&pin_GPIO18) },
53+
{ MP_ROM_QSTR(MP_QSTR_D2P), MP_ROM_PTR(&pin_GPIO19) },
54+
55+
{ MP_ROM_QSTR(MP_QSTR_I2S_RESET), MP_ROM_PTR(&pin_GPIO22) },
56+
{ MP_ROM_QSTR(MP_QSTR_I2S_MCLK), MP_ROM_PTR(&pin_GPIO27) },
57+
{ MP_ROM_QSTR(MP_QSTR_I2S_BCLK), MP_ROM_PTR(&pin_GPIO26) },
58+
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_GPIO25) },
59+
{ MP_ROM_QSTR(MP_QSTR_I2S_DIN), MP_ROM_PTR(&pin_GPIO24) },
60+
{ MP_ROM_QSTR(MP_QSTR_I2S_GPIO1), MP_ROM_PTR(&pin_GPIO23) },
61+
62+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO34) },
63+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_CLOCK), MP_ROM_PTR(&pin_GPIO34) },
64+
65+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35) },
66+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_GPIO35) },
67+
68+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO36) },
69+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_GPIO36) },
70+
71+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_GPIO37) },
72+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_GPIO38) },
73+
74+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO39) },
75+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_GPIO39) },
76+
77+
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_CARD_DETECT), MP_ROM_PTR(&pin_GPIO33) },
78+
79+
{ MP_ROM_QSTR(MP_QSTR_USB_HOST_DATA_PLUS), MP_ROM_PTR(&pin_GPIO1) },
80+
{ MP_ROM_QSTR(MP_QSTR_USB_HOST_DATA_MINUS), MP_ROM_PTR(&pin_GPIO2) },
81+
{ MP_ROM_QSTR(MP_QSTR_USB_HOST_5V_POWER), MP_ROM_PTR(&pin_GPIO11) },
82+
83+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
84+
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
85+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
86+
};
87+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
141141

142142
// If the width is > 400, then it must not be color frame buffer and vice
143143
// versa.
144-
if ((width > 400) == color_framebuffer || color_depth == 4) {
144+
if ((width > 400) == color_framebuffer || color_depth == 4 || color_depth == 32) {
145145
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_color_depth);
146146
}
147147

@@ -385,6 +385,10 @@ int common_hal_picodvi_framebuffer_get_color_depth(picodvi_framebuffer_obj_t *se
385385
return self->color_depth;
386386
}
387387

388+
int common_hal_picodvi_framebuffer_get_native_frames_per_second(picodvi_framebuffer_obj_t *self) {
389+
return 60;
390+
}
391+
388392
bool common_hal_picodvi_framebuffer_get_grayscale(picodvi_framebuffer_obj_t *self) {
389393
return self->color_depth < 8;
390394
}

0 commit comments

Comments
 (0)