aboutsummaryrefslogtreecommitdiff
path: root/tests/test_irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_irq.c')
-rw-r--r--tests/test_irq.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_irq.c b/tests/test_irq.c
new file mode 100644
index 0000000..3c4ee9c
--- /dev/null
+++ b/tests/test_irq.c
@@ -0,0 +1,43 @@
+#include "test_harness.h"
+
+#include "arch/stm32l4xxx/peripherals/irq.h"
+#include "arch/stm32l4xxx/peripherals/nvic.h"
+
+TEST(irq, nvic)
+{
+ interrupt_set_t is = { 0 };
+
+ interrupt_set_add(&is, IRQ_USART2);
+ interrupt_set_add(&is, IRQ_USART3);
+
+ enable_interrupts(&is);
+
+ ASSERT_EQ(is.irqs[1], 0xC0);
+ ASSERT_EQ(NVIC.ise_r[1], 0xC0);
+
+ return 0;
+}
+
+TEST(irq, nvic_edgecase)
+{
+ interrupt_set_t is = { 0 };
+ interrupt_set_add(&is, IRQ_WWDG_IRQ);
+ interrupt_set_add(&is, IRQ_I2C1_ER);
+
+ enable_interrupts(&is);
+
+ ASSERT_EQ(is.irqs[0], 1);
+ ASSERT_EQ(NVIC.ise_r[0], 1);
+ ASSERT_EQ(is.irqs[1], 1);
+ ASSERT_EQ(NVIC.ise_r[1], 1);
+
+ return 0;
+}
+
+TEST(irq, enable_single_interrupt)
+{
+ enable_interrupt(IRQ_USART2);
+ ASSERT_EQ(NVIC.ise_r[1], 0x40);
+
+ return 0;
+}