DSP

DSPLINK DEMO解析之READWRITE

2019-07-13 10:22发布

READWRITE 示例阐明了大缓冲区通过直接读写 DSP 内部 RAM 来进行传输的概念。它实现了在 GPP 端和使用 PROC_Read()和 PROC_Write() API 的 DSP 端以及两个 DSP 端之间的大尺寸数据缓冲器之间的数据与信息的传递和转换。DSP 端应用程序采用 MSGQ 实现了 TSK。   ------------------------------------------------GPP端---------------------------------------------------- status = RDWR_Create (dspExecutable,strBufferSize,strNumIterations,processorId)      -------- status = PROC_setup (NULL) ;     --------status = PROC_attach (processorId, NULL) ;     --------status = POOL_open (POOL_makePoolId(processorId, SAMPLE_POOL_ID),&SamplePoolAttrs) ;     --------status = MSGQ_open (SampleGppMsgqName, &SampleGppMsgq, NULL) ;  //打开GPP端消息队列     --------status = PROC_load (processorId,(Char8 *) &imageInfo,NUM_ARGS,args) ;     --------status = PROC_start (processorId) ;     --------mqtAttrs.poolId = POOL_makePoolId(processorId, SAMPLE_POOL_ID) ;  //打开远程传输         status = MSGQ_transportOpen (processorId, &mqtAttrs) ;     --------status = MSGQ_locate (SampleDspMsgqName,&SampleDspMsgq,&syncLocateAttrs) ;  //定位DSP消息队列 status = RDWR_Execute (dspAddress,bufferSize,numIterations,processorId) ;     --------status = RDWR_AllocateBuffer (bufferSize, (Pvoid *) &bufIn) ; 复制代码 RDWR_AllocateBuffer (IN Uint32 size, OUT Pvoid * buf) { DSP_STATUS status = DSP_SOK ; *buf = malloc (size) ; if (*buf == NULL) { status = DSP_EMEMORY ; } return status ; } 复制代码     --------确定DSP内存区  View Code     --------status = PROC_write (processorId, dspAddr2, bufferSize, bufIn) ;     --------初始化数据为1  View Code     --------status = PROC_write (processorId, dspAddr1, bufferSize, bufOut) ;  //写数据到DSP     --------验证DSP侧数据缓冲是否被写 复制代码 if (DSP_SUCCEEDED (status)) { status = MSGQ_alloc (POOL_makePoolId(processorId, SAMPLE_POOL_ID), APP_MSG_SIZE, (MSGQ_Msg *) &msg) ; if (DSP_SUCCEEDED (status)) { /* Set the message id as the scaling factor */ #if (defined (OMAP) && defined (PCPY_LINK)) || defined (WORD_SWAP) msg->gppWriteAddr = WORDSWAP_LONG ((dspAddr1 / DSP_MAUSIZE)) ; msg->dspWriteAddr = WORDSWAP_LONG ((dspAddr2 / DSP_MAUSIZE)) ; msg->size = WORDSWAP_LONG ((bufferSize/ DSP_MAUSIZE)) ; msg->scalingFactor = WORDSWAP_LONG (i) ; #else /* if (defined (OMAP) && defined (PCPY_LINK)) || defined (WORD_SWAP) */ msg->gppWriteAddr = (dspAddr1 / DSP_MAUSIZE) ; msg->dspWriteAddr = (dspAddr2 / DSP_MAUSIZE) ; msg->size = (bufferSize / DSP_MAUSIZE) ; msg->scalingFactor = i ; #endif /* if (defined (OMAP) && defined (PCPY_LINK)) || defined (WORD_SWAP) */ /* Send the message */ status = MSGQ_put (SampleDspMsgq, (MSGQ_Msg) msg) ; if (DSP_FAILED (status)) { RDWR_1Print ("MSGQ_put failed. Status: [0x%x] ", status) ; } } else { RDWR_1Print ("MSGQ_alloc failed. Status: [0x%x] ", status) ; } 复制代码     --------等待DSP回发确认数据被写入的消息  View Code     -------- status = PROC_read (processorId, dspAddr2, bufferSize, bufIn) ;  //从DSP内存中读取数据     --------验证回读的数据  verify the data read back RDWR_Delete (processorId) ;     --------status = MSGQ_release (SampleDspMsgq) ;     --------status = MSGQ_transportClose (processorId) ;     --------tmpStatus = PROC_stop (processorId) ;     --------tmpStatus = MSGQ_close (SampleGppMsgq) ;     -------- tmpStatus = POOL_close (POOL_makePoolId(processorId, SAMPLE_POOL_ID)) ;     --------tmpStatus = PROC_detach  (processorId) ;     --------tmpStatus = PROC_destroy () ;     --------tmpStatus = RDWR_OS_exit () ;          RDWR_OS_exit   ------------------------------------------------GPP端---------------------------------------------------- DSPLINK_init() status = TSKRDWR_create (&info);     --------status = POOL_open (0, &poolObj) ;     --------status = MSGQ_transportOpen (ID_GPP, &transport) ;     --------*infoPtr = MEM_calloc (DSPLINK_SEGID,sizeof (TSKRDWR_TransferInfo),DSPLINK_BUF_ALIGN) ;     --------GPP端等待DSP打开一个消息队列,DSP首次打开本地消息队列  View Code     --------定位GPP的消息队列  View Code status = TSKRDWR_execute (info);     --------等待关于数据缓冲区信息的消息  View Code status = TSKRDWR_delete (info);     -------- status = MSGQ_close (info->dspMsgqQueue) ;     --------freeStatus = MEM_free(DSPLINK_SEGID, info, sizeof (TSKRDWR_TransferInfo));  //释放信息结构体