Hi Marco Coelho,
Because after the callback is enabled, it bypasses some part of the LPSCI IRQHandler logic, so if you installed rx callback, you have to handle the rxBuff and rxSzie in the callback function. and your callback function is just an empty function, so the receiving driver could not get any data from the terminal. Please refer to the following for more details.
void lpsciCom1_RxCallback(uint32_t instance, void * uartState)
{
/* Write your code here ... */
}
void LPSCI_DRV_IRQHandler(uint32_t instance)
{
lpsci_state_t * lpsciState = (lpsci_state_t *)g_lpsciStatePtr[instance];
UART0_Type * base = g_lpsciBase[instance];
/* Exit the ISR if no transfer is happening for this instance. */
if ((!lpsciState->isTxBusy) && (!lpsciState->isRxBusy))
{
return;
}
/* Handle Rx Data Register Full interrupt */
if((UART0_BRD_C2_RIE(base)) && (UART0_BRD_S1_RDRF(base)))
{
/* Get data and put in receive buffer */
LPSCI_HAL_Getchar(base, lpsciState->rxBuff);
/* Invoke callback if there is one */
if (lpsciState->rxCallback != NULL)
{
lpsciState->rxCallback(instance, lpsciState);
}
else
{
++lpsciState->rxBuff;
--lpsciState->rxSize;
/* Check and see if this was the last byte received */
if (lpsciState->rxSize == 0)
{
LPSCI_DRV_CompleteReceiveData(instance);
}
}
}
/* Handle Tx Data Register Empty interrupt */
if((UART0_BRD_C2_TIE(base)) && (UART0_BRD_S1_TDRE(base)))
{
/* Check to see if there are any more bytes to send */
if (lpsciState->txSize)
{
/* Transmit data and update tx size/buff. */
LPSCI_HAL_Putchar(base, *(lpsciState->txBuff));
/* Invoke callback if there is one */
if (lpsciState->txCallback != NULL)
{
/* The callback MUST set the txSize to 0 if the
* transmit is ended.*/
lpsciState->txCallback(instance, lpsciState);
}
else
{
++lpsciState->txBuff;
--lpsciState->txSize;
}
/* Check and see if this was the last byte */
if (lpsciState->txSize == 0)
{
/* Complete the transfer and disable the interrupt */
LPSCI_DRV_CompleteSendData(instance);
}
}
}
/* Handle receive overrun interrupt */
if (LPSCI_HAL_GetStatusFlag(base, kLpsciRxOverrun))
{
/* Clear the flag, OR the rxDataRegFull will not be set any more */
LPSCI_HAL_ClearStatusFlag(base, kLpsciRxOverrun);
}
}
Hope that makes sense,
Have a great day,
Kan
Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------