Selaa lähdekoodia

feat: 增加单元测试Api,所有单元测试通过

CN\guohui27 2 vuotta sitten
vanhempi
sitoutus
d89a9e1629

+ 0 - 16
User project/2.MotorDrive/Include/adc.h

@@ -163,14 +163,6 @@ _ADCDRV_EXT UWORD adc_RdsonADCGainMin;
 _ADCDRV_EXT UWORD adc_RdsonADCGainSum2;
 _ADCDRV_EXT UWORD adc_RdsonADCGainRecord[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 _ADCDRV_EXT UWORD adc_RdsonADCGainSum = 0;
-_ADCDRV_EXT UWORD adc_uwADDMAPhase1;
-_ADCDRV_EXT UWORD adc_uwADDMAPhase2;
-
-_ADCDRV_EXT UWORD adc_uwRdsonUReg;
-_ADCDRV_EXT UWORD adc_uwRdsonVReg;
-_ADCDRV_EXT UWORD adc_uwRdsonWReg;
-
-_ADCDRV_EXT BOOL tsttstFlg = FALSE;
 
 #else
 _ADCDRV_EXT ADC_COF      adc_stCof;
@@ -185,14 +177,6 @@ _ADCDRV_EXT UWORD adc_RdsonADCGainMin;
 _ADCDRV_EXT UWORD adc_RdsonADCGainSum2;
 _ADCDRV_EXT UWORD adc_RdsonADCGainRecord[10];
 _ADCDRV_EXT UWORD adc_RdsonADCGainSum;
-_ADCDRV_EXT UWORD adc_uwADDMAPhase1;
-_ADCDRV_EXT UWORD adc_uwADDMAPhase2;
-
-_ADCDRV_EXT UWORD adc_uwRdsonUReg;
-_ADCDRV_EXT UWORD adc_uwRdsonVReg;
-_ADCDRV_EXT UWORD adc_uwRdsonWReg;
-
-_ADCDRV_EXT BOOL tsttstFlg;
 
 #endif
 /************************************************************************

+ 1 - 1
User project/2.MotorDrive/Source/adc.c

@@ -189,7 +189,7 @@ void adc_voSampleDown(const ADC_COF *cof, ADC_DOWN_OUT *out) /* parasoft-suppres
 
         /* Register value */
         out->uwFirstCurREG = iAdc_GetResultPointer(2)[HW_ADC_IDC_CH];  // Q12
-        out->uwSecondCurREG = adc_uwADDMAPhase2; // Q12
+        //out->uwSecondCurREG = adc_uwADDMAPhase2; // Q12
 
         tmp_swIphase1 = (SWORD)out->uwFirstCurREG - (SWORD)cof->uwIdcOffset;
         tmp_swIphase1 = (SWORD)((tmp_swIphase1 * (SLONG)cof->uwCurIdcReg2Pu) >> 10); // Q14=Q24-Q10

+ 30 - 23
User project/3.BasicFunction/Source/torquesensor.c

@@ -201,29 +201,6 @@ void torsensor_voTorSensorCof(void)
 //    }
 }
 
