39 lines
958 B
C++
39 lines
958 B
C++
//
|
|
// Created by nano on 8/23/26.
|
|
//
|
|
|
|
#include "usb_serial.h"
|
|
|
|
#include "esp_log.h"
|
|
#include "portmacro.h"
|
|
#include "driver/usb_serial_jtag.h"
|
|
|
|
|
|
void usb_serial::init() {
|
|
usb_serial_jtag_driver_config_t usb_serial_jtag_config = {
|
|
.tx_buffer_size = USB_BUFFER_SIZE,
|
|
.rx_buffer_size = USB_BUFFER_SIZE,
|
|
};
|
|
ESP_ERROR_CHECK(usb_serial_jtag_driver_install(&usb_serial_jtag_config));
|
|
ESP_LOGI("usb_serial", "USB_SERIAL_JTAG init done");
|
|
|
|
}
|
|
|
|
void usb_serial::write(const char* byte, int len) {
|
|
usb_serial_jtag_write_bytes(byte,len,20/ portTICK_PERIOD_MS);
|
|
}
|
|
|
|
int usb_serial::read(char* byte,int len) {
|
|
int read_length = usb_serial_jtag_read_bytes(byte, len, 20/ portTICK_PERIOD_MS);
|
|
return read_length;
|
|
}
|
|
|
|
|
|
void usb_serial::write_byte(char* byte) {
|
|
usb_serial_jtag_write_bytes(byte,1,20/ portTICK_PERIOD_MS);
|
|
}
|
|
|
|
int usb_serial::read_byte(char* byte) {
|
|
int read_length = usb_serial_jtag_read_bytes(byte, 1, 20/ portTICK_PERIOD_MS);
|
|
return read_length;
|
|
} |