IPC模板用的是messageQ,实现双核通信,就是core0接收外部中断,然后通知core1处理数据,处理完后给core0一个通知;主要流程是这样的:
1.core0初始化配置,建立任务task0,接受外部中断,然后MessageQ_put(),给core1中断;
2.core1运行任务task1,一直MessageQ_get(),等到中断后,数据处理完成,然后再MessageQ_put()给core0一个中断;
初始化函数:
Void tsk0_func(UArg arg0, UArg arg1)
{
if (MultiProc_self() == 0) {
/*
* Create the heap that will be used to allocate messages.
*/
HeapBufMP_Params_init(&heapBufParams);
heapBufParams.regionId = 0;
heapBufParams.name = HEAP_NAME;
heapBufParams.numBlocks = 4;
heapBufParams.blockSize = sizeof(MessageQ_MsgHeader);
heapHandle = HeapBufMP_create(&heapBufParams);
if (heapHandle == NULL) {
System_abort("HeapBufMP_create failed\n" );
}
}
else {
/* Open the heap created by the other processor. Loop until opened. */
do {
status = HeapBufMP_open(HEAP_NAME, &heapHandle);
/*
* Sleep for 1 clock tick to avoid inundating remote processor
* with interrupts if open failed
*/
if (status < 0) {
Task_sleep(1);
}
} while (status < 0);
}
/* Register this heap with MessageQ */
MessageQ_registerHeap((IHeap_Handle)heapHandle, HEAPID);
/* Create the local message queue */
messageQ = MessageQ_create(localQueueName, NULL);
if (messageQ == NULL) {
System_abort("MessageQ_create failed\n" );
}
/* Open the remote message queue. Spin until it is ready. */
do {
status = MessageQ_open(nextQueueName, &remoteQueueId);
/*
* Sleep for 1 clock tick to avoid inundating remote processor
* with interrupts if open failed
*/
if (status < 0) {
Task_sleep(1);
}
} while (status < 0);
/* Allocate a message to be ping-ponged around the processors */
msg = MessageQ_alloc(HEAPID, sizeof(MessageQ_MsgHeader));
if (msg == NULL) {
System_abort("MessageQ_alloc failed\n" );
}
}
在开发板上运行的时候,第一个中断能够执行core0->core1->core0,但是第二个开始就出现问题,具体明天再贴出来(数据在公司),
但是我觉得应该和IPC的初始化有关系,大虾帮我看下,初始化哪里不正确了?谢谢