-/***************************************************************
- Function: torsensor_voTorSensorInit;
- Description: Torque initialization
- Call by: functions in main loop;
- Input Variables: N/A
- Output/Return Variables: N/A
- Subroutine Call: N/A;
- Reference: N/A
-****************************************************************/
-static LPF_OUT tst_dynOffsetLpf;
-static UWORD tsttorqCadCnt,tsttorqMin=4096,tstdynOffset;
-void torsensor_voTorSensorInit(void)
-{
-    torsensor_stTorSensorOut.uwTorqueReg = 0;
-    torsensor_stTorSensorOut.uwTorquePu = 0;
-    torsensor_stTorSensorOut.uwTorqueLPFPu = 0;
-    torsensor_stTorSensorOut.uwTorqueErrorCnt = 0;
-    torsensor_stTorSensorOut.blTorqueCaliFlg = FALSE;
-    torsensor_stTorSensorOut.blTorqueErrorFlg = FALSE;
-    mth_voLPFilterCoef(1000000 / 1, EVENT_1MS_HZ, &tst_dynOffsetLpf.uwKx); //25Hz  
-    tstdynOffset= iAdc_GetResultPointer(0)[HW_ADC_TORQ_CH]; 
-    tst_dynOffsetLpf.slY.sw.hi =  (SWORD)iAdc_GetResultPointer(0)[HW_ADC_TORQ_CH];   
-}
 
 /*************************************************************************
  Local Functions (N/A)
@@ -539,6 +516,36 @@ void torsensor_voTorADC(void) // need to match ADC_StartConversion(ADC1);
 //
 //}
 
+/***************************************************************
+ Function: torsensor_voTorSensorInit;
+ Description: Torque initialization
+ Call by: functions in main loop;
+ Input Variables: N/A
+ Output/Return Variables: N/A
+ Subroutine Call: N/A;
+ Reference: N/A
+****************************************************************/
+static LPF_OUT tst_dynOffsetLpf;
+static UWORD tsttorqCadCnt,tsttorqMin=4096,tstdynOffset;
+void torsensor_voTorSensorInit(void)
+{
+    torsensor_stTorSensorOut.uwTorqueReg = 0;
+    torsensor_stTorSensorOut.uwTorquePu = 0;
+    torsensor_stTorSensorOut.uwTorqueLPFPu = 0;
+    torsensor_stTorSensorOut.uwTorqueErrorCnt = 0;
+    torsensor_stTorSensorOut.blTorqueCaliFlg = FALSE;
+    torsensor_stTorSensorOut.blTorqueErrorFlg = FALSE;
+    mth_voLPFilterCoef(1000000 / 1, EVENT_1MS_HZ, &tst_dynOffsetLpf.uwKx); //25Hz  
+    tstdynOffset= iAdc_GetResultPointer(0)[HW_ADC_TORQ_CH]; 
+    tst_dynOffsetLpf.slY.sw.hi =  (SWORD)iAdc_GetResultPointer(0)[HW_ADC_TORQ_CH];   
+
+    tor_pvt_uwOffsetTarget = 0;
+    tor_pvt_uwOffsetMax = 0;
+    tor_pvt_uwOffsetMin = 4096;
+    tor_pvt_ulCnt = 0;
+    tor_pvt_ulCnt2 = 0;
+}
+
 
 /*************************************************************************
  Local Functions (N/A)

+ 1 - 1
User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Include/user.h

@@ -110,7 +110,7 @@ Update Time
 #define M_MAX_TOR_NM        30      // unit: 0.1Nm, Max tor
 
 #elif (MOTOR_ID_SEL == MOTOR_WELLING_CITY_36V)
-#define M_POLE_PAIRS        17       // unit:Null,Pole pairs
+#define M_POLE_PAIRS        7       // unit:Null,Pole pairs
 #define M_RS_OHM            150     // unit: 0.1mOhm, Phase resistance
 #define M_MATERIAL          Al      // unit:Null
 #define M_LD_NOLOAD_MH      7650    // unit: 0.01uH, D axis inductance

+ 1 - 71
User project/5.Api_rt/api_rt_adc.c

@@ -10,39 +10,11 @@ ApiRtAdc_Handle Adcs[3];
 
 void iRtAdc_Init(void)
 {
-    // ADC0 Regular
-    Adcs[0].AdcBase = ADC0;
-    Adcs[0].DmaBase = DMA0;
-    Adcs[0].DmaChannelBase = DMA_CH0;
-    for (int i = 0; i < ADC_RESULT_SIZE; i++)
-    {
-        Adcs[0].Results[i] = 0;
-    }
-    // ADC0 Injected
-    Adcs[1].AdcBase = ADC0;
-    for (int i = 1; i < ADC_RESULT_SIZE; i++)
-    {
-        Adcs[1].Results[i] = 0;
-    }
-    // ADC1 Injected
-    Adcs[2].AdcBase = ADC1;
-    for (int i = 0; i < ADC_RESULT_SIZE; i++)
-    {
-        Adcs[2].Results[i] = 0;
-    }
+
 
 };
 
-void iRtAdc_CompleteIsr(uint8_t devIndex)
-{
-    /* 处理同步采样的逻辑 */
-    iRtPwm_SyncSamplingAdcIsr(0);
 
