diff --git a/application/baremetal/demo_plic/Makefile b/application/baremetal/demo_plic/Makefile new file mode 100644 index 00000000..f4f5c10b --- /dev/null +++ b/application/baremetal/demo_plic/Makefile @@ -0,0 +1,11 @@ +TARGET = demo_plic + +NUCLEI_SDK_ROOT = ../../.. + +SRCDIRS = . + +INCDIRS = . + +INTMODE := plic + +include $(NUCLEI_SDK_ROOT)/Build/Makefile.base diff --git a/application/baremetal/demo_plic/main.c b/application/baremetal/demo_plic/main.c new file mode 100644 index 00000000..ad43132b --- /dev/null +++ b/application/baremetal/demo_plic/main.c @@ -0,0 +1,38 @@ +// See LICENSE for license details. +#include +#include "nuclei_sdk_hal.h" + +// plic uart0 interrupt handler +void plic_uart0_handler(void) +{ + int32_t status = uart_get_status(SOC_DEBUG_UART); + printf("Enter uart0 interrupt, "); + if (status & UART_IP_RXIP_MASK) { + unsigned char c_get; + // Clear rx pending + uart_clear_status(SOC_DEBUG_UART, UART_IP_RXIP_MASK); + c_get = uart_read(SOC_DEBUG_UART); + printf("you just typed: %c\n", c_get); + } else { + printf("\n"); + } +} + + +int main(int argc, char **argv) +{ + int32_t returnCode; + + // register plic uart0 interrupt + returnCode = PLIC_Register_IRQ(PLIC_UART0_IRQn, 1, plic_uart0_handler); + + // Enable interrupts in general. + __enable_irq(); + + // Enable uart0 receive interrupt + uart_enable_rxint(SOC_DEBUG_UART); + printf("You can press any key now to trigger uart receive interrupt\n"); + // Wait uart0 press any key + while (1); + return 0; +} diff --git a/application/baremetal/demo_plic/npk.yml b/application/baremetal/demo_plic/npk.yml new file mode 100644 index 00000000..91958906 --- /dev/null +++ b/application/baremetal/demo_plic/npk.yml @@ -0,0 +1,42 @@ +## Package Base Information +name: app-nsdk_demo_plic +owner: nuclei +description: PLIC Interrupt Demo +type: app +keywords: + - app + - risc-v +license: +homepage: + +## Package Dependency +dependencies: + - name: sdk-nuclei_sdk + version: + +## Package Configurations +configuration: + app_commonflags: + value: + type: text + description: Application Compile Flags + +## Set Configuration for other packages +setconfig: + + +## Source Code Management +codemanage: + copyfiles: + - path: ["*.c", "*.h"] + incdirs: + - path: ["./"] + libdirs: + ldlibs: + - libs: [""] + +## Build Configuration +buildconfig: + - type: common + common_flags: # flags need to be combined together across all packages + - flags: ${app_commonflags}