Skip to content

Commit

Permalink
firmware: drivers: uart: Minor improvements and adding doxygen docume…
Browse files Browse the repository at this point in the history
…ntation #43
  • Loading branch information
mgm8 committed Jul 12, 2023
1 parent 05c0113 commit 64e63cd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
13 changes: 6 additions & 7 deletions firmware/drivers/uart/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,19 @@ int uart_init(uart_config_t config)
int uart_write(uart_config_t config, uint16_t *data, uint16_t len)
{
int err = ERRNO_SUCCESS;
uint32_t usart;

uint16_t i = 0U;
for(i = 0U; i < len; i++)
{
err = uart_send_byte(config, *(data + i));
err = uart_send_byte(config, data[i]);
}

return err;
}

int uart_read(uart_config_t config, uint16_t *data, uint16_t len)
{
int err;
int err = ERRNO_SUCCESS;
uint16_t num_bytes = len;
uint16_t i = 0U;
queue_t *uart_rx_buffer;
Expand Down Expand Up @@ -216,8 +215,8 @@ int uart_rx_enable(uart_config_t config)

int uart_rx_disable(uart_config_t config)
{
int err;
uint32_t usart;
int err = -1;
uint32_t usart = UINT32_MAX;

err = uart_select_port_address(config, &usart);
usart_disable_rx_interrupt(usart);
Expand All @@ -240,7 +239,7 @@ uint16_t uart_read_available(uart_config_t config)

int uart_flush(uart_config_t config)
{
int err;
int err = ERRNO_SUCCESS;

queue_t *uart_rx_buffer;

Expand All @@ -258,7 +257,7 @@ int uart_flush(uart_config_t config)

static inline int uart_send_byte(uart_config_t config, uint16_t c)
{
int err = 0;
int err = ERRNO_SUCCESS;

uint32_t usart;

Expand Down
50 changes: 25 additions & 25 deletions firmware/drivers/uart/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ typedef enum
*/
typedef enum
{
UART_SB_0_5=0, /**< . */
UART_SB_1, /**< . */
UART_SB_1_5, /**< . */
UART_SB_2 /**< . */
UART_SB_0_5=0, /**< 0.5 stop bit. */
UART_SB_1, /**< 1 stop bit. */
UART_SB_1_5, /**< 1.5 stop bit. */
UART_SB_2 /**< 2 stop bits. */
} uart_sb_t;

/**
Expand Down Expand Up @@ -124,71 +124,71 @@ typedef struct
} uart_config_t;

/**
* \brief .
* \brief Initializes a given UART port.
*
* \param[in] config .
* \param[in] config are the configuration parameters of the given UART port.
*
* \return .
* \return The status/error code.
*/
int uart_init(uart_config_t config);

/**
* \brief .
* \brief Writes data to a given UART port.
*
* \param[in] config .
* \param[in] config are the configuration parameters of the given UART port.
*
* \param[in] data .
* \param[in] data is the array of bytes to be written.
*
* \param[in] len .
* \param[in] len is the number of bytes to be written.
*
* \return .
* \return The status/error code.
*/
int uart_write(uart_config_t config, uint16_t *data, uint16_t len);

/**
* \brief .
* \brief Reads data from a given UART port.
*
* \param[in] config .
* \param[in] config are the configuration parameters of the given UART port.
*
* \param[in,out] data .
* \param[in,out] data is a pointer to store the read data.
*
* \param[in] len .
* \param[in] len is the number of bytes to read.
*
* \return .
* \return The status/error code.
*/
int uart_read(uart_config_t config, uint16_t *data, uint16_t len);

/**
* \brief .
* \brief Enables the RX of a given UART port.
*
* \param[in] config .
* \param[in] config are the configuration parameters of the given UART port.
*
* \return The status/error code.
*/
int uart_rx_enable(uart_config_t config);

/**
* \brief .
* \brief Disables the RX of a given UART port.
*
* \param[in] config .
* \param[in] config are the configuration parameters of the given UART port.
*
* \return The status/error code.
*/
int uart_rx_disable(uart_config_t config);

/**
* \brief .
* \brief Checks if there is available data to read from a given UART port.
*
* \param[in] config .
* \param[in] config are the configuration parameters of the given UART port.
*
* \return The status/error code.
*/
uint16_t uart_read_available(uart_config_t config);

/**
* \brief .
* \brief Flushes the RX buffer of a given UART port.
*
* \param[in] config .
* \param[in] config are the configuration parameters of the given UART port.
*
* \return The status/error code.
*/
Expand Down

0 comments on commit 64e63cd

Please sign in to comment.