RTD版本:S32G 4.0 开发板 RDB3
1.init
uint32 varRemainingBytes;
volatile Uart_StatusType Uart_Status;
volatile Std_ReturnType Std_Uart_Status;
uint8 Tx_Buffer[MSG_LEN];
memset(Rx_Buffer, 0 , MSG_LEN);
memset(Tx_Buffer, 0 , MSG_LEN);
/* Initializes an UART driver*/
Uart_Init(&Uart_xConfig_VS_0);
/* Uart_AsyncSend transmit data */
(void)Uart_AsyncSend(UART_CHANNEL, (const uint8 *)WELCOME_MSG, strlen(WELCOME_MSG));
/* Wait for Uart successfully send data */
while(Uart_GetStatus(UART_CHANNEL, &varRemainingBytes, UART_SEND) == UART_STATUS_OPERATION_ONGOING);
// (void)Uart_AsyncReceive(UART_CHANNEL, Rx_Buffer, strlen(EXPECT_RX_MSG));
//(void)Uart_AsyncReceive(UART_CHANNEL, &Rx_int_Buffer, 1);
/* Wait for transfer to be completed */
// while(Rx_int_len<6);
2. callback
void Linflexd_Uart_Callback(uint8 Channel, Uart_EventType Event)
{
switch(Event)
{
case LINFLEXD_UART_IP_EVENT_RX_FULL:// Rx buffer is full.
Rx_Buffer[Rx_int_len] = Rx_int_Buffer;
Uart_SetBuffer(Channel, &Rx_int_Buffer, 1, UART_RECEIVE);
Rx_int_len++;
break;
case LINFLEXD_UART_IP_EVENT_TX_EMPTY: //Tx buffer is empty.
break;
case LINFLEXD_UART_IP_EVENT_END_TRANSFER: //The current transfer is ending.
break;
case LINFLEXD_UART_IP_EVENT_ERROR: //An error occured during transfer.
Uart_AsyncReceive(UART_CHANNEL, &Rx_int_Buffer, 1);
break;
default:
break;
}
}
3. Let's say I call
Uart_AsyncReceive(UART_CHANNEL, Rx_Buffer, 1);
I want to call setbuff inside the interrupt callback function after receiving bytes one by one to set to continue receiving,However, the UART SEND will fail
4.The reason is that the Uart_AsyncSend function has a check to see if receive is running
if ((UART_STATUS_OPERATION_ONGOING == ReceiveStatus) || \
(UART_STATUS_OPERATION_ONGOING == TransmitStatus))
static Std_ReturnType Uart_StartAsyncSend(uint8 CoreId, uint8 Channel, const uint8* Buffer, uint32 BufferSize)
{
Std_ReturnType TempReturn = E_NOT_OK;
Uart_StatusType ReceiveStatus;
Uart_StatusType TransmitStatus;
#if (UART_MULTICORE_SUPPORT == STD_ON)
if (CoreId != Uart_apConfig[CoreId]->PartitionCoreId)
{
#if (UART_DEV_ERROR_DETECT == STD_ON)
/* Invalid CoreId */
(void)Det_ReportError((uint16)UART_MODULE_ID,
(uint8)0,
(uint8)UART_ASYNCSEND_ID,
(uint8)UART_E_PARAM_CONFIG);
#endif /* (UART_DEV_ERROR_DETECT == STD_ON) */
}
else
{
if (NULL_PTR == Uart_apConfig[CoreId]->Configs[Channel])
{
#if (UART_DEV_ERROR_DETECT == STD_ON)
(void)Det_ReportError((uint16)UART_MODULE_ID,
(uint8)0,
(uint8)UART_ASYNCSEND_ID,
(uint8)UART_E_INVALID_CHANNEL);
#endif /* (UART_DEV_ERROR_DETECT == STD_ON) */
}
else
{
#endif /* (UART_MULTICORE_SUPPORT == STD_ON) */
ReceiveStatus = Uart_Ipw_GetReceiveStatus(Channel, NULL_PTR);
TransmitStatus = Uart_Ipw_GetTransmitStatus(Channel, NULL_PTR);
if ((UART_STATUS_OPERATION_ONGOING == ReceiveStatus) || \
(UART_STATUS_OPERATION_ONGOING == TransmitStatus))
{
#if (UART_DEV_ERROR_DETECT == STD_ON)
(void)Det_ReportError((uint16)UART_MODULE_ID,
(uint8)0,
(uint8)UART_ASYNCSEND_ID,
(uint8)UART_E_CHANNEL_BUSY);
#endif /* (UART_DEV_ERROR_DETECT == STD_ON) */
}
else
{
TempReturn = Uart_Ipw_AsyncSend(Channel,
Buffer,
BufferSize);
(void)CoreId;
}
#if (UART_MULTICORE_SUPPORT == STD_ON)
}
}
#endif /* (UART_MULTICORE_SUPPORT == STD_ON) */
return TempReturn;
So this is my use of the wrong or the driver problem, because the previous call IP driver is supported by this way, but the use of MCAL interface has this limitation