It has multiple interface so that we can transfer wifi data to spi, uart, i2c ,i2s,infrared remote ,even sdio(more complicated).
This is a example for this kind of application to turn wifi command into uart serial.
The realization is very simple, that esp8266 works in softap mode , smart phone connect to the softap and send udp command to a certain port.
Then send the corresponding uart command to the driver mcu.
Move ! Make your own project !
UART CONFIG:
Code: Select all
WRITE_PERI_REG(UART_CONF0(uart_no), UART_PARITY_EN
| UART_TXD_INV //the mcu receive a inversed uart signal
| UART_RXD_INV //the mcu send a inversed uart signal
| EVEN_BITS
|( ONE_STOP_BIT << UART_STOP_BIT_NUM_S)
| (EIGHT_BITS << UART_BIT_NUM_S));
//clear rx and tx fifo,not ready
SET_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST);
CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_RXFIFO_RST | UART_TXFIFO_RST);
//set rx fifo trigger
WRITE_PERI_REG(UART_CONF1(uart_no), (50 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S
| (0x10 & UART_RX_TOUT_THRHD) << UART_RX_TOUT_THRHD_S
| UART_RX_TOUT_EN);
//clear all interrupt
WRITE_PERI_REG(UART_INT_CLR(uart_no), 0xffff);
//enable rx_interrupt
//CLEAR_PERI_REG_MASK(UART_INT_ENA(uart_no), 0x1ff);
SET_PERI_REG_MASK(UART_INT_ENA(uart_no),UART_RXFIFO_TOUT_INT_ENA);//UART_RXFIFO_FULL_INT_ENA);
UDP INIT:
Code: Select all
LOCAL struct espconn ptrespconn;
ptrespconn.type = ESPCONN_UDP;
ptrespconn.proto.udp = (esp_udp *)os_zalloc(sizeof(esp_udp));
ptrespconn.proto.udp->local_port = 1025;
espconn_regist_recvcb(&ptrespconn, user_devicefind_recv);
espconn_create(&ptrespconn);