@@ -241,6 +241,15 @@ static inline unsigned char uart_poll_out(struct device *dev,
241
241
/**
242
242
* @brief Fill FIFO with data.
243
243
*
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
+ *
244
253
* @param dev UART device structure.
245
254
* @param tx_data Data to transmit.
246
255
* @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,
262
271
/**
263
272
* @brief Read data from FIFO.
264
273
*
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
+ *
265
284
* @param dev UART device structure.
266
285
* @param rx_data Data container.
267
286
* @param size Container size.
@@ -406,16 +425,21 @@ static inline int __deprecated uart_irq_tx_empty(struct device *dev)
406
425
}
407
426
408
427
/**
409
- * @brief Check if UART RX buffer has a new char
428
+ * @brief Check if UART RX buffer has a received char
410
429
*
430
+ * @details Check if UART RX buffer has at least one pending character
411
431
* (i.e. uart_fifo_read() will succeed and return non-zero). This function
412
432
* must be called in a UART interrupt handler, or its result is undefined.
413
433
* 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.
415
439
*
416
440
* @param dev UART device structure.
417
441
*
418
- * @retval 1 If a new received char is ready.
442
+ * @retval 1 If a received char is ready.
419
443
* @retval 0 Otherwise.
420
444
*/
421
445
static inline int uart_irq_rx_ready (struct device * dev )
0 commit comments