dsp: add bootloader

It works!!
This commit is contained in:
Paul Mathieu
2021-04-17 23:13:20 -07:00
parent a864ca3d7e
commit c12c28fb44
5 changed files with 133 additions and 2 deletions

40
dsp/bootloader.c Normal file
View File

@@ -0,0 +1,40 @@
#include "sys.h"
int main() {
uint16_t addr;
uint8_t len;
uint16_t val;
led0->output = 1;
while(1) {
uint8_t c = uart_read(uart0);
if (c == 'c') {
c = uart_read(uart0);
addr = c << 8;
c = uart_read(uart0);
addr |= c;
len = uart_read(uart0);
for (int i = 0; i < len; i += 2) {
c = uart_read(uart0);
val = c << 8;
c = uart_read(uart0);
val |= c;
*((uint16_t*)(addr + i)) = val;
}
uart_write(uart0, 'a');
uart_write(uart0, len);
led0->output = 0xf0;
} else if (c == 'j') {
c = uart_read(uart0);
addr = c << 8;
c = uart_read(uart0);
addr |= c;
((void (*)())addr)();
}
}
}