Debian Codegraph @

examples/temp_sensor/test/TestTimerInterruptConfigurator.c

raw symbols SCIP
1 #include "unity.h"
2 #include "Types.h"
3 #include "TimerInterruptConfigurator.h"
4 #include "MockTimerInterruptHandler.h"
5 #include "AT91SAM7X256.h"
6
7 AT91S_AIC AicPeripheral;
8 AT91S_TC TimerCounter0Peripheral;
9
10 void setUp(void)
11 {
12 }
13
14 void tearDown(void)
15 {
16 }
17
18 void test_TIMER0_ID_MASK_ShouldBeCorrect(void)
19 {
20 TEST_ASSERT_EQUAL(((uint32)0x1) << AT91C_ID_TC0, TIMER0_ID_MASK);
21 }
22
23 void testDisableInterruptDisablesTimer0InterruptInTheInterruptController(void)
24 {
25 AT91C_BASE_AIC->AIC_IDCR = 0;
26 Timer_DisableInterrupt();
27 TEST_ASSERT_EQUAL(TIMER0_ID_MASK, AT91C_BASE_AIC->AIC_IDCR);
28 }
29
30 void testResetSystemTimeDelegatesTo_Timer_SetSystemTime_Appropriately(void)
31 {
32 Timer_SetSystemTime_Expect(0);
33 Timer_ResetSystemTime();
34 }
35
36 void testConfigureInterruptShouldSetInterruptHandlerAppropriately(void)
37 {
38 AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = (uint32)NULL;
39 Timer_ConfigureInterrupt();
40 TEST_ASSERT_EQUAL((uint32)Timer_InterruptHandler, AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0]);
41 }
42
43 void testConfigureInterruptShouldSetInterruptLevelInSourceModeRegisterAppropriately(void)
44 {
45 AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] = 0;
46 Timer_ConfigureInterrupt();
47 TEST_ASSERT_EQUAL(
48 AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL,
49 AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] & 0x00000060);
50 }
51
52 void testConfigureInterruptShouldSetInterruptPriorityInSourceModeRegisterAppropriately(void)
53 {
54 AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] = 0;
55 Timer_ConfigureInterrupt();
56 TEST_ASSERT_EQUAL(1, AT91C_BASE_AIC->AIC_SMR[AT91C_ID_TC0] & 0x00000007);
57 }
58
59 void testConfigureInterruptShouldClearTimer0InterruptOnTheInterruptController(void)
60 {
61 AT91C_BASE_AIC->AIC_ICCR = 0;
62 Timer_ConfigureInterrupt();
63 TEST_ASSERT_EQUAL(TIMER0_ID_MASK, AT91C_BASE_AIC->AIC_ICCR);
64 }
65
66 void testConfigureInterruptShouldEnableCompareInterruptForRegisterC(void)
67 {
68 AT91C_BASE_TC0->TC_IER = 0;
69 Timer_ConfigureInterrupt();
70 TEST_ASSERT_EQUAL(AT91C_TC_CPCS, AT91C_BASE_TC0->TC_IER);
71 }
72
73 void testEnableInterruptShouldEnableTimer0InterruptsInInterruptCotroller(void)
74 {
75 AT91C_BASE_AIC->AIC_IECR = 0;
76 Timer_EnableInterrupt();
77 TEST_ASSERT_EQUAL(TIMER0_ID_MASK, AT91C_BASE_AIC->AIC_IECR);
78 }