-    if (Adcs[devIndex].CompleteISR.Action != 0)
-    {
-        Adcs[devIndex].CompleteISR.Action();
-    }
-}
 /* ========================================================================== */
 /* ============================== API Functions ============================= */
 /* ========================================================================== */
@@ -57,45 +29,3 @@ uint16_t* iAdc_GetResultPointer(uint8_t devIndex)
     return Adcs[devIndex].Results;
 }
 
-void iAdc_Enable(uint8_t devIndex)
-{
-    if(RESET == (ADC_CTL1(Adcs[devIndex].AdcBase) & ADC_CTL1_ADCON)){
-        ADC_CTL1(Adcs[devIndex].AdcBase) |= (uint32_t)ADC_CTL1_ADCON;
-    }   
-}
-
-void iAdc_Disable(uint8_t devIndex)
-{
-    ADC_CTL1(Adcs[devIndex].AdcBase) &= ~((uint32_t)ADC_CTL1_ADCON);
-}
-
-ApiAdc_Status iAdc_GetStatus(uint8_t devIndex)
-{
-     if (ADC_STAT(Adcs[devIndex].AdcBase) & ADC_STAT_EOC != 0)
-    {
-        return ApiAdc_End;
-    }
-    else
-    {
-        return ApiAdc_Converting;
-    }
-}
-
-void iAdc_Convert(uint8_t devIndex)
-{
-  //for regular only
-    ADC_CTL1(Adcs[devIndex].AdcBase) |= ADC_CTL1_SWRCST;
-}
-
-int8_t iAdc_ChannelGroupSwitch(uint8_t devIndex, uint8_t groupIndex)
-{
-    return 0;
-}
-
-void iAdc_EnableConversionInterrupt(uint8_t devIndex)
-{
-
-}
-
-void iAdc_EnableHardwareTrigger(uint8_t devIndex);
-void iAdc_DisableHardwareTrigger(uint8_t devIndex);

+ 7 - 0
tests/unit_test/board_sim/api_rt/api_rt.c

@@ -0,0 +1,7 @@
+#include "api_rt.h"
+
+void iRt_Init()
+{
+    iRtGpio_Init();
+    iRtCap_Init();
+}

+ 22 - 0
tests/unit_test/board_sim/api_rt/api_rt.h

@@ -0,0 +1,22 @@
+#ifndef _API_LOW_H_
+#define _API_LOW_H_
+
+#include "api_config.h"
+#include "board_config.h"
+#include "api_board_support.h"
+#include "api_rt_gpio.h"
+#include "api_rt_adc.h"
+#include "api_rt_cap.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+void iRt_Init();
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif

+ 32 - 0
tests/unit_test/board_sim/api_rt/api_rt_adc.c

@@ -0,0 +1,32 @@
+#include "api_rt_adc.h"
+
+
+ApiRtAdc_Handle Adcs[3];
+
+/* ========================================================================== */
+/* ============================ Api RT Functions ============================ */
+/* ========================================================================== */
+
+void iRtAdc_Init(void)
+{
+
+
+};
+
+void iRtAdc_CompleteIsr(uint8_t devIndex)
+{
+
+}
+/* ========================================================================== */
+/* ============================== API Functions ============================= */
+/* ========================================================================== */
+
+uint16_t iAdc_GetResult(uint8_t devIndex, uint8_t channelIndex)
+{
+    return Adcs[devIndex].Results[channelIndex];
+}
+
+uint16_t* iAdc_GetResultPointer(uint8_t devIndex)
+{
+    return Adcs[devIndex].Results;
+}

