Sha256: 4d0461221d1e7d984ac69e27e9e400faa678e9d958e34b9a62e9741fa8aaa664

Contents?: true

Size: 1.64 KB

Versions: 37

Compression:

Stored size: 1.64 KB

Contents

#include "unity.h"
#include "Types.h"
#include "TimerInterruptHandler.h"
#include "AT91SAM7X256.h"

AT91S_TC  TimerCounter0Peripheral;

void setUp(void)
{
}

void tearDown(void)
{
}

void testSetAndGetSystemTime(void)
{
  Timer_SetSystemTime(0);
  TEST_ASSERT_EQUAL(0, Timer_GetSystemTime());

  Timer_SetSystemTime(129837);
  TEST_ASSERT_EQUAL(129837, Timer_GetSystemTime());

  Timer_SetSystemTime(UINT32_MAX);
  TEST_ASSERT_EQUAL(UINT32_MAX, Timer_GetSystemTime());
}

void testInterruptHandlerShouldIncrementSystemTimeOnlyIfStatusHasCompareRegisterCOverflowBitSet(void)
{
  Timer_SetSystemTime(0);
  AT91C_BASE_TC0->TC_SR = 0;
  Timer_InterruptHandler();
  TEST_ASSERT_EQUAL(0, Timer_GetSystemTime());

  Timer_SetSystemTime(0);
  AT91C_BASE_TC0->TC_SR = ~AT91C_TC_CPCS;
  Timer_InterruptHandler();
  TEST_ASSERT_EQUAL(0, Timer_GetSystemTime());

  Timer_SetSystemTime(0);
  AT91C_BASE_TC0->TC_SR = AT91C_TC_CPCS;
  Timer_InterruptHandler();
  TEST_ASSERT(Timer_GetSystemTime() > 0);

  Timer_SetSystemTime(0);
  AT91C_BASE_TC0->TC_SR = 0xffffffff;
  Timer_InterruptHandler();
  TEST_ASSERT(Timer_GetSystemTime() > 0);
}

void testInterruptHandlerShouldIncrementSystemTimerBy_10(void)
{
  Timer_SetSystemTime(0);
  AT91C_BASE_TC0->TC_SR = AT91C_TC_CPCS;
  Timer_InterruptHandler();
  TEST_ASSERT_EQUAL(10, Timer_GetSystemTime());

  AT91C_BASE_TC0->TC_SR = AT91C_TC_CPCS;
  Timer_InterruptHandler();
  TEST_ASSERT_EQUAL(20, Timer_GetSystemTime());

  Timer_SetSystemTime(39426857);
  AT91C_BASE_TC0->TC_SR = AT91C_TC_CPCS;
  Timer_InterruptHandler();
  TEST_ASSERT_EQUAL(39426867, Timer_GetSystemTime());
}

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ceedling-0.29.1 vendor/cmock/examples/temp_sensor/test/TestTimerInterruptHandler.c
ceedling-0.29.0 vendor/cmock/examples/temp_sensor/test/TestTimerInterruptHandler.c
ceedling-0.18.0 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.17.0 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.16.0 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.15.6 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.15.5 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.15.4 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.15.3 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.15.2 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.15.1 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.15.0 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.13.0 vendor/cmock/examples/test/TestTimerInterruptHandler.c
ceedling-0.12.2 examples/temp_sensor/test/test_TimerInterruptHandler.c
ceedling-0.12.1 examples/temp_sensor/test/test_TimerInterruptHandler.c
ceedling-0.12.0 examples/temp_sensor/test/test_TimerInterruptHandler.c
ceedling-0.11.2 examples/temp_sensor/test/test_TimerInterruptHandler.c
ceedling-0.11.1 examples/temp_sensor/test/test_TimerInterruptHandler.c
ceedling-0.11.0 examples/temp_sensor/test/test_TimerInterruptHandler.c
ceedling-0.10.0 examples/temp_sensor/test/test_TimerInterruptHandler.c