58 lines
1.2 KiB
C
58 lines
1.2 KiB
C
/** @file usart.h
|
|
* Module handling Universal Synchronous/Asynchronous Receiver/Transmitter
|
|
*
|
|
* The module provides functions to configure the usarts and read/write from/to
|
|
* it
|
|
*/
|
|
|
|
#ifndef _USART_H_
|
|
#define _USART_H_
|
|
|
|
//--includes--------------------------------------------------------------------
|
|
|
|
#include "stdint.h"
|
|
|
|
|
|
//--type definitions------------------------------------------------------------
|
|
|
|
enum UsartPeriph {
|
|
USART_PERIPH_1,
|
|
USART_PERIPH_2,
|
|
USART_PERIPH_3,
|
|
};
|
|
|
|
enum UsartConfig {
|
|
USART_CONFIG_7E1,
|
|
USART_CONFIG_7E2,
|
|
USART_CONFIG_7O1,
|
|
USART_CONFIG_7O2,
|
|
USART_CONFIG_8N1,
|
|
USART_CONFIG_8N2,
|
|
USART_CONFIG_8E1,
|
|
USART_CONFIG_8E2,
|
|
USART_CONFIG_8O1,
|
|
USART_CONFIG_8O2,
|
|
};
|
|
|
|
|
|
//--functions-------------------------------------------------------------------
|
|
|
|
void usart_configure(enum UsartPeriph periph, enum UsartConfig config,
|
|
uint32_t baudrate);
|
|
|
|
void usart_reset(enum UsartPeriph periph);
|
|
|
|
uint32_t usart_write_byte(enum UsartPeriph periph, uint8_t byte);
|
|
|
|
uint32_t usart_read_byte(enum UsartPeriph periph, uint8_t* byte);
|
|
|
|
void usart_set_tx_buffer(enum UsartPeriph periph, uint8_t** buffers,
|
|
uint16_t buffer_size, uint8_t buffer_nb);
|
|
|
|
void usart_set_rx_buffer(enum UsartPeriph periph, uint8_t* buffer,
|
|
uint16_t size);
|
|
|
|
|
|
#endif //_USART_H_
|
|
|