usb_console.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdbool.h>
  8. #include <stddef.h>
  9. #include <stdint.h>
  10. #include "esp_err.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /**
  15. * @file usb_console.h
  16. * This file contains definitions of low-level USB console functions.
  17. * These functions are not considered to be a public interface and
  18. * should not be called by applications directly.
  19. * Application interface to the USB console is provided either by
  20. * "cdcacm" VFS driver, or by the USB CDC driver in TinyUSB.
  21. */
  22. /**
  23. * RX/TX callback function type
  24. * @param arg callback-specific context pointer
  25. */
  26. typedef void (*esp_usb_console_cb_t)(void* arg);
  27. /**
  28. * Initialize USB console output using ROM USB CDC driver.
  29. * This function is called by the early startup code if USB CDC is
  30. * selected as the console output option.
  31. * @return
  32. * - ESP_OK on success
  33. * - ESP_ERR_NO_MEM
  34. * - other error codes from the interrupt allocator
  35. */
  36. esp_err_t esp_usb_console_init(void);
  37. /**
  38. * Write a buffer to USB CDC
  39. * @param buf data to write
  40. * @param size size of the data, in bytes
  41. * @return -1 on error, otherwise the number of bytes
  42. */
  43. ssize_t esp_usb_console_write_buf(const char* buf, size_t size);
  44. ssize_t esp_usb_console_flush(void);
  45. ssize_t esp_usb_console_read_buf(char* buf, size_t buf_size);
  46. ssize_t esp_usb_console_available_for_read(void);
  47. bool esp_usb_console_write_available(void);
  48. esp_err_t esp_usb_console_set_cb(esp_usb_console_cb_t rx_cb, esp_usb_console_cb_t tx_cb, void* arg);
  49. #ifdef __cplusplus
  50. }
  51. #endif