How do I  connect a fsl_uart KSDK component in to the MQX IO layer?

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

How do I  connect a fsl_uart KSDK component in to the MQX IO layer?

1,191 Views
intractablesubt
Contributor III

I have instantiated a fsl_uart component in my FRDM-K64F project using MQX_KSDK_1.0.0 with PE. I am initializing it in a task since the "Auto Initialization" selection doesn't work (see MQX_KSDK_1.0.0 with PE and fsl_uart auto initialization). I would like to hook it in to the MQX IO layer so that it can be accessed using POSIX calls. Can anyone give an example for doing this?

Labels (1)
0 Kudos
2 Replies

627 Views
intractablesubt
Contributor III

I have an answer that seems to work illustrated in the following code snippet:

  const NIO_SERIAL_INIT_DATA_STRUCT _bsp_nserial3_init =

  {

          .UART_INSTANCE       = FSL_UARTCOM3,

          .BAUDRATE            = 115228,

          .PARITY_MODE         = kUartParityDisabled,

          .STOPBIT_COUNT       = kUartOneStopBit,

          .BITCOUNT_PERCHAR    = kUart8BitsPerChar,

          .RXTX_PRIOR          = 4,

  };

  int fd;

  char resp[10];

  char *resp_ptr;

  int nbytes;

  _nio_dev_install("nser3:", &nio_serial_dev_fn, (void*) &_bsp_nserial3_init);

  fd = open("nser3:", O_RDWR);

  write(fd, "AT\r", 3);

  resp_ptr = resp;

  while ((nbytes = read(fd, resp_ptr, resp + sizeof(resp) - resp_ptr - 1)) > 0) {

   resp_ptr += nbytes;

   if (resp_ptr[-1] == '\n' || resp_ptr[-1] == '\n') {

   break;

   }

  }

  resp_ptr = '\0';

  close(fd);

  printf("%s: Modem says %s\n", __FUNCTION__, resp);

0 Kudos

627 Views
danielchen
NXP TechSupport
NXP TechSupport

thanks for your sharing

0 Kudos