@@ -241,6 +241,15 @@ static inline unsigned char uart_poll_out(struct device *dev,
241241/**
242242 * @brief Fill FIFO with data.
243243 *
244+ * @details This function is expected to be called from UART
245+ * interrupt handler (ISR), if uart_irq_tx_ready() returns true.
246+ * Result of calling this function not from an ISR is undefined
247+ * (hardware-dependent). Likewise, *not* calling this function
248+ * from an ISR if uart_irq_tx_ready() returns true may lead to
249+ * undefined behavior, e.g. infinite interrupt loops. It's
250+ * mandatory to test return value of this function, as different
251+ * hardware has different FIFO depth (oftentimes just 1).
252+ *
244253 * @param dev UART device structure.
245254 * @param tx_data Data to transmit.
246255 * @param size Number of bytes to send.
@@ -262,6 +271,16 @@ static inline int uart_fifo_fill(struct device *dev, const u8_t *tx_data,
262271/**
263272 * @brief Read data from FIFO.
264273 *
274+ * @details This function is expected to be called from UART
275+ * interrupt handler (ISR), if uart_irq_rx_ready() returns true.
276+ * Result of calling this function not from an ISR is undefined
277+ * (hardware-dependent). It's unspecified whether "RX ready"
278+ * condition as returned by uart_irq_rx_ready() is level- or
279+ * edge- triggered. That means that once uart_irq_rx_ready() is
280+ * detected, uart_fifo_read() must be called until it reads all
281+ * available data in the FIFO (i.e. until it returns less data
282+ * than was requested).
283+ *
265284 * @param dev UART device structure.
266285 * @param rx_data Data container.
267286 * @param size Container size.
@@ -406,16 +425,21 @@ static inline int __deprecated uart_irq_tx_empty(struct device *dev)
406425}
407426
408427/**
409- * @brief Check if UART RX buffer has a new char
428+ * @brief Check if UART RX buffer has a received char
410429 *
430+ * @details Check if UART RX buffer has at least one pending character
411431 * (i.e. uart_fifo_read() will succeed and return non-zero). This function
412432 * must be called in a UART interrupt handler, or its result is undefined.
413433 * Before calling this function in the interrupt handler, uart_irq_update()
414- * must be called once per the handler invocation.
434+ * must be called once per the handler invocation. It's unspecified whether
435+ * condition as returned by this function is level- or edge- triggered (i.e.
436+ * if this function returns true when RX FIFO is non-empty, or when a new
437+ * char was received since last call to it). See description of
438+ * uart_fifo_read() for implication of this.
415439 *
416440 * @param dev UART device structure.
417441 *
418- * @retval 1 If a new received char is ready.
442+ * @retval 1 If a received char is ready.
419443 * @retval 0 Otherwise.
420444 */
421445static inline int uart_irq_rx_ready (struct device * dev )
0 commit comments