博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OMAPL138学习----DSPLINK DEMO解析之SCALE
阅读量:4952 次
发布时间:2019-06-12

本文共 9770 字,大约阅读时间需要 32 分钟。

SCALE 示例阐明了在DSP/BIOS LINK 的数据流和信息的组合,实现了GPP端和DSP端任务间的数据传递,还从GPP端发送信息到DSP端。

-------------------------------------------GPP端------------------------------------------------

SCALE_BufferSize = DSPLINK_ALIGN (SCALE_Atoi (strBufferSize),DSPLINK_BUF_ALIGN) ;  //验证数据缓冲区大小

status = SCALE_Create (dspExecutable,strBufferSize,strNumIterations,processorId) ;

    --------PROC_setup()

    --------status = PROC_attach (processorId, NULL) ;

    --------status = POOL_open (POOL_makePoolId(processorId, SAMPLE_POOL_ID),&poolAttrs) ;

      --------status = PROC_load (processorId, dspExecutable, numArgs, args) ;

    -------- status = CHNL_create (processorId, CHNL_ID_OUTPUT, &chnlAttrOutput) ;  //创建一个到DSP的channel

    -------- status = CHNL_create (processorId, CHNL_ID_INPUT, &chnlAttrInput) ;    //创建一个来自DSP的channel

    --------status = CHNL_allocateBuffer (processorId,CHNL_ID_OUTPUT,SCALE_Buffers,SCALE_BufferSize , 1) ;  //为发送数据到DSP端分配缓冲区

    --------status = PROC_start (processorId) ;

    --------status = MSGQ_transportOpen (processorId, &mqtAttrs) ;    //打开远程传输

status = SCALE_Execute (SCALE_NumIterations, processorId) ;

    --------status = MSGQ_locate (SampleDspMsgqName,&SampleDspMsgq,&syncLocateAttrs) ;  //定位DSP的消息队列

    --------SCALE_IOReq.buffer = SCALE_Buffers [0] ;    //填充 IO 请求结构

        SCALE_IOReq.size = SCALE_BufferSize ;

    --------用有效数据初始化缓冲:

if (DSP_SUCCEEDED (status)) {            ptr8  = (Uint8 *)  (SCALE_IOReq.buffer) ;            ptr16 = (Uint16 *) (SCALE_IOReq.buffer) ;            for (   (j = 0) ;                    (DSP_SUCCEEDED (status))                 && (j < SCALE_BufferSize / DSP_MAUSIZE) ;                     j++ ) {                if (DSP_MAUSIZE == 1) {                    *ptr8 = XFER_CHAR ;                    ptr8++ ;                }                else if (DSP_MAUSIZE == 2) {                    *ptr16 = XFER_CHAR ;                    ptr16++ ;                }            }        }

    --------status = CHNL_issue (processorId, CHNL_ID_OUTPUT, &SCALE_IOReq) ;    //向DSP发送数据

    --------status = CHNL_reclaim (processorId,CHNL_ID_OUTPUT,WAIT_FOREVER,&SCALE_IOReq) ; //从channel回收空缓冲

      --------status = CHNL_issue (processorId, CHNL_ID_INPUT, &SCALE_IOReq) ;  //从DSP端接收数据

    --------status = CHNL_reclaim (processorId,CHNL_ID_INPUT,WAIT_FOREVER,&SCALE_IOReq) ; //从channel回收填充缓冲

    --------status = SCALE_VerifyData (SCALE_IOReq.buffer) ;

    --------SCALE_XferValue++ ;      //改变换算系数

        status = MSGQ_alloc (POOL_makePoolId(processorId, SAMPLE_POOL_ID),APP_MSG_SIZE,(MSGQ_Msg *) &msg) ;

    --------MSGQ_setMsgId ((MSGQ_Msg) msg, SCALE_REQUEST_MSGID) ;    //发送已经定位的消息

        status = MSGQ_put (SampleDspMsgq, (MSGQ_Msg) msg) ;

    --------- status = MSGQ_release (SampleDspMsgq) ;    //释放消息队列

SCALE_Delete (processorId) ;

    --------status = MSGQ_transportClose (processorId) ;

    --------tmpStatus = PROC_stop (processorId) ;

    --------tmpStatus = CHNL_freeBuffer (processorId,CHNL_ID_OUTPUT,SCALE_Buffers,1) ;

    --------tmpStatus = CHNL_delete  (processorId, CHNL_ID_INPUT) ;

    --------tmpStatus = CHNL_delete  (processorId, CHNL_ID_OUTPUT) ;

    --------tmpStatus = POOL_close (POOL_makePoolId(processorId, SAMPLE_POOL_ID)) ;

    --------tmpStatus = PROC_detach (processorId) ;    

    -------- tmpStatus = PROC_destroy () ;

 

-------------------------------------------DSP端------------------------------------------------

SWI MODE

DSPLINK_init()

status = SWISCALE_create (&info) ;

    --------status = POOL_open (0, &poolObj) ;

    --------status = DEV_createDevice("/dsplink",&ZCPYDATA_FXNS,(Fxn) &ZCPYDATA_init,&devAttrs) ;  //动态建立IOM驱动

    --------status = DEV_createDevice("/dio_dsplink",&DIO_tskDynamicFxns,NULL,&dioDevAttrs);  //动态建立DIO适配器

    --------status = MSGQ_transportOpen (ID_GPP,&transport) ;

    --------*infoPtr = MEM_calloc (DSPLINK_SEGID,sizeof (SWISCALE_TransferInfo),DSPLINK_BUF_ALIGN) ;  //分配结构体

    --------初始化 SWICALE 传输信息结构

        if (status == SYS_OK) {              info->bufferSize        = xferBufSize ;              (info->appReadCb).fxn   = readFinishCb ;              (info->appReadCb).arg   =(Ptr) info ;              (info->appWriteCb).fxn  = writeFinishCb ;              (info->appWriteCb).arg  = (Ptr) info ;              info->scalingFactor     = 1 ;            }

    --------建立channel 句柄

         GIO_Attrs gioAttrs = GIO_ATTRS ;            info->gioInputChan = GIO_create (INPUT_CHANNEL,                                         IOM_INPUT,                                         NULL,                                         NULL,                                         &gioAttrs) ;            info->gioOutputChan = GIO_create (OUTPUT_CHANNEL,                                          IOM_OUTPUT,                                          NULL,                                          NULL,                                          &gioAttrs) ;

    ------为发送和接收数据新建 SWI

if (status == SYS_OK) {        swiAttrs.fxn        = dataSWI ;        swiAttrs.arg0       = (Arg) info ;        swiAttrs.mailbox    = INITIAL_DATA_MAILBOX_VAL ;        info->swiData = SWI_create (&swiAttrs) ;        if (info->swiData == NULL) {            status = SYS_EALLOC ;            SET_FAILURE_REASON (status) ;        }    }

        --------调用dataSWI()

        --------处理数据

for (i = 0 ; i < numMAUs; i++) {        info->outputBuffer [i] = info->inputBuffer [i] * info->scalingFactor ;    }

        --------iomStatus = GIO_submit (info->gioInputChan,IOM_READ,info->inputBuffer,&bufSize,&(info->appReadCb)) ;

            //提交一个读取数据请求

        --------iomStatus = GIO_submit (info->gioOutputChan,IOM_WRITE,info->outputBuffer,&numMAUs,&(info>appWriteCb)) ;

            //提交一个写数据请求

    --------为接收消息新建SWI:

f (status == SYS_OK) {        swiAttrs.fxn        = msgSWI ;        swiAttrs.arg0       = (Arg) info ;        swiAttrs.mailbox    = INITIAL_MSG_MAILBOX_VAL ;        info->swiMsg = SWI_create (&swiAttrs) ;        if (info->swiMsg == NULL) {            status = SYS_EALLOC ;            SET_FAILURE_REASON (status) ;        }    }

        --------调用msgSWI:

        --------status = MSGQ_get (info->msgqQueue, &msg, 0) ;

        --------if (MSGQ_getMsgId (msg) == SCALE_REQUEST_MSGID) {

            info->scalingFactor = ((SCALE_ScaleMsg *) msg)->scalingFactor ;

        --------MSGQ_free (msg) ;

    --------status = POOL_alloc (SAMPLE_POOL_ID,(Ptr *) &(info->inputBuffer),info->bufferSize) ;  //分配输入缓冲

    --------status = POOL_alloc (SAMPLE_POOL_ID,(Ptr *) &(info->outputBuffer),info->bufferSize) ;  //分配输出缓冲

    --------msgqAttrs.notifyHandle = info->swiMsg;

        msgqAttrs.post = (MSGQ_Post) SWI_post ;

        msgqAttrs.pend = NULL ;

    --------status = MSGQ_open (DSP_MSGQNAME, &info->msgqQueue, &msgqAttrs) ;  //建立消息队列

status = SWISCALE_execute (info) ;

    --------iomStatus = GIO_submit (info->gioInputChan,IOM_READ,info->inputBuffer,&bufSize,&(info->appReadCb)) ;//提交读请求

    --------SWI_andn (info->swiData, WRITE_MAILBOX_MASK) ;  //因为没有首次填写所以清除软件中断(SWI)邮箱写位

因为SWI 应用程序会一直运行,所以没有进行SWISCALE_delete()

TSK MODE

DSPLINK_init()

status = TSKSCALE_create (&info);

    --------status = POOL_open (0, &poolObj) ;

    --------status = DEV_createDevice("/dsplink",&ZCPYDATA_FXNS,(Fxn) &ZCPYDATA_init,&devAttrs) ;  //f动态创建IOM驱动

    --------status = DEV_createDevice("/dio_dsplink",&DIO_tskDynamicFxns,NULL,&dioDevAttrs);  //动态创建DIO适配器

    --------status = MSGQ_transportOpen (ID_GPP,&transport) ;

    --------*infoPtr = MEM_calloc (DSPLINK_SEGID,sizeof (TSKSCALE_TransferInfo),DSPLINK_BUF_ALIGN) ;

    --------填充传输信息结构体:

info->numTransfers  = numTransfers ;        info->bufferSize    = xferBufSize ;        info->numBuffers    = 1 ;        info->scalingFactor = 1 ;

    --------用于创建数据流的属性

attrs.nbufs   = info->numBuffers ;        attrs.segid   = DSPLINK_SEGID ;        attrs.align   = DSPLINK_BUF_ALIGN ;        attrs.flush   = TRUE ;        attrs.model   = SIO_ISSUERECLAIM ;        attrs.timeout = SYS_FOREVER ;

    --------info->inputStream = SIO_create (INPUT_CHANNEL,SIO_INPUT,info->bufferSize,&attrs);  //创建输入输出流

    --------info->outputStream = SIO_create (OUTPUT_CHANNEL,SIO_OUTPUT,info->bufferSize,&attrs) ;

    --------status = POOL_alloc (SAMPLE_POOL_ID,(Ptr *) &(info->buffer),info->bufferSize) ; //为将会用到的传输分配一个缓冲

    --------SEM_new (&(info->notifySemObj), 0) ;    //设置信号量

    --------为这个消息队列填充属性值:

msgqAttrs.notifyHandle = &(info->notifySemObj) ;        msgqAttrs.pend         = (MSGQ_Pend) SEM_pendBinary ;        msgqAttrs.post         = (MSGQ_Post) SEM_postBinary ;

    --------status = MSGQ_open (DSP_MSGQNAME, &info->msgqQueue, &msgqAttrs) ;  //创建消息队列

status = TSKSCALE_execute (info);

    --------status = SIO_issue (info->inputStream,buffer,info->bufferSize,arg) ;  //从GPP端接收数据  

    --------nmadus = SIO_reclaim (info->inputStream,(Ptr *) &buffer,&arg) ;

    -------- status = MSGQ_get (info->msgqQueue, &msg, 0) ;

    --------if (MSGQ_getMsgId (msg) == SCALE_REQUEST_MSGID) {

        info->scalingFactor = ((SCALE_ScaleMsg *)msg)->scalingFactor ;

        }

    --------MSGQ_free (msg) ;

    --------if (status == SYS_OK) {      //处理缓冲数据

        for (j = 0 ; (j < info->receivedSize) && (status == SYS_OK); j++) {

        buffer [j] *= info->scalingFactor ;

        }
        }

    --------status = SIO_issue (info->outputStream,buffer,info->receivedSize,arg) ;  //把处理后的数据返回给GPP

    --------nmadus = SIO_reclaim (info->outputStream,(Ptr *)&(buffer),&arg) ;

status = TSKSCALE_delete (info);

    --------status = MSGQ_close (info->msgqQueue) ;

    --------funcStatus = SIO_delete(info->inputStream);

    --------funcStatus = SIO_delete(info->outputStream);

    -------- POOL_free (SAMPLE_POOL_ID, info->buffer, info->bufferSize) ;

    -------- freeStatus = MEM_free(DSPLINK_SEGID, info, sizeof (TSKSCALE_TransferInfo));

转载于:https://www.cnblogs.com/zxycele/p/3626177.html

你可能感兴趣的文章
关于响应式布局
查看>>
详解ASP.Net 4中的aspnet_regsql.exe
查看>>
python 多进程和多线程的区别
查看>>
hdu1398
查看>>
[android] 网络断开的监听
查看>>
156.Binary Tree Upside Down
查看>>
MongoDB在windows下安装配置
查看>>
Upselling promotion stored procedure
查看>>
sigar
查看>>
iOS7自定义statusbar和navigationbar的若干问题
查看>>
程序员如何提高影响力:手把手教你塑造个人品牌
查看>>
[Locked] Wiggle Sort
查看>>
deque
查看>>
Ext JS学习第十三天 Ext基础之 Ext.Element
查看>>
Setting up a Passive FTP Server in Windows Azure VM(ReplyCode: 227, Entering Passive Mode )
查看>>
Atitit mtp ptp rndis midi协议的不同区别
查看>>
Ajax辅助方法
查看>>
Python模块调用
查看>>
委托的调用
查看>>
c#中从string数组转换到int数组
查看>>