mirror of
git://projects.qi-hardware.com/nn-usb-fpga.git
synced 2025-04-21 12:27:27 +03:00
Adding lm32 demo to SAKC project
This commit is contained in:
57
lm32/logic/sakc/firmware/boot0-serial/main.c
Normal file
57
lm32/logic/sakc/firmware/boot0-serial/main.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Primitive first stage bootloader
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "soc-hw.h"
|
||||
|
||||
/* prototypes */
|
||||
uint32_t read_uint32()
|
||||
{
|
||||
uint32_t val = 0, i;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
val <<= 8;
|
||||
val += (uint8_t)uart_getchar();
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int8_t *p;
|
||||
uint8_t c;
|
||||
|
||||
// Initialize UART
|
||||
uart_init();
|
||||
|
||||
c = '*'; // print msg on first iteration
|
||||
for(;;) {
|
||||
uint32_t start, size;
|
||||
|
||||
switch (c) {
|
||||
case 'u': // upload
|
||||
start = read_uint32();
|
||||
size = read_uint32();
|
||||
for (p = (int8_t *) start; p < (int8_t *) (start+size); p++)
|
||||
*p = uart_getchar();
|
||||
break;
|
||||
case 'd': // download
|
||||
start = read_uint32();
|
||||
size = read_uint32();
|
||||
for (p = (int8_t *) start; p < (int8_t *) (start+size); p++)
|
||||
uart_putchar( *p );
|
||||
break;
|
||||
case 'g': // goto
|
||||
start = read_uint32();
|
||||
jump(start);
|
||||
break;
|
||||
default:
|
||||
uart_putstr("**SAKC/bootloader** > \r\n");
|
||||
break;
|
||||
};
|
||||
c = uart_getchar();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user