MPC5748g-Linflexd_UART_drv_installRXcallback

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5748g-Linflexd_UART_drv_installRXcallback

Jump to solution
1,713 Views
kalai
Contributor I

HI,

 

   i try to Run  LINFLEXD_UART_DRV_InstallTxCallback function .

 

 

i run below code i put breakpoint in interrupt but its not hitting while send the data.so please  tell the issue

 


/* User includes (#include below this line is not maintained by Processor Expert) */
#include <string.h>
/* Message sent through UART interface */
#define msg "\nHello!\n"
#define msg1 "\nHello World UART2!\n\r"
/* Length of the message to be received from the console */
#define RX_MSG_LEN 128U
uint8_t rxBuff[RX_MSG_LEN + 1];

void rx_handler(void *driverstate,uart_event_t event,void *userdata)
{
linflexd_uart_state_t *uart_state = (linflexd_uart_state_t*)(driverstate);
uint8_t *data = (uint8_t*)userdata;


}

int main(void)
{

rxBuff[RX_MSG_LEN] = 0;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/
/* Initialize and configure clocks
* - Setup system clocks, dividers
* - see clock manager component for more details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
/* Initialize pins */
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
/* Initialize LINFlexD module for UART usage */
LINFLEXD_UART_DRV_Init(INST_LINFLEXD_UART1, &linflexd_uart1_State, &linflexd_uart1_InitConfig0);
/* Send the greeting message to console */
// LINFLEXD_UART_DRV_SendData(INST_LINFLEXD_UART1, (uint8_t*)msg, strlen(msg));
// LINFLEXD_UART_DRV_Init(INST_LINFLEXD_UART2, &linflexd_uart2_State, &linflexd_uart2_InitConfig0);
//// linflexd_uart_state_t * uartState;

// uartState = (linflexd_uart_state_t *)s_uartLINFlexDStatePtr[instance];
LINFLEXD_UART_DRV_InstallRxCallback(INST_LINFLEXD_UART1,rx_handler,NULL);
/* Infinite loop */
for( ;; )
{
// LINFLEXD_UART_DRV_SendData(INST_LINFLEXD_UART2,(uint8_t*)msg1, strlen(msg1));
// LINFLEXD_UART_DRV_SendData(INST_LINFLEXD_UART1, (uint8_t*)msg, strlen(msg));
/* Get the message sent by user from the console, using blocking method, each 300 ms */
//LINFLEXD_UART_DRV_ReceiveDataBlocking(INST_LINFLEXD_UART1, rxBuff, RX_MSG_LEN, 300U);
// LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART1, rxBuff, RX_MSG_LEN, 1000U);
/* If the user typed "Hello", reply with the "Hello world!" message again */


if(strcmp((char*)rxBuff, "Hello") == 0)
{
// LINFLEXD_UART_DRV_SendData(INST_LINFLEXD_UART1, "message right\n\r",15);
LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART1, (uint8_t*)msg1, strlen(msg1), 100U);
//LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART1, "message right\n\r", 15, 100U);
/* Clear the buffer */
memset(rxBuff, 0 , RX_MSG_LEN);
}
/* else
{
LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART1, "message wrong\n\r", 15, 100U);
//LINFLEXD_UART_DRV_SendData(INST_LINFLEXD_UART1, "message wrong\n\r", 15);
}*/
}

#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END main */
/*!
** @}

 thanks

kalai

0 Kudos
1 Solution
1,671 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

try attached code

BR, Petr

View solution in original post

0 Kudos
4 Replies
1,688 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

what if you will use LINFLEXD_UART_DRV_InstallTxCallback for send function, instead of LINFLEXD_UART_DRV_InstallRxCallback you have?

from driver docummentation...
The driver provides callback notifications for asynchronous transfers. LINFLEXD_UART_DRV_InstallTxCallback function can be used for installing a callback routine to be called when the transmission is finished. In interrupts mode, the tx callback is called twice:
- first when the tx fifo becomes empty (no more data to be transmitted) - at this point the application can call LINFLEXD_UART_DRV_SetTxBuffer inside the callback in order to provide more data, resulting in a continuous transmission;
- if there is no more data to be transmitted, the callback is called again when the transmission is complete (all the bytes have been shifted out on the line).
The event parameter in the callback signature differentiates these two calls - the values are UART_EVENT_TX_EMPTY and UART_EVENT_END_TRANSFER, respectively.

BR, Petr

0 Kudos
1,686 Views
kalai
Contributor I

HI,

i am trying to use receive callback using  Linflexd_UART_drv_installRXcallback

is there any demo code for Linflexd_UART_drv_installRXcallback

i try to debug by sending data through terminal but it not entered into this function void rx_call(uart_event_t event)


#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
#include "dmaController1.h"
#include "linflexd_uart1.h"
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include <string.h>
/* Message sent through UART interface */
#define msg "\nHello World!\n"
#define RX_MSG_LEN 5U
/* Length of the message to be received from the console */
uint8_t rxBuff[RX_MSG_LEN + 1];

/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
void rx_call(uart_event_t event)
{
switch(event)
{
case UART_EVENT_RX_FULL:
LINFLEXD_UART_DRV_SetRxBuffer(INST_LINFLEXD_UART1, rxBuff, RX_MSG_LEN);
LINFLEXD_UART_DRV_SendDataBlocking(INST_LINFLEXD_UART1, "try data", 8, 1000U);
break;


}

}
int main(void)
{
/* Write your local variable definition here */
/* Buffer to store the received message */

/* Last value should be 0 (string terminator); only 5 characters will be read from console */
rxBuff[RX_MSG_LEN] = 0;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif

CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
/* Initialize pins */
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
/* Initialize LINFlexD module for UART usage */
LINFLEXD_UART_DRV_Init(INST_LINFLEXD_UART1, &linflexd_uart1_State, &linflexd_uart1_InitConfig0);
/* Send the greeting message to console */
LINFLEXD_UART_DRV_InstallRxCallback(INST_LINFLEXD_UART1, rx_call, NULL);
LINFLEXD_UART_DRV_SendData(INST_LINFLEXD_UART1, (uint8_t*)msg, strlen(msg));
/* Infinite loop */
for( ;; )
{


}

#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif

for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

0 Kudos
1,672 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

try attached code

BR, Petr

0 Kudos
1,655 Views
kalai
Contributor I

hi,

 

 thanks its working..

 

 

 

thanks

kalai

0 Kudos