-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
99 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ format: false | |
|
||
version: | ||
major: 0 | ||
minor: 1 | ||
patch: 1 | ||
minor: 2 | ||
patch: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* \file | ||
* \brief A simple application interface. | ||
*/ | ||
#pragma once | ||
|
||
/* third-party */ | ||
#include "coral/cli/CommandLineApp.h" | ||
|
||
extern "C" | ||
{ | ||
/* toolchain */ | ||
#include <semihost.h> | ||
} | ||
|
||
using CommandLine = Coral::CommandLineApp::CommandLine; | ||
using CommandLineApp = Coral::CommandLineApp; | ||
|
||
static constexpr const char *prompt = "$ "; | ||
|
||
/* | ||
* Must be set by a debugger. | ||
*/ | ||
volatile bool enable_cli = false; | ||
extern volatile bool enable_semihosting; | ||
|
||
extern int stdin_fd; | ||
|
||
class App | ||
{ | ||
public: | ||
App(CommandLineApp::CommandRegistration register_commands, | ||
bool initialize_semihosting = true) | ||
: logger(), buf(), app(register_commands, buf, &logger) | ||
{ | ||
if (initialize_semihosting && enable_semihosting) | ||
{ | ||
stdin_fd = sys_semihost_open(":tt", 0); | ||
} | ||
|
||
register_common(); | ||
|
||
logger.log("Application starting.\n"); | ||
logger.log(prompt); | ||
} | ||
|
||
inline void poll_stdin(char *input) | ||
{ | ||
if (enable_cli and gets(input) != NULL) | ||
{ | ||
/* Publish command data. */ | ||
buf.push_n_blocking(input, strlen(input)); | ||
buf.push_blocking('\n'); | ||
|
||
logger.log(prompt); | ||
} | ||
} | ||
|
||
Coral::PrintfLogger logger; | ||
CommandLineApp::Processor::Buffer buf; | ||
CommandLineApp app; | ||
|
||
protected: | ||
inline void register_common() | ||
{ | ||
app.add_handler( | ||
"cli", [this](CommandLine &cli) { do_cli(cli); }, | ||
"toggle the CLI on or off"); | ||
} | ||
|
||
void do_cli(CommandLine &cli) | ||
{ | ||
(void)cli; | ||
|
||
enable_cli = not enable_cli; | ||
printf("Toggling CLI %s.\n", enable_cli ? "on" : "off"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/** | ||
* \file | ||
* | ||
* \brief Stubs for library hooks. | ||
*/ | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters