Hi
i used below hardware :
1. omapl137evm ( rev g )
i used below software :
1. dsplink-1_61_03-prebuilt
2. bios_setuplinux_5_33_05
3. ti_cgt_c6000_6.1.9_setup_linux_x86
4. xdctools_setuplinux_3_10_05_61
5. pspdrivers_01_30_00_05
6. OMAPL137_arm_setuplinux_1_00_00_11
7.kernel 2.6.18
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i want used MSGQ and NOTIFY for transfer message and CHNL for transfer data between arm and dsp in omapl137evm with dsplink.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i used this code for armside.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INCLUDES
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <dsplink.h>
#include <proc.h>
#include <chnl.h>
#include <msgq.h>
#include <pool.h>
#include <SDSP.h>
#include <system_os.h>
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/delay.h>
#include <asm/segment.h>
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <assert.h>
#include <sys/mman.h>
#include <notify.h>
#include <signal.h>
#define DDRVNAME "dsp"
#define IC_NAME(drvName) drvName
#define OC_NAME(drvName) drvName
#define IC IC_NAME(DDRVNAME)
#define OC OC_NAME(DDRVNAME)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FOR POOLING
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define NUM_ARGS 2
#define ARG_SIZE 256
#define SAMPLE_POOL_ID 0
#define NUMMSGPOOLS 4
#define NUMMSGINPOOL0 2
#define NUMMSGINPOOL1 2
#define NUMMSGINPOOL2 1
#define NUMMSGINPOOL3 4
#define APP_BUFFER_SIZE DSPLINK_ALIGN (sizeof (ControlMsg), DSPLINK_BUF_ALIGN)
//////////////////////////////////////////////////////////////////
#define DATA_LEN 256
#define DATA_LEN_Byte (DATA_LEN*4)
STATIC Uint32 SCALE_BufferSizeOut = DSPLINK_ALIGN (DATA_LEN_Byte,DSPLINK_BUF_ALIGN);
STATIC Uint32 SCALE_BufferSizeIn = DSPLINK_ALIGN (DATA_LEN_Byte,DSPLINK_BUF_ALIGN);
STATIC Char8 * SCALE_BuffersIn [1] ;
STATIC Char8 * SCALE_BuffersOut[1] ;
STATIC ChannelIOInfo SCALE_IOReqIn,SCALE_IOReqOut;
#define CHNL_ID_OUTPUT 0
#define CHNL_ID_INPUT 1
//////////////////////////////////////////////////////////////////
static char notify_status = 0;
static char ReceiveFlag = 0;
static char mode = 0;
typedef struct ControlMsg
{
MSGQ_MsgHeader header;
Uint16 command;
Char8 arg1[ARG_SIZE];
} ControlMsg;
ControlMsg *msg;
DSP_STATUS status = DSP_SOK;
Uint8 processorId = 0;
Uint16 msgId = 0;
char EndFlag1 = 0;
char EndFlag2 = 0;
Char8 arg1[ARG_SIZE];
Char8 printmessage[ARG_SIZE];
void sendControlMsg(Uint16 cmd,Char8 *arg1);
void signalHandler(int sig);
#define USERINPUTMAXNUMCHARS 70
#define DELIMITERS " "
#if defined ZCPY_LINK
#define SAMPLEMQT_CTRLMSG_SIZE ZCPYMQT_CTRLMSG_SIZE
STATIC ZCPYMQT_Attrs mqtAttrs;
#endif
STATIC Uint32 SampleBufSizes[NUMMSGPOOLS] =
{
APP_BUFFER_SIZE,
SAMPLEMQT_CTRLMSG_SIZE,
DSPLINK_ALIGN (sizeof(MSGQ_AsyncLocateMsg),DSPLINK_BUF_ALIGN),
DSPLINK_ALIGN (DATA_LEN_Byte,DSPLINK_BUF_ALIGN)
};
STATIC Uint32 SampleNumBuffers[NUMMSGPOOLS] =
{
NUMMSGINPOOL0,
NUMMSGINPOOL1,
NUMMSGINPOOL2,
NUMMSGINPOOL3
};
#if defined ZCPY_LINK
STATIC SMAPOOL_Attrs SamplePoolAttrs =
{
NUMMSGPOOLS,
SampleBufSizes,
SampleNumBuffers,
FALSE
};
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Message Naming
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
STATIC Char8 SampleGppMsgqName[DSP_MAX_STRLEN] = "GPPMSGQ1";
STATIC Char8 SampleDspMsgqName[DSP_MAX_STRLEN] = "DSPMSGQ";
STATIC MSGQ_Queue SampleGppMsgq = (Uint32) MSGQ_INVALIDMSGQ;
STATIC MSGQ_Queue SampleDspMsgq = (Uint32) MSGQ_INVALIDMSGQ;
Char8 dspMsgqName[DSP_MAX_STRLEN];
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FOR LOADING
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern LINKCFG_Object LINKCFG_config;
STATIC
NORMAL_API
Void
MP_LIST_Notify (IN Uint32 eventNo,
IN OPT Pvoid arg,
IN OPT Pvoid info) ;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INITIALIZATION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NORMAL_API DSP_STATUS DSP_Create(IN Char8* dspExecutable, IN Char8* strNumIterations, IN Uint8 processorId)
{
Uint32 numArgs = NUM_ARGS;
MSGQ_LocateAttrs syncLocateAttrs;
Char8* args[NUM_ARGS];
ChannelAttrs chnlAttrInput ;
ChannelAttrs chnlAttrOutput ;
SYSTEM_0Print("Entered DSP_Create ()\n");
//////////////////////////////
//PROC_attach
//////////////////////////////
status = PROC_setup(NULL);
if (DSP_SUCCEEDED(status))
{
status = PROC_attach(processorId, NULL);
if (DSP_FAILED(status))
{
SYSTEM_1Print("PROC_attach () failed. Status = [0x%x]\n", status);
}
}
//////////////////////////////
//POOL_open
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
status = POOL_open(POOL_makePoolId(processorId, SAMPLE_POOL_ID), &SamplePoolAttrs);
if (DSP_FAILED(status))
{
SYSTEM_1Print("POOL_open () failed. Status = [0x%x]\n", status);
}
}
else
{
SYSTEM_1Print("PROC_setup () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//MSGQ_open
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
status = MSGQ_open(SampleGppMsgqName, &SampleGppMsgq, NULL);
if (DSP_FAILED(status))
{
SYSTEM_1Print("MSGQ_open () failed. Status = [0x%x]\n", status);
}
}
//////////////////////////////
//MSGQ_setErrorHandler
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
status = MSGQ_setErrorHandler(SampleGppMsgq, POOL_makePoolId(processorId, SAMPLE_POOL_ID));
if (DSP_FAILED(status))
{
SYSTEM_1Print("MSGQ_setErrorHandler () failed. Status = [0x%x]\n", status);
}
}
//////////////////////////////
//Set the notifier
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
status = NOTIFY_register (processorId,
0,
5,
(FnNotifyCbck) MP_LIST_Notify,
0) ;
if (DSP_FAILED (status))
{
SYSTEM_1Print ("NOTIFY_register() failed. Status = [0x%x]\n",
status) ;
}
}
//////////////////////////////
//PROC_load
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
args [0] = strNumIterations;
{
status = PROC_load(processorId, dspExecutable, numArgs, args);
}
if (DSP_FAILED(status))
{
SYSTEM_1Print("PROC_load () failed. Status = [0x%x]\n", status);
}
}
//////////////////////////////
//Create a channel to DSP
//////////////////////////////
if (DSP_SUCCEEDED (status))
{
chnlAttrOutput.mode = ChannelMode_Output ;
chnlAttrOutput.endianism = Endianism_Default ;
chnlAttrOutput.size = ChannelDataSize_32bits ;
status = CHNL_create (processorId, CHNL_ID_OUTPUT, &chnlAttrOutput);
if (DSP_FAILED (status))
{
SYSTEM_1Print("CHNL_create (CHNL_ID_OUTPUT) failed. Status = [0x%x]\n", status) ;
}
else
{
SYSTEM_0Print("CHNL_create (CHNL_ID_OUTPUT) success.\n") ;
}
}
//////////////////////////////
//Create a channel from DSP
//////////////////////////////
if (DSP_SUCCEEDED (status))
{
chnlAttrInput.mode = ChannelMode_Input ;
chnlAttrInput.endianism = Endianism_Default ;
chnlAttrInput.size = ChannelDataSize_32bits ;
status = CHNL_create (processorId, CHNL_ID_INPUT, &chnlAttrInput) ;
if (DSP_FAILED (status))
{
SYSTEM_1Print("CHNL_create () failed. Status = [0x%x]\n", status) ;
}
else
{
SYSTEM_0Print("CHNL_create (CHNL_ID_INPUT) success.\n") ;
}
}
///////////////////////////////////////////////////
//Allocate buffer(s) for data transfer to DSP.
///////////////////////////////////////////////////
if (DSP_SUCCEEDED (status))
{
status = CHNL_allocateBuffer ( processorId,
CHNL_ID_OUTPUT,
SCALE_BuffersOut, //Pointer to receive array of allocated buffers
SCALE_BufferSizeOut , //Size of each buffer
1) ; //Number of buffers to allocate
if (DSP_FAILED (status))
{
SYSTEM_1Print("CHNL_allocateBuffer (1) failed. Status = [0x%x]\n",status);
}
else
{
SYSTEM_0Print("CHNL_allocateBuffer (1) success.\n");
}
}
if (DSP_SUCCEEDED (status))
{
status = CHNL_allocateBuffer ( processorId,
CHNL_ID_INPUT,
SCALE_BuffersIn, //Pointer to receive array of allocated buffers
SCALE_BufferSizeIn , //Size of each buffer
1) ; //Number of buffers to allocate
if (DSP_FAILED (status))
{
SYSTEM_1Print("CHNL_allocateBuffer (2) failed. Status = [0x%x]\n",status);
}
else
{
SYSTEM_0Print("CHNL_allocateBuffer (2) success.\n");
}
}
//////////////////////////////
//PROC_start
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
status = PROC_start(processorId);
if (DSP_FAILED(status))
{
SYSTEM_1Print("PROC_start () failed. Status = [0x%x]\n", status);
}
else
{
SYSTEM_0Print("PROC_start () success.\n");
}
}
//////////////////////////////
//MSGQ_transportOpen
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
mqtAttrs.poolId = POOL_makePoolId(processorId, SAMPLE_POOL_ID);
status = MSGQ_transportOpen(processorId, &mqtAttrs);
if (DSP_FAILED(status))
{
SYSTEM_1Print("MSGQ_transportOpen () failed. Status = [0x%x]\n", status);
}
else
{
SYSTEM_0Print("MSGQ_transportOpen () success.\n");
}
}
//////////////////////////////
//MSGQ_locate
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
syncLocateAttrs.timeout = WAIT_FOREVER;
status = DSP_ENOTFOUND;
SYSTEM_2Sprint(dspMsgqName, "%s%d", (Uint32) SampleDspMsgqName, processorId);
while ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY))
{
status = MSGQ_locate(dspMsgqName, &SampleDspMsgq, &syncLocateAttrs);
if ((status == DSP_ENOTFOUND) || (status == DSP_ENOTREADY))
{
SYSTEM_0Print("DSP_ENOTFOUND || DSP_ENOTREADY.\n");
SYSTEM_Sleep(100000);
}
else if (DSP_FAILED(status))
{
SYSTEM_1Print("MSGQ_locate () failed. Status = [0x%x]\n", status);
}
}
}
SYSTEM_0Print("Finish DSP_Create ()\n");
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXECUTION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NORMAL_API DSP_STATUS DSP_Execute(IN Uint32 numIterations, Uint8 processorId)
{
char *ptr;
char inbuf[USERINPUTMAXNUMCHARS];
int i;
Uint32 AudioPtrSize;
Int32 *AudioPtrBuff;
SYSTEM_0Print("Entered DSP_Execute ()\n");
sprintf(printmessage,"ARM :Wake UP\n");
SYSTEM_0Print(printmessage);
(void) signal(SIGINT, signalHandler);
SYSTEM_0Print("Entered DSP_SUCCEEDED ()\n") ;
if (DSP_SUCCEEDED (status))
{
SCALE_IOReqIn.buffer = SCALE_BuffersIn [0] ;
SCALE_IOReqIn.size = SCALE_BufferSizeIn;
SCALE_IOReqOut.buffer= SCALE_BuffersOut [0] ;
SCALE_IOReqOut.size = SCALE_BufferSizeOut;
}
//////////////////////////////
//Receive Message
//////////////////////////////
status = MSGQ_get(SampleGppMsgq,WAIT_FOREVER, (MsgqMsg *) &msg);
if (DSP_FAILED(status))
{
SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n", status);
}
if (msg->command == 0x01)
{
SYSTEM_1Print("DSP :%s\n", (Uint32) msg->arg1);
sprintf(arg1,"Blink");
sprintf(printmessage,"ARM :BLINK_GPIO012\n");
SYSTEM_0Print(printmessage);
sendControlMsg(0x0a,arg1);
}
notify_status = 0;
ReceiveFlag = 1;
while ( EndFlag1 == 0 )
{
while ( EndFlag2 == 0 )
{
SYSTEM_0Print("ARM :Enter_Command = ");
fgets( inbuf, USERINPUTMAXNUMCHARS, stdin );
ptr = strtok( inbuf, DELIMITERS );
usleep(1000);
if ( EndFlag2 == 0 )
{
switch ( *ptr )
{
case 'a':
{
/////////////////////////////////////////////
// Send Message
/////////////////////////////////////////////
sprintf(arg1,"GPIO_0_12");
sprintf(printmessage,"ARM :BLINK_GPIO012\n");
SYSTEM_0Print(printmessage);
sendControlMsg(0x0a,arg1);
*ptr = 0;
break;
}
case 'b':
{
/////////////////////////////////////////////
// Send Message
/////////////////////////////////////////////
sprintf(arg1,"GPIO_0_13");
sprintf(printmessage,"ARM :BLINK_GPIO013\n");
SYSTEM_0Print(printmessage);
sendControlMsg(0x0b,arg1);
*ptr = 0;
break;
}
case 'c':
{
/////////////////////////////////////////////
// Send Message
/////////////////////////////////////////////
sprintf(arg1,"GPIO_0_14");
sprintf(printmessage,"ARM :BLINK_GPIO014\n");
SYSTEM_0Print(printmessage);
sendControlMsg(0x0c,arg1);
*ptr = 0;
break;
}
case 'd':
{
/////////////////////////////////////////////
// Send Message
/////////////////////////////////////////////
sprintf(arg1,"Data_transfer");
sprintf(printmessage,"ARM :Data_transfer\n");
SYSTEM_0Print(printmessage);
sendControlMsg(0x0d,arg1);
/////////////////////////////////////////////
// Build Data
/////////////////////////////////////////////
AudioPtrBuff = (Int32 *) (SCALE_IOReqIn.buffer);
for ( i=0 ; i<DATA_LEN ; i++ )
{
*AudioPtrBuff = 5;
AudioPtrBuff++;
}
AudioPtrSize = (SCALE_IOReqIn.size);
/////////////////////////////////////////////
// Issue 'filled' buffer to the channel.
/////////////////////////////////////////////
status = CHNL_issue (processorId,CHNL_ID_OUTPUT,&SCALE_IOReqIn);
if (DSP_FAILED (status))
{
SYSTEM_1Print ("CHNL_issue (CHNL_ID_OUTPUT) failed. Status = [0x%x]\n",status) ;
}
//////////////////////////////////////////////
// Reclaim 'empty' buffer from the channel
//////////////////////////////////////////////
status = CHNL_reclaim (processorId,CHNL_ID_OUTPUT,2000,&SCALE_IOReqIn);
if (DSP_FAILED (status))
{
SYSTEM_1Print ("CHNL_reclaim (CHNL_ID_OUTPUT) failed. Status = [0x%x]\n",status) ;
}
///////////////////////////////////////////////
// Issue 'empty' buffer to the channel.
///////////////////////////////////////////////
status = CHNL_issue (processorId,CHNL_ID_INPUT,&SCALE_IOReqOut);
if (DSP_FAILED (status))
{
SYSTEM_1Print ("CHNL_issue (CHNL_ID_INPUT) failed. Status = [0x%x]\n",status) ;
}
/////////////////////////////////////////////////
// Reclaim 'filled' buffer from the channel
/////////////////////////////////////////////////
status = CHNL_reclaim (processorId,CHNL_ID_INPUT,2000,&SCALE_IOReqOut) ;
if (DSP_FAILED (status))
{
SYSTEM_1Print ("CHNL_reclaim (CHNL_ID_INPUT) failed. Status = [0x%x]\n",status) ;
}
/////////////////////////////////////////////
// Print 20 Receive Data
/////////////////////////////////////////////
AudioPtrBuff=(Int32 *)SCALE_IOReqOut.buffer;
AudioPtrSize=(SCALE_IOReqOut.size);
for ( i=0 ; i<20 ; i++ )
{
SYSTEM_1Print("%d,\n", (Uint32)(*AudioPtrBuff));
AudioPtrBuff++;
}
////////////////////////////////////////////////////////
status = DSP_SOK;
*ptr = 0;
break;
}
case 'e':
{
notify_status = 0;
sprintf(arg1,"EXIT");
sprintf(printmessage,"ARM :TURN OFF\n");
SYSTEM_0Print(printmessage);
sendControlMsg(0x0e,arg1);
*ptr = 0;
EndFlag2 = 1;
break;
}
}
}
}
if ( notify_status == 1 )
{
notify_status = 0;
ReceiveFlag = 0;
EndFlag1 = 1;
if (mode == 0x02)
{
SYSTEM_1Print("DSP :%s\n", (Uint32) msg->arg1);
}
}
}
usleep(1000);
SYSTEM_0Print("Finish DSP_Create ()\n");
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FINALIZATION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NORMAL_API Void DSP_Delete(Uint8 processorId)
{
DSP_STATUS tmpStatus = DSP_SOK;
SYSTEM_0Print("Entered DSP_Delete ()\n");
//////////////////////////////
//MSGQ_release
//////////////////////////////
status = MSGQ_release(SampleDspMsgq);
if (DSP_FAILED(status))
{
SYSTEM_1Print("MSGQ_release () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//MSGQ_transportClose
//////////////////////////////
tmpStatus = MSGQ_transportClose(processorId);
if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
{
status = tmpStatus;
SYSTEM_1Print("MSGQ_transportClose () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//PROC_stop
//////////////////////////////
tmpStatus = PROC_stop(processorId);
if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
{
status = tmpStatus;
SYSTEM_1Print("PROC_stop () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//Unregister notification
//////////////////////////////
tmpStatus = NOTIFY_unregister (processorId,
0,
5,
(FnNotifyCbck) MP_LIST_Notify,
0) ;
if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus))
{
status = tmpStatus ;
SYSTEM_1Print ("NOTIFY_unregister () failed. Status = [0x%x]\n",
status) ;
}
//////////////////////////////
//MSGQ_setErrorHandler
//////////////////////////////
tmpStatus = MSGQ_setErrorHandler(MSGQ_INVALIDMSGQ, MSGQ_INVALIDMSGQ);
if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
{
status = tmpStatus;
SYSTEM_1Print("MSGQ_setErrorHandler () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//MSGQ_close
//////////////////////////////
tmpStatus = MSGQ_close(SampleGppMsgq);
if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
{
status = tmpStatus;
SYSTEM_1Print("MSGQ_close () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//POOL_close
//////////////////////////////
tmpStatus = POOL_close(POOL_makePoolId(processorId, SAMPLE_POOL_ID));
if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
{
status = tmpStatus;
SYSTEM_1Print("POOL_close () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//PROC_detach
//////////////////////////////
tmpStatus = PROC_detach(processorId);
if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
{
status = tmpStatus;
SYSTEM_1Print("PROC_detach () failed. Status = [0x%x]\n", status);
}
//////////////////////////////
//PROC_destroy
//////////////////////////////
tmpStatus = PROC_destroy();
if (DSP_SUCCEEDED(status) && DSP_FAILED(tmpStatus))
{
status = tmpStatus;
SYSTEM_1Print("PROC_destroy () failed. Status = [0x%x]\n", status);
}
SYSTEM_0Print("Finish DSP_Delete ()\n");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MAIN
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NORMAL_API Void DSP_Main(IN Char8* dspExecutable, IN Char8* strNumIterations, IN Char8* strProcessorId)
{
Uint32 numIterations = 0;
Uint8 processorId = 0;
if (LINKCFG_config.dspConfigs[processorId]->dspObject->doDspCtrl == DSP_BootMode_Boot_Pwr)
{
SYSTEM_0Print("DSP_BootMode_Boot_Pwr\n");
}
else if ( LINKCFG_config.dspConfigs[processorId]->dspObject->doDspCtrl == DSP_BootMode_NoBoot)
{
SYSTEM_0Print("DSP_BootMode_NoBoot\n");
}
if ((dspExecutable != NULL) && (strNumIterations != NULL))
{
numIterations = SYSTEM_Atoi(strNumIterations);
if (numIterations > 0xFFFF)
{
status = DSP_EINVALIDARG;
SYSTEM_1Print("ERROR! Invalid arguments specified.\n Max iterations = %d\n", 0xFFFF);
}
else
{
processorId = SYSTEM_Atoi(strProcessorId);
if (processorId >= MAX_DSPS)
{
SYSTEM_1Print("== Error: Invalid processor id %d specified ==\n", processorId);
status = DSP_EFAIL;
}
if (DSP_SUCCEEDED(status))
{
status = DSP_Create(dspExecutable, strNumIterations, processorId);
if (DSP_SUCCEEDED(status))
{
status = DSP_Execute(numIterations, processorId);
}
DSP_Delete(processorId);
}
}
}
else
{
status = DSP_EINVALIDARG;
SYSTEM_0Print("ERROR! Invalid arguments specified for DSP application\n");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
STATIC
NORMAL_API
Void
MP_LIST_Notify (IN Uint32 eventNo,IN OPT Pvoid arg,IN OPT Pvoid info)
{
notify_status = 1;
if ( ReceiveFlag == 1 )
{
//////////////////////////////
//Receive Message
//////////////////////////////
status = MSGQ_get(SampleGppMsgq,WAIT_FOREVER,(MsgqMsg *)&msg);
if (DSP_FAILED(status))
{
SYSTEM_1Print("MSGQ_get () failed. Status = [0x%x]\n",status);
}
else
{
mode = msg->command;
}
}
return;
}
void sendControlMsg( unsigned short int cmd,Char8 *arg1)
{
//////////////////////////////
//send message
//////////////////////////////
if (DSP_SUCCEEDED(status))
{
msgId = MSGQ_getMsgId(msg);
MSGQ_setMsgId(msg, msgId);
msg->command = cmd;
sprintf(msg->arg1,arg1);
status = MSGQ_put(SampleDspMsgq,(MsgqMsg) msg);
if (DSP_FAILED(status))
{
MSGQ_free((MsgqMsg) msg);
SYSTEM_1Print("MSGQ_put () failed. Status = [0x%x]\n", status);
}
}
if (DSP_SUCCEEDED (status))
{
status = NOTIFY_notify (processorId,0,5,(Uint32) 0);
if (DSP_FAILED (status))
{
SYSTEM_1Print ("NOTIFY_notify () failed."" Status = [0x%x]\n",status) ;
}
}
return;
}
void signalHandler(int sig)
{
sprintf(arg1,"EXIT");
sprintf(printmessage,"ARM :TURN OFF\n");
SYSTEM_0Print(printmessage);
sendControlMsg(0x0e,arg1);
EndFlag2 = 1;
usleep(1000);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
i used below code for dspside :
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INCLUDES
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "SDSPcfg.h"
#include <gbl.h>
#include <sys.h>
#include <sem.h>
#include <msgq.h>
#include <pool.h>
#include <notify.h>
#include <dsplink.h>
#include <platform.h>
#include <failure.h>
#include "SDSP_config.h"
#include "tskMessage.h"
#include <stdio.h>
#include <string.h>
#include <std.h>
#include <sio.h>
#include <gio.h>
#include <iom.h>
#include <sys.h>
#include <tsk.h>
#include <idl.h>
#include <ecm.h>
#include <mem.h>
#include <log.h>
#include <c64.h>
#include <c6x.h>
#include <ti/pspiom/cslr/cslr_gpio.h>
#include <ti/pspiom/cslr/soc_OMAPL137.h>
#include <ti/pspiom/gpio/Gpio.h>
#include <dio.h>
#include <iom.h>
extern TSKMESSAGE_TransferInfo* info;
ControlMsg* msg;
Char arg1[ARG_SIZE];
Int sendControlMsg( Uint16 cmd,Char *arg1,TSKMESSAGE_TransferInfo* info);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DSPLINK PARAMETERS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
volatile char notify_flag = 0;
volatile char mode = 0;
#define FILEID FID_APP_C
Uint8 dspMsgQName[DSP_MAX_STRLEN];
extern Uint16 numTransfers;
static Void TSKMPLIST_notify (Uint32 eventNo, Ptr arg, Ptr notifyinfo) ;
///////////////////// GPIO CONFIGURATION //////////////////////////////
#define LOW 0x0
#define HIGH 0x1
#define GPIO_BANK_1 0x00
#define GPIO0_12_PIN 13
#define GPIO0_13_PIN 14
#define GPIO0_14_PIN 15
#define GPIO0_15_PIN 16
extern Gpio_Handle gpio;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define DSPLINK_DRVNAME "/dio_dsplink"
#define INPUT_CHNL_NAME(drvName) drvName ## "0"
#define OUTPUT_CHNL_NAME(drvName) drvName ## "1"
#define INPUT_CHANNEL INPUT_CHNL_NAME(DSPLINK_DRVNAME)
#define OUTPUT_CHANNEL OUTPUT_CHNL_NAME(DSPLINK_DRVNAME)
SIO_Handle inputStream,outputStream ;
#define DATA_LEN 256
#define DATA_LEN_Byte (DATA_LEN*4)
Uint32 bufferSize = DATA_LEN_Byte;
Uint32 numBuffers = 1;
Char * buffer1 ;
Char * buffer2 ;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GPIO CONFIGURATION FUNCTION
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Int GpioConfiguration(Void)
{
Int status = SYS_OK;
Gpio_PinCmdArg UserPinCmdArg;
UserPinCmdArg.pin = GPIO0_12_PIN;
UserPinCmdArg.value = Gpio_Direction_Output;
Gpio_setPinDir(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_12_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_13_PIN;
UserPinCmdArg.value = Gpio_Direction_Output;
Gpio_setPinDir(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_13_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_14_PIN;
UserPinCmdArg.value = Gpio_Direction_Output;
Gpio_setPinDir(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_14_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_15_PIN;
UserPinCmdArg.value = Gpio_Direction_Output;
Gpio_setPinDir(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_15_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INITIALIZATION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Int TSKMESSAGE_create(Void)
{
Int status = SYS_OK;
SIO_Attrs attrs = SIO_ATTRS;
MSGQ_Attrs msgqAttrs = MSGQ_ATTRS;
MSGQ_LocateAttrs syncLocateAttrs;
//////////////////////////////
//message allocating
//////////////////////////////
info = MEM_calloc(DSPLINK_SEGID, sizeof(TSKMESSAGE_TransferInfo), DSPLINK_BUF_ALIGN);
if (info == NULL)
{
status = SYS_EALLOC;
SET_FAILURE_REASON(status);
}
else
{
info->numTransfers = numTransfers;
info->localMsgq = MSGQ_INVALIDMSGQ;
info->locatedMsgq = MSGQ_INVALIDMSGQ;
}
//////////////////////////////////////////////////
//Register notification for the event callback
/////////////////////////////////////////////////
if (status == SYS_OK)
{
status = NOTIFY_register (ID_GPP,
0,
5,
(FnNotifyCbck) TSKMPLIST_notify,
info) ;
if (status != SYS_OK)
{
SET_FAILURE_REASON (status) ;
}
}
////////////////////////////////////////
//Create Input and Output Streams
///////////////////////////////////////
if (status == SYS_OK)
{
attrs.nbufs = numBuffers;
attrs.segid = DSPLINK_SEGID;
attrs.align = DSPLINK_BUF_ALIGN;
attrs.flush = TRUE ;
attrs.model = SIO_ISSUERECLAIM;
attrs.timeout = 2000;
inputStream = SIO_create (INPUT_CHANNEL,SIO_INPUT,bufferSize,&attrs);
outputStream = SIO_create (OUTPUT_CHANNEL,SIO_OUTPUT,bufferSize,&attrs);
if ((inputStream == NULL) || (outputStream == NULL))
{
status = SYS_EALLOC ;
SET_FAILURE_REASON (status) ;
}
}
////////////////////////////////////////
//Allocating Buffers
///////////////////////////////////////
if (status == SYS_OK)
{
status = POOL_alloc (SAMPLE_POOL_ID,(Ptr *) &buffer1,bufferSize) ;
if (status != SYS_OK)
{
SET_FAILURE_REASON (status) ;
}
}
if (status == SYS_OK)
{
status = POOL_alloc (SAMPLE_POOL_ID,(Ptr *) &buffer2,bufferSize) ;
if (status != SYS_OK)
{
SET_FAILURE_REASON (status) ;
}
}
if (status == SYS_OK)
{
SEM_new(&(info->notifySemObj), 0);
msgqAttrs.notifyHandle = &(info->notifySemObj);
msgqAttrs.pend = (MSGQ_Pend) SEM_pendBinary;
msgqAttrs.post = (MSGQ_Post) SEM_postBinary;
SYS_sprintf((Char *)dspMsgQName, "%s%d", DSP_MSGQNAME, GBL_getProcId());
//////////////////////////////
//message open
//////////////////////////////
status = MSGQ_open((String)dspMsgQName, &info->localMsgq, &msgqAttrs);
if (status != SYS_OK)
{
SET_FAILURE_REASON(status);
}
else
{
//////////////////////////////
//MSGQ_setErrorHandler
//////////////////////////////
MSGQ_setErrorHandler(info->localMsgq, SAMPLE_POOL_ID);
status = SYS_ENOTFOUND;
while ((status == SYS_ENOTFOUND) || (status == SYS_ENODEV))
{
syncLocateAttrs.timeout = SYS_FOREVER;
//////////////////////////////
//MSGQ_locate
//////////////////////////////
status = MSGQ_locate(GPP_MSGQNAME, &info->locatedMsgq, &syncLocateAttrs);
if ((status == SYS_ENOTFOUND) || (status == SYS_ENODEV))
{
TSK_sleep(1000);
}
}
}
info->sequenceNumber = 0;
}
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXECUTION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Int TSKMESSAGE_execute(Void)
{
Int status = SYS_OK;
Char * Audio_In = (Char *) buffer1;
Char * Audio_Out = (Char *) buffer2;
Arg arg = 0;
Int nmadus;
Int receivedSize;
int i;
Gpio_PinCmdArg UserPinCmdArg;
char EndFlag1 = 0;
char EndFlag2 = 0;
char EndFlag3 = 0;
char EndFlag4 = 0;
char EndFlag5 = 0;
/////////////////////////////
//allocating message
////////////////////////////
status = MSGQ_alloc(SAMPLE_POOL_ID, (MSGQ_Msg*) &msg, APP_BUFFER_SIZE);
//////////////////////////////
//send message
//////////////////////////////
if (status == SYS_OK)
{
SYS_sprintf(arg1,"Wake UP");
sendControlMsg(0x01,arg1,info);
}
//////////////////////////////
//GPIO CONFIGURATION
//////////////////////////////
GpioConfiguration();
if (status == SYS_OK)
{
while ( EndFlag1 == 0 )
{
switch (mode)
{
case 0x0a:
{
while ( EndFlag2 == 0 )
{
UserPinCmdArg.pin = GPIO0_12_PIN;
UserPinCmdArg.value = LOW;
Gpio_setPinVal(gpio,&UserPinCmdArg);
TSK_sleep(1000);
UserPinCmdArg.pin = GPIO0_12_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
TSK_sleep(1000);
if ( notify_flag == 1 )
{
if (status == SYS_OK)
{
switch (mode)
{
case 0x0b:
{
EndFlag2 = 1;
break;
}
case 0x0c:
{
EndFlag2 = 1;
break;
}
case 0x0d:
{
EndFlag2 = 1;
break;
}
case 0x0e:
{
EndFlag1 = 1;
EndFlag2 = 1;
SYS_sprintf(arg1,"TURN OFF");
sendControlMsg(0x02,arg1,info);
break;
}
}
}
else
{
SET_FAILURE_REASON (status);
}
notify_flag = 0;
}
}
EndFlag2 = 0;
break;
}
case 0x0b:
{
while ( EndFlag3 == 0 )
{
UserPinCmdArg.pin = GPIO0_13_PIN;
UserPinCmdArg.value = LOW;
Gpio_setPinVal(gpio,&UserPinCmdArg);
TSK_sleep(1000);
UserPinCmdArg.pin = GPIO0_13_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
TSK_sleep(1000);
if ( notify_flag == 1 )
{
if (status == SYS_OK)
{
switch (mode)
{
case 0x0a:
{
EndFlag3 = 1;
break;
}
case 0x0c:
{
EndFlag3 = 1;
break;
}
case 0x0d:
{
EndFlag3 = 1;
break;
}
case 0x0e:
{
EndFlag1 = 1;
EndFlag3 = 1;
SYS_sprintf(arg1,"TURN OFF");
sendControlMsg(0x02,arg1,info);
break;
}
}
}
else
{
SET_FAILURE_REASON (status);
}
notify_flag = 0;
}
}
EndFlag3 = 0;
break;
}
case 0x0c:
{
while ( EndFlag4 == 0 )
{
UserPinCmdArg.pin = GPIO0_14_PIN;
UserPinCmdArg.value = LOW;
Gpio_setPinVal(gpio,&UserPinCmdArg);
TSK_sleep(1000);
UserPinCmdArg.pin = GPIO0_14_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
TSK_sleep(1000);
if ( notify_flag == 1 )
{
if (status == SYS_OK)
{
switch (mode)
{
case 0x0a:
{
EndFlag4 = 1;
break;
}
case 0x0b:
{
EndFlag4 = 1;
break;
}
case 0x0d:
{
EndFlag4 = 1;
break;
}
case 0x0e:
{
EndFlag1 = 1;
EndFlag4 = 1;
SYS_sprintf(arg1,"TURN OFF");
sendControlMsg(0x02,arg1,info);
break;
}
}
}
else
{
SET_FAILURE_REASON (status);
}
notify_flag = 0;
}
}
EndFlag4 = 0;
break;
}
case 0x0d:
{
while ( EndFlag5 == 0 )
{
///////////////////////////////////////////////
// Issue 'empty' buffer to the channel.
///////////////////////////////////////////////
status = SIO_issue (inputStream,Audio_In,bufferSize,arg);
if (status == SYS_OK)
{
/////////////////////////////////////////////////
// Reclaim 'filled' buffer from the channel
/////////////////////////////////////////////////
nmadus = SIO_reclaim (inputStream,(Ptr *) &Audio_In,&arg);
receivedSize = nmadus;
}
/////////////////////////////////////////////
// Processing Data
/////////////////////////////////////////////
for ( i=0 ;i<DATA_LEN ; i++ )
{
Audio_Out[i] = 2 * Audio_In[i];
}
///////////////////////////////////////////////
// Issue 'filled' buffer to the channel.
///////////////////////////////////////////////
status = SIO_issue (outputStream,Audio_Out,receivedSize,arg);
if (status == SYS_OK)
{
/////////////////////////////////////////////////
// Reclaim 'empty' buffer from the channel
/////////////////////////////////////////////////
SIO_reclaim (outputStream,(Ptr *)&(Audio_Out),&arg);
}
status = SYS_OK;
if ( notify_flag == 1 )
{
if (status == SYS_OK)
{
switch (mode)
{
case 0x0a:
{
EndFlag5 = 1;
break;
}
case 0x0b:
{
EndFlag5 = 1;
break;
}
case 0x0c:
{
EndFlag5 = 1;
break;
}
case 0x0e:
{
EndFlag1 = 1;
EndFlag5 = 1;
SYS_sprintf(arg1,"TURN OFF");
sendControlMsg(0x02,arg1,info);
break;
}
}
}
else
{
SET_FAILURE_REASON (status);
}
notify_flag = 0;
}
}
EndFlag5 = 0;
break;
}
}
}
UserPinCmdArg.pin = GPIO0_12_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_13_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_14_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
UserPinCmdArg.pin = GPIO0_15_PIN;
UserPinCmdArg.value = HIGH;
Gpio_setPinVal(gpio,&UserPinCmdArg);
TSK_sleep(100);
}
else
{
SET_FAILURE_REASON (status);
}
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FINALIZATION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Int TSKMESSAGE_delete(Void)
{
Int status = SYS_OK;
Int tmpStatus = SYS_OK;
Bool freeStatus = FALSE;
//////////////////////////////
//MSGQ_release
//////////////////////////////
if (info->locatedMsgq != MSGQ_INVALIDMSGQ)
{
status = MSGQ_release(info->locatedMsgq);
if (status != SYS_OK)
{
SET_FAILURE_REASON(status);
}
}
//////////////////////////////
//MSGQ_setErrorHandler
//////////////////////////////
MSGQ_setErrorHandler(MSGQ_INVALIDMSGQ, POOL_INVALIDID);
//////////////////////////////
//MSGQ_close
//////////////////////////////
if (info->localMsgq != MSGQ_INVALIDMSGQ)
{
tmpStatus = MSGQ_close(info->localMsgq);
if ((status == SYS_OK) && (tmpStatus != SYS_OK))
{
status = tmpStatus;
SET_FAILURE_REASON(status);
}
}
//////////////////////////////
//Unregister notification
//////////////////////////////
status = NOTIFY_unregister (ID_GPP,0,5,(FnNotifyCbck) TSKMPLIST_notify,info) ;
if (status != SYS_OK)
{
SET_FAILURE_REASON (status) ;
}
//////////////////////////////
//MEM_free
//////////////////////////////
freeStatus = MEM_free(DSPLINK_SEGID, info, sizeof(TSKMESSAGE_TransferInfo));
if ((status == SYS_OK) && (freeStatus != TRUE))
{
status = SYS_EFREE;
SET_FAILURE_REASON(status);
}
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// NOTIFICATION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static
Void
TSKMPLIST_notify (Uint32 eventNo, Ptr arg, Ptr notifyinfo)
{
(Void) eventNo ;
(Void) notifyinfo ;
(Void) arg ;
notify_flag = 1;
MSGQ_get(info->localMsgq,(MSGQ_Msg*) &msg,SYS_FOREVER);
mode = msg->command;
TSK_sleep(10);
return;
}
Int sendControlMsg( Uint16 cmd,Char *arg1,TSKMESSAGE_TransferInfo* info)
{
Int status = SYS_OK;
//////////////////////////////
//send message
//////////////////////////////
msg->command = cmd;
SYS_sprintf(msg->arg1,arg1);
info->sequenceNumber++;
if (info->sequenceNumber == MSGQ_INTERNALIDSSTART)
{
info->sequenceNumber = 0;
}
MSGQ_setMsgId((MSGQ_Msg) msg, info->sequenceNumber);
MSGQ_setSrcQueue((MSGQ_Msg) msg, info->localMsgq);
status = MSGQ_put(info->locatedMsgq,(MSGQ_Msg) msg);
if (status != SYS_OK)
{
SET_FAILURE_REASON(status);
}
else
{
NOTIFY_notify (ID_GPP,0,5,(Uint32) 0);
}
return status;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
when we run the code, we can see below message :
"ARM :Enter_Command = "
//////////////////////////////////////////////////////////////////////////////////////////////////////////
if i put "a" => dsp do blinking gpio_0_12
i can see the user led 1 on the omapl137 evm start blinking and every thing is ok.
if i put "b" => dsp do blinking gpio_0_13
i can see the user led 2 on the omapl137 evm start blinking and every thing is ok.
if i put "c" => dsp do blinking gpio_0_14
i can see the user led 3 on the omapl137 evm start blinking and every thing is ok.
if i put "d" => arm transfer 256 word to dsp with CHNL function, then dsp do process data and transfer 256 word to arm with SIO function,
i see below errors :
"CHNL_reclaim (CHNL_ID_OUTPUT) failed."
"CHNL_reclaim(CHNL_ID_INPUT) failed."
then arm print receive data that is wrong!!!!!
///////////////////////////////////////////////////////////////////////////////////////////////////////
in my code MSGQ and NOTIFY is ok but i cant transfer data with CHNL. i don't know which is wrong in my code. please help to fix this problem.
Thank you
Regards,
Mahdi
↧
fault in Transfer Data between arm and dsp with CHNL and SIO in dsplink
↧