Hi, I am working on C6748 UART using EDMA right now. I am using GIO_sunmit asynchronous call with a callback function. It works with Read. When I write to UART, I want to use Synchronous call with callbak function = NULL. But the GIO_submit call hongon there forever!
void
UART_RxCallback()
{
SEM_post(&SEM_UART1_DataReady);
}
void
cUART::UART_init()
{
EDMA3_DRV_Result edmaResult = 0;
if (NULL == hEdma[0])
{
edmaResult = edma3init();
if (edmaResult != EDMA3_DRV_SOK)
{
/* Report EDMA Error */
LOG_printf(&trace,"\r\nEDMA3 : edma3init() failed\r\n");
}
}
Uart_init();
uartParams = Uart_PARAMS;
uartParams.hwiNumber = 9;
uartParams.opMode = Uart_OpMode_DMAINTERRUPT;
uartParams.rxThreshold = Uart_RxTrigLvl_1;
uartParams.softTxFifoThreshold = 1;
RxCAllbackFunction.fxn = (GIO_TappCallback)UART_RxCallback;
RxCAllbackFunction.arg = NULL;
}
int
cUART::UART_GIO_Init(Void)
{
GIO_Attrs gioAttrs = GIO_ATTRS;
Int32 echoTskStatus = 0;
Uart_ChanParams chanParams = {NULL};
int status = 0;
/* Initialize channel attributes. */
gioAttrs.nPackets = 2;
gioAttrs.timeout = SYS_FOREVER;
chanParams.hEdma = hEdma[0];
/* Initialize pinmux and evm related configurations */
configureUart();
/* Initialize UART Currently is been used to display a string */
hUart_OUT = GIO_create("/UART0",IOM_OUTPUT,NULL,&chanParams,&gioAttrs);
hUart_IN = GIO_create("/UART0",IOM_INPUT,&echoTskStatus,&chanParams,&gioAttrs);
if ((NULL == hUart_IN) || (NULL == hUart_OUT))
{
LOG_printf(&trace, "ERROR: Initialization of UART failed\n");
return 0;
}
//flush the Inout/Output buffer
status = GIO_flush(hUart_IN);
if(status != IOM_COMPLETED)
return 0;
status = GIO_flush(hUart_OUT);
if(status != IOM_COMPLETED)
return 0;
return 1;
}
int
cUART::UART_Read(void * pData, int iLen)
{
Ptr buf = NULL;
Int status = 0;
size_t len = iLen; //read one char everytime
buf = Uart_RxBuffer;
//use async read
status = GIO_submit(hUart_IN,IOM_READ,buf,&len,&RxCAllbackFunction);
//waiting for data read
SEM_pend(&SEM_UART1_DataReady, SYS_FOREVER);
memcpy(pData,buf,iLen);
return status;
}
int
cUART::UART_Write(void *pData, int iLen)
{
Ptr buf = NULL;
Int status = 0;
size_t len = iLen;
//Copy to start string to Cache aligned buffer */
memcpy(Uart_TxBuffer,pData,len);
buf = Uart_TxBuffer;
//use sync to write data
status = GIO_submit(hUart_OUT,IOM_WRITE, buf, &len, NULL);
if(!((status == IOM_COMPLETED)||(status == IOM_PENDING)))
{
LOG_printf(&trace, "\r\n Error from GIO_write for UART\n");
}
return status;
}
I try to change the Write function using asynchronous way. But I allways get a IOM_PENDING return.
Could anyone help me out? Thanks, Yi