[PDK-9594] UDMA: Fix issues with Event Disable and Enable for shared events
[processor-sdk/pdk.git] / packages / ti / drv / adcbuf / example / main_mss.c
1 /*
2  *  Copyright (c) Texas Instruments Incorporated 2021
3  *
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions
6  *  are met:
7  *
8  *    Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *
11  *    Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the
14  *    distribution.
15  *
16  *    Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
33 /* ========================================================================== */
34 /*                             Include Files                                  */
35 /* ========================================================================== */
37 /* Standard Include Files. */
38 #include <stdint.h>
39 #include <stdlib.h>
40 #include <stddef.h>
41 #include <string.h>
42 #include <stdio.h>
44 /* BIOS/XDC Include Files. */
45 #include <xdc/std.h>
46 #include <xdc/runtime/System.h>
47 #include <ti/sysbios/BIOS.h>
48 #include <ti/sysbios/knl/Task.h>
50 /* ADCBUF Driver: */
51 #include <ti/drv/adcbuf/adcbuf.h>
53 #include <ti/drv/edma/edma.h>
54 #include <ti/csl/soc.h>
55 #include <ti/osal/osal.h>
57 /* ========================================================================== */
58 /*                                 Macros                                     */
59 /* ========================================================================== */
60 /* Test definition specific to the device */
61 #define TOTAL_TEST_CASES                    (4U)
62 #define TEST_ADCBUF_NUM_SAMPLES             (1024U)
63 #define TEST_ADCBUF_DMADATA_BASE_ADDRESS    (CSL_DSS_L3_U_BASE + 0x8000U)
65 #if defined(_TMS320C6X)
66 #define RSS_ADC_CAPTURE_COMPLETE_IRQ        (57U)
67 #else
68 #define RSS_ADC_CAPTURE_COMPLETE_IRQ        (142U)
69 #endif
71 #define OSAL_DEFAULT_PRIORITY   (~((uint32_t) 0U))
74 /* ========================================================================== */
75 /*                            Structures                                      */
76 /* ========================================================================== */
77 typedef struct ADCBUFTestParams_t
78 {
79     /* Number of ADC samples */
80     uint32_t    numSamples;
82     /* Device specific ADCBUF memory address */
83     uint32_t    ADCBUFMemAddr;
85     /* Memory address to store ADC samples */
86     uint32_t    dstMemAddr;
88     /* Chirp Interrupt Number */
89     uint32_t    chirpIntNumber;
91     /* Enable Edma for copy data */
92     uint8_t     enableEdma;
93 }ADCBUFTestParams;
95 /* ========================================================================== */
96 /*                            Global Variables                                */
97 /* ========================================================================== */
99 /* Device specific test parameters */
100 ADCBUFTestParams gADCBUFTestParam =
102     TEST_ADCBUF_NUM_SAMPLES,
103         CSL_RSS_ADCBUF_READ_U_BASE,
104     TEST_ADCBUF_DMADATA_BASE_ADDRESS,
105 #if defined(_TMS320C6X)
106         RSS_ADC_CAPTURE_COMPLETE_IRQ,
107 #else
108         RSS_ADC_CAPTURE_COMPLETE_IRQ,
109 #endif
110     0
111 };
113 /* Test cases with different data format */
114 ADCBuf_dataFormat dataFmtTestCase_awr2944[TOTAL_TEST_CASES]=
116     /* Complex, Q+I, non-interleaved */
117     {0, 0, 0},
119     /* Complex, I+Q, non-interleaved */
120     {0, 1, 0},
122     /* Real, I, non-interleaved */
123     {1, 0, 0},
125     /* Real, Q, non-interleaved */
126     {1, 1, 0},
127 };
129 /* Test Control variables */
130 volatile uint32_t           gTestRun = 1U;
131 SemaphoreP_Handle  gIntSemaHandle = NULL;
133 /* Test statistics */
134 volatile uint32_t  gIntCounter = 0U;
135 volatile uint32_t  gVerifyFailCount = 0U;
137 /* ========================================================================== */
138 /*                 Internal Function Declarations                             */
139 /* ========================================================================== */
140 static int32_t Test_ADCBUFApiTest(void);
141 static int32_t Test_ADCBUFCmdParamsCheckTest(void);
142 static EDMA_Handle Test_ADCBUFInitEDMA(void);
143 static void Test_edmaErrorCallbackFxn(EDMA_Handle handle, EDMA_errorInfo_t *errorInfo);
144 static void Test_edmaTransferControllerErrorCallbackFxn(EDMA_Handle handle,
145                 EDMA_transferControllerErrorInfo_t *errorInfo);
146 static void Test_ADCBUFIntCallBackFunc(uintptr_t arg);
147 static void Test_ADCBUFContDataPathWithTestPattern(ADCBuf_Handle handle, ADCBuf_dataFormat *ptrDataFormat);
148 static void Test_ADCBUFContModeConfig(ADCBuf_Handle handle, ADCBuf_dataFormat *ptrDataFormat);
149 static int32_t Test_ADCBUFConfigEdma(EDMA_Handle handle, uint8_t chId, uint32_t* pSrcAddress, uint32_t * pDestAddress,
150                                      uint16_t aCount, uint16_t bCount, uint16_t cCount,uint16_t linkChId);
151 static int32_t Test_ADCBUFEDMA_setup_shadow_link (EDMA_Handle handle, uint32_t chId, uint32_t linkChId,
152                                                   EDMA_paramSetConfig_t *config,
153                                                                                                   EDMA_transferCompletionCallbackFxn_t transferCompletionCallbackFxn);
154 static uint32_t Test_ADCBUFVerifyDataPattern(void *memAddr, ADCBuf_dataFormat *ptrDataFormat);
155 static void Test_ADCBUFCloseEDMA(EDMA_Handle handle);
157 /* ========================================================================== */
158 /*                          Function Definitions                              */
159 /* ========================================================================== */
160 /**
161  *  @b Description
162  *  @n
163  *      Call back function for EDMA CC (Channel controller) error as per EDMA API.
164  *      Declare fatal error if happens, the output errorInfo can be examined if code
165  *      gets trapped here.
166  */
167 void Test_edmaErrorCallbackFxn(EDMA_Handle handle, EDMA_errorInfo_t *errorInfo)
169     DebugP_assert(0);
172 /**
173  *  @b Description
174  *  @n
175  *      Call back function for EDMA transfer controller error as per EDMA API.
176  *      Declare fatal error if happens, the output errorInfo can be examined if code
177  *      gets trapped here.
178  */
179 void Test_edmaTransferControllerErrorCallbackFxn(EDMA_Handle handle,
180                 EDMA_transferControllerErrorInfo_t *errorInfo)
182     DebugP_assert(0);
185 /**
186  *  @b Description
187  *  @n
188  *      Interrupt handler callback for chirp available. It runs in the ISR context.
189  *
190  *  @param[in]  handle
191  *      ADCBUF Instance Handle
192  *
193  *  @retval
194  *      Not Applicable.
195  */
196 void Test_ADCBUFIntCallBackFunc(uintptr_t arg)
198     ADCBuf_Handle     handle;
200     handle = (ADCBuf_Handle)arg;
202     /* Increment interrupt counter for debugging purpose */
203     gIntCounter++;
205     /* Check the buffer every 10 chirp avail interrupt */
206     if(gIntCounter % 10 == 0)
207     {
208         /* Stop Continuous mode */
209         ADCBuf_control(handle, ADCBufMMWave_CMD_STOP_CONTINUOUS_MODE, NULL);
211         /* Stop Test Pattern generation */
212         ADCBuf_control(handle, ADCBufMMWave_CMD_STOP_TEST_PATTERN, NULL);
214         /* Semaphore post for test thread to copy samples and verify */
215         SemaphoreP_post(gIntSemaHandle);
216     }
219 /**
220  *  @b Description
221  *  @n
222  *      Continuous mode with Test pattern generation test.
223  *
224  *  @param[in]  handle
225  *      ADCBUF Instance Handle
226  *  @param[in]  ptrDataFormat
227  *      Pointer to the ADCBuf Data format configuration
228  *
229  *  @retval
230  *      Not Applicable.
231  */
232 void Test_ADCBUFContDataPathWithTestPattern(ADCBuf_Handle handle, ADCBuf_dataFormat *ptrDataFormat)
234     int32_t retVal = 0;
236     /* Configure test pattern */
237     Test_ADCBUFContModeConfig(handle, ptrDataFormat);
239     /* Start Test Pattern generation */
240     if ((retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_START_TEST_PATTERN, NULL) ) < 0)
241        printf("Error: ADCBufMMWave_CMD_START_TEST_PATTERN failed with [Error=%d]\n", retVal);
244 /**
245  *  @b Description
246  *  @n
247  *      Continuous mode with Test patern generation test.
248  *
249  *  @param[in]  handle
250  *      ADCBUF Instance Handle
251  *  @param[in]  ptrDataFormat
252  *      Pointer to the ADCBuf Data format configuration
253  *
254  *  @retval
255  *      Not Applicable.
256  */
257 void Test_ADCBUFContModeConfig(ADCBuf_Handle handle, ADCBuf_dataFormat *ptrDataFormat)
259     uint32_t                 arg;
260     ADCBuf_RxChanConf        rxChanConf;
261     ADCBuf_TestPatternConf   testPatternConf;
262     uint8_t                  channel;
263     uint16_t                 offset = 0;
264     uint32_t                 numSamples;
265     int32_t                  retVal = 0;
267     /* Configure ADC buffer data format */
268     if ((retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_CONF_DATA_FORMAT, (void *)ptrDataFormat)) < 0)
269         printf("Error: ADCBufMMWave_CMD_CONF_DATA_FORMAT failed with [Error=%d]\n", retVal);
271     /* Enable all 4  Rx Channel */
272     for (channel=0; channel < NUM_RX_CHANNEL; channel++)
273     {
274         rxChanConf.channel = channel;
275         rxChanConf.offset    = offset;
276         if((retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_CHANNEL_ENABLE, (void *)&rxChanConf)) < 0)
277             printf("Error: ADCBufMMWave_CMD_CHANNEL_ENABLE failed for channel %d offset =0x%x with [Error = %d]\n",
278                                      channel, offset, retVal);
279         /* Test purpose only : Verify channel address */
280         {
281             uint32_t channelAddr = 0;
283             if ( (channelAddr = ADCBuf_getChanBufAddr(handle, channel, &retVal)) != 0)
284             {
285                 channelAddr -= gADCBUFTestParam.ADCBUFMemAddr;
287                 if(channelAddr != offset)
288                 {
289                     printf("Error: ADCBuf_getChanBufAddr() return mismatched channel(%d) buffer address [%x: %x]\n",
290                                  channel, offset, channelAddr);
292                     retVal = -1;
293                 }
294             }
295             else
296             {
297                 printf("Error: ADCBuf_getChanBufAddr failed for channel %d with [Error = %d]\n",
298                                          channel, retVal);
299             }
300         }
302         offset += gADCBUFTestParam.numSamples * 4;
303     }
305     /* Configure ADC buffer in continuous mode */
306     arg = 1;
307     if ((retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_SET_CONTINUOUS_MODE, (void *)&arg)) < 0)
308         printf("Error: ADCBufMMWave_CMD_SET_CONTINUOUS_MODE failed with [Error=%d]\n", retVal);
310     /* Start the continuous streaming mode in ADCBUFF */
311     numSamples = gADCBUFTestParam.numSamples;
312     if ((retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_START_CONTINUOUS_MODE, (void *)&numSamples)) < 0)
313         printf("Error: ADCBufMMWave_CMD_START_CONTINUOUS_MODE failed with [Error=%d]\n", retVal);
315     /* Configure Test Pattern generation */
316     testPatternConf.period = 255;
317     testPatternConf.numSamples = gADCBUFTestParam.numSamples;
319     for (channel=0; channel < 4; channel++)
320     {
321         testPatternConf.rxConfig[channel].rxIOffset   = 0x0000;
322         testPatternConf.rxConfig[channel].rxIInc      = 2;
323         testPatternConf.rxConfig[channel].rxQOffset   = 0x1000 ;
324         testPatternConf.rxConfig[channel].rxQInc      = 2;
325     }
327     /* Send control command to driver */
328     if ( (retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_CONF_TEST_PATTERN, (void *)&testPatternConf)) < 0)
329         printf("Error: ADCBufMMWave_CMD_CONF_TEST_PATTERN failed with [Error=%d]\n", retVal);
333 /**
334  *  @b Description
335  *  @n
336  *      Config EDMA channel for data buffer copy.
337  *
338  *  @param[in]  handle
339  *      EDMA driver instance Handle
340  *  @param[in]  chId
341  *      EDMA Channle id used to copy data buffer
342  *  @param[in]  pSrcAddress
343  *      Source address
344  *  @param[in]  pDestAddress
345  *      Destination address
346  *  @param[in]  aCount
347  *      EDMA channel Acount configuration
348  *  @param[in]  bCount
349  *      EDMA channel Bcount configuration
350  *  @param[in]  cCount
351  *      EDMA channel Ccount configuration
352  *  @param[in]  linkChId
353  *      EDMA link Id
354  *
355  *  @retval
356  *      Success    - 0
357  *      Fail       < 0 (ErrorCode)
358  */
359 int32_t Test_ADCBUFConfigEdma(EDMA_Handle handle, uint8_t chId,
360                                     uint32_t* pSrcAddress, uint32_t * pDestAddress,
361                                     uint16_t aCount, uint16_t bCount, uint16_t cCount,
362                                     uint16_t linkChId)
364     EDMA_channelConfig_t config;
365     int32_t errorCode = EDMA_NO_ERROR;
367     config.channelId = chId;
368     config.channelType = (uint8_t)EDMA3_CHANNEL_TYPE_DMA;
369     config.paramId = chId;
370     config.eventQueueId = 0;
372     config.paramSetConfig.sourceAddress = (uint32_t) pSrcAddress;
373     config.paramSetConfig.destinationAddress = (uint32_t) pDestAddress;
375     config.paramSetConfig.aCount = aCount;
376     config.paramSetConfig.bCount = bCount;
377     config.paramSetConfig.cCount = cCount;
378     config.paramSetConfig.bCountReload = config.paramSetConfig.bCount;
380     config.paramSetConfig.sourceBindex = 0;
381     config.paramSetConfig.destinationBindex = 0;
383     config.paramSetConfig.sourceCindex = 0;
384     config.paramSetConfig.destinationCindex = 0;
386     config.paramSetConfig.linkAddress = EDMA_NULL_LINK_ADDRESS;
387     config.paramSetConfig.transferType = (uint8_t)EDMA3_SYNC_A;
388     config.paramSetConfig.transferCompletionCode = 0;
389     config.paramSetConfig.sourceAddressingMode = (uint8_t) EDMA3_ADDRESSING_MODE_LINEAR;
390     config.paramSetConfig.destinationAddressingMode = (uint8_t) EDMA3_ADDRESSING_MODE_LINEAR;
392     /* don't care because of linear addressing modes above */
393     config.paramSetConfig.fifoWidth = (uint8_t) EDMA3_FIFO_WIDTH_8BIT;
395     config.paramSetConfig.isStaticSet = false;
396     config.paramSetConfig.isEarlyCompletion = false;
397     config.paramSetConfig.isFinalTransferInterruptEnabled = true;
398     config.paramSetConfig.isIntermediateTransferInterruptEnabled = false;
399     config.paramSetConfig.isFinalChainingEnabled = false;
400     config.paramSetConfig.isIntermediateChainingEnabled = false;
401     config.transferCompletionCallbackFxn = NULL;
403     if ((errorCode = EDMA_configChannel(handle, &config, false)) != EDMA_NO_ERROR)
404     {
405         printf("Error: EDMA_configChannel() failed with error code = %d\n", errorCode);
406         goto Exit;
407     }
409     errorCode = Test_ADCBUFEDMA_setup_shadow_link(handle, chId, linkChId,
410         &config.paramSetConfig, config.transferCompletionCallbackFxn);
412 Exit:
413     return(errorCode);
416 /**
417  *  @b Description
418  *  @n
419  *      Setup shadow link for EDMA copy.
420  *
421  *  @param[in]  handle
422  *      EDMA driver instance Handle
423  *  @param[in]  chId
424  *      EDMA Channle id used to copy data buffer
425  *  @param[in]  linkChId
426  *      EDMA link id used to copy data buffer
427  *  @param[in]  config
428  *      EDMA param set used to copy data buffer
429  *  @param[in]  transferCompletionCallbackFxn
430  *      Callback function when data copy is completed
431  *
432  *  @retval
433  *      Success    - 0
434  *      Fail       < 0 (ErrorCode)
435  */
436 static int32_t Test_ADCBUFEDMA_setup_shadow_link (EDMA_Handle handle, uint32_t chId, uint32_t linkChId,
437     EDMA_paramSetConfig_t *config, EDMA_transferCompletionCallbackFxn_t transferCompletionCallbackFxn)
439     EDMA_paramConfig_t paramConfig;
440     int32_t errorCode = EDMA_NO_ERROR;
442     paramConfig.paramSetConfig = *config;
443     paramConfig.transferCompletionCallbackFxn = transferCompletionCallbackFxn;
444     paramConfig.transferCompletionCallbackFxnArg = (uintptr_t) handle;
445     if ((errorCode = EDMA_configParamSet(handle, linkChId, &paramConfig)) != EDMA_NO_ERROR)
446     {
447         printf("Error: EDMA_configParamSet() failed with error code = %d\n", errorCode);
448         goto exit;
449     }
451     if ((errorCode = EDMA_linkParamSets(handle, chId, linkChId)) != EDMA_NO_ERROR)
452     {
453         printf("Error: EDMA_linkParamSets() failed with error code = %d\n", errorCode);
454         goto exit;
455     }
457     if ((errorCode = EDMA_linkParamSets(handle, linkChId, linkChId)) != EDMA_NO_ERROR)
458     {
459         printf("Error: EDMA_linkParamSets() failed with error code = %d\n", errorCode);
460         goto exit;
461     }
464 exit:
465     return(errorCode);
468 /**
469  *  @b Description
470  *  @n
471  *      Verify the test data pattern .
472  *
473  *  @param[in]  memAddr
474  *      Memory base address that holds the data copied from ADC buffer
475  *  @param[in]  ptrDataFormat
476  *      Pointer to the ADCBuf Data format configuration
477  *
478  *  @retval
479  *      Not Applicable.
480  */
481 uint32_t Test_ADCBUFVerifyDataPattern(void *memAddr, ADCBuf_dataFormat *ptrDataFormat)
483     volatile uint32_t*   ptrDataAddress;
484     uint8_t              channel;
485     uint32_t             sampleIdx;
486     volatile uint32_t    addrOffset;
487     uint32_t             data, firstSample;
488     uint16_t             idata, qdata;
489     uint32_t             incr = 2;
490     uint32_t             failFlag = 0;
491     uint32_t             dataIncr;
492     uint32_t             numSamples;
494     ptrDataAddress = (volatile uint32_t *)memAddr;
495     printf("Debug: First 4 32 bit words 0x%x     0x%x    0x%x    0x%x\n", ptrDataAddress[0],
496                         ptrDataAddress[1], ptrDataAddress[2], ptrDataAddress[3]);
498     /* Set the address offset */
499     addrOffset = 0;
501     /* Get number of samples from test params */
502     numSamples = gADCBUFTestParam.numSamples;
504     /* Get the first sample */
505     firstSample = *ptrDataAddress;
507     /* Channel interleaved-mode */
508     if (ptrDataFormat->channelInterleave == 0)
509     {
510         /* Test 10 samples for all channels */
511         for (sampleIdx=0; sampleIdx < numSamples; sampleIdx++)
512         {
513             for (channel = 0; channel < 4; channel++)
514             {
515                 addrOffset = sampleIdx * 4;
516                 if(ptrDataFormat->adcOutFormat == 0)
517                 {
518                     data = ptrDataAddress[addrOffset + channel];
520                     /* Complex data format, get I and Q data */
521                     if(ptrDataFormat->sampleInterleave == 0)
522                     {
523                         qdata = (data & 0xffff0000) >> 16;
524                         idata  = (data & 0xffff);
525                     }
526                     else
527                     {
528                         idata = (data & 0xffff0000) >> 16;
529                         qdata  = (data & 0xffff);
530                     }
532                     /* Verify data 1: increment = 2, */
533                     dataIncr =( ( sampleIdx * incr)<<16) + (incr * sampleIdx);
534                     if((data - firstSample) != dataIncr)
535                     {
536                          failFlag = 1;
537                     }
539                     /* Verify data 2: Q = I + 0x1000 */
540                     if( (idata + 0x1000) != qdata)
541                     {
542                          failFlag = 1;
543                     }
544                 }
545                 else
546                 {
547                     uint16_t *ptrRealData = (uint16_t *)ptrDataAddress;
548                     uint16_t  realData;
549                     uint16_t  firstRealSample;
551                     /* Address offset in terms of 16bits real data */
552                     addrOffset = sampleIdx * 4;
553                     realData = ptrRealData[addrOffset + channel];
554                     firstRealSample = ptrRealData[channel];
556                     /* Verify data 1: increment = 2, */
557                     dataIncr =incr * sampleIdx;
558                     if((realData - firstRealSample) != dataIncr)
559                     {
560                          failFlag = 1;
561                     }
562                 }
563             }
564         }
566     }
567     else
568     {
569         for (channel = 0; channel < 4; channel++)
570         {
571             addrOffset = (channel * numSamples) ;
572             firstSample = ptrDataAddress[addrOffset];
574             for (sampleIdx=0; sampleIdx<numSamples; sampleIdx++)
575             {
576                 data = ptrDataAddress[addrOffset + sampleIdx];
578                 if(ptrDataFormat->adcOutFormat == 0)
579                 {
580                     /* Complex data format, get I and Q data */
581                     if(ptrDataFormat->sampleInterleave == 0)
582                     {
583                         qdata = (data & 0xffff0000) >> 16;
584                         idata  = (data & 0xffff);
585                     }
586                     else
587                     {
588                         idata = (data & 0xffff0000) >> 16;
589                         qdata  = (data & 0xffff);
590                     }
592                     /* Verify data 1: increment = 2, */
593                     dataIncr =( ( sampleIdx * incr)<<16) + (incr * sampleIdx);
594                     if((data - firstSample) != dataIncr)
595                     {
596                          failFlag = 1;
597                     }
599                     /* Verify data 2: Q = I + 0x1000 */
600                     if( (idata + 0x1000) != qdata)
601                     {
602                          failFlag = 1;
603                     }
604                 }
605                 else
606                 {
607                     volatile uint16_t *ptrRealData = (uint16_t *)ptrDataAddress;
608                     uint16_t  realData;
609                     uint16_t  firstRealSample;
611                     /* Address offset in terms of 16bits real data */
612                     addrOffset = (channel * numSamples * 2) ;
613                     realData = ptrRealData[addrOffset + sampleIdx];
614                     firstRealSample = ptrRealData[addrOffset];
616                     /* Verify data 1: increment = 2, */
617                     dataIncr =incr * sampleIdx;
618                     if((realData - firstRealSample) != dataIncr)
619                     {
620                          failFlag = 1;
621                     }
622                 }
623             }
625         }
626     }
627     return ((failFlag == 0) ? 0 : 1);
630 /**
631  *  @b Description
632  *  @n
633  *      Close EDMA driver instance
634  *
635  *  @param[in]  handle
636  *      EDMA driver instance Handle
637  *
638  *  @retval
639  *      Not applicable
640  */
641 void Test_ADCBUFCloseEDMA(EDMA_Handle handle)
643     int32_t    retVal = 0;
645     if ((retVal = EDMA_close(handle)) != EDMA_NO_ERROR)
646     {
647         printf("Debug: edma Instance %p closing error, errorCode = %d\n", handle, retVal);
648     }
652 /**
653  *  @b Description
654  *  @n
655  *      ADCBuf driver API test.
656  *
657  *  @retval
658  *      =0       Test passed
659  *      <0       Test Failed
660  */
661 static int32_t Test_ADCBUFApiTest(void)
663     ADCBuf_Params        params;
664     ADCBuf_Handle        handle;
665     int32_t              retVal = 0;
667     /* Setup the default ADCBUF Parameters */
668     ADCBuf_Params_init(&params);
670     /* Open the first ADCBUF Instance */
671     handle = ADCBuf_open(0, &params);
672     if (handle == NULL)
673     {
674         printf("Error: Unable to open the ADCBUF Instance\n");
675         retVal = -1;
676         goto Exit;
677     }
678     printf("Debug: ADCBUF Instance(0) %p has been opened successfully\n", handle);
680     /**************************************************************************
681      * Test: Graceful shutdown
682      **************************************************************************/
683     ADCBuf_close(handle);
684     printf("Debug: ADCBUF Instance %p has been closed successfully\n", handle);
686 Exit:
687     return retVal;
690 /**
691  *  @b Description
692  *  @n
693  *      ADCBuf driver test to validate command parameters.
694  *
695  *  @retval
696  *      =0       Test passed
697  *      <0       Test Failed
698  */
699 static int32_t Test_ADCBUFCmdParamsCheckTest(void)
701     ADCBuf_Params        params;
702     ADCBuf_Handle        handle;
703     uint32_t             arg;
704     int32_t              retVal = 0;
705     ADCBufMMWave_CMD     command;
706     ADCBuf_dataFormat    dataFormat;
707     ADCBuf_RxChanConf    rxChanConf;
708     ADCBuf_CQConf        cqConf;
709     int32_t              testResult = 0;
711     /* Setup the default ADCBUF Parameters */
712     ADCBuf_Params_init(&params);
714     /* Open the first ADCBUF Instance */
715     handle = ADCBuf_open(0, &params);
716     if (handle == NULL)
717     {
718         printf("Error: Unable to open the ADCBUF Instance\n");
719         testResult = -1;
720         goto Exit;
721     }
722     printf("Debug: ADCBUF Instance(0) %p has been opened successfully\n", handle);
724     /* Params check Test */
725     command = ADCBufMMWave_CMD_SET_SRC;
726     arg = 0x5;
727     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
728         printf("Debug: Passed the param check for command=%d with arg=%d\n", command, arg);
729     else
730     {
731         printf("Error: Failed the param check for command=%d with arg=%d\n", command, arg);
732         testResult = -1;
733     }
735     command = ADCBufMMWave_CMD_SET_CONTINUOUS_MODE;
736     arg = 0x8;
737     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
738         printf("Debug: Passed the param check for command=%d with arg=%d\n", command, arg);
739     else
740     {
741         printf("Error: Failed the param check for command=%d with arg=%d\n", command, arg);
742         testResult = -1;
743     }
745     command = ADCBufMMWave_CMD_CONF_DATA_FORMAT;
746     memset ((void *)&dataFormat, 0, sizeof(dataFormat));
747     dataFormat.adcOutFormat = 2;
748     if ((retVal = ADCBuf_control(handle, command, (void *)&dataFormat)) < 0)
749         printf("Debug: Passed the param check for command=%d with adcOutFormat=%d \n", command, dataFormat.adcOutFormat);
750     else
751     {
752         printf("Error: Failed the param check for command=%d with adcOutFormat=%d\n", command, dataFormat.adcOutFormat);
753         testResult = -1;
754     }
756     memset ((void *)&dataFormat, 0, sizeof(dataFormat));
757     dataFormat.sampleInterleave = 2;
758     if ((retVal = ADCBuf_control(handle, command, (void *)&dataFormat)) < 0)
759         printf("Debug: Passed the param check for command=%d with sampleInterleave=%d\n", command, dataFormat.sampleInterleave);
760     else
761     {
762         printf("Error: Failed the param check for command=%d with sampleInterleave=%d\n", command, dataFormat.sampleInterleave);
763         testResult = -1;
764     }
766     memset ((void *)&dataFormat, 0, sizeof(dataFormat));
767     dataFormat.channelInterleave = 2;
768     if ((retVal = ADCBuf_control(handle, command, (void *)&dataFormat)) < 0)
769         printf("Debug: Passed the param check for command=%d channelInterleave=%d\n", command, dataFormat.channelInterleave);
770     else
771     {
772         printf("Error: Failed the param check for command=%d with channelInterleave=%d\n", command, dataFormat.channelInterleave);
773         testResult = -1;
774     }
776     command = ADCBufMMWave_CMD_CONF_CQ;
777     memset ((void *)&cqConf, 0, sizeof(cqConf));
778     cqConf.cqDataWidth= 5;
779     if ((retVal = ADCBuf_control(handle, command, (void *)&cqConf)) < 0)
780         printf("Debug: Passed the param check for command=%d with cqDataWidth=%d \n", command, cqConf.cqDataWidth);
781     else
782     {
783         printf("Error: Failed the param check for command=%d with cqDataWidth=%d\n", command, cqConf.cqDataWidth);
784         testResult = -1;
785     }
787     command = ADCBufMMWave_CMD_CONF_CQ;
788     memset ((void *)&cqConf, 0, sizeof(cqConf));
789     cqConf.cq96BitPackEn = 4;
790     if ((retVal = ADCBuf_control(handle, command, (void *)&cqConf)) < 0)
791         printf("Debug: Passed the param check for command=%d with cq96BitPackEn=%d \n", command, cqConf.cqDataWidth);
792     else
793     {
794         printf("Error: Failed the param check for command=%d with cq96BitPackEn=%d\n", command, cqConf.cq96BitPackEn);
795         testResult = -1;
796     }
798     command = ADCBufMMWave_CMD_START_CONTINUOUS_MODE;
799     arg = 0x1U<<16;
800     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
801         printf("Debug: Passed the param check for command=%d \n", command);
802     else
803     {
804         printf("Error: Failed the param check for command=%d with arg=%d\n", command, arg);
805         testResult = -1;
806     }
808     command = ADCBufMMWave_CMD_CHANNEL_ENABLE;
809     memset ((void *)&rxChanConf, 0, sizeof(rxChanConf));
810     rxChanConf.channel = 6;
811     if ((retVal = ADCBuf_control(handle, command, (void *)&rxChanConf)) < 0)
812         printf("Debug: Passed the param check for command=%d with channel = %d\n", command, rxChanConf.channel);
813     else
814     {
815         printf("Error: Failed the param check for command=%d with channel=%d\n", command, rxChanConf.channel);
816         testResult = -1;
817     }
819     memset ((void *)&rxChanConf, 0, sizeof(rxChanConf));
820     rxChanConf.channel = 2;
821     rxChanConf.offset = 0x1U << 15U;
822     if ((retVal = ADCBuf_control(handle, command, (void *)&rxChanConf)) < 0)
823         printf("Debug: Passed the param check for command=%d with offset = %d\n", command, rxChanConf.offset);
824     else
825     {
826         printf("Error: Failed the param check for command=%d with offset=%d\n", command, rxChanConf.offset);
827         testResult = -1;
828     }
830     command = ADCBufMMWave_CMD_SET_CHIRP_THRESHHOLD;
831     arg = 35;
832     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
833         printf("Debug: Passed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
834     else
835     {
836         printf("Error: Failed the param check for command=%d with arg = %d , retVal=%d\n", command, arg, retVal);
837         testResult = -1;
838     }
840     command = ADCBufMMWave_CMD_SET_PING_CHIRP_THRESHHOLD;
841     arg = 35;
842     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
843         printf("Debug: Passed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
844     else
845     {
846         printf("Error: Failed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
847         testResult = -1;
848     }
850     command = ADCBufMMWave_CMD_SET_PONG_CHIRP_THRESHHOLD;
851     arg = 35;
852     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
853         printf("Debug: Passed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
854     else
855     {
856         printf("Error: Failed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
857         testResult = -1;
858     }
860     command = ADCBufMMWave_CMD_CHANNEL_DISABLE;
861     arg = 0xc;
862     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
863     {
864         printf("Error: Failed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
865         testResult = -1;
866     }
867     else
868     {
869         printf("Debug: Passed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
870     }
872     command = ADCBufMMWave_CMD_CHANNEL_DISABLE;
873     arg = 0x1c;
874     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
875         printf("Debug: Passed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
876     else
877     {
878         printf("Error: Failed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
879         testResult = -1;
880     }
882     command = ADCBufMMWave_CMD_CHANNEL_DISABLE;
883     arg = 0x0;
884     if ((retVal = ADCBuf_control(handle, command, (void *)&arg)) < 0)
885         printf("Debug: Passed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
886     else
887     {
888         printf("Error: Failed the param check for command=%d with arg = %d, retVal=%d\n", command, arg, retVal);
889         testResult = -1;
890     }
892     /* Close ADCbuf driver */
893     ADCBuf_close(handle);
894     printf("Debug: ADCBUF Instance %p has been closed successfully\n", handle);
896 Exit:
897     return testResult;
900 /**
901  *  @b Description
902  *  @n
903  *      Init EDMA driver for data buffer copy.
904  *
905  *  @retval
906  *      Success     - EDMA handle
907  *      Fail        - NULL pointer
908  */
909 EDMA_Handle Test_ADCBUFInitEDMA(void)
911     EDMA_errorInfo_t  EDMAErrorInfo;
912     EDMA_transferControllerErrorInfo_t EDMATransferControllerErrorInfo;
913     EDMA_Handle         EdmaHandle = NULL;
914     EDMA_instanceInfo_t instanceInfo;
915     EDMA_errorConfig_t errorConfig;
917     /*******************/
918     EDMA3CCInitParams initParam;
919     int8_t gInstanceId = EDMA_DRV_INST_DSS_A;
921     int32_t    retVal = 0;
923     EDMA3CCInitParams_init(&initParam);
924     initParam.initParamSet = TRUE;
926     retVal = EDMA_init(gInstanceId, &initParam);
927     if (retVal != EDMA_NO_ERROR)
928     {
929         printf ("Debug: EDMA instance 0 initialization returned error %d\n", retVal);
930         return NULL;
931     }
932     printf ("Debug: EDMA instance 0 has been initialized\n");
934     memset(&EDMAErrorInfo, 0, sizeof(EDMAErrorInfo));
935     memset(&EDMATransferControllerErrorInfo, 0, sizeof(EDMATransferControllerErrorInfo));
937     /* Open the first EDMA Instance */
938     EdmaHandle = EDMA_open(gInstanceId, &retVal, &instanceInfo);
939     if (EdmaHandle == NULL)
940     {
941         printf("Error: Unable to open the edma Instance, erorCode = %d\n", retVal);
942     }
944     /* Configure EDMA Error Monitor */
945     errorConfig.isConfigAllEventQueues = true;
946     errorConfig.isConfigAllTransferControllers = true;
947     errorConfig.isEventQueueThresholdingEnabled = true;
948     errorConfig.eventQueueThreshold = EDMA_EVENT_QUEUE_THRESHOLD_MAX;
949     errorConfig.isEnableAllTransferControllerErrors = true;
950     errorConfig.callbackFxn = Test_edmaErrorCallbackFxn;
951     errorConfig.transferControllerCallbackFxn = Test_edmaTransferControllerErrorCallbackFxn;
952     if ((retVal = EDMA_configErrorMonitoring(EdmaHandle, &errorConfig)) != EDMA_NO_ERROR)
953     {
954         printf("Debug: EDMA_configErrorMonitoring() failed with errorCode = %d\n", retVal);
955         return NULL;
956     }
958     return EdmaHandle;
961 /**
962  *  @b Description
963  *  @n
964  *      System Initialization Task which initializes the various
965  *      components in the system.
966  *
967  *  @retval
968  *      Not Applicable.
969  */
970 void Test_ADCBUFInitTask(UArg arg0, UArg arg1)
972         EDMA_Handle          EdmaHandle = NULL;
973         SemaphoreP_Params    semParams;
974         ADCBuf_Params        params;
975         ADCBuf_Handle        handle;
976         ADCBuf_dataFormat    dataFormat;
977         bool                 edmaTransComplete ;
978         uint8_t              index;
979     volatile uint32_t    srcMemAddr;
980     volatile uint32_t    dstMemAddr;
981     uint32_t             numSamples;
982     ADCBuf_dataFormat    *ptrDataFormat = &dataFormat;
983     int32_t              retVal = 0;
985     OsalRegisterIntrParams_t    intrPrms;
986     HwiP_Handle                 hwiHandle = NULL;
987     uint32_t                    intrPriority;
989     printf("\n/*******************************************************************/ \n");
990     printf("/************************* ADCBUF Test *****************************/ \n");
991     printf("/*******************************************************************/ \n");
993     /* Initialize the ADCBUF */
994     ADCBuf_init();
996     if(gADCBUFTestParam.enableEdma)
997     {
998         EdmaHandle = Test_ADCBUFInitEDMA();
999         if(EdmaHandle == NULL)
1000         {
1001             printf("Debug: EDMA Init failed \n");
1002             goto Exit;
1003         }
1004     }
1006     /**************************************************************************
1007      * Test: Basic API test
1008      **************************************************************************/
1010     /* Basic API Test */
1011     if(Test_ADCBUFApiTest() < 0)
1012         printf ("ADCBUF Basic API test failed\n");
1013     else
1014         printf ("ADCBUF Basic API test passed\n");
1016     /**************************************************************************
1017      * Test: Parameter validation test
1018      **************************************************************************/
1020     /* Test input parameters */
1021     if (Test_ADCBUFCmdParamsCheckTest() < 0)
1022         printf ("ADCBUF Input Parameters Validation Test failed\n");
1023     else
1024         printf ("ADCBUF Input Parameters Validation Test passed\n");
1026     /**************************************************************************
1027      * Test: Reopen the driver to test in Continuous Mode
1028      **************************************************************************/
1030     /* YES: Create a binary semaphore which is used to handle interrupt handling. */
1031     SemaphoreP_Params_init(&semParams);
1032     semParams.mode             = SemaphoreP_Mode_BINARY;
1033     gIntSemaHandle             = SemaphoreP_create(0, &semParams);
1035     /* Setup the default ADCBUF Parameters */
1036     ADCBuf_Params_init(&params);
1037     params.continousMode = 1;
1039     /* Go through different data format test cases */
1040     for (index = 0; index < TOTAL_TEST_CASES; index++)
1041     {
1042         handle = ADCBuf_open(0, &params);
1043         if (handle == NULL)
1044         {
1045             printf("Error: Unable to open the ADCBUF Instance\n");
1046             return;
1047         }
1048         printf("Debug: ADCBUF Instance %p has been reopened successfully\n", handle);
1050         /* Register chirp interrupt */
1051         #if defined(_TMS320C6X)
1052         intrPriority = OSAL_DEFAULT_PRIORITY;
1053         #else
1054         intrPriority = 0x1U;
1055         #endif
1057         Osal_RegisterInterrupt_initParams(&intrPrms);
1059         /* Populate the interrupt parameters */
1060         intrPrms.corepacConfig.arg              = (uintptr_t) handle;
1061         intrPrms.corepacConfig.isrRoutine       = Test_ADCBUFIntCallBackFunc;
1062         intrPrms.corepacConfig.priority         = intrPriority;
1063         intrPrms.corepacConfig.name             = "ADC_CAPTURE_COMPLETE";
1065         #if defined (_TMS320C6X)
1066         /* On C66x, we use Event Combiner to map the interrupt to the CPU Intc.  To
1067          * do this, OSAL expects that event number holds the interrupt number and we
1068          * use the macro for interrupt number to specify we wish to use Event
1069          * Combiner.
1070          */
1071         intrPrms.corepacConfig.corepacEventNum  = (int32_t)gADCBUFTestParam.chirpIntNumber;
1072         intrPrms.corepacConfig.intVecNum        = OSAL_REGINT_INTVEC_EVENT_COMBINER;
1073         #else
1074         /* Other (non-C66x) CPUs don't use event number and interrupt number is
1075          * passed in and programmed to CPU Intc directly.
1076          */
1077         intrPrms.corepacConfig.corepacEventNum  = (int32_t)0;
1078         intrPrms.corepacConfig.intVecNum        = (int32_t)gADCBUFTestParam.chirpIntNumber;
1079         #endif
1081         /* Register interrupts */
1082         if(OSAL_INT_SUCCESS != Osal_RegisterInterrupt(&intrPrms, &hwiHandle))
1083         {
1084                 printf("Error: Unable to register Chirp interrupt\n");
1085                 hwiHandle = NULL;
1086                 goto Exit;
1087         }
1089         /* Initialize the data format for the test */
1090         dataFormat = dataFmtTestCase_awr2944[index];
1092         /* Print out the test params */
1093         printf("ADCBUF Test Pattern with dataFormat=%d, sampleSwap=%d, interleave=%d \n",
1094                        dataFormat.adcOutFormat, dataFormat.sampleInterleave,
1095                                            dataFormat.channelInterleave);
1097         /* Number of loops that test run for current data Format
1098             Data is validated for every 10 ping/pong buffer swap.
1099           */
1100         gTestRun = 20;
1102         /* ADCBuf Test Pattern Test, this function will be blocked until gTestRun is set to 0 */
1103         Test_ADCBUFContDataPathWithTestPattern(handle, &dataFormat);
1105         /* Assign memory base address to save the ADC samples */
1106         dstMemAddr = CSL_locToGlobAddr(gADCBUFTestParam.dstMemAddr);
1107         srcMemAddr = CSL_locToGlobAddr(gADCBUFTestParam.ADCBUFMemAddr);
1108         numSamples = gADCBUFTestParam.numSamples;
1110         while(gTestRun)
1111         {
1112             /* Wait for the Semaphore */
1113             SemaphoreP_pend(gIntSemaHandle, SemaphoreP_WAIT_FOREVER);
1116             if(gADCBUFTestParam.enableEdma)
1117             {
1118                 edmaTransComplete = false;
1119                 /* Trigger DMA copy */
1120                 Test_ADCBUFConfigEdma(EdmaHandle, EDMA_DSS_TPCC_A_EVT_FREE_0,
1121                                       (uint32_t *)srcMemAddr, (uint32_t *)dstMemAddr,
1122                                       16 * numSamples, 1, 1, EDMA_NUM_DMA_CHANNELS);
1124                 EDMA_startDmaTransfer(EdmaHandle, EDMA_DSS_TPCC_A_EVT_FREE_0);
1126                 /* Polling transfer completion */
1127                 while(edmaTransComplete == false)
1128                 {
1129                     EDMA_isTransferComplete(EdmaHandle, 0, &edmaTransComplete);
1130                     Task_sleep(1);
1131                 }
1132             }
1133             else
1134             {
1135                 /* Copy the adcbuf data to memory */
1136                 memcpy( (void *)(dstMemAddr),  (void *)(srcMemAddr),  16 * numSamples );
1138                 CacheP_wbInv ((const void*)dstMemAddr, 16 * numSamples);
1139             }
1141             CacheP_Inv((const void*)srcMemAddr, (16 * numSamples));
1142             CacheP_Inv((const void*)dstMemAddr, (16 * numSamples));
1144             /* Verify data integrity */
1145             if (Test_ADCBUFVerifyDataPattern((void *)dstMemAddr, ptrDataFormat) !=0 )
1146             {
1147                 gVerifyFailCount++;
1148             }
1150             gTestRun--;
1152             /* Re-Start Test Pattern generation if test is not stopped */
1153             if(gTestRun)
1154             {
1155                 uint32_t  rxChanMask;
1157                 /* Disable all channels */
1158                 rxChanMask = 0xF;
1159                 if ((retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_CHANNEL_DISABLE, (void *)&rxChanMask)) < 0)
1160                 {
1161                    printf("Error: ADCBufMMWave_CMD_CHANNEL_DISABLE failed with [Error=%d]\n", retVal);
1162                 }
1164                 /* ADCBuf Test Pattern Test, this function will be blocked until gTestRun is set to 0 */
1165                 Test_ADCBUFContDataPathWithTestPattern(handle, &dataFormat);
1166             }
1167         }
1169         /* StopTest Pattern generation */
1170         if (( retVal = ADCBuf_control(handle, ADCBufMMWave_CMD_STOP_TEST_PATTERN, NULL)) < 0)
1171            printf("Error: ADCBufMMWave_CMD_STOP_TEST_PATTERN failed with [Error=%d]\n", retVal);
1173         /* Close  ADCBuf driver */
1174         ADCBuf_close(handle);
1175         printf("Debug: ADCBUF Instance %p has been closed successfully\n", handle);
1177         /* Deregister chirp interrupt listener */
1178         #if defined (_TMS3206X)
1179         corepacEventNum = (int32_t)gADCBUFTestParam.chirpIntNumber;
1180         Osal_DisableInterrupt(corepacEventNum, (int32_t)OSAL_REGINT_INTVEC_EVENT_COMBINER);
1181         #else
1182         Osal_DisableInterrupt(0, (int32_t)gADCBUFTestParam.chirpIntNumber);
1183         #endif
1185         #if defined (_TMS320C6x)
1186         corepacEventNum = (int32_t)coreIntrNum;
1187         #endif
1189         /* Delete interrupts */
1190         #if defined (_TMS3206X)
1191         corepacEventNum = (int32_t)gADCBUFTestParam.chirpIntNumber;
1192         (void) Osal_DeleteInterrupt((HwiP_Handle) hwiHandle, corepacEventNum);
1193         #else
1194         (void) Osal_DeleteInterrupt((HwiP_Handle) hwiHandle, gADCBUFTestParam.chirpIntNumber);
1196         #endif
1198         /* Send test results to logger */
1199         if (gVerifyFailCount > 0)
1200         {
1201             printf ("ADCBUF Test Pattern failed\n");
1202             printf ("gVerifyFailCount = %d\n", gVerifyFailCount);
1203         }
1204         else
1205                 printf ("ADCBUF Test Pattern passed\n");
1207         /* Clear the counter */
1208         gIntCounter = 0;
1209         gVerifyFailCount = 0;
1211     }
1213     /**************************************************************************
1214      * Test: Graceful shutdown
1215      **************************************************************************/
1216     /* Close EDMA driver */
1217     if(EdmaHandle != NULL)
1218         Test_ADCBUFCloseEDMA(EdmaHandle);
1219     /* Delete semaphore */
1220     SemaphoreP_delete(gIntSemaHandle);
1221     printf("Debug: Semaphore Instance %p has been closed successfully\n", gIntSemaHandle);
1223 Exit:
1224     /* After test all done, terminate DSP by calling BIOS_exit().
1225         This is required by MCPI test framework script.
1226         MCPI test framework script waits for DSP halt,
1227         if DSP doesn't halt, script will wait until timeout then claim test fail.
1228      */
1229     BIOS_exit(0);
1231     return;
1234 /**
1235  *  @b Description
1236  *  @n
1237  *      Entry point into the test code.
1238  *
1239  *  @retval
1240  *      Not Applicable.
1241  */
1242 int main (void)
1244     Task_Params    taskParams;
1246     /* Initialize the Task Parameters. */
1247     Task_Params_init(&taskParams);
1248     taskParams.stackSize = 4*1024;
1249     Task_create(Test_ADCBUFInitTask, &taskParams, NULL);
1251     /* Start BIOS */
1252     BIOS_start();
1254     return 0;