Skip to content
Ryan Summers edited this page Dec 31, 2015 · 3 revisions

UART Functions

This page contains informations pertaining to the UART peripheral library of SUBLIBinal. Please refer to the following list to be redirected towards the appropriate documentation.

Functions


initialize_UART

Definition
UART_Data* initialize_UART(UART_Config config);

Description
This function is used for the initialization of the UART channel on the microcontroller.

Parameters

  • config: This parameter should be a completely filled out UART_Config structure. It is important to note that the UART rx and tx callback functions are not necessary for proper UART functionality.

Return
This function will return a pointer to a UART_Data structure pointer. This structure is to be used only for querying information about the status of the UART. This structure must not be modified. If it is, the UART channel can potentially malfunction.

top


send_UART

Definition
Error send_UART(UART_Channel channel, uint8 *data_ptr, uint data_size);

Description
This function will transmit information on the UART channel specified. The data transmitted does not need to remain in scope to function correctly.

Parameters

  • channel: This parameter specifies the channel upon which the send should occur.
  • data_ptr: This parameter is a pointer to the data that should be transmitted on the UART. This data does not need to remain in scope, as it is copied into the UART transmission buffer upon a send_UART function call.
  • data_size: This parameter specifies the number of bytes that should be transmitted. Transmission will begin from the data pointed to by data_ptr and continue sequentially until data_size bytes have been copied into the transmission buffer.

Return

This function will return an error code based upon success status:

  • ERR_INVALID_SEND: This will occur if the specified UART_Channel is not UART_CH_1 or UART_CH_2. These are the only available UART channels.
  • ERR_QUEUE_FULL: This will occur if the UART buffer is full. This indicates that the message was not properly sent.

top


receive_UART

Definition
Error receive_UART(UART_Channel channel, uint8 *data_ptr, uint data_size);

Description
This function will attempt to read data from the received UART channel.

Parameters

  • channel: This specifies which UART channel that we should attempt to read from.
  • data_ptr: The data_ptr parameter specifies a location that the read data will be placed if a successful read occurs.
  • data_size: This parameter specifies how many bytes should be read from the UART buffer. If there are less than data_size bytes available in the UART receive buffer, the function will not read any pieces of information.

Return
This function will return an error based upon its completion status:

  • ERR_INVALID_CHANNEL: This error code will be returned if UART_CH_1 or UART_CH_2 is not specified properly. These are the only available UART channels.
  • ERR_QUEUE_INVALID_READ: This error is returned if there was not enough information available on the UART channel. That is, there was less data available than there was data requested.

top


Clone this wiki locally