MiraOS  1.22
Typedefs | Enumerations | Functions
mira_uart.h File Reference

MiraOS UART driver. More...

#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef void(* MiraUartDataReceivedCallback) (uint8_t *data_ptr, uint8_t length)
 

Enumerations

enum  MiraUartError { MIRA_UART_NONE = 0x00, MIRA_UART_ERROR = 0x01 }
 
enum  MiraUartBits { MIRA_UART_BITS_5 = 5, MIRA_UART_BITS_6, MIRA_UART_BITS_7, MIRA_UART_BITS_8 }
 
enum  MiraUartParity { MIRA_UART_PARITY_NONE, MIRA_UART_PARITY_ODD, MIRA_UART_PARITY_EVEN }
 
enum  MiraUartStopBits { MIRA_UART_STOP_BITS_1 = 1, MIRA_UART_STOP_BITS_2 }
 

Functions

MiraUartError mira_uart_init (uint32_t baud_rate, MiraUartBits bits, MiraUartParity parity, MiraUartStopBits stop_bits, MiraUartDataReceivedCallback callback)
 Initialize UART. More...
 
void mira_uart_send_byte (uint8_t data)
 Send one byte. More...
 
uint8_t mira_uart_receive_byte ()
 Receive one byte. More...
 
uint8_t mira_uart_send_buffer_is_full ()
 
uint8_t mira_uart_send_buffer_is_empty ()
 
uint8_t mira_uart_receive_buffer_is_full ()
 
uint8_t mira_uart_receive_buffer_is_empty ()
 

Detailed Description

MiraOS UART driver.

Author
LumenRadio AB
Date
16 Nov 2016 The MiraOS library provides functions for controlling the Mira radio module, sending/receiving messages, controlling peripherals, etc.
See also
http://docs.lumenrad.io/mira

Enumeration Type Documentation

Enumerator
MIRA_UART_NONE 

Success

MIRA_UART_ERROR 

Error

Function Documentation

MiraUartError mira_uart_init ( uint32_t  baud_rate,
MiraUartBits  bits,
MiraUartParity  parity,
MiraUartStopBits  stop_bits,
MiraUartDataReceivedCallback  callback 
)

Initialize UART.

Parameters
baud_rateUART baud rate. A value between 300 and 1000000.
bitsWord length.
parityParity.
stop_bitsNumber of stop bits.
callbackCallback to call when words are received. The callback is called from an interrupt handler and care should be taken to avoid race conditions. NULL if no callback.
Returns
Returns an error if initialization could not be completed.
uint8_t mira_uart_receive_buffer_is_empty ( )
Returns
True if the receive buffer is empty.
uint8_t mira_uart_receive_buffer_is_full ( )
Returns
True if the receive buffer is full.
uint8_t mira_uart_receive_byte ( )

Receive one byte.

Blocks until there are bytes available in the receive buffer.

Returns
Received byte
uint8_t mira_uart_send_buffer_is_empty ( )
Returns
True if the send buffer is empty.
uint8_t mira_uart_send_buffer_is_full ( )
Returns
True if the send buffer is not full
void mira_uart_send_byte ( uint8_t  data)

Send one byte.

Add one byte to the send buffer. Blocks until the send buffer is not full.

Parameters
dataData to send.