Files
kunlun/driver/inc/vfs_uart.h
2024-09-28 14:24:04 +08:00

117 lines
2.7 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef _VFS_UART_H
#define _VFS_UART_H
#include "iot_config.h"
#include "os_task.h"
#include "termios.h"
#include "iot_irq.h"
#include "iot_ringbuf.h"
#include "iot_uart_api.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
#if IOT_FTM_SUPPORT
#define UART_TXBUF_SUPPORT 1
#endif
*/
/* Disable tx ring buffer. */
#ifdef UART_TXBUF_SUPPORT
#undef UART_TXBUF_SUPPORT
#endif
#define UART_TXBUF_SUPPORT 0
#define UART_RX_Q_LEN 1024
#define UART_ICC_Q_LEN (2048 + 128)
#if IOT_VRITUAL_UART_PORT_ENABLE
#define UART0_RX_Q_LEN (2048 + 64)
#else
#define UART0_RX_Q_LEN UART_RX_Q_LEN
#endif
#if UART_TXBUF_SUPPORT
#define UART_TX_Q_LEN 2048
#endif
#define USART_NO_BLOCK 0
#define USART_BLOCK_TIME 0xffffffffUL
#define UART_ASYNC_READ_ONCE 50
#define UART_EXT_RX_BUF_LEN 256
typedef enum {
USART1_FILENO = 0,
USART2_FILENO,
USART3_FILENO,
USART4_FILENO,
USART5_FILENO,
USART6_FILENO,
USART7_FILENO,
USART8_FILENO,
}USART_FILENO;
#ifdef UART_ASYNC_OPERATION
typedef struct _tx_rx_info{
uint8_t *p_buf;
void *param;
void (*cb)(void*, uint8_t);
size_t size;
size_t old_size;
}tx_rx_info;
#endif
enum {
PORT_TYPE_UART = 0,
PORT_TYPE_RS485,
PORT_TYPE_IR,
PORT_TYPE_VP
};
typedef struct uart_info
{
uint8_t port;
uint8_t type;
uint16_t txe_pin; /* gpio NO. */
uint32_t irq;
uint32_t used;
struct ringbuf rx_rb;
#if UART_TXBUF_SUPPORT
struct ringbuf tx_rb;
#endif
struct termios termios;
os_task_h task_h;
iot_irq_t handle;
#ifdef UART_ASYNC_OPERATION
tx_rx_info rx_info;
tx_rx_info tx_info;
bool_t async_mode;
#endif
struct uart_ctrl *drv;
}uart_info;
#ifdef __cplusplus
}
#endif
#endif //_VFS_UART_H