Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions ports/raspberrypi/bindings/picodvi/Framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
//| * 4 - Each nibble is a pixels in RGB format. The fourth bit is ignored. (RP2350 only)
//| * 8 - Each byte is a pixels in RGB332 format.
//| * 16 - Each two bytes are a pixel in RGB565 format.
//| * 32 - Each four bytes are a pixel in RGB888 format. The top byte is ignored.
//|
//| Output resolution support varies between the RP2040 and RP2350.
//|
Expand All @@ -63,17 +64,17 @@
//| full resolution. Color framebuffers must be half resolution (320x240
//| or 400x240) and pixels will be duplicated to create the signal.
//|
//| On RP2350, output resolution is always 640x480. Monochrome
//| On RP2350, output resolution is either 640x480 or 720x400. Monochrome
//| framebuffers (color_depth=1 or 2) must be full resolution. 4-bit
//| color must also be full resolution. 8-bit color can be half or full
//| resolution. 16-bit color must be half resolution due to RAM
//| limitations.
//| color must also be full resolution. 8-bit color can be quarter, half
//| or full resolution. 16-bit color and 32-bit color must be quarter or
//| half resolution due to internal RAM limitations.
//|
//| A Framebuffer is often used in conjunction with a
//| `framebufferio.FramebufferDisplay`.
//|
//| :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.
//| :param int height: the height of the target display signal. Only 240 or 480 is currently supported depending on color_depth and chip set.
//| :param int width: the width of the source framebuffer. Support varies with chipset.
//| :param int height: the height of the source framebuffer. Support varies with chipset.
//| :param ~microcontroller.Pin clk_dp: the positive clock signal pin
//| :param ~microcontroller.Pin clk_dn: the negative clock signal pin
//| :param ~microcontroller.Pin red_dp: the positive red signal pin
Expand All @@ -83,7 +84,7 @@
//| :param ~microcontroller.Pin blue_dp: the positive blue signal pin
//| :param ~microcontroller.Pin blue_dn: the negative blue signal pin
//| :param int color_depth: the color depth of the framebuffer in bits. 1, 2 for grayscale
//| and 4 (RP2350 only), 8 or 16 for color
//| and 4 (RP2350 only), 8 or 16 for color, 32 for color (RP2350 only)
//| """
//|

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

static int picodvi_framebuffer_get_native_frames_per_second_proto(mp_obj_t self_in) {
return 60;
return common_hal_picodvi_framebuffer_get_native_frames_per_second(self_in);
}

static bool picodvi_framebuffer_get_pixels_in_byte_share_row_proto(mp_obj_t self_in) {
Expand Down
1 change: 1 addition & 0 deletions ports/raspberrypi/bindings/picodvi/Framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ int common_hal_picodvi_framebuffer_get_width(picodvi_framebuffer_obj_t *self);
int common_hal_picodvi_framebuffer_get_height(picodvi_framebuffer_obj_t *self);
int common_hal_picodvi_framebuffer_get_row_stride(picodvi_framebuffer_obj_t *self);
int common_hal_picodvi_framebuffer_get_color_depth(picodvi_framebuffer_obj_t *self);
int common_hal_picodvi_framebuffer_get_native_frames_per_second(picodvi_framebuffer_obj_t *self);
bool common_hal_picodvi_framebuffer_get_grayscale(picodvi_framebuffer_obj_t *self);
mp_int_t common_hal_picodvi_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
36 changes: 36 additions & 0 deletions ports/raspberrypi/boards/adafruit_fruit_jam/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include "common-hal/microcontroller/Pin.h"
#include "hardware/gpio.h"
#include "shared-bindings/usb_host/Port.h"
#include "supervisor/board.h"

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.


#if defined(DEFAULT_USB_HOST_5V_POWER)
bool board_reset_pin_number(uint8_t pin_number) {
if (pin_number == DEFAULT_USB_HOST_5V_POWER->number) {
// doing this (rather than gpio_init) in this specific order ensures no
// glitch if pin was already configured as a high output. gpio_init() temporarily
// configures the pin as an input, so the power enable value would potentially
// glitch.
gpio_put(pin_number, 1);
gpio_set_dir(pin_number, GPIO_OUT);
gpio_set_function(pin_number, GPIO_FUNC_SIO);

return true;
}
return false;
}
#endif

#if defined(DEFAULT_USB_HOST_DATA_PLUS)
void board_init(void) {
common_hal_usb_host_port_construct(DEFAULT_USB_HOST_DATA_PLUS, DEFAULT_USB_HOST_DATA_MINUS);
}
#endif
24 changes: 24 additions & 0 deletions ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#define MICROPY_HW_BOARD_NAME "Adafruit Fruit Jam"
#define MICROPY_HW_MCU_NAME "rp2350b"

#define MICROPY_HW_NEOPIXEL (&pin_GPIO32)
#define MICROPY_HW_NEOPIXEL_COUNT (5)

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO21)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO20)

