57 lines
1.5 KiB
C
57 lines
1.5 KiB
C
#ifndef DRV_UART_
|
|
#define DRV_UART_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "kit_macro.h"
|
|
|
|
typedef enum
|
|
{
|
|
kUartDev_1,
|
|
kUartDev_2,
|
|
kUartDev_3,
|
|
kUartDev_4,
|
|
kUartDev_5,
|
|
kUartDev_6,
|
|
#if defined(STM32F429_439xx)
|
|
kUartDev_7,
|
|
#endif
|
|
kUartDev_End,
|
|
}UartDev;
|
|
|
|
|
|
typedef enum
|
|
{
|
|
kUartInterrupt_Rx = 0,
|
|
kUartInterrupt_Tx,
|
|
kUartInterrupt_End,
|
|
}UartInterrupt;
|
|
|
|
|
|
#define UART_CFG_DATA_LEN_8_BIT (0x0000u)
|
|
#define UART_CFG_DATA_LEN_9_BIT (0x0001u)
|
|
#define UART_CFG_PARITY_NONE (0x0000u) //无校验
|
|
#define UART_CFG_PARITY_EVEN (0x0004u) //偶校验
|
|
#define UART_CFG_PARITY_ODD (0x0006u) //奇校验
|
|
#define UART_CFG_STOP_BIT_1 (0x0000u)
|
|
#define UART_CFG_STOP_BIT_0_5 (0x0008u)
|
|
#define UART_CFG_STOP_BIT_2 (0x0010u)
|
|
#define UART_CFG_STOP_BIT_1_5 (0x0018u)
|
|
|
|
kit_ret_e drv_uart_init(UartDev dev, uint32_t baudrate, uint32_t uart_config, uint8_t tx_io, uint8_t rx_io);
|
|
kit_ret_e drv_uart_set_dma(UartDev dev, bool is_rx_en, bool is_tx_en);
|
|
|
|
kit_ret_e drv_uart_dma_async_send(UartDev dev, uint8_t *buf, uint16_t len);
|
|
kit_ret_e drv_uart_int_async_send(UartDev dev, uint8_t *buf, uint16_t len);
|
|
kit_ret_e drv_uart_series_sync_send(UartDev dev, uint8_t *buf, uint16_t len);
|
|
void drv_uart_ctrl_interrupt(UartDev dev, UartInterrupt it_type, bool is_enable);
|
|
kit_ret_e drv_uart_set_interrupt(UartDev dev, UartInterrupt it_type, uint16_t priority, KitIrqCall call);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|