Skip to content
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

WIP: uart: Byteverlust bei der Übertragung #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define SINGLE_UART 1
#endif

#define RING_BUFFER_SIZE 64
#define RING_BUFFER_SIZE 128

#define MIN_U2X_BAUD (F_CPU/(16*(255 + 1)) + 1)

Expand Down Expand Up @@ -120,11 +120,12 @@ void uart_send_byte(uint8_t id, uint8_t data) {
#if SINGLE_UART
id = 0;
#endif
if (instances[id].ready) { // Can send directly
instances[id].ready = false;
if (instances[id].ready && (instances[id].head == instances[id].tail)) { // Can send directly
instances[id].ready = false;
*instances[id].udr = data;
} else if (instances[id].tail != instances[id].head
|| !instances[id].full) { // Not empty but needs to be added to queue
instances[id].ready = false; // Luca: indicate queue not empty
instances[id].data[instances[id].head] = data;
instances[id].head = (instances[id].head + 1) % RING_BUFFER_SIZE;
if (instances[id].tail == instances[id].head) {
Expand Down