Statistics: Posted by Pato — Tue Jul 24, 2018 5:46 pm
fifo_len = (READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT;
Code:
#include "ets_sys.h"
#include "osapi.h"
#include "os_type.h"
#include "user_interface.h" // Provide init_done_cb()
#include "espconn.h" // Provides the UDP/TCP functions
#include "../esp-open-sdk/sdk/driver_lib/include/driver/uart.h"
static os_timer_t readUartTimer_st;
/**
* Callback called on each tick of the timer, for the moment just to print the number of bytes available...
*/
void ReadUartTimerCb(void)
{
uint8 fifo_len;
fifo_len = (READ_PERI_REG(UART_STATUS(UART0)) >> UART_RXFIFO_CNT_S) & UART_RXFIFO_CNT;
os_printf("UART0: len = %d \n", fifo_len);
}
/**
* Callback called when the ESP is fully initialized.
*/
void PostInitCb(void)
{
// Hello
gpio_init();
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0);
GPIO_OUTPUT_SET(GPIO_ID_PIN(0u), 0);
// Setting up UART0
uart_init(BIT_RATE_9600, BIT_RATE_9600);
os_timer_disarm(&readUartTimer_st);
os_timer_setfn(&readUartTimer_st, (os_timer_func_t *) ReadUartTimerCb, NULL);
os_timer_arm(&readUartTimer_st, 100, true);
}
/**
* Main entry point of our programm
*/
void user_init()
{
system_init_done_cb(PostInitCb);
}
Statistics: Posted by Pato — Tue Jul 24, 2018 1:04 am