usart_enhanced.h File Reference

library for enhanced USART communication (API) More...

Go to the source code of this file.

## Enumerations

enum | usart_enhanced_parity_t { USART_ENHANCED_PARITY_NONE, USART_ENHANCED_PARITY_EVEN, USART_ENHANCED_PARITY_ODD, USART_ENHANCED_PARITY_MARK, USART_ENHANCED_PARITY_SPACE }
| enhanced USART setting for the additional parity bit More...

## Functions

bool | usart_enhanced_config (uint32_t usart, uint8_t databits, enum usart_enhanced_parity_t parity)
| configure enhanced USART More...
void | usart_enhanced_send (uint32_t usart, uint8_t data)
| send data over the enhanced USART using the configuration More...
uint8_t | usart_enhanced_recv (uint32_t usart)
| receive data over the enhanced USART using the configuration More...
bool | usart_enhanced_parity_error (uint32_t usart)
| get the parity status of the received data More...

## Detailed Description

library for enhanced USART communication (API)

Author
  King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info

Date
  2018

the USART peripherals only support 8 or 9-bit word and even or odd parity (included in the data bits). The library adds support for 5 to 8-bit words, none/even/odd/mark/space parity (on top of the data bits)

Note
  since parity is handled in software, the parity error (PE) flag is unused and should be replaced by the value return by usart_enhanced_parity_error

Remarks
  9-bit raw communication is not supported since this is not common and can be done without this library

Definition in file usart_enhanced.h.

## Enumeration Type Documentation

## usart_enhanced_parity_t

enum usart_enhanced_parity_t

enhanced USART setting for the additional parity bit

Enumerator
USART_ENHANCED_PARITY_NONE | no parity

USART_ENHANCED_PARITY_EVEN

even parity

Note
  the number of 1's is even

USART_ENHANCED_PARITY_ODD

odd parity

Note
  the number of 1's is odd

USART_ENHANCED_PARITY_MARK

mark parity

Note
  the parity bit is 1

USART_ENHANCED_PARITY_SPACE

space parity

Note
  the parity bit is 0

Definition at line 26 of file usart_enhanced.h.

## Function Documentation

## usart_enhanced_config()

bool usart_enhanced_config | ( | uint32_t | usart,
|  | uint8_t | databits,
|  | enum usart_enhanced_parity_t | parity
| ) |  |

configure enhanced USART

Parameters

  [in] | usart | USART peripheral base address
  [in] | databits | word size in bits (5 to 8)
  [in] | parity | additional parity bit

Returns
  if the input settings are valid and the configuration is successful

Definition at line 72 of file usart_enhanced.c.

## usart_enhanced_parity_error()

bool usart_enhanced_parity_error | ( | uint32_t | usart | ) |

get the parity status of the received data

Parameters

  [in] | usart | USART peripheral base address

Returns
  if there is a parity error

Note
  the check only applies to the last data retrieved using usart_enhanced_recv

Definition at line 177 of file usart_enhanced.c.

## usart_enhanced_recv()

uint8_t usart_enhanced_recv | ( | uint32_t | usart | ) |

receive data over the enhanced USART using the configuration

Parameters

  [in] | usart | USART peripheral base address

Returns
  data received

Note
  uses usart_recv

Definition at line 135 of file usart_enhanced.c.

## usart_enhanced_send()

void usart_enhanced_send | ( | uint32_t | usart,
|  | uint8_t | data
| ) |  |

send data over the enhanced USART using the configuration

Parameters

  [in] | usart | USART peripheral base address
  [in] | data | data to be sent

Note
  uses usart_send

Definition at line 100 of file usart_enhanced.c.