-->
Page 1 of 1

Uart driver with transmit buffer & interrupt

PostPosted: Tue Feb 17, 2015 3:25 am
by tve
Does anyone have some code to buffer uart output (TX) and send characters to the uart using an interrupt? The driver in the AT demo only uses interrupt for RX. Thanks!

Re: Uart driver with transmit buffer & interrupt

PostPosted: Tue Feb 17, 2015 4:06 am
by igrr
I'm using TX interrupts in my code, take a look: https://gist.github.com/igrr/5c93c37e8f062e544ed7
It's not a self-contained driver, as it depends on a circular buffer class and some task switching functions (yield()), but you should be able to adapt it to your use case by writing proper _tx_empty_irq, _rx_complete_irq, write, and read functions.
The key insight here is to disable TX_FIFO_EMPTY interrupt whenever you don't have any more data to put into the FIFO.

Re: Uart driver with transmit buffer & interrupt

PostPosted: Tue Feb 17, 2015 2:26 pm
by tve
Cool, thank you!

Re: Uart driver with transmit buffer & interrupt /esp8266-br

PostPosted: Wed Feb 25, 2015 4:18 pm
by hreintke
@tve
I looked at your code in esp8266-bridge as I am also working(learning) with FREERTOS.
I want to make a telnet connection to the esp8266, and when that is enabled forward all the "printf output" to that connection instead of the uart0.
When trying and reading about options and possibilities I read that the lwip is not thread safe and so all communication should take place in the same thread. I sometimes see unclear behaviour in my working environment but that also may be caused by other issues.
However, in your bridge, you use separate recv and transmit tasks, both with netconn and raw tcp.

- Did you notice any "thread-safe" issues when running ?
- You made both a netconn and rawIP version. Does any of the two have a preference ?

Kind regards,
Herman

PS : Thanks also for the better uart.c you posted on bbs.espreesif.com