Skip to content

Commit

Permalink
application: add demo_plic for plic demostration
Browse files Browse the repository at this point in the history
currently you can only work in command line mode

Signed-off-by: Huaqi Fang <[email protected]>
  • Loading branch information
fanghuaqi committed Nov 29, 2023
1 parent 602c4f0 commit 74f3d2b
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
11 changes: 11 additions & 0 deletions application/baremetal/demo_plic/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TARGET = demo_plic

NUCLEI_SDK_ROOT = ../../..

SRCDIRS = .

INCDIRS = .

INTMODE := plic

include $(NUCLEI_SDK_ROOT)/Build/Makefile.base
38 changes: 38 additions & 0 deletions application/baremetal/demo_plic/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// See LICENSE for license details.
#include <stdio.h>
#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;
}
42 changes: 42 additions & 0 deletions application/baremetal/demo_plic/npk.yml
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 74f3d2b

Please sign in to comment.