Don't relaunch uploaded program automatically

This commit is contained in:
shylie 2026-05-26 06:12:34 -04:00
parent 394794cce0
commit 034122ed92
Signed by: shylie
GPG Key ID: 20C8D70580687D9D
2 changed files with 14 additions and 12 deletions

View File

@ -1,13 +1,17 @@
#include <card-os.h>
static volatile int value;
int main(void)
{
card_os_put_rect((card_os_rect){
.r = 0, .g = 0, .b = 0, .x = 0, .y = 0, .w = 240, .h = 320 });
card_os_put_rect((card_os_rect){
.r = 0xFF, .g = 0xFF, .b = 0xFF, .x = 60, .y = 80, .w = 60, .h = 80 });
uint8_t value = 0;
while (value < 250)
{
card_os_put_rect((card_os_rect){
.r = value++, .g = 0, .b = 0, .x = 0, .y = 0, .w = 240, .h = 320 });
card_os_put_rect((card_os_rect){
.r = 0xFF, .g = 0xFF, .b = 0xFF, .x = 60, .y = 80, .w = 60, .h = 60 });
}
return 0;
}

View File

@ -41,7 +41,6 @@ int main(void)
spi_set_format(DISPLAY_SPI, 8, SPI_CPOL_1, SPI_CPHA_1, SPI_MSB_FIRST);
display_init();
display_put_rect(0xFF, 0xFF, 0xFF, 0, 0, 240, 320);
tud_init(0);
@ -82,14 +81,12 @@ void tud_vendor_rx_cb(uint8_t itf, const uint8_t* buffer, uint16_t bufsize)
break;
case RECV_HIGH8_LENGTH:
display_put_rect(0, 0, 0xFF, 0, 0, 240, 320);
program_length |= buffer[bufidx];
program_length <<= 8;
recv_status = RECV_LOW8_LENGTH;
break;
case RECV_LOW8_LENGTH:
display_put_rect(0xFF, 0, 0, 0, 0, 240, 320);
program_length |= buffer[bufidx];
recv_status = RECV_PROGRAM;
break;
@ -98,7 +95,6 @@ void tud_vendor_rx_cb(uint8_t itf, const uint8_t* buffer, uint16_t bufsize)
(&__user_ram_start)[program_write_index++] = buffer[bufidx];
if (program_write_index == program_length)
{
display_put_rect(0, 0xFF, 0, 0, 0, 240, 320);
__dmb();
user_program = (user_program_fn)((uintptr_t)&__user_ram_start | 1);
__sev();
@ -117,8 +113,6 @@ static volatile os_ring_buffer core1_buffer
void core1_entry(void)
{
display_put_rect(0xFF, 0, 0xFF, 0, 0, 240, 320);
while (!user_program)
{
__wfe();
@ -200,6 +194,10 @@ void os_handle_message(const os_message* msg, os_message* out)
case OS_CMD_TERMINATE_PROGRAM:
multicore_fifo_drain();
multicore_reset_core1();
__dmb();
user_program = NULL;
__sev();
multicore_launch_core1(core1_entry);
break;
case OS_CMD_SBRK:
os_sbrk(msg->data, &out->data);