135 lines
3.7 KiB
C
135 lines
3.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 _UART_H
|
|
#define _UART_H
|
|
|
|
#include "iot_config.h"
|
|
#include "iot_uart_api.h"
|
|
#include "uart_e.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define IOT_UART_PORT_NUM_ONCHIP HW_UART_PORT_NUM
|
|
|
|
typedef struct uart_ctrl {
|
|
int (*init)(int pt);
|
|
int (*txfifo_full)(int pt);
|
|
int (*putc)(int pt, char ch);
|
|
int (*puts)(int pt, uint8_t *tx_rb, uint32_t len);
|
|
int (*getc)(int pt);
|
|
int (*gets)(int pt, uint8_t *rx_rb, uint32_t len);
|
|
int (*try_putc)(int pt, char ch);
|
|
int (*try_getc)(int pt);
|
|
int (*config)(int pt, int br, int d_len, int stop, int parity);
|
|
int (*get_int_status)(int pt);
|
|
int (*clear_int_status)(int pt, int msk);
|
|
int (*set_int)(int pt, int msk);
|
|
int (*clear_int)(int pt, int msk);
|
|
int (*flow_ctrl)(int pt, int fl, int thr);
|
|
int (*set_irda)(int pt, int tx_pin);
|
|
int (*threshold)(int pt, int type, int thr);
|
|
void (*reset_fifo)(int pt);
|
|
int (*rx_disable)(int pt, int rx_pin);
|
|
int (*rx_enable)(int pt, int rx_pin);
|
|
int (*tx_fifo_cnt)(int pt);
|
|
int (*rx_fifo_cnt)(int pt);
|
|
int (*set_brk)(int pt, int value);
|
|
int (*set_baud_rate)(int pt, int br);
|
|
int (*tx_disable)(int pt, int tx_pin);
|
|
int (*tx_enable)(int pt, int tx_pin);
|
|
int (*enable_rs485)(int pt);
|
|
int (*get_vector)(int pt);
|
|
int (*update_baudrate)(void);
|
|
}iot_uart_ctrl_t;
|
|
|
|
typedef struct {
|
|
unsigned used:1;
|
|
unsigned baudrate:31;
|
|
}uart_baudrate_info_t;
|
|
|
|
typedef enum {
|
|
UART_PT0 = 0,
|
|
UART_PT1,
|
|
UART_PT2,
|
|
UART_PT3,
|
|
UART_PT4,
|
|
UART_PT5,
|
|
UART_PT6,
|
|
UART_PT7,
|
|
UART_PT8,
|
|
|
|
UART_COUNT
|
|
} UART_PORT;
|
|
|
|
#define DEBUG_UART_PORT IOT_UART_PORT0
|
|
|
|
enum
|
|
{
|
|
UART_DATA_5_BITS = IOT_UART_DLEN_5_BITS,
|
|
UART_DATA_6_BITS = IOT_UART_DLEN_6_BITS,
|
|
UART_DATA_7_BITS = IOT_UART_DLEN_7_BITS,
|
|
UART_DATA_8_BITS = IOT_UART_DLEN_8_BITS
|
|
};
|
|
|
|
enum
|
|
{
|
|
UART_STOP_BITS_1 = IOT_UART_STOP_1_BITS,
|
|
UART_STOP_BITS_1_5 = IOT_UART_STOP_1_5_BITS,
|
|
UART_STOP_BITS_2 = IOT_UART_STOP_2_BITS
|
|
};
|
|
|
|
enum
|
|
{
|
|
UART_PARITY_DISABLE = IOT_UART_PARITY_NONE,
|
|
UART_PARITY_ODD = IOT_UART_PARITY_ODD,
|
|
UART_PARITY_EVEN = IOT_UART_PARITY_EVEN
|
|
};
|
|
|
|
/* RXFIFO_FULL_INT_ENA_MASK */
|
|
#define UART_RXI 0x01
|
|
/* TXFIFO_EMPTY_INT_ENA_MASK */
|
|
#define UART_TXI 0x02
|
|
/* RXFIFO_TOUT_INT_ENA_MASK */
|
|
#define UART_RTI 0x04
|
|
/* UART_TX_DONE */
|
|
#define UART_TX_DONE 0x08
|
|
/* RXFIFO_OVF_INT_ENA_MASK */
|
|
#define UART_OVR_FL 0x10
|
|
/* UART_RX_BRK */
|
|
#define UART_RX_BRK 0x20
|
|
/* UART_TX_BRK */
|
|
#define UART_TX_BRK 0x40
|
|
/* UART_RX_IDLE */
|
|
#define UART_RX_IDLE 0x80
|
|
|
|
#define UART_BANDRATE_AUTO 0
|
|
|
|
#define UART_BANDRATE_DEFAULT IOT_UART_BANDRATE_DEFAULT
|
|
|
|
/* The API table from HW level. HW will define all the APIs. */
|
|
extern struct uart_ctrl uart_e_ctrl;
|
|
|
|
/* The API table for HAL used finally. */
|
|
extern struct uart_ctrl g_uart_ctrl;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif //_UART_H
|