diff --git a/dsp/array.c b/dsp/array.c new file mode 100644 index 0000000..7bde81a --- /dev/null +++ b/dsp/array.c @@ -0,0 +1,40 @@ +#include "sys.h" + +#define CYCLES_PER_MS 6666 // ish + +void busy_sleep_1ms() { + for (int i = 0; i < CYCLES_PER_MS; ++i) { + // nothing + } +} + +/** waits a general amount of time */ +void busy_sleep(int ms) { + for (int i = 0; i < ms; ++i) { + busy_sleep_1ms(); + } +} + +int strlen(const char* str) { + int i = 0; + while(str[i] != '\0') { + i++; + } + return i; +} + +void log(const char* stuff) { + uart_writen(uart0, stuff, strlen(stuff)); +} + +int main() { + const int array[4] = {1, 2, 3}; + + while (1) { + if (array[1] == 2) { + log("youhou\r\n"); + } + log("blarg\r\n"); + busy_sleep(1000); + } +} diff --git a/dsp/echo.c b/dsp/echo.c new file mode 100644 index 0000000..30cae84 --- /dev/null +++ b/dsp/echo.c @@ -0,0 +1,22 @@ +#include "sys.h" + +int strlen(const char* str) { + int i = 0; + while(str[i] != '\0') { + i++; + } + return i; +} + +void log(const char* stuff) { + uart_writen(uart0, stuff, strlen(stuff)); +} + +int main() { + led0->output = 37; + + while(1) { + uint8_t c = uart_read(uart0); + uart_write(uart0, c); + } +}