Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
511328c3aThis file is pinned to the selected release. Download the original to open it in your design tool.
// Copyright © 2024, Julian Scheffers, see LICENSE for more information
#include "power.h"
#include "print.h"
#include "printf_impl.h"
#include "rng.h"
#include "uart.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
void isr() {
long mcause;
asm("csrr %0, mcause" : "=r"(mcause));
if (mcause < 0) {
// Interrupt.
mcause &= 31;
// Unhandled interrupt.
print("Interrupt ");
putd(mcause, 2);
print("\n");
halt();
} else {
// Trap.
print("Trap ");
putd(mcause, 2);
print("\n");
halt();
}
}
void try(int rc) {
print("Return value: ");
if (rc < 0) {
rc = -rc;
putc('-');
}
putd(rc, 10);
print("\n");
}
void main() {
// Set up interrupts.
while (!UART0.status.rx_hasdat) continue;
try(printf("%02x\n", 0xa00));
try(printf("%-8x,\n", 0xb00));
try(printf("%024x\n", 0xc00));
try(printf("%p\n", &UART0));
try(printf("%d\n", 1234));
try(printf("%-10d,\n", 1234));
try(printf("%10d,\n", 1234));
try(printf("%-10d,\n", -1234));
try(printf("%10d,\n", -1234));
try(printf("%d,%d\n", 10, 10));
try(printf("%s\n", "This string"));
softreset();
}