EasyManua.ls Logo

Espressif Systems ESP8266EX - Hardware Overview; 2.1. Terminal Configuration and Functions

Espressif Systems ESP8266EX
41 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
!
3. Sample Codes
How to get the RSSI (Received Signal Strength Indicator) of an AP
How to read and write information from sectors on a flash memory
Examples of RTC
How to port apps from non-OS SDK to RTOS SDK
3.2.1. Initialization
1. The initialization of application programs can be implemented in user_main.c. The
function void󰲧user_init(void), which is the entry-point function, can be used by users
to implement the initialization process. It is suggested that the SDK’s version information
be printed, and the Wi-Fi working mode be set.
void󰲧user_init(void)
{
󰲧󰲧󰲧󰲧printf("SDK󰲧version:%s\n",󰲧system_get_sdk_version());
󰲧󰲧󰲧󰲧/*󰲧station󰲧+󰲧soft-AP󰲧mode󰲧*/
󰲧󰲧󰲧󰲧Wi-Fi_set_opmode(STATIONAP_MODE);
󰲧󰲧󰲧󰲧……
}
2. ESP8266_RTOS_SDK adopts UART0 to print debugging information by default, and the
baud rate is 74880 by default. UART initialization can be defined by users themselves in
user_init. Please refer to uart_init_new on how to implement this.
Sample of UART driver: \ESP8266_RTOS_SDK\driver_lib\driver\uart.c
Take the initialization of UART0 as an example. Configure the parameters of UART:
󰲧󰲧󰲧󰲧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);
Register the UART interrupt function and enable the UART interrupt:
󰲧󰲧󰲧󰲧UART_IntrConfTypeDef󰲧uart_intr;
󰲧󰲧󰲧󰲧uart_intr.UART_IntrEnMask󰲧=󰲧UART_RXFIFO_TOUT_INT_ENA󰲧|󰲧UART_FRM_ERR_INT_ENA󰲧|󰲧
UART_RXFIFO_FULL_INT_ENA󰲧|󰲧UART_TXFIFO_EMPTY_INT_ENA;
󰲧󰲧󰲧󰲧uart_intr.UART_RX_FifoFullIntrThresh󰲧=󰲧10;
󰲧󰲧󰲧󰲧uart_intr.UART_RX_TimeOutIntrThresh󰲧=󰲧2;
󰲧󰲧󰲧󰲧uart_intr.UART_TX_FifoEmptyIntrThresh󰲧=󰲧20;
󰲧󰲧󰲧󰲧UART_IntrConfig(UART0,󰲧&uart_intr);
Espressif
! /!5 37
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals