1.
it can't write immediately to shared ram.
code list delow:
static bool server_upp_data_transfer(Server *server) { if(server->ad_started == false) return true;
while (ListMP_empty(server->list_free)) /* wait */
Task_sleep(10000);
DataNode *node = (DataNode *)ListMP_getTail(server->list_free); /* get free node */
int *data = (int *)SharedRegion_getPtr(node->SR_buffer);
server->transposeParA.WindowAddress = (unsigned int *)data; /* set taget */
server->transposeParA.LineCount = node->buffer_height;
server->transposeParA.ByteCount = node->buffer_pitch; server->transposeParA.LineOffsetAddress = node->buffer_pitch;
upp_error_count = 0;
upp_dmai_int_cut = 0;
/* fill in data */
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHI, &server->transposeParA);
/* wait */
while (upp_dmai_int_cut < 1 && upp_error_count == 0);
if (upp_error_count != 0) {
LOG_ERROR("data mismatch in buffers");
LOG_ERROR("upp_error_count=%d",upp_error_count);
}
/* make data node in busy list */
ListMP_putHead(server->list_busy, (ListMP_Elem *)node);
return true;
}
………………………………………………
2.
IHeap_Handle heap_node = (IHeap_Handle)SharedRegion_getHeap(SYS_CFG_SR_ID_LIST_HEAP);
IHeap_Handle heap_data = (IHeap_Handle)SharedRegion_getHeap(SYS_CFG_SR_ID_UPP_HEAP);
DataNode *nodes[SYS_CFG_LIST_NODES];
int i;
for (i = 0; i < SYS_CFG_LIST_NODES; i++) {
DataNode *node = (DataNode *)Memory_alloc(heap_node, sizeof(DataNode), 0, NULL);
node->SR_buffer = SharedRegion_getSRPtr(data, SYS_CFG_SR_ID_UPP_HEAP);
node->size = SR_BUFFER_SIZE;
node->buffer_pitch = BUFFER_PITCH;
node->buffer_height = BUFFER_HEIGHT;
}
ListMP_Params params_list;
ListMP_Params_init(¶ms_list);
params_list.name = SYS_CFG_LIST_FREE;
params_list.regionId = SYS_CFG_SR_ID_LIST_HEAP;
ListMP_Handle list_free = ListMP_create(¶ms_list);
for (i = 0; i < SYS_CFG_LIST_NODES; i++) /* init free list */
ListMP_putHead(list_free, (ListMP_Elem *)nodes[i]);
params_list.name = SYS_CFG_LIST_BUSY;
ListMP_Handle list_busy = ListMP_create(¶ms_list);
2)、arm等待数据块有效,并写入disk:
while (! quit) { while (ListMP_empty(list_busy) && ! quit) // wait data usleep(1000);
continue;
DataNode *node = (DataNode *)ListMP_getTail(list_busy);
uint16_t *data = (uint16_t *)SharedRegion_getPtr(node->SR_buffer);
LOG_DEBUG("data[0]=%x", data[0]);
file_saver_save(file_saver, (void *)data, node->size);
ListMP_putHead(list_free, (ListMP_Elem *)node);
}
while (ListMP_empty(server->list_free)) /* wait */
Task_sleep(10000);
int *data = (int *)SharedRegion_getPtr(node->SR_buffer);
server->transposeParA.LineCount = node->buffer_height;
server->transposeParA.ByteCount = node->buffer_pitch; server->transposeParA.LineOffsetAddress = node->buffer_pitch;
upp_dmai_int_cut = 0;
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHI, &server->transposeParA);
while (upp_dmai_int_cut < 1 && upp_error_count == 0);
LOG_ERROR("data mismatch in buffers");
LOG_ERROR("upp_error_count=%d",upp_error_count);
}
ListMP_putHead(server->list_busy, (ListMP_Elem *)node);
}
不知什么原因?
Tony Tang:
代码看不大懂,但有几个疑问:
#1. 你提到分成几块,那么应该会有几个uPP DMA的配置,没看到检测pending位更新uPP_DMA参数过程。
#2。 不明白为什么要task sleep 1000,如果外部在连续的发数据,这时侯task在sleep,upp_DMA参数没有配置,数据谁来接收?
#3。中断ISR呢?如果实现的?是在ISR里更新uPP DMA参数的吗?
jack zhao3:
回复 Tony Tang:
void uPPIsr(void){ unsigned int intr_dmai_status, intr_dmaq_status;
// 取?? DMA ?卸?状态 intr_dmai_status = uPPIntStatus(SOC_UPP_0_REGS, uPP_DMA_CHI); intr_dmaq_status = uPPIntStatus(SOC_UPP_0_REGS, uPP_DMA_CHQ);
while(intr_dmai_status != 0 || intr_dmaq_status != 0) { if (intr_dmai_status & uPP_INT_EOL) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHI, uPP_INT_EOL); }
if (intr_dmai_status & uPP_INT_EOW) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHI, uPP_INT_EOW); upp_dmai_int_cut++; }
if (intr_dmai_status & uPP_INT_ERR) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHI, uPP_INT_ERR); upp_error_count++; }
if (intr_dmai_status & uPP_INT_UOR) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHI, uPP_INT_UOR); upp_error_count++; }
if (intr_dmai_status & uPP_INT_DPE) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHI, uPP_INT_DPE); upp_error_count++; }
if (intr_dmaq_status & uPP_INT_EOL) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHQ, uPP_INT_EOL); }
if (intr_dmaq_status & uPP_INT_EOW) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHQ, uPP_INT_EOW); upp_dmaq_int_cut++; }
if (intr_dmaq_status & uPP_INT_ERR) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHQ, uPP_INT_ERR); upp_error_count++; }
if (intr_dmaq_status & uPP_INT_UOR) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHQ, uPP_INT_UOR); upp_error_count++; }
if (intr_dmaq_status & uPP_INT_DPE) { uPPIntClear(SOC_UPP_0_REGS, uPP_DMA_CHQ, uPP_INT_DPE); upp_error_count++; }
// uPP ?卸辖??????录?????为同一?卸?源 // ?卸??欠?全?????楸???????? intr_dmai_status = uPPIntStatus(SOC_UPP_0_REGS, uPP_DMA_CHI); intr_dmaq_status = uPPIntStatus(SOC_UPP_0_REGS, uPP_DMA_CHQ); }
// 通知 CPU uPP ?卸洗????????员??????录????圆??? uPPEndOfInt(SOC_UPP_0_REGS);}