ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_uart.h File Reference

Interface for UART operations. More...

#include "ruuvi_driver_error.h"
#include "ruuvi_interface_gpio.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  ruuvi_interface_uart_init_config_t
 

Enumerations

enum  ruuvi_interface_uart_baud_t { RUUVI_INTERFACE_UART_BAUD_9600 , RUUVI_INTERFACE_UART_BAUD_115200 }
 

Functions

ruuvi_driver_status_t ruuvi_interface_uart_init (const ruuvi_interface_uart_init_config_t *const config)
 Callback function for received data. More...
 
bool ruuvi_interface_uart_is_init ()
 check if UART interface is already initialized. More...
 
ruuvi_driver_status_t ruuvi_interface_uart_uninit ()
 Uninitialize UART driver. More...
 
ruuvi_driver_status_t ruuvi_interface_uart_send_blocking (const uint8_t *const p_tx, const size_t tx_len)
 UART write function. Function is blocking and will not sleep while transaction is ongoing. More...
 

Detailed Description

Interface for UART operations.

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2019-10-01

Definition in file ruuvi_interface_uart.h.

Enumeration Type Documentation

◆ ruuvi_interface_uart_baud_t

Baudrate for UART

Enumerator
RUUVI_INTERFACE_UART_BAUD_9600 

9600 bauds

RUUVI_INTERFACE_UART_BAUD_115200 

2 Mbps

Definition at line 27 of file ruuvi_interface_uart.h.

Function Documentation

◆ ruuvi_interface_uart_init()

ruuvi_driver_status_t ruuvi_interface_uart_init ( const ruuvi_interface_uart_init_config_t *const  config)

Callback function for received data.

Initialize UART driver with given settings

This function also handles configuring the GPIO pins as required

Parameters
configConfiguration of the UART peripheral. Will setup given pins as required.
Returns
RUUVI_DRIVER_SUCCESS if no error occurred
RUUVI_DRIVER_ERROR_INVALID_STATE if UART was already initialized

◆ ruuvi_interface_uart_is_init()

bool ruuvi_interface_uart_is_init ( )

check if UART interface is already initialized.

Returns
true if UART is initialized
false otherwise

◆ ruuvi_interface_uart_send_blocking()

ruuvi_driver_status_t ruuvi_interface_uart_send_blocking ( const uint8_t *const  p_tx,
const size_t  tx_len 
)

UART write function. Function is blocking and will not sleep while transaction is ongoing.

Parameters
p_txpointer to data to be sent. Must be in RAM.
tx_lenlength of data to be sent.
Returns
RUUVI_DRIVER_SUCCSS when data was sent.
RUUVI_DRIVER_ERROR_NULL if p_tx is NULL.
RUUVI_DRIVER_ERROR_INVALID_ADDRESS if p_tx is not in RAM
error code from stack on other error.

◆ ruuvi_interface_uart_uninit()

ruuvi_driver_status_t ruuvi_interface_uart_uninit ( )

Uninitialize UART driver.

This function might not uninitialize the UART GPIO pins, only the underlying peripheral. Uninitialized GPIOs explicitly if that is required.

Returns
RUUVI_DRIVER_SUCCESS
Warning
Uninitializes the UART peripheral, may or may not uninitialize the associated gpio pins