HPM SDK
HPMicro Software Development Kit
hpm_uart_drv.h File Reference
#include "hpm_common.h"
#include "hpm_uart_regs.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

Data Structures

struct  uart_modem_config
 UART modem config. More...
 
struct  hpm_uart_rxline_idle_detect_config
 UART Idle config, suitable for RX and TX. More...
 
struct  hpm_uart_config
 UART config. More...
 
struct  uart_trig_config_t
 
struct  uart_fifo_ctrl_t
 

Typedefs

typedef enum parity parity_setting_t
 
typedef enum num_of_stop_bits num_of_stop_bits_t
 
typedef enum word_length word_length_t
 
typedef enum uart_fifo_trg_lvl uart_fifo_trg_lvl_t
 
typedef enum uart_signal uart_signal_t
 
typedef enum uart_signal_level uart_signal_level_t
 
typedef enum uart_modem_stat uart_modem_stat_t
 
typedef enum uart_intr_enable uart_intr_enable_t
 
typedef enum uart_intr_id uart_intr_id_t
 
typedef enum uart_stat uart_stat_t
 
typedef struct uart_modem_config uart_modem_config_t
 UART modem config. More...
 
typedef enum hpm_uart_rxline_idle_cond uart_rxline_idle_cond_t
 UART Idle detection conditions, suitable for RX and TX. More...
 
typedef struct hpm_uart_rxline_idle_detect_config uart_rxline_idle_config_t
 UART Idle config, suitable for RX and TX. More...
 
typedef struct hpm_uart_config uart_config_t
 UART config. More...
 

Enumerations

enum  { status_uart_no_suitable_baudrate_parameter_found = ((uint32_t)( status_group_uart )*1000U + (uint32_t)( 1 )) }
 UART status. More...
 
enum  parity {
  parity_none = 0 , parity_odd , parity_even , parity_always_1 ,
  parity_always_0
}
 
enum  num_of_stop_bits { stop_bits_1 = 0 , stop_bits_1_5 , stop_bits_2 }
 
enum  word_length { word_length_5_bits = 0 , word_length_6_bits , word_length_7_bits , word_length_8_bits }
 
enum  uart_fifo_trg_lvl {
  uart_fifo_1_byte = 0 , uart_fifo_2_bytes = 1 , uart_fifo_3_bytes = 2 , uart_fifo_4_bytes = 3 ,
  uart_fifo_5_bytes = 4 , uart_fifo_6_bytes = 5 , uart_fifo_7_bytes = 6 , uart_fifo_8_bytes = 7 ,
  uart_fifo_9_bytes = 8 , uart_fifo_10_bytes = 9 , uart_fifo_11_bytes = 10 , uart_fifo_12_bytes = 11 ,
  uart_fifo_13_bytes = 12 , uart_fifo_14_bytes = 13 , uart_fifo_15_bytes = 14 , uart_fifo_16_bytes = 15 ,
  uart_fifo_17_bytes = 16 , uart_fifo_18_bytes = 17 , uart_fifo_19_bytes = 18 , uart_fifo_20_bytes = 19 ,
  uart_fifo_21_bytes = 20 , uart_fifo_22_bytes = 21 , uart_fifo_23_bytes = 22 , uart_fifo_24_bytes = 23 ,
  uart_fifo_25_bytes = 24 , uart_fifo_26_bytes = 25 , uart_fifo_27_bytes = 26 , uart_fifo_28_bytes = 27 ,
  uart_fifo_29_bytes = 28 , uart_fifo_30_bytes = 29 , uart_fifo_31_bytes = 30 , uart_fifo_32_bytes = 31 ,
  uart_rx_fifo_trg_not_empty = uart_fifo_1_byte , uart_rx_fifo_trg_gt_one_quarter = (UART_SOC_FIFO_SIZE / 4) - 1 , uart_rx_fifo_trg_gt_half = (UART_SOC_FIFO_SIZE / 2) - 1 , uart_rx_fifo_trg_gt_three_quarters = ((UART_SOC_FIFO_SIZE * 3) / 4) - 1 ,
  uart_tx_fifo_trg_not_full = UART_SOC_FIFO_SIZE - 1 , uart_tx_fifo_trg_lt_three_quarters = ((UART_SOC_FIFO_SIZE * 3) / 4) - 1 , uart_tx_fifo_trg_lt_half = (UART_SOC_FIFO_SIZE / 2) - 1 , uart_tx_fifo_trg_lt_one_quarter = (UART_SOC_FIFO_SIZE / 4) - 1
}
 
enum  uart_signal { uart_signal_rts = UART_MCR_RTS_MASK }
 
enum  uart_signal_level { uart_signal_level_high , uart_signal_level_low }
 
