WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
hal_uart_v151.c 文件参考
#include "chip_io.h"
#include "soc_osal.h"
#include "platform_types.h"
#include "hal_uart.h"
#include "hal_uart_v151_regs_def.h"
#include "hal_uart_v151_regs_op.h"
#include "tcxo.h"
#include "log_printf.h"
hal_uart_v151.c 的引用(Include)关系图:

宏定义

#define hal_uart_get_high_8bit(val)   ((val) >> 8)
 
#define hal_uart_get_low_8bit(val)   ((val) & 0xff)
 
#define round_off(val)   ((uint32_t)((val) + 1 / 2))
 
#define HAL_UART_FIFO_DEPTH_SHIFT_2   2
 
#define HAL_UART_FIFO_DEPTH_MINUS_2   2
 
#define HAL_UART_FIFO_DEPTH_MULTIPLE   16
 
#define HAL_UART_BARD_LEFT_SHIFT_2   2
 
#define HAL_UART_BARD_LEFT_SHIFT_6   6
 
#define HAL_UART_INIT_DELAY_10US   10
 
#define IBRD_NEED_BAUD_OFFSET_NUM   4
 
#define REMAINDER_NEED_BAUD_OFFSET_NUM   4
 
#define HAL_UART_GET_BAUD_RATE_SHIFT   8
 
#define HAL_UART_FORCE_TX_ISR_FLAG   0x01
 
#define HAL_UART_FORCE_IDLE_ISR_FLAG   0x02
 
#define hal_uart_print_err(log_id, fmt, count, args...)    BASE_PRINT_ERR(CONNECT(LOG_BCORE_PLT_DRIVER_UART, log_id), fmt, count, ##args)
 
#define hal_uart_print_info(log_id, fmt, count, args...)    BASE_PRINT_INFO(CONNECT(LOG_BCORE_PLT_DRIVER_UART, log_id), fmt, count, ##args)
 

枚举

enum  hal_uart_fifo_int_lvl_t {
  HAL_UART_RX_FIFO_AVAILABLE_LEVEL_EQ_1 = 0 , HAL_UART_TX_FIFO_EMPTY_LEVEL_EQ_0 = 0 , HAL_UART_RX_FIFO_AVAILABLE_LEVEL_1_4 = 1 , HAL_UART_TX_FIFO_EMPTY_LEVEL_EQ_2 = 1 ,
  HAL_UART_RX_FIFO_AVAILABLE_LEVEL_1_2 = 2 , HAL_UART_TX_FIFO_EMPTY_LEVEL_1_4 = 2 , HAL_UART_RX_FIFO_AVAILABLE_LEVEL_LESS_2 = 3 , HAL_UART_TX_FIFO_EMPTY_LEVEL_1_2 = 3
}
 

函数

void hal_uart_init_fifo (uart_bus_t uart, hal_uart_fifo_int_lvl_t rx_level, hal_uart_fifo_int_lvl_t tx_level)
 Sets the FIFO interrupt leves for receiving and transmitting.
 
void hal_uart_set_data_bits (uart_bus_t uart, hal_uart_data_bit_t bits)
 Sets the data bits to use in the uart.
 
void hal_uart_set_ptim_en (uart_bus_t uart, bool value)
 UART TX interrupt and DMA request signal trigger by TX fifo level.
 
void hal_uart_auto_flow_ctl_en (uart_bus_t bus, hal_uart_auto_flow_ctl_t auto_flow)
 
void hal_uart_set_fifo_en (uart_bus_t uart, hal_uart_fifo_t fifo)
 Sets FIFO enabled or not.
 
uint16_t hal_uart_get_fifo_depth (uart_bus_t uart)
 
uint16_t hal_uart_get_rx_fifo_level (uart_bus_t uart)
 Obtains the RX FIFO trigger level in bytes, as configured by hal_uart_init_fifo
 
volatile uint32_t * hal_uart_get_data_register (uart_bus_t uart)
 Returns a pointer to the data register to write or read from.
 
uint32_t hal_uart_get_error_status (uart_bus_t uart)
 Returns a pointer to the error register to read from.
 
