Low-Level

group group_scb_uart_low_level_functions

Functions

__STATIC_INLINE uint32_t Cy_SCB_UART_Put (CySCB_Type *base, uint32_t data)

Places a single data element in the UART TX FIFO.

This function does not block and returns how many data elements were placed in the TX FIFO.

Return

The number of data elements placed in the TX FIFO: 0 or 1.

Parameters
  • base: The pointer to the UART SCB instance.

  • data: Data to put in the TX FIFO. The element size is defined by the data type, which depends on the configured data width.

__STATIC_INLINE uint32_t Cy_SCB_UART_PutArray (CySCB_Type *base, void *buffer, uint32_t size)

Places an array of data in the UART TX FIFO.

This function does not block. It returns how many data elements were placed in the TX FIFO.

Return

The number of data elements placed in the TX FIFO.

Parameters
  • base: The pointer to the UART SCB instance.

  • buffer: The pointer to data to place in the TX FIFO. The element size is defined by the data type, which depends on the configured TX data width.

  • size: The number of data elements to TX.

__STATIC_INLINE void Cy_SCB_UART_PutArrayBlocking (CySCB_Type *base, void *buffer, uint32_t size)

Places an array of data in the UART TX FIFO.

This function blocks until the number of data elements specified by the size is placed in the TX FIFO.

Parameters
  • base: The pointer to the UART SCB instance.

  • buffer: The pointer to data to place in the TX FIFO. The element size is defined by the data type, which depends on the configured data width.

  • size: The number of data elements to write into the TX FIFO.

__STATIC_INLINE void Cy_SCB_UART_PutString (CySCB_Type *base, char_t const string[])

Places a NULL terminated string in the UART TX FIFO.

This function blocks until the entire string is placed in the TX FIFO.

Parameters
  • base: The pointer to the UART SCB instance.

  • string: The pointer to the null terminated string array.

void Cy_SCB_UART_SendBreakBlocking(CySCB_Type *base, uint32_t breakWidth)

Sends a break condition (logic low) of specified width on UART TX line.

Blocks until break is completed. Only call this function when UART TX FIFO and shifter are empty.

note

Before sending break all UART TX interrupt sources are disabled. The state of UART TX interrupt sources is restored before function returns.

Side Effects

If this function is called while there is data in the TX FIFO or shifter that data will be shifted out in packets the size of breakWidth.

Parameters
  • base: The pointer to the UART SCB instance.

  • breakWidth: Width of break condition. Valid range is the TX data width (4 to 16 bits)

__STATIC_INLINE uint32_t Cy_SCB_UART_Get (CySCB_Type const *base)

Reads a single data element from the UART RX FIFO.

This function does not check whether the RX FIFO has data before reading it. If the RX FIFO is empty, the function returns CY_SCB_UART_RX_NO_DATA.

Return

Data from the RX FIFO. The data element size is defined by the configured data width.

Parameters
  • base: The pointer to the UART SCB instance.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetArray (CySCB_Type const *base, void *buffer, uint32_t size)

Reads an array of data out of the UART RX FIFO.

This function does not block. It returns how many data elements were read from the RX FIFO.

Return

The number of data elements read from the RX FIFO.

Parameters
  • base: The pointer to the UART SCB instance.

  • buffer: The pointer to the location to place the data read from the RX FIFO. The element size is defined by the data type, which depends on the configured data width.

  • size: The number of data elements to read from the RX FIFO.

__STATIC_INLINE void Cy_SCB_UART_GetArrayBlocking (CySCB_Type const *base, void *buffer, uint32_t size)

Reads an array of data out of the UART RX FIFO.

This function blocks until the number of data elements specified by the size has been read from the RX FIFO.

Parameters
  • base: The pointer to the UART SCB instance.

  • buffer: The pointer to the location to place the data read from the RX FIFO. The element size is defined by the data type, which depends on the configured data width.

  • size: The number of data elements to read from the RX FIFO.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetTxFifoStatus (CySCB_Type const *base)

Returns the current status of the TX FIFO.

Return

UART TX FIFO Statuses

Parameters
  • base: The pointer to the UART SCB instance.

__STATIC_INLINE void Cy_SCB_UART_ClearTxFifoStatus (CySCB_Type *base, uint32_t clearMask)

Clears the selected statuses of the TX FIFO.

note

Parameters
  • base: The pointer to the UART SCB instance.

  • clearMask: The mask whose statuses to clear. See UART TX FIFO Statuses for the set of constants.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetRxFifoStatus (CySCB_Type const *base)

