void user_init(void) { ETS_UART_INTR_DISABLE(); UART_SetBaudrate(UART0, BIT_RATE_9600); UART_ResetFifo(UART0); UART_SetBaudrate(UART1, BIT_RATE_115200); UART_ResetFifo(UART1); flash_param_init(); flash_param = flash_param_get(); emsRxBuf = allocateRcvMsgBuff(); uart_init(BIT_RATE_9600, BIT_RATE_115200); rtc_clock_calibration = system_rtc_clock_cali_proc(); // get RTC clock period os_printf("rtc_clock_calibration: %0x\n", rtc_clock_calibration >>12 ); os_printf("system_get_rtc_time: %d\n", system_get_rtc_time()); os_printf("system_get_time: %d\n", system_get_time()); serverInit(flash_param->port); wifi_set_sleep_type(LIGHT_SLEEP_T); system_os_task(recvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen); ETS_UART_INTR_ENABLE(); }
void UART_ParamConfig(UART_Port uart_no, UART_ConfigTypeDef *pUARTConfig) { if (uart_no == UART1) { PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_U1TXD_BK); } else { PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD); PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD); } UART_SetFlowCtrl(uart_no, pUARTConfig->flow_ctrl, pUARTConfig->UART_RxFlowThresh); UART_SetBaudrate(uart_no, pUARTConfig->baud_rate); WRITE_PERI_REG(UART_CONF0(uart_no), ((pUARTConfig->parity == USART_Parity_None) ? 0x0 : (UART_PARITY_EN | pUARTConfig->parity)) | (pUARTConfig->stop_bits << UART_STOP_BIT_NUM_S) | (pUARTConfig->data_bits << UART_BIT_NUM_S) | ((pUARTConfig->flow_ctrl & USART_HardwareFlowControl_CTS) ? UART_TX_FLOW_EN : 0x0) | pUARTConfig->UART_InverseMask); UART_ResetFifo(uart_no); }