This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3358: UART basic example

Part Number: AM3358

in UART_BasicExample_bbbAM335x_armTestProject's function UART_test_trglvl(...)

there are the code

for ( i = -1; i < 2; i++)

{

uart = UART_open(uartTestInstance, &uartParams);

if (uart == NULL)

{

goto Err;

}

if (UART_test_trglvl_xfer(uart, dmaMode, (uint32_t)(uintptr_t)(txTrigLvl + i)) == false)

{

goto Err;

}

if (uart)

{

UART_close(uart);

uart = NULL;

}

uart = UART_open(uartTestInstance, &uartParams);

if (uart == NULL)

{

goto Err;

}

if (UART_test_trglvl_xfer(uart, dmaMode, (uint32_t)(uintptr_t)(rxTrigLvl + i)) == false)

{

goto Err;

}

if (uart)

{

UART_close(uart);

uart = NULL;

}

}

My question is why we need to callopen and close twice? Thanks

  • Hi Anping,

    1st open and close is for UART transmit operation - txTrigLvl

    2nd open and close is for UART receive operation - rxTrigLvl

    Seems that &uartParams are different for TX and RX modes (for example we have Write and Read modes). 1st open is called with &uartParams for transmit/write, 2nd open is called with &uartParams for receive/read.

    pdk_am335x_1_0_15/packages/ti/drv/uart/UART.h

    Regards,
    Pavel

  • Hi Pavel

         uartTestInstance is same. uartParams doesn't change. I don't see why it need to UART_close and UART_open again. Thanks