Skip to content

Commit

Permalink
Merge pull request #6 from pimoroni/fix-wifi-load
Browse files Browse the repository at this point in the history
Fix wifi setup after display init
  • Loading branch information
Gadgetoid authored Nov 14, 2024
2 parents 404d3aa + f854da8 commit a1460a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
17 changes: 4 additions & 13 deletions drivers/st7701/st7701.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,29 +205,23 @@ void ST7701::init_framebuffer() {
framebuffer += 0x2000000;
}

ST7701::ST7701(uint16_t width, uint16_t height, Rotation rotation, SPIPins control_pins, uint16_t* framebuffer, uint16_t* linebuffer,
ST7701::ST7701(uint16_t width, uint16_t height, Rotation rotation, SPIPins control_pins, uint16_t* framebuffer,
uint d0, uint hsync, uint vsync, uint lcd_de, uint lcd_dot_clk) :
DisplayDriver(width, height, rotation),
spi(control_pins.spi),
spi_cs(control_pins.cs), spi_sck(control_pins.sck), spi_dat(control_pins.mosi), lcd_bl(control_pins.bl),
d0(d0), hsync(hsync), vsync(vsync), lcd_de(lcd_de), lcd_dot_clk(lcd_dot_clk),
framebuffer(framebuffer),
line_buffer(linebuffer)
framebuffer(framebuffer)
{
st7701_inst = this;

// Allocate line buffers only if none supplied and frame buffer is not in internal RAM.
if(!line_buffer && (intptr_t)framebuffer < 0x20000000) {
line_buffer = (uint16_t*)malloc(NUM_LINE_BUFFERS * width * sizeof(line_buffer[0]));
}
}

void ST7701::init() {
irq_handler_t current = nullptr;

init_framebuffer();

st_pio = pio2;
st_pio = pio1;
parallel_sm = pio_claim_unused_sm(st_pio, true);

if (width == 480) parallel_offset = pio_add_program(st_pio, &st7701_parallel_program);
Expand Down Expand Up @@ -319,19 +313,16 @@ void ST7701::init_framebuffer() {

dma_channel_config config = dma_channel_get_default_config(st_dma);
channel_config_set_transfer_data_size(&config, DMA_SIZE_32);
channel_config_set_high_priority(&config, true);
channel_config_set_dreq(&config, pio_get_dreq(st_pio, parallel_sm, true));
channel_config_set_bswap(&config, true);
channel_config_set_chain_to(&config, st_dma2);
dma_channel_configure(st_dma, &config, &st_pio->txf[parallel_sm], line_buffer, width >> 1, false);
dma_channel_configure(st_dma, &config, &st_pio->txf[parallel_sm], nullptr, width >> 1, false);

config = dma_channel_get_default_config(st_dma2);
channel_config_set_transfer_data_size(&config, DMA_SIZE_32);
channel_config_set_read_increment(&config, false);
dma_channel_configure(st_dma2, &config, &dma_hw->ch[st_dma].al3_read_addr_trig, &next_line_addr, 1, false);

hw_set_bits(&bus_ctrl_hw->priority, (BUSCTRL_BUS_PRIORITY_PROC1_BITS | BUSCTRL_BUS_PRIORITY_DMA_R_BITS | BUSCTRL_BUS_PRIORITY_DMA_W_BITS));

printf("Begin SPI setup\n");

common_init();
Expand Down
3 changes: 1 addition & 2 deletions drivers/st7701/st7701.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace pimoroni {

public:
// Parallel init
ST7701(uint16_t width, uint16_t height, Rotation rotation, SPIPins control_pins, uint16_t* framebuffer, uint16_t* linebuffer,
ST7701(uint16_t width, uint16_t height, Rotation rotation, SPIPins control_pins, uint16_t* framebuffer,
uint d0=1, uint hsync=19, uint vsync=20, uint lcd_de = 21, uint lcd_dot_clk = 22);

void init();
Expand Down Expand Up @@ -87,7 +87,6 @@ namespace pimoroni {
uint16_t* framebuffer;
uint16_t* next_framebuffer = nullptr;

uint16_t* line_buffer;
uint16_t* next_line_addr;
int display_row = 0;
int row_shift = 0;
Expand Down
2 changes: 1 addition & 1 deletion modules/c/presto/presto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mp_obj_t Presto_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
presto_debug("m_new_class(ST7701...\n");
ST7701 *presto = m_new_class(ST7701, WIDTH, HEIGHT, ROTATE_0,
SPIPins{spi1, LCD_CS, LCD_CLK, LCD_DAT, PIN_UNUSED, LCD_DC, BACKLIGHT},
self->next_fb, nullptr,
self->next_fb,
LCD_D0);

self->presto = presto;
Expand Down

0 comments on commit a1460a0

Please sign in to comment.