embeddeduartnxp-microcontrollerthreadx

How to implement ThreadX's ppp_byte_send for NXP MIMXRT1040-EVK


I'm working on getting PPPoS working in ThreadX on an MIMXRT1040-EVK. However, I'm facing an obstacle related to the sending of PPP data over UART.

In ThreadX's nx_ppp_create function one of the parameters is ppp_byte_send, which should send 1 byte over the serial interface to the modem (Quectel EG800Q). To do this I use LPUART_WriteBlocking from NXP's SDK. However, the modem doesn't respond when using this mechanism. Here's the implementation:

void ppp_byte_send(UCHAR byte)
{
    LPUART_WriteBlocking(MODEM_REG_BASE, byte, 1);
}

I've determined the sequence of bytes being sent in the first message, and when sending these in a single call to LPUART_WriteBlocking it works:

void ppp_byte_send(UCHAR byte)
{
    uint8_t cmd[] = { 0x7E, 0xFF, 0x7D, 0x23, 0xC0, 0x21, 0x7D, 0x21, 0xC3, 0x7D, 0x20, 0x7D, 0x28, 0x7D, 0x21, 0x7D, 0x24, 0x7D, 0x25, 0xDC, 0xF1, 0xB7, 0x7E };
    LPUART_WriteBlocking(MODEM_REG_BASE, cmd, sizeof(cmd));
}

I also tried sending the bytes listed above one by one in a loop, but that also doesn't work.

I'm wondering if there's a different way I should go about implementing the ppp_byte_send function that ThreadX requires? From my testing it seems that sending byte by byte like this is too slow for the modem.

For reference:

Thanks


Solution

  • I'll blame this on it being Friday afternoon. LPUART_WriteBlocking takes in a pointer to the data, not a single byte, so it should be:

    void ppp_byte_send(UCHAR byte)
    {
        LPUART_WriteBlocking(MODEM_REG_BASE, &byte, 1);
    }
    

    Now it works...!