44c30b170754b2e8583815187d2fb9937ff8c15e
 .../components/drivers_nrf/uart/nrf_drv_uart.c     |  9 +++++--
 .../components/drivers_nrf/uart/nrf_drv_uart.h     | 16 +++++++++---
 .../components/libraries/uart/app_uart_fifo.c      | 30 ++++++++++++++--------
 3 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.c b/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.c
index 31c3e45..e992bd5 100755
--- a/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.c
+++ b/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.c
@@ -352,8 +352,8 @@ ret_code_t nrf_drv_uart_tx(uint8_t const * const p_data, uint8_t length)
             return NRF_ERROR_INVALID_ADDR;
         }
     )
-    
-    if (m_cb.tx_buffer_length != 0)
+
+    if (nrf_drv_uart_tx_in_progress())
     {
         return NRF_ERROR_BUSY;
     }
@@ -371,6 +371,11 @@ ret_code_t nrf_drv_uart_tx(uint8_t const * const p_data, uint8_t length)
     )
 }
 
+bool nrf_drv_uart_tx_in_progress(void)
+{
+    return (m_cb.tx_buffer_length != 0);
+}
+
 #if defined(UART_IN_USE)
 __STATIC_INLINE void rx_enable(void)
 {
diff --git a/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.h b/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.h
index 58e26da..53c9498 100755
--- a/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.h
+++ b/Nordic/nrf51/components/drivers_nrf/uart/nrf_drv_uart.h
@@ -155,18 +155,18 @@ void nrf_drv_uart_uninit(void);
 /**
  * @brief Function for getting the address of a specific UART task.
  *
- * @param[in]  task Task.
+ * @param[in] task Task.
  *
- * @retval     Task address.
+ * @return    Task address.
  */
 __STATIC_INLINE uint32_t nrf_drv_uart_task_address_get(nrf_uart_task_t task);
 
 /**
  * @brief Function for getting the address of a specific UART event.
  *
- * @param[in]  event Event.
+ * @param[in] event Event.
  *
- * @retval     Event address.
+ * @return    Event address.
  */
 __STATIC_INLINE uint32_t nrf_drv_uart_event_address_get(nrf_uart_event_t event);
 
@@ -195,6 +195,14 @@ __STATIC_INLINE uint32_t nrf_drv_uart_event_address_get(nrf_uart_event_t event);
 ret_code_t nrf_drv_uart_tx(uint8_t const * const p_data, uint8_t length);
 
 /**
+ * @brief Function for checking if UART is currently transmitting.
+ *
+ * @retval true  If UART is transmitting.
+ * @retval false If UART is not transmitting.
+ */
+bool nrf_drv_uart_tx_in_progress(void);
+
+/**
  * @brief Function for aborting any ongoing transmission.
  * @note @ref NRF_DRV_UART_EVT_TX_DONE event will be generated in non-blocking mode. Event will
  *       contain number of bytes sent until abort was called. If Easy DMA is not used event will be
diff --git a/Nordic/nrf51/components/libraries/uart/app_uart_fifo.c b/Nordic/nrf51/components/libraries/uart/app_uart_fifo.c
index 651da997..e35f0df 100644
--- a/Nordic/nrf51/components/libraries/uart/app_uart_fifo.c
+++ b/Nordic/nrf51/components/libraries/uart/app_uart_fifo.c
@@ -27,7 +27,6 @@ static __INLINE uint32_t fifo_length(app_fifo_t * const fifo)
 
 static app_uart_event_handler_t   m_event_handler;            /**< Event handler function. */
 static uint8_t tx_buffer[1];
-static uint8_t tx_tmp;
 static uint8_t rx_buffer[1];
 
 static app_fifo_t                  m_rx_fifo;                               /**< RX FIFO buffer for storing data received on the UART until the application fetches them using app_uart_get(). */
@@ -59,14 +58,14 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context)
         }
         if (FIFO_LENGTH(m_rx_fifo) <= m_rx_fifo.buf_size_mask)
         {
-            (void)nrf_drv_uart_rx(rx_buffer,1);
+            (void)nrf_drv_uart_rx(rx_buffer, 1);
         }
     }
     else if (p_event->type == NRF_DRV_UART_EVT_ERROR)
     {
         app_uart_event.evt_type                 = APP_UART_COMMUNICATION_ERROR;
         app_uart_event.data.error_communication = p_event->data.error.error_mask;
-        (void)nrf_drv_uart_rx(rx_buffer,1);
+        (void)nrf_drv_uart_rx(rx_buffer, 1);
         m_event_handler(&app_uart_event);
     }
     else if (p_event->type == NRF_DRV_UART_EVT_TX_DONE)
@@ -74,12 +73,11 @@ static void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context)
         // Get next byte from FIFO.
         if (app_fifo_get(&m_tx_fifo, tx_buffer) == NRF_SUCCESS)
         {
-            (void)nrf_drv_uart_tx(tx_buffer,1);
+            (void)nrf_drv_uart_tx(tx_buffer, 1);
         }
         if (FIFO_LENGTH(m_tx_fifo) == 0)
         {
             // Last byte from FIFO transmitted, notify the application.
-            // Notify that new data is available if this was first byte put in the buffer.
             app_uart_event.evt_type = APP_UART_TX_EMPTY;
             m_event_handler(&app_uart_event);
         }
@@ -163,12 +161,24 @@ uint32_t app_uart_put(uint8_t byte)
 {
     uint32_t err_code;
 
-    tx_tmp = byte;
-    err_code = nrf_drv_uart_tx(&tx_tmp, 1);
-
-    if (err_code == NRF_ERROR_BUSY)
+    err_code = app_fifo_put(&m_tx_fifo, byte);
+    if (err_code == NRF_SUCCESS)
     {
-        err_code = app_fifo_put(&m_tx_fifo, byte);
+        // The new byte has been added to FIFO. It will be picked up from there
+        // (in 'uart_event_handler') when all preceding bytes are transmitted.
+        // But if UART is not transmitting anything at the moment, we must start
+        // a new transmission here.
+        if (!nrf_drv_uart_tx_in_progress())
+        {
+            // This operation should be almost always successful, since we've
+            // just added a byte to FIFO, but if some bigger delay occurred
+            // (some heavy interrupt handler routine has been executed) since
+            // that time, FIFO might be empty already.
+            if (app_fifo_get(&m_tx_fifo, tx_buffer) == NRF_SUCCESS)
+            {
+                err_code = nrf_drv_uart_tx(tx_buffer, 1);
+            }
+        }
     }
 
     return err_code;
