📄 srio_lsu_example.c
字号:
/* ============================================================================
* 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 Srio_lsu_example.c
*
* @path $(CSLPATH)\example\srio\src
*
* @desc This is a simple example of usage of CSL APIs of the SRIO module.
*
* ============================================================================
* @n Target Platform: QT
* ============================================================================
* @n <b> Example Description </b>
* @n This is an example of the CSL SRIO usage for a LSU port.
* @verbatim
1. Setup SRIO module for loop back transfer on LSU1.
2. Setup the destination and source data areas.
3. Configure LSU1 registers.
4. Start transfer.
5. Wait for completion of the transfer.
6. Verify the destination contains the expected data.
@endverbatim
*
*=============================================================================
*
* @n <b> Procedure </b>
* @verbatim
1. Configure the CCS setup
2. Please refer CCS manual for setup configuration and loading
proper GEL file
3. Launch CCS window
4. Open project srio_lsu_example.pjt
5. Build the project and load the .out file of the project.
@endverbatim
*
*
* ============================================================================
*/
/* ============================================================================
* Revision History
* ===============
* 02-Sep-2005 Chandra File Created.
* 19-Dec-2005 SD Changes for the SERDES configuration
* 06-Feb-2006 SD Changes to support the DEV functional layer
* 24-Apr-2006 NG Updated - psc
* ============================================================================
*/
#include <csl_srio.h>
#include <soc.h>
#include <stdio.h>
#include <cslr_dev.h>
/* Macros */
#define SRIO_SET_DEVICE_ID(base_dev_id, large_base_dev_id) \
CSL_FMK(SRIO_BASE_ID_BASE_DEVICEID, base_dev_id) | \
CSL_FMK(SRIO_BASE_ID_LARGE_BASE_DEVICEID, large_base_dev_id)
#define LARGE_DEV_ID 0xBEEF
#define SMALL_DEV_ID 0xAB
#define SRIO_PKT_TYPE_NWRITE 0x54
#define SELECTED_LSU 0
#define TRANSFER_SIZE 256
/* globals */
static Uint8 src[TRANSFER_SIZE];
static Uint8 dst[TRANSFER_SIZE];
static CSL_SrioHwSetup setup = CSL_SRIO_HWSETUP_DEFAULTS;
/* Function prototypes */
void srio_Create_Setup (
CSL_SrioHwSetup *pSetup
);
/*
* ============================================================================
* @func main
*
* @desc
* This is the main routine of this program which invokes the different
* components to complete a simple LSU transfer.
* ============================================================================
*/
void main (
void
)
{
volatile Uint32 index, dummy_cnt;
Uint8 lsu_no;
CSL_SrioContext context;
CSL_Status status;
CSL_SrioHandle hSrio;
CSL_SrioObj srioObj;
CSL_InstNum srioNum = 0; /* Instance number of the SRIO */
CSL_SrioParam srioParam;
CSL_SrioDirectIO_ConfigXfr lsu_conf = {0};
CSL_SrioPortData response;
/* Enable SRIO in DEVSTAT register */
((CSL_DevRegs *)CSL_DEV_REGS)->DEVSTAT_KEY = 0x0E3C5A78;
CSL_FINST(((CSL_DevRegs *)CSL_DEV_REGS)->DEVSTAT, DEV_DEVSTAT_RIO_EN, ENABLE);
/* Enable SRIO in PSC control module */
*(volatile unsigned int *)0x02ae0a18 = 0x03;
/* Initialization and Open of the SRIO */
status = CSL_srioInit (&context);
hSrio = CSL_srioOpen (&srioObj, srioNum, &srioParam, &status);
if (status != CSL_SOK) {
printf("SRIO: ... Cannot open SRIO, failed\n");
return;
}
/* Create the setup structure */
srio_Create_Setup (&setup);
/* Setup the SRIO with the selected setup in the last step */
status = CSL_srioHwSetup (hSrio, &setup);
if (status != CSL_SOK) {
printf("SRIO: ... Hardwrae setup, failed\n");
return;
}
/* Setup the source and destination */
for(index=0; index<TRANSFER_SIZE; index++) {
src[index] = index + 1;
dst[index] = 0;
}
/* Create an LSU configuration */
lsu_conf.srcNodeAddr = (Uint32)&src[0]; /* Source address */
lsu_conf.dstNodeAddr.addressHi = 0;
lsu_conf.dstNodeAddr.addressLo = (Uint32)&dst[0]; /* Destination address */
lsu_conf.byteCnt = TRANSFER_SIZE;
lsu_conf.idSize = 1; /* 16 bit device id */
lsu_conf.priority = 2; /* PKT priority is 2 */
lsu_conf.xambs = 0; /* Not an extended
address */
lsu_conf.dstId = LARGE_DEV_ID;
lsu_conf.intrReq = 0; /* No interrupts */
lsu_conf.pktType = SRIO_PKT_TYPE_NWRITE;
/* write with no
response */
lsu_conf.hopCount = 0; /* Valid for
maintainance pkt */
lsu_conf.doorbellInfo = 0; /* Not a doorbell pkt */
lsu_conf.outPortId = 0; /* Tx on Port 0 */
/* Configure the LSU1 and start transmission */
lsu_no = SELECTED_LSU;
CSL_srioLsuSetup (hSrio, &lsu_conf, lsu_no);
/* Wait for the completion of transfer */
response.index = lsu_no;
do {
CSL_srioGetHwStatus (hSrio, CSL_SRIO_QUERY_LSU_BSY_STAT, &response);
}while(response.data == 1);
/* A delay, above checks seems to be not working
may be because, it is a write operation with
no response */
for(index=0; index<0x10000; index++) {
dummy_cnt = index + 1;
dummy_cnt++;
}
/* Verify whether data is transfered */
for(index=0; index<TRANSFER_SIZE; index++) {
if (src[index] != dst[index]) {
break;
}
}
if (index == TRANSFER_SIZE) {
printf("SRIO: ... LSU transfered %d bytes of data correctly\n",
TRANSFER_SIZE);
} else {
printf("SRIO: ... LSU failed to transfer data\n");
}
}
/*
* ============================================================================
* @func srio_Create_Setup
*
* @desc
* This routine setsup a structure with the required setup of the SRIO.
* ============================================================================
*/
void srio_Create_Setup (
CSL_SrioHwSetup *pSetup
)
{
Uint32 index;
/* Peripheral enable */
pSetup->perEn = 1;
/* While in shutdown, put memories in sleep mode */
pSetup->periCntlSetup.swMemSleepOverride = 1;
/* Enable loopback operation */
pSetup->periCntlSetup.loopback = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -