8000 uart: BW improvements by d-a-v · Pull Request #4620 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

uart: BW improvements #4620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e5c2fea
uart fixes and BW improvements
d-a-v Apr 4, 2018
f79bc90
uart: read_char straightly use hw buffer
d-a-v Apr 5, 2018
45e2bd5
+attributes for functions called by ISR
d-a-v Apr 5, 2018
974b758
uart: BW improvements
d-a-v Apr 4, 2018
3eb8c95
Merge branch 'master' into serialagain
devyte Apr 9, 2018
0aefb09
Merge branch 'master' into serialagain
devyte Jun 7, 2018
4c6bab4
Merge branch 'master' into serialagain
devyte Jul 3, 2018
3c1e312
Merge branch 'master' into serialagain
d-a-v Nov 30, 2018
132f7f3
Merge branch 'serialagain' of github.com:d-a-v/Arduino into serialagain
d-a-v Nov 30, 2018
6560ab8
fix merge
d-a-v Nov 30, 2018
ebdf57a
Merge branch 'master' into serialagain
d-a-v Dec 5, 2018
c68d474
fix buffer overflow
d-a-v Dec 5, 2018
ff63718
serial stress test sketch
d-a-v Dec 5, 2018
40f237f
astyle
d-a-v Dec 5, 2018
d6316aa
Merge branch 'serialagain' of github.com:d-a-v/Arduino into serialagain
d-a-v Dec 5, 2018
3428144
serial stress example: interactive keyboard, stop reading, overrun
d-a-v Dec 5, 2018
684879d
Merge branch 'master' into serialagain
d-a-v Dec 6, 2018
882989e
serial device test: bandwidth & overrun
d-a-v Dec 6, 2018
3ec2a60
update + HardwareSerial::hasError()
d-a-v Dec 6, 2018
a38f9d8
interactive overrun in example
d-a-v Dec 6, 2018
6b77715
astyle
d-a-v Dec 6, 2018
b639261
Test using @plerup's SoftwareSerial as submodule (tag 3.4.1)
d-a-v Dec 6, 2018
40d1237
update upstream ref (fix warning)
d-a-v Dec 6, 2018
64f7ac1
Merge branch 'master' into serialagain
d-a-v Dec 6, 2018
c48b54f
host mock uart/read(buf,size)
d-a-v Dec 6, 2018
18a189f
reset style changes in submodules before style diff
d-a-v Dec 7, 2018
ddcd908
Merge branch 'serialagain' of github.com:d-a-v/Arduino into serialagain
d-a-v Dec 7, 2018
48ad6bc
Merge branch 'master' into serialagain
earlephilhower Dec 7, 2018
0a7322f
Merge branch 'master' into serialagain
devyte Dec 8, 2018
fb25c8d
update build_boards_manager_package.sh for submodules
d-a-v Dec 8, 2018
8785e3a
Merge branch 'master' into serialagain
d-a-v Dec 8, 2018
e83316f
Merge branch 'master' into serialagain
devyte Dec 9, 2018
62ead27
Merge branch 'master' into serialagain
devyte Dec 9, 2018
c7eba46
Merge branch 'master' into serialagain
devyte Dec 10, 2018
cbd8b44
trigger CI (removing space)
d-a-v Dec 10, 2018
99fcfda
cannot reproduce locally the CI issue, setting bash -x option to get …
d-a-v Dec 10, 2018
6234fe0
remove previously added (in this PR) 'set -e' in package builder (pas…
d-a-v Dec 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix merge
  • Loading branch information
d-a-v committed Nov 30, 2018
commit 6560ab87f509fbeb6e1827aaed90f866ccde37d3
4 changes: 2 additions & 2 deletions cores/esp8266/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ class HardwareSerial: public Stream

int peek(void) override
{
// this may return -1, but that's okay
// return -1 when data is unvailable (arduino api)
return uart_peek_char(_uart);
}
int read(void) override
{
// this may return -1, but that's okay
// return -1 when data is unvailable (arduino api)
return uart_read_char(_uart);
}
size_t readBytes(char* buffer, size_t size) override
Expand Down
89 changes: 13 additions & 76 deletions cores/esp8266/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "user_interface.h"
#include "uart_register.h"

//const char overrun_str [] PROGMEM STORE_ATTR = "uart input full!\r\n";
const char overrun_str [] PROGMEM STORE_ATTR = "uart input full!\r\n";
static int s_uart_debug_nr = UART0;


Expand Down Expand Up @@ -111,11 +111,8 @@ uart_rx_available_unsafe(uart_t* uart)
return uart_rx_buffer_available_unsafe(uart->rx_buffer) + uart_rx_fifo_available(uart->uart_nr);
}

<<<<<<< HEAD
=======
//#define UART_DISCARD_NEWEST

