DV Display: Claim DMA channels and cleanup unused pio_prog.

TODO: Use claim_unused_channel in a way that survives MicroPython soft reset.
dv_stick
Phil Howard 2023-06-28 11:11:16 +01:00
rodzic 7e9f16d80c
commit 7d8bbf5c08
2 zmienionych plików z 5 dodań i 10 usunięć

Wyświetl plik

@ -48,19 +48,19 @@ namespace pimoroni {
gpio_disable_pulls(pin_d0 + i);
}
pio_prog = &sram_reset_program;
pio_offset = pio_change_exclusive_program(pio, &sram_reset_program);
pio_sm = 1;
pio_sm_claim(pio, pio_sm);
// Claim DMA channels
dma_channel = 0;
dma_channel_claim(dma_channel);
read_cmd_dma_channel = 1;
dma_channel_claim(read_cmd_dma_channel);
}
void APS6404::init() {
pio_sm_set_enabled(pio, pio_sm, false);
pio_prog = &sram_reset_program;
pio_offset = pio_change_exclusive_program(pio, &sram_reset_program);
aps6404_reset_program_init(pio, pio_sm, pio_offset, pin_csn, pin_d0);
@ -79,7 +79,6 @@ namespace pimoroni {
void APS6404::set_qpi() {
pio_sm_set_enabled(pio, pio_sm, false);
pio_prog = &sram_reset_program;
pio_offset = pio_change_exclusive_program(pio, &sram_reset_program);
aps6404_reset_program_init(pio, pio_sm, pio_offset, pin_csn, pin_d0);
pio_sm_put_blocking(pio, pio_sm, 0x00000007u);
@ -93,7 +92,6 @@ namespace pimoroni {
void APS6404::set_spi() {
pio_sm_set_enabled(pio, pio_sm, false);
pio_prog = &sram_reset_qpi_program;
pio_offset = pio_change_exclusive_program(pio, &sram_reset_qpi_program);
aps6404_program_init(pio, pio_sm, pio_offset, pin_csn, pin_d0, false, false, true);
pio_sm_put_blocking(pio, pio_sm, 0x00000001u);
@ -104,17 +102,14 @@ namespace pimoroni {
pio_sm_set_enabled(pio, pio_sm, false);
if (clock_get_hz(clk_sys) > 296000000) {
pio_prog = &sram_fast_program;
pio_offset = pio_change_exclusive_program(pio, &sram_fast_program);
aps6404_program_init(pio, pio_sm, pio_offset, pin_csn, pin_d0, false, true, false);
}
else if (clock_get_hz(clk_sys) < 130000000) {
pio_prog = &sram_slow_program;
pio_offset = pio_change_exclusive_program(pio, &sram_slow_program);
aps6404_program_init(pio, pio_sm, pio_offset, pin_csn, pin_d0, true, false, false);
}
else {
pio_prog = &sram_program;
pio_offset = pio_change_exclusive_program(pio, &sram_program);
aps6404_program_init(pio, pio_sm, pio_offset, pin_csn, pin_d0, false, false, false);
}

Wyświetl plik

@ -73,7 +73,7 @@ namespace pimoroni {
// Note resolutions on the second line require quite extreme overclocking and may not work on all hardware.
// Either or both of the horizontal or vertical component of any resolution may be halved.
DVDisplay(uint16_t width, uint16_t height, Mode mode = MODE_RGB555)
: ram(CS, D0, pio0)
: ram(CS, D0, pio1)
, i2c(new I2C(I2C_SDA, I2C_SCL))
, width(width), height(height)
, mode(mode)
@ -81,7 +81,7 @@ namespace pimoroni {
{}
DVDisplay(uint16_t width, uint16_t height, I2C* i2c, Mode mode = MODE_RGB555)
: ram(CS, D0, pio0)
: ram(CS, D0, pio1)
, i2c(i2c)
, width(width), height(height)
, mode(mode)