Returns the current status of the RX FIFO.

Return

UART RX FIFO status.

Parameters
  • base: The pointer to the UART SCB instance.

__STATIC_INLINE void Cy_SCB_UART_ClearRxFifoStatus (CySCB_Type *base, uint32_t clearMask)

Clears the selected statuses of the RX FIFO.

note

Parameters
  • base: The pointer to the UART SCB instance.

  • clearMask: The mask whose statuses to clear. See UART RX FIFO status. for the set of constants.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetNumInTxFifo (CySCB_Type const *base)

Returns the number of data elements in the UART TX FIFO.

note

This number does not include any data currently in the TX shifter.

Return

The number of data elements in the TX FIFO. The size of date element defined by the configured data width.

Parameters
  • base: The pointer to the UART SCB instance.

__STATIC_INLINE bool Cy_SCB_UART_IsTxComplete (CySCB_Type const *base)

Checks whether the TX FIFO and Shifter are empty and there is no more data to send.

Return

If true, transmission complete. If false, transmission is not complete.

Parameters
  • base: Pointer to the UART SCB instance.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetNumInRxFifo (CySCB_Type const *base)

Returns the number of data elements in the UART RX FIFO.

Return

The number of data elements in the RX FIFO. The size of date element defined by the configured data width.

Parameters
  • base: The pointer to the UART SCB instance.

__STATIC_INLINE void Cy_SCB_UART_ClearRxFifo (CySCB_Type *base)

Clears all data out of the UART RX FIFO.

Side Effects

Any data currently in the shifter is cleared and lost.

Parameters
  • base: The pointer to the UART SCB instance.

__STATIC_INLINE void Cy_SCB_UART_ClearTxFifo (CySCB_Type *base)

Clears all data out of the UART TX FIFO.

Side Effects

The TX FIFO clear operation also clears the shift register, so that the shifter could be cleared in the middle of a data element transfer, corrupting it. The data element corruption means that all bits that have not been transmitted are transmitted as 1s on the bus.

Parameters
  • base: The pointer to the UART SCB instance.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetOverSample (CySCB_Type const *base)

Returns the value of oversample.

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Get current oversample value for provided SCB */
    (void) Cy_SCB_UART_GetOverSample(SCB5);
Return

The value of oversample.

Parameters
  • base: The pointer to the UART SCB instance.

cy_en_scb_uart_status_t Cy_SCB_UART_SetOverSample(CySCB_Type *base, uint32_t overSample, cy_stc_scb_uart_context_t *context)

Sets oversample bits of UART.

note

Ensure that the SCB block is disabled before calling this function.

    /* Assign appropriate oversample value for UART */
    uint32_t OverSample = 8UL;

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Set oversample value for UART */
    (void) Cy_SCB_UART_SetOverSample(SCB5, OverSample, &UART_1_context);

    /* Enable UART to operate */
    Cy_SCB_UART_Enable(SCB5);
Return

cy_en_scb_uart_status_t

Parameters
  • base: The pointer to the UART SCB instance.

  • overSample: Value of oversample to be set.

  • context: The pointer to the context structure cy_stc_scb_uart_context_t allocated by the user. The structure is used during the UART operation for internal configuration and data retention. The user must not modify anything in this structure. User should not pass NULL as pointer to context.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetDataWidth (CySCB_Type const *base)

Returns the value of datawidth.

note

Values of Tx and Rx datawidth are same.

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Get current datawidth value for provided SCB */
    (void) Cy_SCB_UART_GetDataWidth(SCB5);
Return

The value of datawidth.

Parameters
  • base: The pointer to the UART SCB instance.

void Cy_SCB_UART_SetDataWidth(CySCB_Type *base, uint32_t dataWidth)

Sets datawidth for UART transaction.

note

Ensure that the SCB block is disabled before calling this function.

    /* Assign appropriate datawidth value for UART */
    uint32_t dataWidth = 8UL;

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Set datawidth value for UART */
    (void) Cy_SCB_UART_SetDataWidth(SCB5, dataWidth);

    /* Enable UART to operate */
    Cy_SCB_UART_Enable(SCB5);
Parameters
  • base: The pointer to the UART SCB instance.

  • dataWidth: The width of UART data in the UART transaction.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetParity (CySCB_Type const *base)

Returns the value of parity.

note

