librpipUartConfigWrite

uint32_t librpipUartConfigWrite(uint32_t id, uint32_t baud, uint32_t csize, uint32_t parity, uint32_t stop, uint32_t mode);

Description

Sets the configuration of a UART.

Parameters

  • uint32_t id
    The UART to configure. The UART needs to have been detected during the librpipInit().
  • uint32_t baud
    The baud rate of the UART. It should be one of the LIBRPIP_UART_BAUD_* constants or its integer equivalent.
  • uint32_t csize
    The word size of the UART. It should be one of the LIBRPIP_UART_SIZE_* constants or its integer equivalent. Note that UART1 only supports a 7 or 8 word size.
  • uint32_t parity
    The parity of the UART. It should be one of the LIBRPIP_UART_PARITY_* constants or its integer equivalent. Note that UART1 does not support parity.
  • uint32_t stop
    The stop bits of the UART. It should be one of the LIBRPIP_UART_STOPBITS_* constants or its integer equivalent. Not that UART1 only supports 1 stop bit.
  • uint32_t mode
    The mode (ascii/binary) of the UART. In ascii mode some characters are translated so that they display properly on a console. Binary mode makes no changes to characters. It should be one of the LIBRPIP_UART_MODE_* constants.

Returns

0 on failure or 1 on success.

Example

Set the configuration of UART0 to 115.2k baud 8n1 using constants and the integer equivalent:

uint32_t feature_set, baud, csize, parity, stop, mode;
feature_set = librpipInit(LIBRPIP_BOARD_DETECT, LIBRPIP_FLAG_DEBUG_ON, 0);
if(feature_set & LIBRPIP_FEATURE_UART0) { 
        librpipUartConfigWrite(0, LIBRPIP_UART_BAUD_115200, 
                                  LIBRPIP_UART_SIZE_8, 
                                  LIBRPIP_UART_PARITY_OFF, 
                                  LIBRPIP_UART_STOPBITS_1, 
                                  LIBRPIP_UART_MODE_ASCII);
        librpipUartConfigWrite(0, 115200, 8, 0, 1, LIBRPIP_UART_MODE_ASCII);
}