mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-05 21:00:04 +00:00
feat(uart): move periph_ll_uart_enabled to uart_ll.h
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "soc/uart_reg.h"
|
||||
@@ -56,6 +57,26 @@ typedef enum {
|
||||
UART_INTR_CMD_CHAR_DET = (0x1<<18),
|
||||
} uart_intr_t;
|
||||
|
||||
/**
|
||||
* @brief Check if UART is enabled or disabled.
|
||||
*
|
||||
* @param uart_num UART port number, the max port number is (UART_NUM_MAX -1).
|
||||
*
|
||||
* @return true: enabled; false: disabled
|
||||
*/
|
||||
FORCE_INLINE_ATTR bool uart_ll_is_enabled(uint32_t uart_num)
|
||||
{
|
||||
HAL_ASSERT(uart_num < SOC_UART_HP_NUM);
|
||||
uint32_t uart_rst_bit = ((uart_num == 0) ? DPORT_UART_RST :
|
||||
(uart_num == 1) ? DPORT_UART1_RST :
|
||||
(uart_num == 2) ? DPORT_UART2_RST : 0);
|
||||
uint32_t uart_en_bit = ((uart_num == 0) ? DPORT_UART_CLK_EN :
|
||||
(uart_num == 1) ? DPORT_UART1_CLK_EN :
|
||||
(uart_num == 2) ? DPORT_UART2_CLK_EN : 0);
|
||||
return DPORT_REG_GET_BIT(DPORT_PERIP_RST_EN_REG, uart_rst_bit) == 0 &&
|
||||
DPORT_REG_GET_BIT(DPORT_PERIP_CLK_EN_REG, uart_en_bit) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable the bus clock for uart
|
||||
* @param uart_num UART port number, the max port number is (UART_NUM_MAX -1).
|
||||
|
Reference in New Issue
Block a user