mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 17:47:04 +08:00
fix(esp8266): fix UART output error when start up
Add UART system API to flush UART and wait until all characters are sent.
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/uart.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_phy_init.h"
|
||||
@ -69,6 +70,11 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibrat
|
||||
esp_err_t status = ESP_OK;
|
||||
uint8_t sta_mac[6];
|
||||
uint8_t *local_init_data = calloc(1, 256);
|
||||
#ifdef CONFIG_CONSOLE_UART_BAUDRATE
|
||||
const uint32_t uart_baudrate = CONFIG_CONSOLE_UART_BAUDRATE;
|
||||
#else
|
||||
const uint32_t uart_baudrate = 74880; // ROM default baudrate
|
||||
#endif
|
||||
|
||||
memcpy(local_init_data, init_data->params, 128);
|
||||
|
||||
@ -85,6 +91,16 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibrat
|
||||
|
||||
esp_efuse_mac_get_default(sta_mac);
|
||||
|
||||
/**
|
||||
* The API "register_chipv6_phy" will modify the APB frequency to 80MHz,
|
||||
* so UARTs must be flush here, then reconfigurate the UART frequency dividor
|
||||
*/
|
||||
uart_tx_wait_idle(0);
|
||||
uart_div_modify(0, UART_CLK_FREQ / uart_baudrate);
|
||||
|
||||
uart_tx_wait_idle(1);
|
||||
uart_div_modify(1, UART_CLK_FREQ / uart_baudrate);
|
||||
|
||||
int ret = register_chipv6_phy(local_init_data);
|
||||
if (ret) {
|
||||
ESP_LOGI(TAG, "phy register error, ret:%d", ret);
|
||||
|
Reference in New Issue
Block a user