⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tsip_elb_example.c

📁 dsp tms320c6486的csl例程
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  ============================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006
 *
 *   Use of this software is controlled by the terms and conditions found
 *   in the license agreement under which this software has been supplied.
 *  ============================================================================
 */
/** ============================================================================
 *   @file  Tsip_elb_example.c
 *
 *   @path  $(CSLPATH)\example\c6486\tsip_elb_example\tsip\src
 *
 *   @desc  This is an example program for TSIP of CSL 3x.  
 *
 *  ============================================================================
 *   @n Target Platform: TCI6486 VDB
 *  ============================================================================
 *   @n <b> Example Description </b>
 *   @n The example shows the functionality of TSIP in external loop back mode
 *          - TB Synchronisation-> Setting GPIO 12 as O/p and 13 as I/P
 *          - Enable LPSC domains of 3 TSIPs 
 *          - Setup TSIP channel
 *          - Setup TSIP Interrupt
 *          - Wait for the TB synchronisation
 *          - Enable TSIP DMA channel
 *          - Wait till transmit completes
 *          - Verify the data
 *          - Closes the opened instance
 *
 * =============================================================================
 *      
 *   <b> Procedure to run the example </b>
 *   @verbatim
 *      1. Configure the CCS setup to work with the emulator being used
 *      2. Please refer CCS manual for setup configuration and loading 
 *         proper GEL file
 *      3. Launch CCS window
 *      4. Open project Tsip_elb_example.pjt
 *      5. Build the project and load the .out file of the project.
 *          
 *   @endverbatim
 *   
 * =============================================================================
 */ 
/** ============================================================================
 *  Revision History
 *  ===============*
 *  18-Dec-2006 NG  File Created
 *
 * =============================================================================
 */

#include <stdio.h>
#include "example_init.h"
#include <csl_types.h>
#include <csl_gpio.h>

#define FAIL    0

#define BufferSize 128
#define GEM_ID 	((Uint32) (0))

CSL_GpioHandle      hGpio;
CSL_GpioPinData     gpioPinData;
CSL_GpioPinConfig   gpioConfig;

CSL_TsipHandle hTsip0;
CSL_TsipHandle hTsip1;
CSL_TsipHandle hTsip2;

CSL_TsipObj    tsipObj0;
CSL_TsipObj    tsipObj1;
CSL_TsipObj    tsipObj2;

CSL_TsipHwSetup tsipSetup;

CSL_Status     status;

CSL_TsipGblSetup        gblsetup;

/** Xmt Clock setup */
CSL_TsipXclkSetup       xclk;

/** Rcv Clock setup*/
CSL_TsipRclkSetup       rclk;

/** Transmit Frame Setup */
CSL_TsipFrameSetup      xframesetup;

/** Receive Frame Setup */
CSL_TsipFrameSetup      rframesetup;

/** Receive Interrupt Setup */
CSL_TsipIntSetup        xint;

/** Receive Interrupt Setup */
CSL_TsipIntSetup        rint;

Uint32    ChannelNumber;

