Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLIC handlers array #363

Merged
merged 14 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ hw/system/pad_control/rtl/pad_control_reg_top.sv

# same for the C header file and linker scripts
sw/device/lib/runtime/core_v_mini_mcu.h
sw/device/lib/runtime/core_intr.h
JuanSapriza marked this conversation as resolved.
Show resolved Hide resolved
sw/linker/link.ld
sw/linker/link_flash_exec.ld
sw/linker/link_flash_load.ld
Expand Down
4 changes: 4 additions & 0 deletions sw/applications/example_dma/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "core_v_mini_mcu.h"
#include "x-heep.h"
#include "csr.h"
#include "rv_plic.h"

#define TEST_SINGULAR_MODE
#define TEST_PENDING_TRANSACTION
Expand Down Expand Up @@ -343,6 +344,9 @@ int main(int argc, char *argv[])
PRINTF(" TESTING WINDOW INTERRUPT ");
PRINTF("\n\n\r===================================\n\n\r");

plic_Init();
plic_irq_set_priority( DMA_WINDOW_INTR, 1);
plic_irq_set_enabled( DMA_WINDOW_INTR, kPlicToggleEnabled);

window_intr_flag = 0;

Expand Down
36 changes: 33 additions & 3 deletions sw/applications/example_gpio_intr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@

plic_result_t plic_res;

uint8_t gpio_intr_flag = 0;

void handler_1()
{
PRINTF("handler 1\n");
gpio_intr_flag = 1;
}

void handler_2()
{
PRINTF("handler 2\n");
gpio_intr_flag = 1;
}

int main(int argc, char *argv[])
{

Expand Down Expand Up @@ -96,7 +110,6 @@ int main(int argc, char *argv[])
// Set mie.MEIE bit to one to enable machine-level external interrupts
const uint32_t mask = 1 << 11;
CSR_SET_BITS(CSR_REG_MIE, mask);
plic_intr_flag = 0;

//gpio_reset_all();
gpio_result_t gpio_res;
Expand Down Expand Up @@ -125,15 +138,32 @@ int main(int argc, char *argv[])
return -1;
}

gpio_assign_irq_handler( GPIO_INTR, &handler_1 );
gpio_intr_flag = 0;

PRINTF("Write 1 to GPIO 30 and wait for interrupt...\n\r");
while(gpio_intr_flag == 0) {
// disable_interrupts
// this does not prevent waking up the core as this is controlled by the MIP register
CSR_CLEAR_BITS(CSR_REG_MSTATUS, 0x8);
gpio_write(GPIO_TB_OUT, true);
// wait_for_interrupt();
CSR_SET_BITS(CSR_REG_MSTATUS, 0x8);
}

gpio_assign_irq_handler( GPIO_INTR, &handler_2 );
gpio_intr_flag = 0;

PRINTF("Write 1 to GPIO 30 and wait for interrupt...\n\r");
while(plic_intr_flag==0) {
while(gpio_intr_flag == 0) {
// disable_interrupts
// this does not prevent waking up the core as this is controlled by the MIP register
CSR_CLEAR_BITS(CSR_REG_MSTATUS, 0x8);
gpio_write(GPIO_TB_OUT, true);
wait_for_interrupt();
//wait_for_interrupt();
CSR_SET_BITS(CSR_REG_MSTATUS, 0x8);
}

PRINTF("Success\n\r");

return EXIT_SUCCESS;
Expand Down
1 change: 1 addition & 0 deletions sw/applications/example_i2s/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <stdlib.h>

#include "core_v_mini_mcu.h"

#include "x-heep.h"
#include "i2s.h"
#include "i2s_structs.h"
Expand Down
Loading