wip
This commit is contained in:
@@ -21,12 +21,15 @@ class SerialUSBHost {
|
||||
|
||||
public:
|
||||
SerialUSBHost() = delete;
|
||||
static void init();
|
||||
static void init(uint32_t baudrate, uint8_t stop_bits, uint8_t parity, uint8_t dataBits);
|
||||
|
||||
static void handle_event(const cdc_acm_host_dev_event_data_t *event, void *user_ctx);
|
||||
static bool handle_rx(const uint8_t *data, size_t data_len, void *arg);
|
||||
|
||||
static void takeSem();//XXX
|
||||
|
||||
static cdc_acm_host_device_config_t* getDevConfig();
|
||||
static cdc_acm_line_coding_t* getLineCoding();
|
||||
private:
|
||||
/**
|
||||
* @brief USB Host library handling task
|
||||
|
@@ -3,6 +3,19 @@
|
||||
|
||||
static SemaphoreHandle_t device_disconnected_sem;//XXX
|
||||
|
||||
|
||||
static cdc_acm_host_device_config_t dev_config = {
|
||||
.connection_timeout_ms = 5000, // 5 seconds, enough time to plug the device in or experiment with timeout
|
||||
.out_buffer_size = 512,
|
||||
.in_buffer_size = 512,
|
||||
.event_cb = SerialUSBHost::handle_event,
|
||||
.data_cb = SerialUSBHost::handle_rx,
|
||||
.user_arg = NULL,
|
||||
};
|
||||
|
||||
static cdc_acm_line_coding_t line_coding;
|
||||
|
||||
|
||||
static const char *TAG = "VCP example";
|
||||
|
||||
/**
|
||||
@@ -19,6 +32,7 @@ static const char *TAG = "VCP example";
|
||||
*/
|
||||
bool SerialUSBHost::handle_rx(const uint8_t *data, size_t data_len, void *arg)
|
||||
{
|
||||
//ESP_LOGI("USB_HANDLE", "Recivend data !!");
|
||||
printf("%.*s", data_len, data);
|
||||
return true;
|
||||
}
|
||||
@@ -65,7 +79,7 @@ void SerialUSBHost::usb_lib_task(void* arg) {
|
||||
}
|
||||
}
|
||||
|
||||
void SerialUSBHost::init() {
|
||||
void SerialUSBHost::init(uint32_t baudrate, uint8_t stop_bits, uint8_t parity, uint8_t dataBits) {
|
||||
const String TAG = "SerialUSBHost_constructor";
|
||||
device_disconnected_sem = xSemaphoreCreateBinary();
|
||||
assert(device_disconnected_sem);
|
||||
@@ -91,9 +105,21 @@ void SerialUSBHost::init() {
|
||||
esp_usb::VCP::register_driver<esp_usb::CP210x>();
|
||||
esp_usb::VCP::register_driver<esp_usb::CH34x>();
|
||||
|
||||
|
||||
line_coding.dwDTERate = baudrate;
|
||||
line_coding.bCharFormat = stop_bits;
|
||||
line_coding.bParityType = parity;
|
||||
line_coding.bDataBits = dataBits;
|
||||
}
|
||||
|
||||
|
||||
void SerialUSBHost::takeSem(){//XXX
|
||||
void SerialUSBHost::takeSem() {//XXX
|
||||
xSemaphoreTake(device_disconnected_sem, portMAX_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
cdc_acm_host_device_config_t* SerialUSBHost::getDevConfig() {
|
||||
return &dev_config;
|
||||
}
|
||||
|
||||
cdc_acm_line_coding_t* SerialUSBHost::getLineCoding() {
|
||||
return &line_coding;
|
||||
}
|
||||
|
Reference in New Issue
Block a user