#define DEFAULT_SPI_BUS_SCK (&pin_GPIO30)
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO31)
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO28)

#define DEFAULT_USB_HOST_DATA_PLUS (&pin_GPIO1)
#define DEFAULT_USB_HOST_DATA_MINUS (&pin_GPIO2)
#define DEFAULT_USB_HOST_5V_POWER (&pin_GPIO11)

#define CIRCUITPY_PSRAM_CHIP_SELECT (&pin_GPIO47)
10 changes: 10 additions & 0 deletions ports/raspberrypi/boards/adafruit_fruit_jam/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
USB_VID = 0x239A
USB_PID = 0x816C
USB_PRODUCT = "Fruit Jam"
USB_MANUFACTURER = "Adafruit"

CHIP_VARIANT = RP2350
CHIP_PACKAGE = B
CHIP_FAMILY = rp2

EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ"
10 changes: 10 additions & 0 deletions ports/raspberrypi/boards/adafruit_fruit_jam/pico-sdk-configboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

// Put board-specific pico-sdk definitions here. This file must exist.

// Allow extra time for xosc to start.
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
87 changes: 87 additions & 0 deletions ports/raspberrypi/boards/adafruit_fruit_jam/pins.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include "shared-bindings/board/__init__.h"

static const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS

{ MP_OBJ_NEW_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO41) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO42) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO43) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO44) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO45) },

// On-board switch reverses D0 and D1 connections to RX and TX.

{ MP_OBJ_NEW_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO29) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_GPIO4) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_GPIO5) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO20) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO21) },

{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO30) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO31) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO28) },

{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO46) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO32) },

{ MP_ROM_QSTR(MP_QSTR_CKN), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_CKP), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_D0N), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_D0P), MP_ROM_PTR(&pin_GPIO15) },
{ MP_ROM_QSTR(MP_QSTR_D1N), MP_ROM_PTR(&pin_GPIO16) },
{ MP_ROM_QSTR(MP_QSTR_D1P), MP_ROM_PTR(&pin_GPIO17) },
{ MP_ROM_QSTR(MP_QSTR_D2N), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_D2P), MP_ROM_PTR(&pin_GPIO19) },

{ MP_ROM_QSTR(MP_QSTR_I2S_RESET), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_I2S_MCLK), MP_ROM_PTR(&pin_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_I2S_BCLK), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_GPIO25) },
{ MP_ROM_QSTR(MP_QSTR_I2S_DIN), MP_ROM_PTR(&pin_GPIO24) },
{ MP_ROM_QSTR(MP_QSTR_I2S_GPIO1), MP_ROM_PTR(&pin_GPIO23) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO34) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_CLOCK), MP_ROM_PTR(&pin_GPIO34) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_GPIO35) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO36) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_GPIO36) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_GPIO37) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_GPIO38) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO39) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_GPIO39) },

{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_CARD_DETECT), MP_ROM_PTR(&pin_GPIO33) },

{ MP_ROM_QSTR(MP_QSTR_USB_HOST_DATA_PLUS), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_USB_HOST_DATA_MINUS), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_USB_HOST_5V_POWER), MP_ROM_PTR(&pin_GPIO11) },

{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
6 changes: 5 additions & 1 deletion ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2040.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,

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

Expand Down Expand Up @@ -385,6 +385,10 @@ int common_hal_picodvi_framebuffer_get_color_depth(picodvi_framebuffer_obj_t *se
return self->color_depth;
}

int common_hal_picodvi_framebuffer_get_native_frames_per_second(picodvi_framebuffer_obj_t *self) {
return 60;
}

bool common_hal_picodvi_framebuffer_get_grayscale(picodvi_framebuffer_obj_t *self) {
return self->color_depth < 8;
}
Expand Down
Loading