furi-hal-vcp.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @file furi-hal-vcp.h
  3. * VCP HAL API
  4. */
  5. #pragma once
  6. #include <stdbool.h>
  7. #include <stdint.h>
  8. #include <string.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /** Init VCP HAL Allocates ring buffer and initializes state
  13. */
  14. void furi_hal_vcp_init();
  15. /** Recieve data from VCP Waits till some data arrives, never returns 0
  16. *
  17. * @param buffer pointer to buffer
  18. * @param size buffer size
  19. *
  20. * @return items copied in buffer, 0 if channel closed
  21. */
  22. size_t furi_hal_vcp_rx(uint8_t* buffer, size_t size);
  23. /** Recieve data from VCP with timeout Waits till some data arrives during
  24. * timeout
  25. *
  26. * @param buffer pointer to buffer
  27. * @param size buffer size
  28. * @param timeout rx timeout in ms
  29. *
  30. * @return items copied in buffer, 0 if channel closed or timeout occurs
  31. */
  32. size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout);
  33. /** Transmit data to VCP
  34. *
  35. * @param buffer pointer to buffer
  36. * @param size buffer size
  37. */
  38. void furi_hal_vcp_tx(const uint8_t* buffer, size_t size);
  39. #ifdef __cplusplus
  40. }
  41. #endif