>>>>>>> 3c1e312faff1669b62cfd47bee6edaea49785aa5
// Copy all the rx fifo bytes that fit into the rx buffer
// called by ISR
inline void ICACHE_RAM_ATTR
Expand All @@ -127,26 +124,32 @@ uart_rx_copy_fifo_to_buffer_unsafe(uart_t* uart)
{
size_t nextPos = (rx_buffer->wpos + 1) % rx_buffer->size;
if(nextPos == rx_buffer->rpos)
<<<<<<< HEAD
=======
{
uart->overrun = true;
if (!uart->overrun)
{
uart->overrun = true;
os_printf_plus(overrun_str);
}

// a choice has to be made here,
// do we discard newest or oldest data?
#ifdef UART_DISCARD_NEWEST
// discard newest data
// Stop copying if rx buffer is full
USF(uart->uart_nr);
>>>>>>> 3c1e312faff1669b62cfd47bee6edaea49785aa5
break;
#else
// discard oldest data
if (++rx_buffer->rpos == rx_buffer->size)
rx_buffer->rpos = 0;
#endif
}
uint8_t data = USF(uart->uart_nr);
rx_buffer->buffer[rx_buffer->wpos] = data;
rx_buffer->wpos = nextPos;
}
}


inline int
uart_peek_char_unsafe(uart_t* uart)
{
Expand All @@ -161,27 +164,6 @@ uart_peek_char_unsafe(uart_t* uart)
return uart->rx_buffer->buffer[uart->rx_buffer->rpos];
}

<<<<<<< HEAD
#if 0

inline int
=======
// taking data straight from hw fifo: loopback-test BW jumps by 19%
inline int
>>>>>>> 3c1e312faff1669b62cfd47bee6edaea49785aa5
uart_read_char_unsafe(uart_t* uart)
{
if (uart_rx_buffer_available_unsafe(uart->rx_buffer))
{
// take oldest sw data
int ret = uart->rx_buffer->buffer[uart->rx_buffer->rpos];
uart->rx_buffer->rpos = (uart->rx_buffer->rpos + 1) % uart->rx_buffer->size;
return ret;
}

<<<<<<< HEAD
#else

// taking data straight from hw fifo: loopback-test BW jumps by 19%
inline int
uart_read_char_unsafe(uart_t* uart)
Expand All @@ -193,33 +175,11 @@ uart_read_char_unsafe(uart_t* uart)
uart->rx_buffer->rpos = (uart->rx_buffer->rpos + 1) % uart->rx_buffer->size;
return ret;
}
=======
if (uart_rx_fifo_available(uart->uart_nr))
{
// no sw data, take from hw fifo
return USF(uart->uart_nr);
}

// unavailable
return -1;
}
>>>>>>> 3c1e312faff1669b62cfd47bee6edaea49785aa5

if (uart_rx_fifo_available(uart->uart_nr))
{
// no sw data, take from hw fifo
return USF(uart->uart_nr);
}

// unavailable
return -1;
return -3;
}

#endif
/**********************************************************/



size_t
uart_rx_available(uart_t* uart)
{
Expand Down Expand Up @@ -257,12 +217,6 @@ uart_read_char(uart_t* uart)
return data;
}

<<<<<<< HEAD
extern void iprint (int x);
extern void sprint (const char* s);

=======
>>>>>>> 3c1e312faff1669b62cfd47bee6edaea49785aa5
// loopback-test BW jumps by 190%
size_t
uart_read(uart_t* uart, char* userbuffer, size_t usersize)
Expand All @@ -281,11 +235,7 @@ uart_read(uart_t* uart, char* userbuffer, size_t usersize)
while (ret < usersize && uart_rx_fifo_available(uart->uart_nr))
userbuffer[ret++] = USF(uart->uart_nr);

<<<<<<< HEAD
// no more sw/hw data available
=======
// no more sw/hw data available
>>>>>>> 3c1e312faff1669b62cfd47bee6edaea49785aa5
break;
}

Expand Down Expand Up @@ -375,7 +325,6 @@ uart_start_isr(uart_t* uart)
// triggers the IRS very often. A value of 127 would not leave much time
// for ISR to clear fifo before the next byte is dropped. So pick a value
// in the middle.
<<<<<<< HEAD
// update: loopback test @ 3Mbauds/8n1 (=2343Kibits/s):
// - 4..120 give 2300Kibits/s
// - 1, 2, 3 are below
Expand All @@ -387,18 +336,6 @@ uart_start_isr(uart_t* uart)
USIC(uart->uart_nr) = 0xffff;
//was: USIE(uart->uart_nr) = (1 << UIFF) | (1 << UIFR) | (1 << UITO);
USIE(uart->uart_nr) = (1 << UIFF) | (1 << UIOF);
=======
// update: with direct peeking and loopback test @ 3Mbauds/8n1 (=2343Kibits/s):
// when high, allows to directly peek into hw buffer, avoiding two copies
// - 4..120 give 2300Kibits/s
// - 1, 2, 3 are below
// - far below 2000 without direct peeking
#define INTRIGGER 100

USC1(uart->uart_nr) = (INTRIGGER << UCFFT);
USIC(uart->uart_nr) = 0xffff;
USIE(uart->uart_nr) = (1 << UIFF);
>>>>>>> 3c1e312faff1669b62cfd47bee6edaea49785aa5
ETS_UART_INTR_ATTACH(uart_isr, (void *)uart);
ETS_UART_INTR_ENABLE();
}
Expand Down
0