enum  uart_modem_stat { uart_modem_stat_cts = UART_MSR_CTS_MASK , uart_modem_stat_dcts_changed = UART_MSR_DCTS_MASK }
 
enum  uart_intr_enable {
  uart_intr_rx_data_avail_or_timeout = UART_IER_ERBI_MASK , uart_intr_tx_slot_avail = UART_IER_ETHEI_MASK , uart_intr_rx_line_stat = UART_IER_ELSI_MASK , uart_intr_modem_stat = UART_IER_EMSI_MASK ,
  uart_intr_rx_line_idle = UART_IER_ERXIDLE_MASK , uart_intr_tx_line_idle = UART_IER_ETXIDLE_MASK , uart_intr_addr_match = UART_IER_EADDRM_MASK , uart_intr_addr_match_and_rxidle = UART_IER_EADDRM_IDLE_MASK ,
  uart_intr_addr_datalost = UART_IER_EDATLOST_MASK
}
 
enum  uart_intr_id {
  uart_intr_id_modem_stat = 0x0 , uart_intr_id_tx_slot_avail = 0x2 , uart_intr_id_rx_data_avail = 0x4 , uart_intr_id_rx_line_stat = 0x6 ,
  uart_intr_id_rx_timeout = 0xc
}
 
enum  uart_stat {
  uart_stat_data_ready = UART_LSR_DR_MASK , uart_stat_overrun_error = UART_LSR_OE_MASK , uart_stat_parity_error = UART_LSR_PE_MASK , uart_stat_framing_error = UART_LSR_FE_MASK ,
  uart_stat_line_break = UART_LSR_LBREAK_MASK , uart_stat_tx_slot_avail = UART_LSR_THRE_MASK , uart_stat_transmitter_empty = UART_LSR_TEMT_MASK , uart_stat_rx_fifo_error = UART_LSR_ERRF_MASK
}
 
enum  hpm_uart_rxline_idle_cond { uart_rxline_idle_cond_rxline_logic_one = 0 , uart_rxline_idle_cond_state_machine_idle = 1 }
 UART Idle detection conditions, suitable for RX and TX. More...
 

Functions

static uint8_t uart_get_fifo_size (UART_Type *ptr)
 Get fifo size. More...
 
void uart_config_fifo_ctrl (UART_Type *ptr, uart_fifo_ctrl_t *ctrl)
 uart config fifo control More...
 
static void uart_clear_rx_fifo (UART_Type *ptr)
 uart clear rx fifo by reading data More...
 
static void uart_enable_rx_function (UART_Type *ptr, bool enable)
 
static void uart_reset_tx_fifo (UART_Type *ptr)
 Reset TX Fifo. More...
 
static void uart_reset_rx_fifo (UART_Type *ptr)
 Reset RX Fifo. More...
 
static void uart_reset_all_fifo (UART_Type *ptr)
 [in] Reset both TX and RX Fifo More...
 
static void uart_modem_enable_loopback (UART_Type *ptr)
 Enable modem loopback. More...
 
static void uart_modem_disable_loopback (UART_Type *ptr)
 Disable modem loopback. More...
 
static void uart_modem_disable_auto_flow_control (UART_Type *ptr)
 Disable modem auto flow control. More...
 
static void uart_modem_enable_auto_flow_control (UART_Type *ptr)
 Enable modem auto flow control. More...
 
static void uart_modem_config (UART_Type *ptr, uart_modem_config_t *config)
 Configure modem. More...
 
static uint8_t uart_get_modem_status (UART_Type *ptr)
 Get modem status. More...
 
static void uart_write_byte (UART_Type *ptr, uint8_t c)
 Write byte to TX. More...
 
static uint8_t uart_read_byte (UART_Type *ptr)
 Read byte from RX. More...
 
static bool uart_check_modem_status (UART_Type *ptr, uart_modem_stat_t mask)
 Check modem status with given mask. More...
 
static void uart_disable_irq (UART_Type *ptr, uint32_t irq_mask)
 Disable IRQ with mask. More...
 
static void uart_enable_irq (UART_Type *ptr, uint32_t irq_mask)
 Enable IRQ with mask. More...
 
static uint32_t uart_get_enabled_irq (UART_Type *ptr)
 Get Enabled IRQ. More...
 
static uint8_t uart_get_irq_id (UART_Type *ptr)
 Get interrupt identification. More...
 
static void uart_enable_rxline_idle_detection (UART_Type *ptr)
 Enable UART RX Idle Line detection logic. More...
 
static void uart_disable_rxline_idle_detection (UART_Type *ptr)
 Disable UART RX Idle Line detection logic. More...
 
hpm_stat_t uart_init_rxline_idle_detection (UART_Type *ptr, uart_rxline_idle_config_t rxidle_config)
 Configure UART RX Line detection. More...
 
