Skip to content

Commit

Permalink
temporary fix to avoid micropython locking up on subsequent runs with…
Browse files Browse the repository at this point in the history
… unicorn (#22)

Co-authored-by: Jonathan Williamson <[email protected]>
  • Loading branch information
lowfatcode and Jonathan Williamson authored Jan 24, 2021
1 parent 1a1ed98 commit 032c17d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libraries/pico_unicorn/pico_unicorn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ namespace pimoroni {
gpio_set_function(pin::X, GPIO_FUNC_SIO); gpio_set_dir(pin::X, GPIO_IN); gpio_pull_up(pin::X);
gpio_set_function(pin::Y, GPIO_FUNC_SIO); gpio_set_dir(pin::Y, GPIO_IN); gpio_pull_up(pin::Y);

// todo: shouldn't need to do this if things were cleaned up properly but without
// this any attempt to run a micropython script twice will fail
static bool already_init = false;

if(already_init) {
return;
}

// setup dma transfer for pixel data to the pio
dma_channel = dma_claim_unused_channel(true);
dma_channel_config config = dma_channel_get_default_config(dma_channel);
Expand All @@ -212,6 +220,8 @@ namespace pimoroni {

dma_channel_set_trans_count(dma_channel, BITSTREAM_LENGTH / 4, false);
dma_channel_set_read_addr(dma_channel, bitstream, true);

already_init = true;
}

void PicoUnicorn::clear() {
Expand Down

0 comments on commit 032c17d

Please sign in to comment.