From d8e8057a5794fb9a642657a4568f7f58db106e18 Mon Sep 17 00:00:00 2001 From: TravisRo Date: Mon, 20 Jun 2022 19:21:24 -0600 Subject: [PATCH] Add missing static inline class functions tud_ch341_read_char tud_ch341_write_char tud_ch341_write_str --- src/class/ch341/ch341_device.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/class/ch341/ch341_device.h b/src/class/ch341/ch341_device.h index 5d03a8be8..9ba74bbbb 100644 --- a/src/class/ch341/ch341_device.h +++ b/src/class/ch341/ch341_device.h @@ -91,6 +91,7 @@ uint32_t tud_ch341_available (void); uint32_t tud_ch341_read (void* buffer, uint32_t bufsize); // Read a byte, return -1 if there is none +static inline int32_t tud_ch341_read_char (void); // Clear the received FIFO @@ -103,9 +104,11 @@ bool tud_ch341_peek (uint8_t* ui8); uint32_t tud_ch341_write (void const* buffer, uint32_t bufsize); // Write a byte +static inline uint32_t tud_ch341_write_char (char ch); // Write a null-terminated string +static inline uint32_t tud_ch341_write_str (char const* str); // Force sending data if possible, return number of forced bytes @@ -148,6 +151,25 @@ TU_ATTR_WEAK void tud_ch341_line_coding_cb(ch341_line_coding_t const* p_line_cod // Invoked when received send break TU_ATTR_WEAK void tud_ch341_send_break_cb(bool is_break_active); +//--------------------------------------------------------------------+ +// Inline functions +//--------------------------------------------------------------------+ +static inline int32_t tud_ch341_read_char (void) +{ + uint8_t ch; + return tud_ch341_read(&ch, 1) ? (int32_t) ch : -1; +} + +static inline uint32_t tud_ch341_write_char (char ch) +{ + return tud_ch341_write((void const*)&ch, 1); +} + +static inline uint32_t tud_ch341_write_str (char const* str) +{ + return tud_ch341_write((uint8_t const*)str, strlen(str)); +} + /** @} */ /** @} */