furi_hal_vcp.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /** Disable VCP to make CDC interface usable by other application
  16. */
  17. void furi_hal_vcp_disable();
  18. /** Enable VCP
  19. */
  20. void furi_hal_vcp_enable();
  21. /** Recieve data from VCP Waits till some data arrives, never returns 0
  22. *
  23. * @param buffer pointer to buffer
  24. * @param size buffer size
  25. *
  26. * @return items copied in buffer, 0 if channel closed
  27. */
  28. size_t furi_hal_vcp_rx(uint8_t* buffer, size_t size);
  29. /** Recieve data from VCP with timeout Waits till some data arrives during
  30. * timeout
  31. *
  32. * @param buffer pointer to buffer
  33. * @param size buffer size
  34. * @param timeout rx timeout in ms
  35. *
  36. * @return items copied in buffer, 0 if channel closed or timeout occurs
  37. */
  38. size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout);
  39. /** Transmit data to VCP
  40. *
  41. * @param buffer pointer to buffer
  42. * @param size buffer size
  43. */
  44. void furi_hal_vcp_tx(const uint8_t* buffer, size_t size);
  45. /** Check whether VCP is connected
  46. *
  47. * @return true if connected
  48. */
  49. bool furi_hal_vcp_is_connected(void);
  50. #ifdef __cplusplus
  51. }
  52. #endif