static bool uart_is_txline_idle (UART_Type *ptr)
 Determine whether UART TX Line is idle. More...
 
static void uart_clear_txline_idle_flag (UART_Type *ptr)
 Clear UART TX Line Idle Flag. More...
 
static bool uart_is_rxline_idle (UART_Type *ptr)
 Determine whether UART RX Line is idle. More...
 
static void uart_clear_rxline_idle_flag (UART_Type *ptr)
 Clear UART RX Line Idle Flag. More...
 
static void uart_enable_txline_idle_detection (UART_Type *ptr)
 Enable UART TX Idle Line detection logic. More...
 
static void uart_disable_txline_idle_detection (UART_Type *ptr)
 Disable UART TX Idle Line detection logic. More...
 
hpm_stat_t uart_init_txline_idle_detection (UART_Type *ptr, uart_rxline_idle_config_t txidle_config)
 Configure UART TX Line detection. More...
 
static uint32_t uart_get_status (UART_Type *ptr)
 Get status. More...
 
static bool uart_check_status (UART_Type *ptr, uart_stat_t mask)
 Check uart status according to the given status mask. More...
 
void uart_default_config (UART_Type *ptr, uart_config_t *config)
 Get default config. More...
 
hpm_stat_t uart_init (UART_Type *ptr, uart_config_t *config)
 Initialization. More...
 
hpm_stat_t uart_send_byte (UART_Type *ptr, uint8_t c)
 Send one byte after checking thresh hold status. More...
 
hpm_stat_t uart_receive_byte (UART_Type *ptr, uint8_t *c)
 Receive one byte after checking data ready status. More...
 
hpm_stat_t uart_try_receive_byte (UART_Type *ptr, uint8_t *c)
 Try to receive one byte without checking data ready status. More...
 
void uart_set_signal_level (UART_Type *ptr, uart_signal_t signal, uart_signal_level_t level)
 Set uart signal output level. More...
 
hpm_stat_t uart_flush (UART_Type *ptr)
 Flush sending buffer/fifo. More...
 
hpm_stat_t uart_receive_data (UART_Type *ptr, uint8_t *buf, uint32_t size_in_byte)
 Receive bytes blocking. More...
 
hpm_stat_t uart_send_data (UART_Type *ptr, uint8_t *buf, uint32_t size_in_byte)
 Send bytes blocking. More...
 
hpm_stat_t uart_set_baudrate (UART_Type *ptr, uint32_t baudrate, uint32_t src_clock_hz)
 Sets UART baudrate. More...
 
void uart_config_transfer_trig_mode (UART_Type *ptr, uart_trig_config_t *config)
 uart configure transfer trigger mode More...
 
static void uart_software_trig_transfer (UART_Type *ptr)
 uart software trigger transmit More...
 
static void uart_enable_hardware_trig_transfer (UART_Type *ptr, bool enable)
 uart enable hardware trigger mode More...
 
static uint8_t uart_get_data_count_in_rx_fifo (UART_Type *ptr)
 UART get data count in rx fifo. More...
 
static uint8_t uart_get_data_count_in_tx_fifo (UART_Type *ptr)
 UART get data count in tx fifo. More...
 
static void uart_enable_9bit_transmit_mode (UART_Type *ptr, bool enable)
 uart enable 9bit transmit mode More...
 
static void uart_enable_address0_match (UART_Type *ptr, uint8_t addr)
 uart enable address0 match More...
 
static void uart_enable_address1_match (UART_Type *ptr, uint8_t addr)
 uart enable address1 match More...
 
static void uart_disable_address0_match (UART_Type *ptr)
 uart disable address0 match More...
 
static void uart_disable_address1_match (UART_Type *ptr)
 uart disable address1 match More...
 
static void uart_disable_address_match (UART_Type *ptr)
 uart disable address match(address0 and address1) More...
 
static bool uart_is_addr_match (UART_Type *ptr)
 Determine whether address match for 9bit mode. More...
 
static void uart_clear_addr_match_flag (UART_Type *ptr)
 Clear UART address match Flag. More...
 
static bool uart_is_addr_match_and_rxidle (UART_Type *ptr)
 Determine whether address match and rx idle for 9bit mode. More...
 
static void uart_clear_addr_match_and_rxidle_flag (UART_Type *ptr)
 Clear UART address match and rxidle Flag. More...
 
static bool uart_is_data_lost (UART_Type *ptr)
 Determine whether data lost for 9bit mode. More...
 
static void uart_clear_data_lost_flag (UART_Type *ptr)
 Clear UART data lost Flag. More...
 
static void uart_modem_write_rts_pin (UART_Type *ptr, uint8_t high)
 Write RTS level for uart modem mode. More...