From 76ca382f003a17fd4d30cf0a851f42b1af014d0f Mon Sep 17 00:00:00 2001
From: Sandeep Mistry <s.mistry@arduino.cc>
Date: Fri, 3 Jun 2016 09:28:09 -0400
Subject: [PATCH] Add Uart::availableForWrite()

---
 cores/arduino/Uart.cpp | 5 +++++
 cores/arduino/Uart.h   | 1 +
 2 files changed, 6 insertions(+)

diff --git a/cores/arduino/Uart.cpp b/cores/arduino/Uart.cpp
index 7a718e2c..13e0ebaa 100644
--- a/cores/arduino/Uart.cpp
+++ b/cores/arduino/Uart.cpp
@@ -77,6 +77,11 @@ int Uart::available()
   return rxBuffer.available();
 }
 
+int Uart::availableForWrite()
+{
+  return (sercom->isDataRegisterEmptyUART() ? 1 : 0);
+}
+
 int Uart::peek()
 {
   return rxBuffer.peek();
diff --git a/cores/arduino/Uart.h b/cores/arduino/Uart.h
index 7115da74..02d30bd4 100644
--- a/cores/arduino/Uart.h
+++ b/cores/arduino/Uart.h
@@ -32,6 +32,7 @@ class Uart : public HardwareSerial
     void begin(unsigned long baudrate, uint16_t config);
     void end();
     int available();
+    int availableForWrite();
     int peek();
     int read();
     void flush();
-- 
GitLab