[sw/example] minor UART console fixes

This commit is contained in:
stnolting 2022-11-05 09:52:53 +01:00
parent ef715f5116
commit 2e3b7e1bc3
2 changed files with 6 additions and 0 deletions

View file

@ -145,6 +145,7 @@ void print_random_data(void) {
neorv32_uart0_printf("%u ", (uint32_t)(trng_data));
num_samples++;
if (neorv32_uart0_char_received()) { // abort when key pressed
neorv32_uart0_char_received_get(); // discard received char
break;
}
}
@ -166,6 +167,8 @@ void generate_histogram(void) {
neorv32_uart0_printf("Press any key to start.\n");
while(neorv32_uart0_char_received() == 0);
neorv32_uart0_char_received_get(); // discard received char
neorv32_uart0_printf("Sampling... Press any key to stop.\n");
// clear histogram
@ -192,6 +195,7 @@ void generate_histogram(void) {
// abort conditions
if ((neorv32_uart0_char_received()) || // abort when key pressed
(cnt & 0x80000000UL)) { // to prevent overflow
neorv32_uart0_char_received_get(); // discard received char
break;
}
}

View file

@ -136,6 +136,7 @@ int main(void) {
while (neorv32_uart0_char_received() == 0) {
xorshift32();
}
neorv32_uart0_char_received_get(); // discard received char
// initialize universe using random data
@ -163,6 +164,7 @@ int main(void) {
// user abort?
if (neorv32_uart0_char_received()) {
neorv32_uart0_char_received_get(); // discard received char
neorv32_uart0_printf("\nRestart (y/n)?");
if (neorv32_uart0_getc() == 'y') {
break;