summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Barbier <dbarbi1@gmail.com>2018-07-05 14:14:04 -0500
committerDrew Barbier <dbarbi1@gmail.com>2018-07-05 14:14:04 -0500
commit24010b53cdc225cea7de8662d0b54425f86f8b61 (patch)
tree074ee15552b7f93621d568e8193ad12b554a9aa3
parent962b23a3797ba659577056ed3fc57c2d0a77df62 (diff)
fix level calculation
-rw-r--r--bsp/drivers/clic/clic_driver.c4
-rw-r--r--software/clic_vectored/clic_vectored.c5
2 files changed, 3 insertions, 6 deletions
diff --git a/bsp/drivers/clic/clic_driver.c b/bsp/drivers/clic/clic_driver.c
index 66b24d6..0612e58 100644
--- a/bsp/drivers/clic/clic_driver.c
+++ b/bsp/drivers/clic/clic_driver.c
@@ -92,7 +92,7 @@ uint8_t clic_set_int_level( clic_instance_t * this_clic, uint32_t source, uint8_
//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));
+ level = level << (8-this_clic->num_config_bits) + (this_clic->num_config_bits - nlbits);
//write to clicintcfg
uint8_t current_intcfg = clic_get_intcfg(this_clic, source);
@@ -114,7 +114,7 @@ uint8_t clic_get_int_level( clic_instance_t * this_clic, uint32_t source) {
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.
+ level = level>>(this_clic->num_config_bits-nlbits); //this_clic->nmbits which is always 0 for now.
return level;
}
diff --git a/software/clic_vectored/clic_vectored.c b/software/clic_vectored/clic_vectored.c
index 872aba3..3f632df 100644
--- a/software/clic_vectored/clic_vectored.c
+++ b/software/clic_vectored/clic_vectored.c
@@ -57,7 +57,6 @@ void button_0_isr(void) {
printf("Button 0 was pressed, interrupt level %d. Toggle Red.\n", level);
GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << RED_LED_OFFSET);
wait_ms(500);
- clic_enable_interrupt(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_0));
GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << RED_LED_OFFSET);
}
@@ -74,7 +73,6 @@ void button_1_isr(void) {
printf("Button 1 was pressed, interrupt level %d. Toggle Blue.\n", level);
GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << BLUE_LED_OFFSET);
wait_ms(500);
- clic_enable_interrupt(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_1));
GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << BLUE_LED_OFFSET);
}
@@ -91,7 +89,6 @@ void button_2_isr(void) {
printf("Button 2 was pressed, interrupt level %d. Toggle Green.\n", level);
GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << GREEN_LED_OFFSET);
wait_ms(500);
- clic_enable_interrupt(&clic, (LOCALINTIDBASE + LOCAL_INT_BTN_2));
GPIO_REG(GPIO_OUTPUT_VAL) = GPIO_REG(GPIO_OUTPUT_VAL) ^ (0x1 << GREEN_LED_OFFSET);
}
@@ -137,7 +134,7 @@ int main(int argc, char **argv)
CLIC_CONFIG_BITS);
//use all 4 config bits for levels, no shv
- clic_set_cliccfg(&clic, ((CLIC_CONFIG_BITS<<1)|0));
+ clic_set_cliccfg(&clic, (CLIC_CONFIG_BITS<<1));
//initialize gpio and buttons.
//each button registers an interrupt handler