Skip to content

Commit

Permalink
uart tx ready fix; check if queue empty before immediate write to reg…
Browse files Browse the repository at this point in the history
…ister
  • Loading branch information
swappad committed May 14, 2021
1 parent a3075b3 commit 8bed903
Showing 1 changed file with 4 additions and 3 deletions.
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; // Luca: indicate queue not empty

This comment has been minimized.

Copy link
@aul12

aul12 May 16, 2021

Member

@swappad wieso ist das jetzt auskommentiert?

This comment has been minimized.

Copy link
@swappad

swappad May 19, 2021

Author Collaborator

Das sollte nicht auskommentiert sein. Ich dachte, dass das .ready nur zeigt, ob die Queue leer ist. Stimmt aber nicht

*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

0 comments on commit 8bed903

Please sign in to comment.