api-hal-vcp.h 654 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. /**
  9. * Init VCP HAL
  10. * Allocates ring buffer and initializes state
  11. */
  12. void api_hal_vcp_init();
  13. /**
  14. * Recieve data from VCP
  15. * Waits till some data arrives, never returns 0
  16. * @param buffer - pointer to buffer
  17. * @param size - buffer size
  18. * @return items copied in buffer, 0 if channel closed
  19. */
  20. size_t api_hal_vcp_rx(uint8_t* buffer, size_t size);
  21. /**
  22. * Transmit data to VCP
  23. * @param buffer - pointer to buffer
  24. * @param size - buffer size
  25. */
  26. void api_hal_vcp_tx(const uint8_t* buffer, size_t size);
  27. #ifdef __cplusplus
  28. }
  29. #endif