Lazuli
Data Structures | Enumerations | Functions
serial.h File Reference

Serial port configuration interface. More...

#include <Lazuli/common.h>

Go to the source code of this file.

Data Structures

struct  Lz_SerialConfiguration
 Represents the configuration of a serial interface. More...
 

Enumerations

enum  Lz_SerialEnableFlags {
  LZ_SERIAL_DISABLE_ALL = 0,
  LZ_SERIAL_ENABLE_TRANSMIT = POSITION(1U),
  LZ_SERIAL_ENABLE_RECEIVE = POSITION(2U),
  LZ_SERIAL_ENABLE_ALL = LZ_SERIAL_ENABLE_RECEIVE | LZ_SERIAL_ENABLE_TRANSMIT
}
 Define flags for enabling/disabling serial transmission/reception. More...
 
enum  Lz_SerialStopBits {
  LZ_SERIAL_STOP_BITS_1,
  LZ_SERIAL_STOP_BITS_2
}
 Define the number of stop bits to use on serial line. More...
 
enum  Lz_SerialParityBit {
  LZ_SERIAL_PARITY_NONE,
  LZ_SERIAL_PARITY_EVEN,
  LZ_SERIAL_PARITY_ODD
}
 Define the kind of parity bit to use on serial line. More...
 
enum  Lz_SerialSize {
  LZ_SERIAL_SIZE_5,
  LZ_SERIAL_SIZE_6,
  LZ_SERIAL_SIZE_7,
  LZ_SERIAL_SIZE_8
}
 Define the size of the character used on serial line. More...
 
enum  Lz_SerialSpeed {
  LZ_SERIAL_SPEED_2400,
  LZ_SERIAL_SPEED_4800,
  LZ_SERIAL_SPEED_9600,
  LZ_SERIAL_SPEED_19200
}
 Define the baud rate of the serial line. More...
 

Functions

void Lz_Serial_GetConfiguration (Lz_SerialConfiguration *const serialConfiguration)
 Retrieve the configuration of the serial line. More...
 
void Lz_Serial_SetConfiguration (Lz_SerialConfiguration *const serialConfiguration)
 Set the configuration of the serial line. More...
 

Detailed Description

Serial port configuration interface.

This file describes the interface of serial port configuration. Serial port means here UART/USART device.

The configuration is the same for input (Receive/Rx) and ouput (Transmit/Tx).

Definition in file serial.h.

Enumeration Type Documentation

◆ Lz_SerialEnableFlags

Define flags for enabling/disabling serial transmission/reception.

These flags can be combined using bitwise OR (i.e. | operator).

Enumerator
LZ_SERIAL_DISABLE_ALL 

Disable both serial transmission and reception.

LZ_SERIAL_ENABLE_TRANSMIT 

Enable serial transmission.

LZ_SERIAL_ENABLE_RECEIVE 

Enable serial reception.

LZ_SERIAL_ENABLE_ALL 

Enable both serial transmission and reception.

Definition at line 30 of file serial.h.

◆ Lz_SerialStopBits

Define the number of stop bits to use on serial line.

Enumerator
LZ_SERIAL_STOP_BITS_1 

Use 1 stop bit.

LZ_SERIAL_STOP_BITS_2 

Use 2 stop bits.

Definition at line 55 of file serial.h.

◆ Lz_SerialParityBit

Define the kind of parity bit to use on serial line.

Enumerator
LZ_SERIAL_PARITY_NONE 

Use no parity bit.

LZ_SERIAL_PARITY_EVEN 

Use even parity bit.

LZ_SERIAL_PARITY_ODD 

Use odd parity bit.

Definition at line 90 of file serial.h.

◆ Lz_SerialSize

Define the size of the character used on serial line.

Enumerator
LZ_SERIAL_SIZE_5 

Use 5-bit character size on serial line.

LZ_SERIAL_SIZE_6 

Use 6-bit character size on serial line.

LZ_SERIAL_SIZE_7 

Use 7-bit character size on serial line.

LZ_SERIAL_SIZE_8 

Use 8-bit character size on serial line.

Definition at line 130 of file serial.h.

◆ Lz_SerialSpeed

Define the baud rate of the serial line.

Enumerator
LZ_SERIAL_SPEED_2400 

Use a 2400 baud rate on the serial line.

LZ_SERIAL_SPEED_4800 

Use a 4800 baud rate on the serial line.

LZ_SERIAL_SPEED_9600 

Use a 9600 baud rate on the serial line.

LZ_SERIAL_SPEED_19200 

Use a 19200 baud rate on the serial line.

Definition at line 175 of file serial.h.

Function Documentation

◆ Lz_Serial_GetConfiguration()

void Lz_Serial_GetConfiguration ( Lz_SerialConfiguration *const  serialConfiguration)

Retrieve the configuration of the serial line.

This function will fill the object pointed by the parameter with current serial settings.

Parameters
serialConfigurationA pointer to an allocated Lz_SerialConfiguration (e.g. allocated on the stack).

Definition at line 20 of file serial.c.

◆ Lz_Serial_SetConfiguration()

void Lz_Serial_SetConfiguration ( Lz_SerialConfiguration *const  serialConfiguration)

Set the configuration of the serial line.

This function will set the different parameters of the serial line according to the configuration pointed by the serialConfiguration parameter.

Warning
On the AVR platform this function will block interrupts if configuration option LZ_CONFIG_SERIAL_USE_INTERRUPTS is activated. On the AVR platform, this function will wait all transmit and receive operations has completed.
Parameters
serialConfigurationA pointer to an allocated Lz_SerialConfiguration (e.g. allocated on the stack).

Definition at line 32 of file serial.c.