+ 27 - 0
tests/unit_test/board_sim/api_rt/api_rt_adc.h

@@ -0,0 +1,27 @@
+#ifndef _API_RT_ADC_H_
+#define _API_RT_ADC_H_
+
+#include <stdint.h>
+#include "api_adc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+
+#define ADC_DEVICE_COUNT        1
+#define ADC_RESULT_SIZE         16
+
+typedef struct
+{
+    uint16_t Results[ADC_RESULT_SIZE];
+}  ApiRtAdc_Handle;
+
+extern ApiRtAdc_Handle Adcs[3];
+
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif

+ 50 - 0
tests/unit_test/board_sim/api_rt/api_rt_cap.c

@@ -0,0 +1,50 @@
+#include "api_rt_cap.h"
+#include "api_rt_dbg.h"
+#include "board_config.h"
+#include "test_user.h"
+
+
+ApiRtCap_Handle Caps[1];
+
+
+/* ========================================================================== */
+/* ============================ Api RT Functions ============================ */
+/* ========================================================================== */
+void iRtCap_Init(void)
+{
+    Caps[0].CapBase = TIMER1;
+}
+
+
+
+/* ========================================================================== */
+/* ============================== API Functions ============================= */
+/* ========================================================================== */
+
+uint32_t iCap_GetClock(uint8_t devIndex)
+{
+    return HW_TIM_CLOCK_HZ;
+}
+
+
+uint32_t iCap_GetCaptureValue(uint8_t devIndex, uint8_t channelIndex)
+{
+    uint32_t base = Caps[devIndex].CapBase;
+
+    uint32_t value = 0;
+    switch (channelIndex)
+    {
+    case 2:
+        value = TIMER_CH2CV(base);
+        break;
+    case 3:
+        value = TIMER_CH3CV(base);
+        break;
+    default:
+        break;
+    }
+    return value;
+}
+    
+
+

+ 19 - 0
tests/unit_test/board_sim/api_rt/api_rt_cap.h

@@ -0,0 +1,19 @@
+#ifndef _API_RT_CAP_H_
+#define _API_RT_CAP_H_
+
+#include "api_cap.h"
+#include <stdint.h>
+
+
+typedef struct 
+{
+    uint32_t            CapBase;
+
+} ApiRtCap_Handle;
+
+extern ApiRtCap_Handle Caps[1];
+
+void iRtCap_Init(void);
+void iRtCap_Isr(uint8_t devIndex);
+
+#endif

+ 10 - 0
tests/unit_test/board_sim/api_rt/api_rt_dbg.c

@@ -0,0 +1,10 @@
+#include "api_rt_dbg.h"
+
+AssertFailRecord AssertRecord;
+
+void assert_fail(char *fileName, int lineNo)
+{
+    AssertRecord.LastFileName = fileName;
+    AssertRecord.LastLineNo   = lineNo;
+    AssertRecord.FailCount += 1;
+}

+ 74 - 0
tests/unit_test/board_sim/api_rt/api_rt_dbg.h

