Skip to content

Commit

Permalink
Basic shell example for Rishka.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Feb 17, 2024
1 parent 6a150d8 commit 453d8d7
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions examples/shell/shell.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka).
* Copyright (c) 2024 Nathanne Isip.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <rishka.h>

void setup() {
Serial.begin(115200);
while(!Serial);

if(!SD.begin(5)) {
Serial.println("Failed to initialize SD card.");
while(true);
}

Serial.print("> ");
}

void loop() {
if(!Serial.available())
return;

String input = Serial.readString();
Serial.print(input);

if(!rishka_vm_loadfile(&riscvm_machine, input.c_str())) {
Serial.println("Failed to load specified file: " + input);
return;
}

rishka_vm_run(&riscvm_machine, 0, NULL);
rishka_vm_reset(&riscvm_machine);

Serial.print("> ");
}

0 comments on commit 453d8d7

Please sign in to comment.