- ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
- if (tx_head == tx_tail) {
- UCSR0B |= _BV(TXCIE0); // enable xmit complete irq
- UCSR0B &= ~_BV(UDRIE0);
- tx_tail = tx_head = 0;
- } else {
- UDR0 = txbuf[tx_tail];
- tx_tail = bufptr_inc(tx_tail);
- }
+ if (tx_ptr+1 >= buf_len) {
+ UCSR0B |= _BV(TXCIE0); // enable xmit complete irq
+ UCSR0B &= ~_BV(UDRIE0); // disable ourselves
+ } else {
+ UDR0 = buffer[tx_ptr++];