@@ -0,0 +1,74 @@
+#ifndef _API_RT_DBG_H_
+#define _API_RT_DBG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+#define API_RT_ASSERT_NONE 0
+#define API_RT_ASSERT_MIN  1
+#define API_RT_ASSERT_FULL 2
+
+#define API_RT_USE_ASSERT API_RT_ASSERT_MIN
+
+#if API_RT_USE_ASSERT == API_RT_ASSERT_FULL
+#define ASSERT_EQ(X, Y)                      \
+    do                                       \
+    {                                        \
+        if (((X) != (Y)))                    \
+        {                                    \
+            assert_fail(__FILE__, __LINE__); \
+            while (1)                        \
+                ;                            \
+        }                                    \
+    } while (0)
+#define ASSERT_LESS(X, Y)                    \
+    do                                       \
+    {                                        \
+        if (((X) >= (Y)))                    \
+        {                                    \
+            assert_fail(__FILE__, __LINE__); \
+            while (1)                        \
+                ;                            \
+        }                                    \
+    } while (0)
+#elif API_RT_USE_ASSERT == API_RT_ASSERT_MIN
+#define ASSERT_EQ(X, Y)   \
+    do                    \
+    {                     \
+        if (((X) != (Y))) \
+        {                 \
+            while (1)     \
+                ;         \
+        }                 \
+    } while (0)
+#define ASSERT_LESS(X, Y) \
+    do                    \
+    {                     \
+        if (((X) >= (Y))) \
+        {                 \
+            while (1)     \
+                ;         \
+        }                 \
+    } while (0)
+#elif API_RT_USE_ASSERT == API_RT_ASSERT_NONE
+#define ASSERT_EQ(X, Y)
+#define ASSERT_LESS(X, Y)
+#endif
+
+typedef struct
+{
+    int   FailCount;
+    char *LastFileName;
+    int   LastLineNo;
+} AssertFailRecord;
+
+extern AssertFailRecord AssertRecord;
+
+void assert_fail(char *fileName, int lineNo);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif

+ 7 - 0
tests/unit_test/board_sim/api_rt/api_rt_delay.c

@@ -0,0 +1,7 @@
+#include "api_rt_delay.h"
+
+void iDelay_Us(uint32_t time)
+{}
+
+void iDelay_Ms(uint32_t time)
+{}

+ 6 - 0
tests/unit_test/board_sim/api_rt/api_rt_delay.h

@@ -0,0 +1,6 @@
+#ifndef _API_RT_DELAY_H_
+#define _API_RT_DELAY_H_
+
+#include "api_delay.h"
+
+#endif

+ 52 - 0
tests/unit_test/board_sim/api_rt/api_rt_gpio.c

@@ -0,0 +1,52 @@
+#include "api_rt_gpio.h"
+#include "test_user.h"
+
+
+Gpio_Handle const Gpios[GPIO_PIN_COUNT] = {
+    [0] = {.GpioBase = GPIOC, .Index = 0},
+    [1] = {.GpioBase = GPIOC, .Index = 1},
+    [2] = {.GpioBase = GPIOC, .Index = 7},
+    [3] = {.GpioBase = GPIOC, .Index = 8},
+    [4] = {.GpioBase = GPIOC, .Index = 15},
+    [5] = {.GpioBase = GPIOC, .Index = 13},
+    [6] = {.GpioBase = GPIOC, .Index = 14},
+    [7] = {.GpioBase = GPIOC, .Index = 10},
+    [8] = {.GpioBase = GPIOC, .Index = 11},
+    [9] = {.GpioBase = GPIOC, .Index = 2},
+    [10] = {.GpioBase = GPIOB, .Index = 9},
+    [11] = {.GpioBase = GPIOB, .Index = 8},
+    [12] = {.GpioBase = GPIOA, .Index = 12},
+    [13] = {.GpioBase = GPIOC, .Index = 12},
+    [14] = {.GpioBase = GPIOB, .Index = 2},
+    [15] = {.GpioBase = GPIOB, .Index = 10},
+};
+
+void iRtGpio_Init()
+{}
+
+void iGpio_SetMode(uint16_t pin, ApiGpio_PinMode mode)
+{
+
+
+}
+
+
+ApiGpio_Level iGpio_Read(uint16_t pin)
+{
+    const Gpio_Handle *const gpio = &Gpios[pin];
+
+    ApiGpio_Level level = ApiGpio_LowLevel;
+
+    if ((uint32_t)0 != (GPIO_ISTAT(gpio->GpioBase)&((uint32_t)((uint32_t)0x01U << gpio->Index))))
+    {
+        level = ApiGpio_HighLevel;
+    }
+
+    return level;
+}
+
+
+void iGpio_Write(uint16_t pin, ApiGpio_Level level)
+{
+
+}

+ 26 - 0
tests/unit_test/board_sim/api_rt/api_rt_gpio.h

