mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-23 17:42:22 +00:00
fix number of endpoint for ch340x, also open notification even not used for now
This commit is contained in:
parent
e2aa671346
commit
07e3d5c691
@ -512,8 +512,7 @@ bool tuh_cdc_set_baudrate(uint8_t idx, uint32_t baudrate, tuh_xfer_cb_t complete
|
||||
}
|
||||
}
|
||||
|
||||
bool tuh_cdc_set_line_coding(uint8_t idx, cdc_line_coding_t const* line_coding, tuh_xfer_cb_t complete_cb, uintptr_t user_data)
|
||||
{
|
||||
bool tuh_cdc_set_line_coding(uint8_t idx, cdc_line_coding_t const* line_coding, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
|
||||
cdch_interface_t* p_cdc = get_itf(idx);
|
||||
// only ACM support this set line coding request
|
||||
TU_VERIFY(p_cdc && p_cdc->serial_drid == SERIAL_DRIVER_ACM);
|
||||
@ -711,7 +710,6 @@ static bool acm_open(uint8_t daddr, tusb_desc_interface_t const* itf_desc, uint1
|
||||
|
||||
cdch_interface_t* p_cdc = make_new_itf(daddr, itf_desc);
|
||||
TU_VERIFY(p_cdc);
|
||||
|
||||
p_cdc->serial_drid = SERIAL_DRIVER_ACM;
|
||||
|
||||
//------------- Control Interface -------------//
|
||||
@ -881,7 +879,6 @@ static bool ftdi_open(uint8_t daddr, const tusb_desc_interface_t *itf_desc, uint
|
||||
TU_VERIFY(p_cdc);
|
||||
|
||||
TU_LOG_DRV("FTDI opened\r\n");
|
||||
|
||||
p_cdc->serial_drid = SERIAL_DRIVER_FTDI;
|
||||
|
||||
// endpoint pair
|
||||
@ -921,8 +918,7 @@ static bool ftdi_sio_reset(cdch_interface_t* p_cdc, tuh_xfer_cb_t complete_cb, u
|
||||
return ftdi_sio_set_request(p_cdc, FTDI_SIO_RESET, FTDI_SIO_RESET_SIO, complete_cb, user_data);
|
||||
}
|
||||
|
||||
static bool
|
||||
ftdi_sio_set_modem_ctrl(cdch_interface_t* p_cdc, uint16_t line_state, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
|
||||
static bool ftdi_sio_set_modem_ctrl(cdch_interface_t* p_cdc, uint16_t line_state, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
|
||||
TU_LOG_DRV("CDC FTDI Set Control Line State\r\n");
|
||||
p_cdc->user_control_cb = complete_cb;
|
||||
TU_ASSERT(ftdi_sio_set_request(p_cdc, FTDI_SIO_MODEM_CTRL, 0x0300 | line_state,
|
||||
@ -1172,9 +1168,9 @@ enum {
|
||||
};
|
||||
|
||||
static bool ch34x_open(uint8_t daddr, tusb_desc_interface_t const* itf_desc, uint16_t max_len) {
|
||||
// CH34x Interface includes 1 vendor interface + 3 bulk endpoints
|
||||
// CH34x Interface includes 1 vendor interface + 2 bulk + 1 interrupt endpoints
|
||||
TU_VERIFY (itf_desc->bNumEndpoints == 3);
|
||||
TU_VERIFY ( sizeof ( tusb_desc_interface_t ) + 2 * sizeof ( tusb_desc_endpoint_t ) <= max_len );
|
||||
TU_VERIFY (sizeof(tusb_desc_interface_t) + 3 * sizeof(tusb_desc_endpoint_t) <= max_len);
|
||||
|
||||
cdch_interface_t* p_cdc = make_new_itf(daddr, itf_desc);
|
||||
TU_VERIFY (p_cdc);
|
||||
@ -1182,15 +1178,23 @@ static bool ch34x_open ( uint8_t daddr, tusb_desc_interface_t const *itf_desc, u
|
||||
TU_LOG_DRV ("CH34x opened\r\n");
|
||||
p_cdc->serial_drid = SERIAL_DRIVER_CH34X;
|
||||
|
||||
// endpoint pair
|
||||
tusb_desc_endpoint_t const* desc_ep = (tusb_desc_endpoint_t const*) tu_desc_next(itf_desc);
|
||||
|
||||
// data endpoints expected to be in pairs
|
||||
return open_ep_stream_pair ( p_cdc, desc_ep );
|
||||
TU_ASSERT(open_ep_stream_pair(p_cdc, desc_ep));
|
||||
desc_ep += 2;
|
||||
|
||||
// Interrupt endpoint: not used for now
|
||||
TU_ASSERT(TUSB_DESC_ENDPOINT == tu_desc_type(desc_ep) &&
|
||||
TUSB_XFER_INTERRUPT == desc_ep->bmAttributes.xfer);
|
||||
TU_ASSERT(tuh_edpt_open(daddr, desc_ep));
|
||||
p_cdc->ep_notif = desc_ep->bEndpointAddress;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ch34x_set_request ( cdch_interface_t* p_cdc, uint8_t direction, uint8_t request, uint16_t value, uint16_t index, uint8_t* buffer, uint16_t length, tuh_xfer_cb_t complete_cb, uintptr_t user_data )
|
||||
{
|
||||
static bool ch34x_set_request(cdch_interface_t* p_cdc, uint8_t direction, uint8_t request, uint16_t value,
|
||||
uint16_t index, uint8_t* buffer, uint16_t length, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
|
||||
tusb_control_request_t const request_setup = {
|
||||
.bmRequestType_bit = {
|
||||
.recipient = TUSB_REQ_RCPT_DEVICE,
|
||||
@ -1222,7 +1226,6 @@ static bool ch34x_set_request ( cdch_interface_t* p_cdc, uint8_t direction, uint
|
||||
};
|
||||
|
||||
return tuh_control_xfer(&xfer);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ch341_control_out ( cdch_interface_t* p_cdc, uint8_t request, uint16_t value, uint16_t index, tuh_xfer_cb_t complete_cb, uintptr_t user_data ) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2023 Heiko Kuester (tinyusb.org)
|
||||
* Copyright (c) 2023 Heiko Kuester
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -34,6 +34,7 @@
|
||||
#define CH34X_BUFFER_SIZE 2
|
||||
|
||||
// The following defines have been taken over from Linux driver /drivers/usb/serial/ch341.c
|
||||
// Note: updated driver can also be found in https://github.com/WCHSoftGroup/ch341ser_linux/tree/main/driver
|
||||
|
||||
#define DEFAULT_BAUD_RATE 9600
|
||||
|
||||
@ -53,8 +54,7 @@
|
||||
/* second interrupt byte */
|
||||
#define CH341_MULT_STAT 0x04 /* multiple status since last interrupt event */
|
||||
|
||||
/* status returned in third interrupt answer byte, inverted in data
|
||||
from irq */
|
||||
/* status returned in third interrupt answer byte, inverted in data from irq */
|
||||
#define CH341_BIT_CTS 0x01
|
||||
#define CH341_BIT_DSR 0x02
|
||||
#define CH341_BIT_RI 0x04
|
||||
|
Loading…
x
Reference in New Issue
Block a user