hello,
i want receive a byte by Serial port,but i can not receive a byte in Lpuart_Uart_Ip_Handler,
the demo is as follows(but it is not i want ,i need reveive a byte in Serial port interruption function)
can you help me?
Std_ReturnType Send_Data(uint8 transChannel, uint8 recvChannel, const uint8* pBuffer, uint32 length)
{
Std_ReturnType T_Uart_Status;
Uart_StatusType Uart_ReceiveStatus = UART_STATUS_TIMEOUT;
Uart_StatusType Uart_TransmitStatus = UART_STATUS_TIMEOUT;
uint32 T_bytesRemaining;
uint32 T_timeout = 0xFFFFFF;
uint8 Rx_Buffer[MSG_LEN];
/* Uart_AsyncReceive transmit data */
T_Uart_Status = Uart_AsyncReceive(recvChannel, Rx_Buffer, length);
if (E_OK != T_Uart_Status)
{
return E_NOT_OK;
}
/* Uart_AsyncSend transmit data */
T_Uart_Status = Uart_AsyncSend(transChannel, pBuffer, length);
if (E_OK != T_Uart_Status)
{
return E_NOT_OK;
}
/* Check for no on-going transmission */
do
{
Uart_TransmitStatus = Uart_GetStatus(transChannel, &T_bytesRemaining, UART_SEND);
} while (UART_STATUS_NO_ERROR != Uart_TransmitStatus && 0 < T_timeout--);
T_timeout = 0xFFFFFF;
do
{
Uart_ReceiveStatus = Uart_GetStatus(recvChannel, &T_bytesRemaining, UART_RECEIVE);
} while (UART_STATUS_NO_ERROR != Uart_ReceiveStatus && 0 < T_timeout--);
if ((UART_STATUS_NO_ERROR != Uart_TransmitStatus) || (UART_STATUS_NO_ERROR != Uart_ReceiveStatus))
{
return E_NOT_OK;
}
return E_OK;
}
/*==================================================================================================
* GLOBAL FUNCTIONS
==================================================================================================*/
/**
* @brief Main function of the example
* @details Initializez the used drivers and uses the Icu
* and Dio drivers to toggle a LED on a push button
*/
int main(void)
{
volatile Std_ReturnType T_Uart_Status1;
volatile Std_ReturnType T_Uart_Status2;
/* Initialize the Mcu driver */
Mcu_Init(NULL_PTR);
Mcu_InitClock(McuClockSettingConfig_0);
#if (MCU_NO_PLL == STD_OFF)
while ( MCU_PLL_LOCKED != Mcu_GetPllStatus() )
{
/* Busy wait until the System PLL is locked */
}
Mcu_DistributePllClock();
#endif
Mcu_SetMode(McuModeSettingConf_0);
/* Initialize Mcl module */
Mcl_Init(NULL_PTR);
/* Initialize all pins using the Port driver */
Port_Init(NULL_PTR);
/* Initialize IRQs */
Platform_Init(NULL_PTR);
/* Initializes an UART driver*/
Uart_Init(NULL_PTR);
T_Uart_Status2 = Send_Data(UART_LPUART_INTERNAL_CHANNEL, UART_LPUART_INTERNAL_CHANNEL, (const uint8 *)WELCOME_MSG_2, strlen(WELCOME_MSG_2));
Uart_Deinit();
Mcl_DeInit();
Exit_Example((T_Uart_Status1 == E_OK) && (T_Uart_Status2 == E_OK));
return (0U);
}