ESP8266-SDK-串口开发求助

2019-12-13 18:28发布

SDK版本:esp8266_nonos_sdk_v1.5.4
1、system_uart_swap()函数要放到什么地方才能屏蔽上电打印呢?
2、使用UART1打印日志,将官网的程序复制过来,总是出现错误。
官网程序:
void ICACHE_FLASH_ATTR uart_init_new(void)
{
          // Wait for FIFOs to be emptied
            UART_WaitTxFifoEmpty(UART0);
            UART_WaitTxFifoEmpty(UART1);
            // Configure UART settings
            UART_ConfigTypeDef uart_config;
            uart_config.baud_rate  = BIT_RATE_74880;
            uart_config.data_bits   = UART_WordLength_8b;
            uart_config.parity     = USART_Parity_None;
            uart_config.stop_bits   = USART_StopBits_1
            uart_config.flow_ctrl   = USART_HardwareFlowControl_None;
            uart_config.UART_RxFlowThresh = 120;
            uart_config.UART_InverseMask = UART_None_Inverse;
            UART_ParamConfig(UART0, &uart_config);
            UART_IntrConfTypeDef uart_intr;
            uart_intr.UART_IntrEnMask = UART_RXFIFO_TOUT_INT_ENA | UART_FRM_ERR_INT_ENA | UART_RXFIFO_FULL_INT_ENA;
            uart_intr.UART_RX_FifoFullIntrThresh = 100;
            uart_intr.UART_RX_TimeOutIntrThresh = 2;
            uart_intr.UART_TX_FifoEmptyIntrThresh = 20;
            UART_IntrConfig(UART0, &uart_intr);
            // Set UART1 for printing
            UART_SetPrintPort(UART1);
            // Register interrupt handler
            UART_intr_handler_register(uart0_rx_intr_handler);
            ETS_UART_INTR_ENABLE();

错误:
user_main.c: In function 'uart_init_new':
user_main.c:38:13: error: unknown type name 'UART_ConfigTypeDef'
             UART_ConfigTypeDef uart_config;
             ^
user_main.c:39:24: error: request for member 'baud_rate' in something not a structure or union
             uart_config.baud_rate  = BIT_RATE_74880;
                        ^
user_main.c:40:24: error: request for member 'data_bits' in something not a structure or union
             uart_config.data_bits   = UART_WordLength_8b;
                        ^
user_main.c:40:39: error: 'UART_WordLength_8b' undeclared (first use in this function)
             uart_config.data_bits   = UART_WordLength_8b;
                                       ^
user_main.c:40:39: note: each undeclared identifier is reported only once for each function it appears in
user_main.c:41:24: error: request for member 'parity' in something not a structure or union
             uart_config.parity     = USART_Parity_None;
                        ^
user_main.c:41:38: error: 'USART_Parity_None' undeclared (first use in this function)
             uart_config.parity     = USART_Parity_None;
                                      ^
user_main.c:42:24: error: request for member 'stop_bits' in something not a structure or union
             uart_config.stop_bits   = USART_StopBits_1
                        ^
user_main.c:42:39: error: 'USART_StopBits_1' undeclared (first use in this function)
             uart_config.stop_bits   = USART_StopBits_1
                                       ^
user_main.c:43:13: error: expected ';' before 'uart_config'
             uart_config.flow_ctrl   = USART_HardwareFlowControl_None;
             ^
user_main.c:44:24: error: request for member 'UART_RxFlowThresh' in something not a structure or union
             uart_config.UART_RxFlowThresh = 120;
                        ^
user_main.c:45:24: error: request for member 'UART_InverseMask' in something not a structure or union
             uart_config.UART_InverseMask = UART_None_Inverse;
                        ^
user_main.c:47:13: error: unknown type name 'UART_IntrConfTypeDef'
             UART_IntrConfTypeDef uart_intr;
             ^
user_main.c:48:22: error: request for member 'UART_IntrEnMask' in something not a structure or union
             uart_intr.UART_IntrEnMask = UART_RXFIFO_TOUT_INT_ENA | UART_FRM_ERR_INT_ENA | UART_RXFIFO_FULL_INT_ENA;
                      ^
user_main.c:49:22: error: request for member 'UART_RX_FifoFullIntrThresh' in something not a structure or union
             uart_intr.UART_RX_FifoFullIntrThresh = 100;
                      ^
user_main.c:50:22: error: request for member 'UART_RX_TimeOutIntrThresh' in something not a structure or union
             uart_intr.UART_RX_TimeOutIntrThresh = 2;
                      ^
user_main.c:51:22: error: request for member 'UART_TX_FifoEmptyIntrThresh' in something not a structure or union
             uart_intr.UART_TX_FifoEmptyIntrThresh = 20;
                      ^
user_main.c:56:40: error: 'uart0_rx_intr_handler' undeclared (first use in this function)
             UART_intr_handler_register(uart0_rx_intr_handler);

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
8条回答
caoxuedong
1楼-- · 2019-12-14 12:26
 精彩回答 2  元偷偷看……
cumthe
2楼-- · 2019-12-14 14:33
laujc 发表于 2019-2-18 14:56
乐鑫官网有的。。。。
https://www.espressif.com/zh-hans/products/hardware/esp8266ex/resources

收到。多谢

一周热门 更多>