summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
Diffstat (limited to 'bsp')
-rw-r--r--bsp/drivers/clic/clic_driver.c75
-rw-r--r--bsp/drivers/clic/clic_driver.h8
-rw-r--r--bsp/env/coreip-e2-arty/platform.h2
3 files changed, 84 insertions, 1 deletions
diff --git a/bsp/drivers/clic/clic_driver.c b/bsp/drivers/clic/clic_driver.c
index a4c4694..66b24d6 100644
--- a/bsp/drivers/clic/clic_driver.c
+++ b/bsp/drivers/clic/clic_driver.c
@@ -83,6 +83,81 @@ uint8_t clic_get_cliccfg (clic_instance_t * this_clic){
return *(volatile uint8_t*)(this_clic->hart_addr+CLIC_CFG);
}
+//sets an interrupt level based encoding of nmbits, nlbits
+uint8_t clic_set_int_level( clic_instance_t * this_clic, uint32_t source, uint8_t level) {
+ //extract nlbits
+ uint8_t nlbits = clic_get_cliccfg(this_clic);
+ nlbits = (nlbits >>1) & 0x7;
+
+ //shift level right to mask off unused bits
+ level = level>>((this_clic->num_config_bits)-nlbits); //plus this_clic->nmbits which is always 0 for now.
+ //shift level into correct bit position
+ level = level << (8-((this_clic->num_config_bits)-nlbits));
+
+ //write to clicintcfg
+ uint8_t current_intcfg = clic_get_intcfg(this_clic, source);
+ clic_set_intcfg(this_clic, source, (current_intcfg | level));
+
+ return level;
+}
+
+//gets an interrupt level based encoding of nmbits, nlbits
+uint8_t clic_get_int_level( clic_instance_t * this_clic, uint32_t source) {
+ uint8_t level;
+ level = clic_get_intcfg(this_clic, source);
+
+ //extract nlbits
+ uint8_t nlbits = clic_get_cliccfg(this_clic);
+ nlbits = (nlbits >>1) & 0x7;
+
+ //shift level
+ level = level >> (8-(this_clic->num_config_bits));
+ //shift level right to mask off priority bits
+ level = level>>((this_clic->num_config_bits)-nlbits); //this_clic->nmbits which is always 0 for now.
+
+ return level;
+}
+
+//sets an interrupt priority based encoding of nmbits, nlbits
+uint8_t clic_set_int_priority( clic_instance_t * this_clic, uint32_t source, uint8_t priority) {
+ //priority bits = num_config_bits - nlbits
+ //extract nlbits
+ uint8_t nlbits = clic_get_cliccfg(this_clic);
+ nlbits = (nlbits >>1) & 0x7;
+
+ uint8_t priority_bits = this_clic->num_config_bits-nlbits;
+ if(priority_bits = 0) {
+ //no bits to set
+ return 0;
+ }
+ //mask off unused bits
+ priority = priority >> (8-priority_bits);
+ //shift into the correct bit position
+ priority = priority << (8-(this_clic->num_config_bits));
+
+ //write to clicintcfg
+ uint8_t current_intcfg = clic_get_intcfg(this_clic, source);
+ clic_set_intcfg(this_clic, source, (current_intcfg | priority));
+ return current_intcfg;
+}
+
+//gets an interrupt priority based encoding of nmbits, nlbits
+uint8_t clic_get_int_priority( clic_instance_t * this_clic, uint32_t source) {
+ uint8_t priority;
+ priority = clic_get_intcfg(this_clic, source);
+
+ //extract nlbits
+ uint8_t nlbits = clic_get_cliccfg(this_clic);
+ nlbits = (nlbits >>1) & 0x7;
+
+ //shift left to mask off level bits
+ priority = priority << nlbits;
+
+ //shift priority
+ priority = priority >> (8-((this_clic->num_config_bits)+nlbits));
+
+ return priority;
+}
diff --git a/bsp/drivers/clic/clic_driver.h b/bsp/drivers/clic/clic_driver.h
index 1fd9bb6..27c34c2 100644
--- a/bsp/drivers/clic/clic_driver.h
+++ b/bsp/drivers/clic/clic_driver.h
@@ -30,6 +30,14 @@ void clic_set_intcfg (clic_instance_t * this_clic, uint32_t source, uint32_t int
uint8_t clic_get_intcfg (clic_instance_t * this_clic, uint32_t source);
void clic_set_cliccfg (clic_instance_t * this_clic, uint32_t cfg);
uint8_t clic_get_cliccfg (clic_instance_t * this_clic);
+//sets an interrupt level based encoding of nmbits, nlbits
+uint8_t clic_set_int_level( clic_instance_t * this_clic, uint32_t source, uint8_t level);
+//get an interrupt level based encoding of nmbits, nlbits
+uint8_t clic_get_int_level( clic_instance_t * this_clic, uint32_t source);
+//sets an interrupt priority based encoding of nmbits, nlbits
+uint8_t clic_set_int_priority( clic_instance_t * this_clic, uint32_t source, uint8_t priority);
+//sets an interrupt priority based encoding of nmbits, nlbits
+uint8_t clic_get_int_priority( clic_instance_t * this_clic, uint32_t source);
__END_DECLS
diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h
index 305726d..ba06160 100644
--- a/bsp/env/coreip-e2-arty/platform.h
+++ b/bsp/env/coreip-e2-arty/platform.h
@@ -79,7 +79,7 @@
#define NUM_GPIO 16
#define CLIC_NUM_INTERRUPTS 28 + 16
-#define CLIC_CONFIG_BITS 0x1E //2 for E20
+#define CLIC_CONFIG_BITS 4
#define HAS_BOARD_BUTTONS