summaryrefslogtreecommitdiff
path: root/FreeRTOS-Plus/Test/CMock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c
diff options
context:
space:
mode:
Diffstat (limited to 'FreeRTOS-Plus/Test/CMock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c')
-rw-r--r--FreeRTOS-Plus/Test/CMock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/FreeRTOS-Plus/Test/CMock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c b/FreeRTOS-Plus/Test/CMock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c
new file mode 100644
index 000000000..13c35f444
--- /dev/null
+++ b/FreeRTOS-Plus/Test/CMock/examples/temp_sensor/test/TestTimerInterruptConfigurator.c
@@ -0,0 +1,78 @@
+#include "unity.h"
+#include "Types.h"
+#include "TimerInterruptConfigurator.h"
+#include "MockTimerInterruptHandler.h"
+#include "AT91SAM7X256.h"
+
+AT91S_AIC AicPeripheral;
+AT91S_TC TimerCounter0Peripheral;
+
+void setUp(void)
+{
+}
+
+void tearDown(void)
+{
+}
+
+void test_TIMER0_ID_MASK_ShouldBeCorrect(void)
+{
+ TEST_ASSERT_EQUAL(((uint32)0x1) << AT91C_ID_TC0, TIMER0_ID_MASK);
+}
+
+void testDisableInterruptDisablesTimer0InterruptInTheInterruptController(void)
+{
+ AT91C_BASE_AIC->AIC_IDCR = 0;
+ Timer_DisableInterrupt();
+ TEST_ASSERT_EQUAL(TIMER0_ID_MASK, AT91C_BASE_AIC->AIC_IDCR);
+}
+
+void testResetSystemTimeDelegatesTo_Timer_SetSystemTime_Appropriately(void)
+{
+ Timer_SetSystemTime_Expect(0);
+ Timer_ResetSystemTime();
+}
+
+void testConfigureInterruptShouldSetInterruptHandlerAppropriately(void)
+{
+ AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = (uint32)NULL;
+ Timer_ConfigureInterrupt();
+ TEST_ASSERT_EQUAL((uint32)Timer_InterruptHandler, AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0]);
+}
+
+void testConfigureInterruptShouldSetInterruptLevelInSourceModeRegisterAppropriately(void)
+{
+ AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] = 0;
+ Timer_ConfigureInterrupt();
+ TEST_ASSERT_EQUAL(
+ AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
+ AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] & 0x00000060);
+}
+
+void testConfigureInterruptShouldSetInterruptPriorityInSourceModeRegisterAppropriately(void)
+{
+ AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] = 0;
+ Timer_ConfigureInterrupt();
+ TEST_ASSERT_EQUAL(1, AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] & 0x00000007);
+}
+
+void testConfigureInterruptShouldClearTimer0InterruptOnTheInterruptController(void)
+{
+ AT91C_BASE_AIC->AIC_ICCR = 0;
+ Timer_ConfigureInterrupt();
+ TEST_ASSERT_EQUAL(TIMER0_ID_MASK, AT91C_BASE_AIC->AIC_ICCR);
+}
+
+void testConfigureInterruptShouldEnableCompareInterruptForRegisterC(void)
+{
+ AT91C_BASE_TC0->TC_IER = 0;
+ Timer_ConfigureInterrupt();
+ TEST_ASSERT_EQUAL(AT91C_TC_CPCS, AT91C_BASE_TC0->TC_IER);
+}
+
+void testEnableInterruptShouldEnableTimer0InterruptsInInterruptCotroller(void)
+{
+ AT91C_BASE_AIC->AIC_IECR = 0;
+ Timer_EnableInterrupt();
+ TEST_ASSERT_EQUAL(TIMER0_ID_MASK, AT91C_BASE_AIC->AIC_IECR);
+}