Values of Tx and Rx parity are same.

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Get current parity value for provided SCB */
    (void) Cy_SCB_UART_GetParity(SCB5);
Return

The value of parity.

Parameters
  • base: The pointer to the UART SCB instance.

void Cy_SCB_UART_SetParity(CySCB_Type *base, cy_en_scb_uart_parity_t parity)

Sets parity for UART transaction.

note

Ensure that the SCB block is disabled before calling this function.

    /* Assign appropriate parity value for UART */
    cy_en_scb_uart_parity_t parity = CY_SCB_UART_PARITY_NONE;

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Set parity value for UART */
    (void) Cy_SCB_UART_SetParity(SCB5, parity);

    /* Enable UART to operate */
    Cy_SCB_UART_Enable(SCB5);
Parameters
  • base: The pointer to the UART SCB instance.

  • parity: The UART parity bit in the UART transaction.

__STATIC_INLINE uint32_t Cy_SCB_UART_GetStopBits (CySCB_Type const *base)

Returns the value of stop bits.

note

Values of Tx and Rx stop bits are same.

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Get current stop bits value for provided SCB */
    (void) Cy_SCB_UART_GetStopBits(SCB5);
Return

The value of stop bits.

Parameters
  • base: The pointer to the UART SCB instance.

void Cy_SCB_UART_SetStopBits(CySCB_Type *base, cy_en_scb_uart_stop_bits_t stopBits)

Sets stop bits for UART transaction.

note

Ensure that the SCB block is disabled before calling this function.

    /* Assign appropriate stop bits value for UART */
    cy_en_scb_uart_stop_bits_t stopBits = CY_SCB_UART_STOP_BITS_1;

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Set stop bits value for UART */
    (void) Cy_SCB_UART_SetStopBits(SCB5, stopBits);

    /* Enable UART to operate */
    Cy_SCB_UART_Enable(SCB5);
Parameters
  • base: The pointer to the UART SCB instance.

  • stopBits: The number of stop bits in the UART transaction.

__STATIC_INLINE bool Cy_SCB_UART_GetDropOnParityError (CySCB_Type const *base)

Returns the value of SetDropOnParityError.

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Get current SetDropOnParityError value for provided SCB */
    (void) Cy_SCB_UART_GetDropOnParityError(SCB5);
Return

The value of SetDropOnParityError.

Parameters
  • base: The pointer to the UART SCB instance.

void Cy_SCB_UART_SetDropOnParityError(CySCB_Type *base, bool dropOnParityError)

Sets SetDropOnParityError for UART transaction.

note

Ensure that the SCB block is disabled before calling this function.

    /* Assign appropriate SetDropOnParityError value for UART */
    bool setDropOnParityError = false;

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Set SetDropOnParityError value for UART */
    (void) Cy_SCB_UART_SetDropOnParityError(SCB5, setDropOnParityError);

    /* Enable UART to operate */
    Cy_SCB_UART_Enable(SCB5);
Parameters
  • base: The pointer to the UART SCB instance.

  • dropOnParityError: To enable the hardware to drop data in the RX FIFO when a parity error is detected in the UART transaction.

__STATIC_INLINE bool Cy_SCB_UART_GetEnableMsbFirst (CySCB_Type const *base)

Returns the value of enableMsbFirst.

note

Values of Tx and Rx enableMsbFirst are same.

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Get current enableMsbFirst value for provided SCB */
    (void) Cy_SCB_UART_GetEnableMsbFirst(SCB5);
Return

The value of enableMsbFirst.

Parameters
  • base: The pointer to the UART SCB instance.

void Cy_SCB_UART_SetEnableMsbFirst(CySCB_Type *base, bool enableMsbFirst)

Sets enableMsbFirst for UART transaction.

note

Ensure that the SCB block is disabled before calling this function.

    /* Assign appropriate enableMsbFirst value for UART */
    bool enableMsbFirst = false;

    /* Initialize SCB for UART operation */
    (void) Cy_SCB_UART_Init(SCB5, &UART_1_config, &UART_1_context);

    /* Set enableMsbFirst value for UART */
    (void) Cy_SCB_UART_SetEnableMsbFirst(SCB5, enableMsbFirst);

    /* Enable UART to operate */
    Cy_SCB_UART_Enable(SCB5);
Parameters
  • base: The pointer to the UART SCB instance.

  • enableMsbFirst: Enables the hardware to shift out data element MSB first; otherwise, LSB first in the UART transaction.