@@ -0,0 +1,26 @@
+#ifndef _API_RT_GPIO_H_
+#define _API_RT_GPIO_H_
+
+#include "api_gpio.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif // __cplusplus
+
+#define GPIO_PIN_COUNT 16
+
+typedef struct
+{
+    uint32_t      GpioBase;
+    uint8_t       Index;
+} Gpio_Handle;
+
+extern Gpio_Handle const Gpios[GPIO_PIN_COUNT];
+
+void iRtGpio_Init();
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif

+ 1 - 0
tests/unit_test/test_bikespeed.cpp

@@ -10,6 +10,7 @@ protected:
     static void SetUpTestSuite()
     {
         bikespeed_voBikeSpeedInit();
+        iRt_Init();
     }
     virtual void SetUp() override
     {

+ 1 - 0
tests/unit_test/test_cadence.cpp

@@ -10,6 +10,7 @@ protected:
     static void SetUpTestSuite()
     {
         cadence_voCadenceInit();
+        iRt_Init();
     }
     virtual void SetUp() override
     {

+ 8 - 1
tests/unit_test/test_cursample_calib.cpp

@@ -192,6 +192,13 @@ TEST_P(CurSampleCalibTest1, SingResCalib)
             testAdcIntFlg[ADC1][ADC_INT_FLAG_EOIC] = 0;
         }
 
+        /* Api变量赋值 */
+        Adcs[1].Results[HW_ADC_IA_CH] = adc_uwRdsonUReg;
+        Adcs[1].Results[HW_ADC_IB_CH] = adc_uwRdsonVReg;
+        Adcs[1].Results[HW_ADC_IC_CH] = adc_uwRdsonWReg;
+        Adcs[2].Results[HW_ADC_IDC_CH] = adc_uwADDMAPhase1;
+
+
         /* Timer Interrupt */
         if (testTimerIntFlg[TIMER0][TIMER_INT_FLAG_UP] == 1)
         {
@@ -220,7 +227,7 @@ TEST_P(CurSampleCalibTest1, SingResCalib)
                 pwm_voGen(&pwm_stGenIn, &pwm_stGenCoef, &pwm_stGenOut);
 
                 /* Scope */ 
-                //UdpScope::Send(0, adc_stDownOut.slSampIcPu, adc_stUpOut.swCalibIcPu, adc_stDownOut.swIcPu);
+                UdpScope::Send(0, adc_stDownOut.slSampIcPu, adc_stUpOut.swCalibIcPu, adc_stDownOut.swIcPu);
                 //UdpScope::Send(0, scm_uwSpdFbkLpfAbsPu, pwm_stGenOut.blSampleCalibFlag);
 
                 /* Determine whether the unit test pass */

+ 5 - 0
tests/unit_test/test_torquesensor.cpp

@@ -47,6 +47,7 @@ TEST_P(TorqueSensorTest1, TorqCal)
     torsensor_stTorSensorCof.uwBikeTorStep3RealNm = 75;
     torsensor_stTorSensorCof.uwBikeTorStep4RealNm = 100;
     hw_uwADC0[7] = 720;   // 上电零点
+    Adcs[0].Results[HW_ADC_TORQ_CH] = hw_uwADC0[7];
     torsensor_voTorSensorCof();
 
     /* Torque Input */
@@ -112,6 +113,7 @@ TEST_P(TorqueSensorTest2, OffsetUpdate)
     torsensor_stTorSensorCof.uwBikeTorStep3RealNm = 75;
     torsensor_stTorSensorCof.uwBikeTorStep4RealNm = 100;
     hw_uwADC0[7] = 500;    // 上电零点
+    Adcs[0].Results[HW_ADC_TORQ_CH] = hw_uwADC0[7];
     torsensor_voTorSensorCof();
 
     /* Torque Input */
@@ -147,6 +149,8 @@ TEST_P(TorqueSensorTest2, OffsetUpdate)
             // do nothing 
         }
 
+        Adcs[0].Results[HW_ADC_TORQ_CH] = hw_uwADC0[7];
+
         /* Torque Pu Cal */
         torsensor_voTorADC();
         torsensor_voOffsetUpdate();
@@ -206,6 +210,7 @@ TEST_P(TorquePowerOnTest1, OffsetUpdate)
     torsensor_stTorSensorCof.uwBikeTorStep3RealNm = 75;
     torsensor_stTorSensorCof.uwBikeTorStep4RealNm = 100;
     hw_uwADC0[7] = (uint16_t)GetParam();   // 上电零点
+    Adcs[0].Results[HW_ADC_TORQ_CH] = hw_uwADC0[7];
     torsensor_voTorSensorCof();
 
     i++;

+ 5 - 0
tests/unit_test/test_user.c

@@ -16,6 +16,11 @@ UWORD scm_uwSpdFbkLpfAbsPu;
 UWORD hw_uwADC0[8];
 MC_UpperPCInfo_Struct_t MC_UpcInfo;
 
+UWORD adc_uwRdsonUReg;
+UWORD adc_uwRdsonVReg;
+UWORD adc_uwRdsonWReg;
+UWORD adc_uwADDMAPhase1;
+
 int timer_interrupt_flag_get(int timer_periph, int interrupt)
 {
     return testTimerIntFlg[timer_periph][interrupt];

+ 6 - 1
tests/unit_test/test_user.h

@@ -22,6 +22,7 @@
 
 
 #include "api_rt.h"
+#include "api.h"
 
 
 
@@ -43,6 +44,7 @@ extern "C" {
 #define TIMER_INT_FLAG_CH2 2
 #define TIMER_INT_FLAG_CH3 3
 
+#define GPIOA 0
 #define GPIOB 1
 #define GPIOC 2
 
@@ -65,8 +67,11 @@ extern int testCh3CapValue[2];
 extern int testGpioBValue[2];
 
 
-
 extern UWORD hw_uwADC0[8];
+extern UWORD adc_uwRdsonUReg;
+extern UWORD adc_uwRdsonVReg;
+extern UWORD adc_uwRdsonWReg;
+extern UWORD adc_uwADDMAPhase1;
 
 
 int  timer_interrupt_flag_get(int timer_periph, int interrupt);

+ 5 - 1
xmake.lua

@@ -14,6 +14,7 @@ target("unittest")
     add_files("tests/unit_test/motor_sim/rt_nonfinite.cpp")
     add_files("tests/unit_test/motor_sim/rtGetInf.cpp")
     add_files("tests/unit_test/motor_sim/rtGetNaN.cpp")
+    add_files("tests/unit_test/board_sim/api_rt/*.c")
     
     add_files("User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Source/CodePara.c", "User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Source/mathtool.c")
     add_files("User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Source/macroequ.c","User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Source/glbcof.c")
@@ -22,7 +23,7 @@ target("unittest")
     add_files("User project/2.MotorDrive/Source/packed/pwrlim.c", "User project/2.MotorDrive/Source/packed/asr.c", "User project/2.MotorDrive/Source/packed/brake.c")
     add_files("User project/3.BasicFunction/Source/Temp.c")
 
-
+    
     -- add_includedirs("Std project/CMSIS")
     -- add_includedirs("Std project/CMSIS/GD/GD32F30x/Inc_GD")
     -- add_includedirs("Std project/GD32F30x_standard_peripheral/Inc_Peri")
@@ -33,8 +34,11 @@ target("unittest")
     add_includedirs("User project/3.BasicFunction/Include")
     add_includedirs("User project/4.BasicHardwSoftwLayer/1.BasicHardwLayer/Include")
     add_includedirs("User project/4.BasicHardwSoftwLayer/2.BasicSoftwLayer/Include")
+    add_includedirs("api")
     add_includedirs("tests/unit_test/tools", "tests/unit_test/motor_sim")
     add_includedirs("tests/unit_test")
+    add_includedirs("tests/unit_test/board_sim/api_rt")
+    
 
     add_defines("RUN_ARCH_SIM")