-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
application: add demo_plic for plic demostration
currently you can only work in command line mode Signed-off-by: Huaqi Fang <[email protected]>
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 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
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 |
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,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; | ||
} |
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,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} |