bool hal_uart_get_error_status_parity (uart_bus_t uart)
 Get the parity error status
 
bool hal_uart_get_error_status_fram (uart_bus_t uart)
 Get the frame error status
 
bool hal_uart_get_error_status_break (uart_bus_t uart)
 Get the break error status
 
bool hal_uart_get_error_status_overrun (uart_bus_t uart)
 Get the overrun error status
 
void hal_uart_set_baud_rate (uart_bus_t uart, uint32_t baud, uint32_t uart_clk)
 Sets the baud rate.
 
uint32_t hal_uart_get_baud_rate (uart_bus_t uart, uint32_t uart_clk)
 Reads the baud rate back from the registers
 
void hal_uart_set_stop_bits (uart_bus_t uart, hal_uart_stop_bit_t bits)
 Sets the data bits to use in the uart.
 
void hal_uart_set_parity (uart_bus_t uart, hal_uart_parity_t parity)
 Sets the parity bits to use in the uart.
 
void hal_uart_enable_interrupt (uart_bus_t uart, hal_uart_interrupt_t interrupt_type, bool val)
 Enables the uart interrupt type specified
 
void hal_uart_clear_interrupt (uart_bus_t uart, hal_uart_interrupt_t interrupt_type)
 Clears the uart interrupt type specified.
 
void hal_uart_disable_uart (uart_bus_t uart)
 Disables the uart.
 
bool hal_uart_is_rx_fifo_full (uart_bus_t uart)
 
uint32_t hal_uart_get_fifo_status (uart_bus_t uart)
 Returns the raw fifo status of the uart.
 
void hal_uart_force_tx_isr (uart_bus_t uart)
 Forces the pending excecution of the tx isr in an interrupt context.
 
void hal_uart_force_idle_isr (uart_bus_t uart)
 Forces the pending excecution of the idle isr in an interrupt context.
 
void hal_uart_check_en (uart_bus_t uart, bool val)
 Enable/disable uart parity check.
 
void hal_uart_parity_en (uart_bus_t uart, hal_uart_parity_t val)
 Select uart odd/even parity check.
 
void hal_uart_sir_mode_en (uart_bus_t uart, bool val)
 Enable/disable uart sir mode.
 
void hal_uart_tx_pause_en (uart_bus_t uart, bool val)
 Enable/disable uart tx pause.
 
void hal_uart_set_baud_div (uart_bus_t uart, uint8_t val)
 Sets the sample baud rate to use in the uart.
 
uint32_t hal_uart_get_baud_div (uart_bus_t uart)
 Returns the sample baud rate of the uart.
 
void hal_uart_irq_handler (uart_bus_t uart)
 UART中断处理函数
 
void hal_uart_uartifls_set_rxiflsel (uart_bus_t bus, uint32_t val)
 
void hal_uart_int_set (uart_bus_t bus, uint32_t reg, uint32_t int_id, uint32_t val)
 
hal_uart_funcs_thal_uart_v151_funcs_get (void)
 

变量

uart_reg_tg_hal_uart_reg [UART_BUS_MAX_NUMBER]
 
hal_uart_fifo_int_lvl_t g_hal_uart_rx_fifo_level [UART_BUS_MAX_NUMBER]
 
hal_uart_fifo_int_lvl_t g_hal_uart_tx_fifo_level [UART_BUS_MAX_NUMBER]
 
volatile uint32_t g_test_uart_write = 1
 

宏定义说明

◆ HAL_UART_BARD_LEFT_SHIFT_2

#define HAL_UART_BARD_LEFT_SHIFT_2   2

◆ HAL_UART_BARD_LEFT_SHIFT_6

#define HAL_UART_BARD_LEFT_SHIFT_6   6

◆ HAL_UART_FIFO_DEPTH_MINUS_2

#define HAL_UART_FIFO_DEPTH_MINUS_2   2

◆ HAL_UART_FIFO_DEPTH_MULTIPLE

#define HAL_UART_FIFO_DEPTH_MULTIPLE   16

◆ HAL_UART_FIFO_DEPTH_SHIFT_2

#define HAL_UART_FIFO_DEPTH_SHIFT_2   2

◆ HAL_UART_FORCE_IDLE_ISR_FLAG

