197 lines
6.7 KiB
C
197 lines
6.7 KiB
C
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
|
|
|
/*=======Test Runner Used To Run Each Test Below=====*/
|
|
#define RUN_TEST(TestFunc, TestLineNum) \
|
|
{ \
|
|
Unity.CurrentTestName = #TestFunc; \
|
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
|
Unity.NumberOfTests++; \
|
|
if (TEST_PROTECT()) { \
|
|
setUp(); \
|
|
TestFunc(); \
|
|
} \
|
|
if (TEST_PROTECT()) { \
|
|
tearDown(); \
|
|
} \
|
|
UnityConcludeTest(); \
|
|
}
|
|
|
|
/*=======Automagically Detected Files To Include=====*/
|
|
#include "unity.h"
|
|
#include <setjmp.h>
|
|
#include <stdio.h>
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
|
|
/*======= Functions This Runner Calls=====*/
|
|
#include "Driver_DUAL_TIMER.h"
|
|
#include "IOMuxManager.h"
|
|
#include "ClockManager.h"
|
|
#include "chip.h"
|
|
#include "systick.h"
|
|
|
|
void *dualtimer_handler = NULL;
|
|
|
|
// /*Global control macro*/
|
|
#define dualtimer_test_channel (CSK_TIMER_CHANNEL_1)
|
|
#define dualtimer_reload_count (1500)
|
|
|
|
static volatile uint32_t dualtimer_flag = 0;
|
|
|
|
/*Callback*/
|
|
static void dualtimer_eventcallback(uint32_t event, void *workspace)
|
|
{
|
|
dualtimer_flag = 1;
|
|
}
|
|
|
|
static void dualtimer_test_init(void)
|
|
{
|
|
DUALTIMERS_Initialize(dualtimer_handler);
|
|
DUALTIMERS_PowerControl(dualtimer_handler, CSK_POWER_FULL);
|
|
DUALTIMERS_SetTimerCallback(dualtimer_handler, dualtimer_test_channel, dualtimer_eventcallback, NULL);
|
|
DUALTIMERS_SetTimerPeriodByCount(dualtimer_handler, dualtimer_test_channel, dualtimer_reload_count);
|
|
}
|
|
|
|
static void dualtimer_test_uninit(void)
|
|
{
|
|
DUALTIMERS_StopTimer(dualtimer_handler, dualtimer_test_channel);
|
|
DUALTIMERS_PowerControl(dualtimer_handler, CSK_POWER_OFF);
|
|
DUALTIMERS_Uninitialize(dualtimer_handler);
|
|
}
|
|
|
|
void setUp(void)
|
|
{
|
|
/* This is run before EACH TEST */
|
|
dualtimer_handler = DUALTIMERS1();
|
|
dualtimer_test_init();
|
|
enable_GINT();
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
dualtimer_test_uninit();
|
|
disable_GINT();
|
|
}
|
|
|
|
void test_dualtimer_pointer_verify(void)
|
|
{
|
|
TEST_ASSERT_NOT_NULL(dualtimer_handler);
|
|
}
|
|
|
|
void test_dualtimer_interrupt_one_shot(void)
|
|
{
|
|
DUALTIMERS_Control(dualtimer_handler, CSK_TIMER_PRESCALE_Divide_1 | \
|
|
CSK_TIMER_SIZE_16Bit | \
|
|
CSK_TIMER_MODE_OneShot | \
|
|
CSK_TIMER_INTERRUPT_Enabled, dualtimer_test_channel);
|
|
|
|
|
|
DUALTIMERS_StartTimer(dualtimer_handler, dualtimer_test_channel);
|
|
|
|
while (dualtimer_flag == 0);
|
|
dualtimer_flag = 0;
|
|
|
|
uint32_t count = 0;
|
|
DUALTIMERS_ReadTimerCount(dualtimer_handler, dualtimer_test_channel, &count);
|
|
|
|
TEST_ASSERT_EQUAL_UINT32(0, count);
|
|
}
|
|
|
|
void test_dualtimer_interrupt_free_running(void)
|
|
{
|
|
DUALTIMERS_Control(dualtimer_handler, CSK_TIMER_PRESCALE_Divide_1 | \
|
|
CSK_TIMER_SIZE_16Bit | \
|
|
CSK_TIMER_MODE_FreeRunning | \
|
|
CSK_TIMER_INTERRUPT_Enabled, dualtimer_test_channel);
|
|
|
|
DUALTIMERS_StartTimer(dualtimer_handler, dualtimer_test_channel);
|
|
|
|
while (dualtimer_flag == 0);
|
|
dualtimer_flag = 0;
|
|
|
|
uint32_t count = 0;
|
|
DUALTIMERS_ReadTimerCount(dualtimer_handler, dualtimer_test_channel, &count);
|
|
|
|
TEST_ASSERT_NOT_EQUAL_UINT32(0, count);
|
|
}
|
|
|
|
void test_dualtimer_interrupt_periodic(void)
|
|
{
|
|
DUALTIMERS_Control(dualtimer_handler, CSK_TIMER_PRESCALE_Divide_1 | \
|
|
CSK_TIMER_SIZE_32Bit | \
|
|
CSK_TIMER_MODE_Periodic | \
|
|
CSK_TIMER_INTERRUPT_Enabled, dualtimer_test_channel);
|
|
|
|
DUALTIMERS_StartTimer(dualtimer_handler, dualtimer_test_channel);
|
|
|
|
while (dualtimer_flag == 0);
|
|
dualtimer_flag = 0;
|
|
|
|
uint32_t count = 0;
|
|
DUALTIMERS_ReadTimerCount(dualtimer_handler, dualtimer_test_channel, &count);
|
|
|
|
TEST_ASSERT_EQUAL_UINT32(dualtimer_reload_count, count);
|
|
}
|
|
|
|
void test_dualtimer_interrupt_free_running_in_div16(void)
|
|
{
|
|
DUALTIMERS_Control(dualtimer_handler, CSK_TIMER_PRESCALE_Divide_16 | \
|
|
CSK_TIMER_SIZE_16Bit | \
|
|
CSK_TIMER_MODE_FreeRunning | \
|
|
CSK_TIMER_INTERRUPT_Enabled, dualtimer_test_channel);
|
|
|
|
|
|
DUALTIMERS_StartTimer(dualtimer_handler, dualtimer_test_channel);
|
|
|
|
while (dualtimer_flag == 0);
|
|
dualtimer_flag = 0;
|
|
|
|
uint32_t count = 0;
|
|
|
|
SysTick_Delay_Ms(5);
|
|
DUALTIMERS_ReadTimerCount(dualtimer_handler, dualtimer_test_channel, &count);
|
|
|
|
TEST_ASSERT_NOT_EQUAL_UINT32(0, count);
|
|
}
|
|
|
|
void test_dualtimer_interrupt_free_running_in_div1_32bit(void)
|
|
{
|
|
DUALTIMERS_Control(dualtimer_handler, CSK_TIMER_PRESCALE_Divide_1 | \
|
|
CSK_TIMER_SIZE_32Bit | \
|
|
CSK_TIMER_MODE_FreeRunning | \
|
|
CSK_TIMER_INTERRUPT_Enabled, dualtimer_test_channel);
|
|
|
|
DUALTIMERS_StartTimer(dualtimer_handler, dualtimer_test_channel);
|
|
|
|
while (dualtimer_flag == 0);
|
|
dualtimer_flag = 0;
|
|
|
|
uint32_t count = 0;
|
|
|
|
DUALTIMERS_ReadTimerCount(dualtimer_handler, dualtimer_test_channel, &count);
|
|
|
|
TEST_ASSERT_NOT_EQUAL_UINT32(0, count);
|
|
}
|
|
|
|
/*=======Test Reset Option=====*/
|
|
void resetTest(void);
|
|
void resetTest(void)
|
|
{
|
|
tearDown();
|
|
setUp();
|
|
}
|
|
|
|
/*=======MAIN=====*/
|
|
int main(void)
|
|
{
|
|
UnityBegin("test/derivers/dualtimer/test_dualtimer.c");
|
|
RUN_TEST(test_dualtimer_pointer_verify, __LINE__);
|
|
RUN_TEST(test_dualtimer_interrupt_one_shot, __LINE__);
|
|
RUN_TEST(test_dualtimer_interrupt_free_running, __LINE__);
|
|
RUN_TEST(test_dualtimer_interrupt_periodic, __LINE__);
|
|
RUN_TEST(test_dualtimer_interrupt_free_running_in_div16, __LINE__);
|
|
RUN_TEST(test_dualtimer_interrupt_free_running_in_div1_32bit, __LINE__);
|
|
return (UnityEnd());
|
|
}
|