stm32f1xx_HBL/drivers/usart.h
Steins7 4464156981 Move DMA config to buffers
Control over most parameters is not needed since they cannot change for the
buffer to work as expected. Only the priority should be adjustable
2023-09-17 17:52:14 +02:00

60 lines
1.3 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 "dma.h"
#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, enum DmaConfig priority);
void usart_set_rx_buffer(enum UsartPeriph periph, uint8_t* buffer,
uint16_t size, enum DmaConfig priority);
#endif //_USART_H_