Skip to content

Commit 622ba84

Browse files
committed
GPIO Output: Send an Emulator Notification to the Console: {"nuttxemu":{"gpio29":1}}
1 parent 72a9f5c commit 622ba84

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

riscv_cpu.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,18 @@ int target_write_slow(RISCVCPUState *s, target_ulong addr,
530530
virtio_ack_irq(NULL);
531531
break;
532532
}
533+
// GPIO Output: Send an Emulator Notification to the Console: {"nuttxemu":{"gpio29":1}}
534+
case 0x20000938: { // GPIO 29
535+
// Check if the Output Bit is Off or On
536+
#define reg_gpio_xx_o 24
537+
#define reg_gpio_xx_i 28
538+
const char b =
539+
((val & (1 << reg_gpio_xx_o)) == 0)
540+
? '0' : '1';
541+
char notify[] = "{\"nuttxemu\":{\"gpio29\":0}}";
542+
notify[strlen(notify) - 3] = b;
543+
print_console(NULL, notify, strlen(notify));
544+
}
533545
default: // Unknown Memory-Mapped I/O
534546
#ifdef DUMP_INVALID_MEM_ACCESS
535547
printf("target_write_slow: invalid physical address 0x");

0 commit comments

Comments
 (0)