2021-10-03 13:36:05 +03:00
|
|
|
/**
|
2022-01-05 19:10:18 +03:00
|
|
|
* @file furi_hal_vcp.h
|
2021-10-03 13:36:05 +03:00
|
|
|
* VCP HAL API
|
|
|
|
*/
|
|
|
|
|
2020-11-16 13:16:34 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2020-12-02 13:47:13 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Init VCP HAL Allocates ring buffer and initializes state
|
2020-11-16 13:16:34 +03:00
|
|
|
*/
|
2021-08-08 21:03:25 +03:00
|
|
|
void furi_hal_vcp_init();
|
2020-11-16 13:16:34 +03:00
|
|
|
|
2021-10-21 21:12:20 +03:00
|
|
|
/** Disable VCP to make CDC interface usable by other application
|
|
|
|
*/
|
|
|
|
void furi_hal_vcp_disable();
|
|
|
|
|
|
|
|
/** Enable VCP
|
|
|
|
*/
|
|
|
|
void furi_hal_vcp_enable();
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Recieve data from VCP Waits till some data arrives, never returns 0
|
|
|
|
*
|
|
|
|
* @param buffer pointer to buffer
|
|
|
|
* @param size buffer size
|
|
|
|
*
|
|
|
|
* @return items copied in buffer, 0 if channel closed
|
2020-11-16 13:16:34 +03:00
|
|
|
*/
|
2021-08-08 21:03:25 +03:00
|
|
|
size_t furi_hal_vcp_rx(uint8_t* buffer, size_t size);
|
2020-11-16 13:16:34 +03:00
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Recieve data from VCP with timeout Waits till some data arrives during
|
|
|
|
* timeout
|
|
|
|
*
|
|
|
|
* @param buffer pointer to buffer
|
|
|
|
* @param size buffer size
|
|
|
|
* @param timeout rx timeout in ms
|
|
|
|
*
|
|
|
|
* @return items copied in buffer, 0 if channel closed or timeout occurs
|
2021-04-19 19:36:45 +03:00
|
|
|
*/
|
2021-08-08 21:03:25 +03:00
|
|
|
size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout);
|
2021-04-19 19:36:45 +03:00
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Transmit data to VCP
|
|
|
|
*
|
|
|
|
* @param buffer pointer to buffer
|
|
|
|
* @param size buffer size
|
2020-11-16 13:16:34 +03:00
|
|
|
*/
|
2021-08-08 21:03:25 +03:00
|
|
|
void furi_hal_vcp_tx(const uint8_t* buffer, size_t size);
|
2020-12-02 13:47:13 +03:00
|
|
|
|
2021-10-26 20:05:28 +04:00
|
|
|
/** Check whether VCP is connected
|
|
|
|
*
|
|
|
|
* @return true if connected
|
|
|
|
*/
|
|
|
|
bool furi_hal_vcp_is_connected(void);
|
|
|
|
|
2020-12-02 13:47:13 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|