formatted code.
This commit is contained in:
@@ -13,50 +13,55 @@ uint32_t tmcReg[32] = {0};
|
||||
|
||||
TIMECTRL_CONFIG tmcConfig = {
|
||||
.baseAddr = 0,
|
||||
.reset = 10
|
||||
};
|
||||
.reset = 10};
|
||||
|
||||
TIMECTRL_INST* tmcInstPtr = NULL;
|
||||
TIMECTRL_INST *tmcInstPtr = NULL;
|
||||
|
||||
void tmc_setup(void){
|
||||
void tmc_setup(void)
|
||||
{
|
||||
int32_t Status;
|
||||
tmcReg[1] = HARDWARE_VERSION; // Version
|
||||
tmcReg[2] = 253; // Int
|
||||
tmcReg[3] = 253; // Frac
|
||||
tmcReg[4] = 0; // Reset
|
||||
tmcReg[5] = 0; // Preset H
|
||||
tmcReg[6] = 0; // Preset L
|
||||
tmcReg[7] = 0; // Adjustment H
|
||||
tmcReg[8] = 0; // Adjustment L
|
||||
tmcReg[9] = 0; // Adjustment Trigger
|
||||
tmcReg[10] = 0; // step opt
|
||||
tmcReg[2] = 253; // Int
|
||||
tmcReg[3] = 253; // Frac
|
||||
tmcReg[4] = 0; // Reset
|
||||
tmcReg[5] = 0; // Preset H
|
||||
tmcReg[6] = 0; // Preset L
|
||||
tmcReg[7] = 0; // Adjustment H
|
||||
tmcReg[8] = 0; // Adjustment L
|
||||
tmcReg[9] = 0; // Adjustment Trigger
|
||||
tmcReg[10] = 0; // step opt
|
||||
tmcConfig.baseAddr = (uintptr_t)tmcReg;
|
||||
Status = TimeCtrl_Init(&tmcInstPtr, &tmcConfig);
|
||||
ASSERT_EQUAL(SUCCESS, Status);
|
||||
}
|
||||
|
||||
void tmc_teardown(void){
|
||||
void tmc_teardown(void)
|
||||
{
|
||||
TimeCtrl_Destroy(tmcInstPtr);
|
||||
}
|
||||
|
||||
TEST(tmc_version) {
|
||||
TEST(tmc_version)
|
||||
{
|
||||
ASSERT_EQUAL(HARDWARE_VERSION, TimeCtrl_GetVersion(tmcInstPtr));
|
||||
return;
|
||||
}
|
||||
|
||||
TEST(tmc_basic_operations) {
|
||||
TEST(tmc_basic_operations)
|
||||
{
|
||||
TIME_WORD timeStamp;
|
||||
TIME_INT timeH;
|
||||
TIME_FRAC timeL;
|
||||
TimeCtrl_GetCurrentTime(tmcInstPtr, &timeStamp);
|
||||
timeH = TimeCtrl_GetIntCnt(tmcInstPtr);
|
||||
timeL = TimeCtrl_GetFracCnt(tmcInstPtr);
|
||||
if(timeL >= timeStamp.frac_part) {
|
||||
if (timeL >= timeStamp.frac_part)
|
||||
{
|
||||
ASSERT_EQUAL(timeH, timeStamp.int_part);
|
||||
ASSERT_TRUE(timeL - timeStamp.frac_part < MAX_OPT_DELAY);
|
||||
}
|
||||
else {
|
||||
ASSERT_EQUAL(timeH, timeStamp.int_part+1);
|
||||
else
|
||||
{
|
||||
ASSERT_EQUAL(timeH, timeStamp.int_part + 1);
|
||||
ASSERT_TRUE(timeL + TIME_FRAC_MAX - timeStamp.frac_part < MAX_OPT_DELAY);
|
||||
}
|
||||
|
||||
@@ -69,16 +74,16 @@ TEST(tmc_basic_operations) {
|
||||
return;
|
||||
}
|
||||
|
||||
TEST_SUITE(tmc_unit_test) {
|
||||
TEST_SUITE(tmc_unit_test)
|
||||
{
|
||||
TEST_SUITE_CONFIGURE(tmc_setup, tmc_teardown);
|
||||
RUN_TEST(tmc_version);
|
||||
RUN_TEST(tmc_basic_operations);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int main(void)
|
||||
{
|
||||
RUN_TEST_SUITE(tmc_unit_test);
|
||||
TEST_REPORT();
|
||||
return TEST_EXIT_CODE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user