Uint32    xbitmapa1[CSL_TSIP_BITMAP_SIZE];
Uint32    xbitmapb1[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapa1[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapb1[CSL_TSIP_BITMAP_SIZE];

Uint32    xbitmapa2[CSL_TSIP_BITMAP_SIZE];
Uint32    xbitmapb2[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapa2[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapb2[CSL_TSIP_BITMAP_SIZE];

Uint32    xbitmapa3[CSL_TSIP_BITMAP_SIZE];
Uint32    xbitmapb3[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapa3[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapb3[CSL_TSIP_BITMAP_SIZE];

Uint32    xbitmapa4[CSL_TSIP_BITMAP_SIZE];
Uint32    xbitmapb4[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapa4[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapb4[CSL_TSIP_BITMAP_SIZE];

Uint32    xbitmapa5[CSL_TSIP_BITMAP_SIZE];
Uint32    xbitmapb5[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapa5[CSL_TSIP_BITMAP_SIZE];
Uint32    rbitmapb5[CSL_TSIP_BITMAP_SIZE];

Uint32    Rcv0aDestAddr[BufferSize];

Uint32    Xmt0bSrcAddr[BufferSize];
Uint32    Rcv0bDestAddr[BufferSize];

Uint32    Rcv1aDestAddr[BufferSize];

Uint32    Xmt1bSrcAddr[BufferSize];
Uint32    Rcv1bDestAddr[BufferSize];

Uint32    Rcv2aDestAddr[BufferSize];

Uint32    Xmt2bSrcAddr[BufferSize];
Uint32    Rcv2bDestAddr[BufferSize];

Uint32    Rcv3aDestAddr[BufferSize];

Uint32    Xmt3bSrcAddr[BufferSize];
Uint32    Rcv3bDestAddr[BufferSize];

Uint32    Rcv4aDestAddr[BufferSize];

Uint32    Xmt4bSrcAddr[BufferSize];
Uint32    Rcv4bDestAddr[BufferSize];

Uint32    Rcv5aDestAddr[BufferSize];

Uint32    Xmt5bSrcAddr[BufferSize];
Uint32    Rcv5bDestAddr[BufferSize];

CSL_TsipChanSetup    xchannela;
CSL_TsipChanSetup    xchannelb;
CSL_TsipChanSetup    rchannela;
CSL_TsipChanSetup    rchannelb;

Uint32 interruptIteration[6] = {0, 0, 0, 0, 0, 0};

Uint32 arg;
Uint32  channel;
volatile Uint32 TsipDone = 0;
Uint32 result = 0;
Uint32 TSIP_ID = 0;
Uint32 bitmappos = 0;
Uint32* SrcDataIncPtr;
void tsip_basic_setup();
void tsip_Channel_setup();
void CID_Init();

/*
 * =============================================================================
 *   @func   tsip_txRx
 *
 *   @desc
 *  @n This function transmit and receive the data using test bench as external
 *     loopback.
 *
 *  @arg  
 *      None
 *
 *  @return
 *      result 
 *          0 - data transmit and receive successful.
 *          1 - data transmit/receive not successful.
 * =============================================================================
 */
Uint32 tsip_txRx (
    void
) 
{
    Uint32         TraceCounter = 0;
    CSL_GpioObj    gpioObj;
    CSL_Status     status;

    if (GEM_ID == 0) {
        hGpio = CSL_gpioOpen(&gpioObj, CSL_GPIO, NULL, &status);
    
        /* TB Synchronisation-> Setting GPIO 12 as O/p and 13 as I/P */
        hGpio->regs->DIR = 0x2000;
        
        /* Enable LPSC domains of 3 TSIPs */
        TSIP_Domain_Enable();
    
        hTsip0 = CSL_tsipOpen(&tsipObj0, CSL_TSIP_0, NULL, &status);
        tsip_basic_setup();
        hTsip1 = CSL_tsipOpen(&tsipObj1, CSL_TSIP_1, NULL, &status);
        hTsip2 = CSL_tsipOpen(&tsipObj2, CSL_TSIP_2, NULL, &status);
        CSL_tsipHwSetup(hTsip0, &tsipSetup);

        tsip_Channel_setup(Test_List[0].ChannelNumber);
        CSL_tsipChHwSetup(hTsip0, &tsipSetup);

        tsip_Channel_setup(Test_List[1].ChannelNumber);
        CSL_tsipChHwSetup(hTsip0, &tsipSetup);
    
        tsip_Channel_setup(Test_List[2].ChannelNumber);
        CSL_tsipChHwSetup(hTsip0, &tsipSetup);

        tsip_Channel_setup(Test_List[3].ChannelNumber);
        CSL_tsipChHwSetup(hTsip0, &tsipSetup);

        tsip_Channel_setup(Test_List[4].ChannelNumber);
        CSL_tsipChHwSetup(hTsip0, &tsipSetup);

        tsip_Channel_setup(Test_List[5].ChannelNumber);
        CSL_tsipChHwSetup(hTsip0, &tsipSetup);

        CID_Init();
        printf("CID Initialization done \n");
    
        arg = 0x1;
        CSL_FINS( hTsip0->regs->SIUCTL, TSIP_SIUCTL_XMTENB, arg );
        CSL_FINS( hTsip0->regs->SIUCTL, TSIP_SIUCTL_RCVENB, arg );
    
        setup_Tsip_Interrupt();
    
        arg = 1;
        CSL_tsipHwControl(hTsip0, CSL_TSIP_CMD_ENA_DMA, &arg);
    
        /* TB Synchronisation-> Setting GPIO 12 */
        hGpio->regs->OUT_DATA = 0x1000;
    
        /* TB Synchronisation-> Setting GPIO 12 */
        hGpio->regs->OUT_DATA = 0x0000;

        while(TsipDone == 0) {
            TraceCounter++;
        }
    
        result = Verify_Transfer((Test_List[0].xmt_frame_count ), 
                 ((Test_List[0].xmt_frame_size + 9)), 
                 (Xmt0aSrcAddr + GEM_ID * 0x1000000/4 + 0x10000000/4), 
                 (Rcv0aDestAddr + GEM_ID * 0x1000000/4 + 0x10000000/4));
        if (!result) {
    	    printf("Channel 0 Passed \n");
    	}
    
        result += Verify_Transfer((Test_List[1].xmt_frame_count ), 
                  ((Test_List[1].xmt_frame_size + 9)), 
                  (Xmt1aSrcAddr + GEM_ID * 0x1000000/4 + 0x10000000/4), 
                  (Rcv1aDestAddr + GEM_ID * 0x1000000/4 + 0x10000000/4));
        if (!result) {
    	    printf("Channel 1 Passed \n");
    	}
    
        result += Verify_Transfer((Test_List[2].xmt_frame_count ), 
                  ((Test_List[2].xmt_frame_size + 9)), 
                  (Xmt2aSrcAddr + GEM_ID * 0x1000000/4 + 0x10000000/4), 
                  (Rcv2aDestAddr + GEM_ID * 0x1000000/4 + 0x10000000/4));
        if (!result) {
    	    printf("Channel 2 Passed \n");
    	}
    
        result += Verify_Transfer((Test_List[3].xmt_frame_count ), 
                  ((Test_List[3].xmt_frame_size + 9)), 
                  (Xmt3aSrcAddr + GEM_ID * 0x1000000/4 + 0x10000000/4), 
                  (Rcv3aDestAddr + GEM_ID * 0x1000000/4 + 0x10000000/4));
        if (!result) {
    	    printf("Channel 3 Passed \n");
    	}
    
        result += Verify_Transfer((Test_List[4].xmt_frame_count ), 
                  ((Test_List[4].xmt_frame_size + 9)), 
                  (Xmt4aSrcAddr + GEM_ID * 0x1000000/4 + 0x10000000/4), 
                  (Rcv4aDestAddr + GEM_ID * 0x1000000/4 + 0x10000000/4));
        if (!result) {
    	    printf("Channel 4 Passed \n");
    	}
    
        result += Verify_Transfer((Test_List[5].xmt_frame_count ), 
                  ((Test_List[5].xmt_frame_size + 9)), 
                  (Xmt5aSrcAddr + GEM_ID * 0x1000000/4 + 0x10000000/4), 
                  (Rcv5aDestAddr + GEM_ID * 0x1000000/4 + 0x10000000/4));
        if (!result) {
    	    printf("Channel 5 Passed \n");
    	}
    }

    CSL_gpioClose(hGpio);

    return (result);
}

/*
 * =============================================================================
 *   @func   tsip_basic_setup
 *
 *   @desc
 *  @n This function sets up the TSIP to transmit and receive the data.
 *     loopback.
 *
 *  @arg  
 *      None
 *
 *  @return
 *      None
 * =============================================================================
 */
void tsip_basic_setup (
)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -