AnsweredAssumed Answered

S32K Flexio_Uart freertos

Question asked by liyun liyun on Dec 9, 2019

Hello:

  I use FLEXIO to simulate UART serial port,  NXP support demo is ok, But I cann’t send and receive anything in free_rtos system , Specify system is dead when runing FLEXIO_UART_DRV_SendDataBlocking,Hope give flexio_uart demo about freertos .

 

 

#if 1
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
#include "flexio_uart_TX.h"
#include "osif1.h"
#include "flexio_uart_RX.h"
#include "dmaController1.h"
#if CPU_INIT_CONFIG
#include "Init_Config.h"
#endif

#include <stdint.h>
#include <stdbool.h>
#include <string.h>

#define WELCOME_MSG ("Hello World\r\n")


volatile bool g_dataReceived;

uint8_t rxBuffer;
uint8_t txBuffer;
flexio_device_state_t flexIODeviceState;
flexio_uart_state_t uartStateTX;
flexio_uart_state_t uartStateRX;

typedef struct {
uint8_t Cnt;
uint8_t Buff[50]; //
}STt_FlexUart;

STt_FlexUart TstFlexUart;


void flexio_uart_RX_Callback0(void *driverState, uart_event_t event, void *userData)
{
(void)userData;
(void)driverState;

if (event == UART_EVENT_RX_FULL)
{
/* Copy data received into the TX buffer */
txBuffer = rxBuffer;
/* Send received data */
FLEXIO_UART_DRV_SendData(&uartStateTX, &txBuffer, 1U);
/* Set new RX buffer */
FLEXIO_UART_DRV_SetRxBuffer(&uartStateRX, &rxBuffer, 1UL);
}
}

void Tst_FlexioUart(void)
{

CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);

/* Initialize pins
* - Init FlexIO UART RX and TX pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

/* Init the FLEXIO device */
FLEXIO_DRV_InitDevice(INST_FLEXIO_UART_TX, &flexIODeviceState);

/* Init the FlexIO UART driver
* - 115200 baudrate
* - TX only
* - 8 bit per frame
* - Interrupt based
*/
FLEXIO_UART_DRV_Init(INST_FLEXIO_UART_TX, &flexio_uart_TX_Config0, &uartStateTX);

/* Init the FlexIO UART driver
* - 115200 baudrate
* - RX only
* - 8 bit per frame
* - Interrupt based
*/
FLEXIO_UART_DRV_Init(INST_FLEXIO_UART_RX, &flexio_uart_RX_Config0, &uartStateRX);

FLEXIO_UART_DRV_SendDataBlocking(&uartStateTX, (uint8_t * )WELCOME_MSG, strlen(WELCOME_MSG), 100);

FLEXIO_UART_DRV_ReceiveData(&uartStateRX, &rxBuffer, 1U);
}
#endif

#define oproad "deviloping "
void G4StdCommTXTask( void *pvParameters)
{
(void)pvParameters;
static u8 AccumulatTim = 0;
Type_stMSG MPUUartTxMessage;
Type_Universal_Return Result = RSLT_NG;
MPUUartTxMessage.Receiver = TASK_ID_MPU_UART_TX;
while(1)
{
Result = MsgQueueMgr_ReceiveMessage(&MPUUartTxMessage, 200);
if(Result == RSLT_OK)
{
if(1 == MPUUartTxMessage.What)
{
Tst_FlexioUart();
}
else if(2 == MPUUartTxMessage.What)
{
FLEXIO_UART_DRV_SendDataBlocking(&uartStateTX, (uint8_t * )oproad, 6, 100);
}
else if(3 == MPUUartTxMessage.What)
{
}
}
else if(Result == RSLT_TOUT)
{
}
}
}

Outcomes