#define HAL_UART_FORCE_IDLE_ISR_FLAG   0x02

◆ HAL_UART_FORCE_TX_ISR_FLAG

#define HAL_UART_FORCE_TX_ISR_FLAG   0x01

◆ HAL_UART_GET_BAUD_RATE_SHIFT

#define HAL_UART_GET_BAUD_RATE_SHIFT   8

◆ hal_uart_get_high_8bit

#define hal_uart_get_high_8bit (   val)    ((val) >> 8)

◆ hal_uart_get_low_8bit

#define hal_uart_get_low_8bit (   val)    ((val) & 0xff)

◆ HAL_UART_INIT_DELAY_10US

#define HAL_UART_INIT_DELAY_10US   10

◆ hal_uart_print_err

#define hal_uart_print_err (   log_id,
  fmt,
  count,
  args... 
)     BASE_PRINT_ERR(CONNECT(LOG_BCORE_PLT_DRIVER_UART, log_id), fmt, count, ##args)

◆ hal_uart_print_info

#define hal_uart_print_info (   log_id,
  fmt,
  count,
  args... 
)     BASE_PRINT_INFO(CONNECT(LOG_BCORE_PLT_DRIVER_UART, log_id), fmt, count, ##args)

◆ IBRD_NEED_BAUD_OFFSET_NUM

#define IBRD_NEED_BAUD_OFFSET_NUM   4

◆ REMAINDER_NEED_BAUD_OFFSET_NUM

#define REMAINDER_NEED_BAUD_OFFSET_NUM   4

◆ round_off

#define round_off (   val)    ((uint32_t)((val) + 1 / 2))

枚举类型说明

◆ hal_uart_fifo_int_lvl_t

Uart FIFO Level

枚举值
HAL_UART_RX_FIFO_AVAILABLE_LEVEL_EQ_1 
HAL_UART_TX_FIFO_EMPTY_LEVEL_EQ_0 
HAL_UART_RX_FIFO_AVAILABLE_LEVEL_1_4 
HAL_UART_TX_FIFO_EMPTY_LEVEL_EQ_2 
HAL_UART_RX_FIFO_AVAILABLE_LEVEL_1_2 
HAL_UART_TX_FIFO_EMPTY_LEVEL_1_4 
HAL_UART_RX_FIFO_AVAILABLE_LEVEL_LESS_2 
HAL_UART_TX_FIFO_EMPTY_LEVEL_1_2 

函数说明

◆ hal_uart_auto_flow_ctl_en()

void hal_uart_auto_flow_ctl_en ( uart_bus_t  bus,
hal_uart_auto_flow_ctl_t  auto_flow 
)

◆ hal_uart_get_fifo_depth()

uint16_t hal_uart_get_fifo_depth ( uart_bus_t  uart)

◆ hal_uart_init_fifo()

void hal_uart_init_fifo ( uart_bus_t  uart,
hal_uart_fifo_int_lvl_t  rx_level,
hal_uart_fifo_int_lvl_t  tx_level 
)

Sets the FIFO interrupt leves for receiving and transmitting.

参数
uartUart bus.
rx_levelLevel at which the receive interrupt interrupt will be triggered.
tx_levelLevel at which the transmit interrupt interrupt will be triggered.

◆ hal_uart_is_rx_fifo_full()

bool hal_uart_is_rx_fifo_full ( uart_bus_t  uart)

◆ hal_uart_set_ptim_en()

void hal_uart_set_ptim_en ( uart_bus_t  uart,
bool  value 
)

UART TX interrupt and DMA request signal trigger by TX fifo level.

参数
uartUart bus.
valueProgrammable the interrupt mode enable or disable

变量说明

◆ g_hal_uart_rx_fifo_level

hal_uart_fifo_int_lvl_t g_hal_uart_rx_fifo_level[UART_BUS_MAX_NUMBER]

◆ g_hal_uart_tx_fifo_level

hal_uart_fifo_int_lvl_t g_hal_uart_tx_fifo_level[UART_BUS_MAX_NUMBER]

◆ g_test_uart_write

volatile uint32_t g_test_uart_write = 1