2020-12-10 11:02:26 +08:00
|
|
|
/*
|
2021-01-21 16:08:06 +08:00
|
|
|
* Copyright (c) 2020-2021, Bluetrum Development Team
|
2021-03-11 13:26:54 +08:00
|
|
|
*
|
2020-12-10 11:02:26 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2020-11-20 greedyhao first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DRV_USART_H__
|
|
|
|
#define DRV_USART_H__
|
|
|
|
|
|
|
|
#include "drv_common.h"
|
|
|
|
|
|
|
|
#ifdef RT_USING_SERIAL
|
|
|
|
|
|
|
|
/* an32 config class */
|
|
|
|
struct ab32_uart_config
|
|
|
|
{
|
|
|
|
const char *name;
|
2021-08-08 16:31:00 +08:00
|
|
|
hal_sfr_t instance;
|
|
|
|
uint8_t mode;
|
|
|
|
uint16_t fifo_size;
|
|
|
|
uint8_t reserve[1];
|
2020-12-10 11:02:26 +08:00
|
|
|
// struct dma_config *dma_rx;
|
|
|
|
// struct dma_config *dma_tx;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ab32 uart driver class */
|
|
|
|
struct ab32_uart
|
|
|
|
{
|
|
|
|
struct uart_handle handle;
|
|
|
|
struct ab32_uart_config *config;
|
|
|
|
|
|
|
|
#ifdef RT_SERIAL_USING_DMA
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
DMA_HandleTypeDef handle;
|
|
|
|
rt_size_t last_index;
|
|
|
|
} dma_rx;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
DMA_HandleTypeDef handle;
|
|
|
|
} dma_tx;
|
|
|
|
#endif
|
|
|
|
rt_uint16_t uart_dma_flag;
|
|
|
|
struct rt_serial_device serial;
|
2021-08-08 16:31:00 +08:00
|
|
|
rt_uint8_t *rx_buf;
|
|
|
|
rt_uint8_t rx_idx;
|
|
|
|
rt_uint8_t rx_idx_prev;
|
2020-12-10 11:02:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int rt_hw_usart_init(void);
|
|
|
|
|
|
|
|
#endif
|