
#ifndef TEST_IRME_H
#define TEST_IRME_H

/* std and typedef related */
#include <stdio.h>
#include "typedefs.h"
#include "StdRegMacros.h"

/* The compare type of count values */
typedef enum
{
  COMPARE_TYPE_NOT_EQUEL_ZERO = 0,
  COMPARE_TYPE_NOT_EQUEL,
  COMPARE_TYPE_EQUEL,
}COUNT_COMPARE_TYPE;

/* The definition of test step enum */
typedef enum
{
  TEST_STEP_1 = 1,
  TEST_STEP_2,
  TEST_STEP_3,
  TEST_STEP_4,
  TEST_STEP_5,
  TEST_STEP_6,
  TEST_STEP_7,
  TEST_STEP_8,
  TEST_STEP_9,
  
}TEST_STEP_TYPE;

/* The result of checking the DET errors status */
typedef enum
{
  CHECK_ERR_STATUS_FAILED = 0,
  CHECK_ERR_STATUS_SUCCESS ,
}CHECK_ERR_STATUS_RESULT;

/* The register read/write attribute */
typedef enum
{
    READ_WRITE_ATTR = 0U,
    READ_ONLY_ATTR  = 1U,
    WRITE_ONLY_ATTR = 2U,
    WRITE_1_CLR_ATTR = 3U
}Register_RWAttrType;

/* The inserted API type */
typedef void (*Api_InsertedType)(void);

/* The registers bit region abstract object*/
typedef struct
{
    uint8_t *bitRegionName;     //!<Bit region name 
    uint32_t bitRegionOffset;   //!<Bit region offset
    uint32_t bitRegionMask;      //!<Bit region bits mask
    uint32_t bitRegionVal;      //!<Bit region value
}Register_BitRegionObjType;

/* The registers abstract object*/
typedef struct
{
    uint8_t *regName;    //!<Register name 
    uint32_t regAddr;    //!<Register address
    uint32_t regVal;     //!<Register value
    Register_RWAttrType regRWAttr;  //!<Register read/write attribute
    Register_BitRegionObjType *bitRegionArrPtr;  //!<Bit region array
    uint8_t bitRegionCnt;  //!<Bit region count
    Api_InsertedType insertApi;  //!<The inserted api:wait some flag
}Register_ObjType;

/** 
* @brief Variables of this type are used to record the step result.
* @implements TestResult
*/
typedef enum
{
    TEST_SUCCESS = 0U,
    TEST_FAILED
} TestResult;

/* Test case function pointer definition */
typedef TestResult (*TestCase)(void);

extern const TestCase testCases[];
extern const int NUM_OF_TEST_CASES;

/* The funcitons used in test cases*/
void print_test_start(const uint8_t *i_p_test_case);
void print_test_end(const uint8_t *i_p_test_case);
void print_test_step(const uint8_t i_cur_step);
void print_refered_single_debug_res(uint8_t *i_p_refered_info);
TestResult check_res_test(uint16_t i_res_steps, uint8_t i_total_steps, const uint8_t *i_p_test_case);
void print_common_string(uint8_t *i_p_str);
void sys_delay(uint32_t i_delay_time);

#endif
