mirror of
https://github.com/hathach/tinyusb.git
synced 2026-08-18 11:02:16 +00:00
minor clean up
This commit is contained in:
@ -221,45 +221,57 @@ static uint8_t const ncm_hs_configuration[] = {
|
||||
|
||||
#endif
|
||||
|
||||
// Configuration array: RNDIS and CDC-ECM
|
||||
// NCM work with all latest OS i.e macos 10.10+, windows 10+, and Linux.
|
||||
// For older system Configuration array of RNDIS and CDC-ECM may be needed for better compatibility.
|
||||
// - Windows only works with RNDIS
|
||||
// - MacOS only works with CDC-ECM
|
||||
// - Linux will work on both
|
||||
static const uint8_t *const configuration_fs_arr[CONFIG_ID_COUNT] = {
|
||||
#if CFG_TUD_ECM_RNDIS
|
||||
|
||||
static const uint8_t *const configuration_fs_arr[CONFIG_ID_COUNT] = {
|
||||
[CONFIG_ID_RNDIS] = rndis_fs_configuration,
|
||||
[CONFIG_ID_ECM] = ecm_fs_configuration
|
||||
#else
|
||||
[CONFIG_ID_NCM] = ncm_fs_configuration
|
||||
#endif
|
||||
};
|
||||
|
||||
#if TUD_OPT_HIGH_SPEED
|
||||
static const uint8_t *const configuration_hs_arr[CONFIG_ID_COUNT] = {
|
||||
#if CFG_TUD_ECM_RNDIS
|
||||
[CONFIG_ID_RNDIS] = rndis_hs_configuration,
|
||||
[CONFIG_ID_ECM] = ecm_hs_configuration
|
||||
#else
|
||||
[CONFIG_ID_NCM] = ncm_hs_configuration
|
||||
#endif
|
||||
};
|
||||
|
||||
// Size array for each configuration
|
||||
static const uint16_t configuration_sz_arr[CONFIG_ID_COUNT] = {
|
||||
#if CFG_TUD_ECM_RNDIS
|
||||
[CONFIG_ID_RNDIS] = MAIN_CONFIG_TOTAL_LEN,
|
||||
[CONFIG_ID_ECM] = ALT_CONFIG_TOTAL_LEN
|
||||
#else
|
||||
[CONFIG_ID_NCM] = NCM_CONFIG_TOTAL_LEN
|
||||
#endif
|
||||
};
|
||||
|
||||
// Scratch buffer for other speed configuration (sized to hold the largest config)
|
||||
#if CFG_TUD_ECM_RNDIS
|
||||
#define MAX_CONFIG_TOTAL_LEN TU_MAX(MAIN_CONFIG_TOTAL_LEN, ALT_CONFIG_TOTAL_LEN)
|
||||
#else
|
||||
#define MAX_CONFIG_TOTAL_LEN NCM_CONFIG_TOTAL_LEN
|
||||
#define MAX_CONFIG_TOTAL_LEN TU_MAX(MAIN_CONFIG_TOTAL_LEN, ALT_CONFIG_TOTAL_LEN)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
static const uint8_t *const configuration_fs_arr[CONFIG_ID_COUNT] = {
|
||||
[CONFIG_ID_NCM] = ncm_fs_configuration
|
||||
};
|
||||
|
||||
#if TUD_OPT_HIGH_SPEED
|
||||
static const uint8_t *const configuration_hs_arr[CONFIG_ID_COUNT] = {
|
||||
[CONFIG_ID_NCM] = ncm_hs_configuration
|
||||
};
|
||||
|
||||
// Size array for each configuration
|
||||
static const uint16_t configuration_sz_arr[CONFIG_ID_COUNT] = {
|
||||
[CONFIG_ID_NCM] = NCM_CONFIG_TOTAL_LEN
|
||||
};
|
||||
|
||||
// Scratch buffer for other speed configuration (sized to hold the largest config)
|
||||
#define MAX_CONFIG_TOTAL_LEN NCM_CONFIG_TOTAL_LEN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if TUD_OPT_HIGH_SPEED
|
||||
static uint8_t desc_other_speed_config[MAX_CONFIG_TOTAL_LEN];
|
||||
|
||||
// device qualifier: device descriptor fields that differ at other speed
|
||||
|
||||
@ -48,10 +48,10 @@ typedef struct {
|
||||
uint8_t itf_num; // Index number of Management Interface, +1 for Data Interface
|
||||
uint8_t itf_data_alt; // Alternate setting of Data Interface. 0 : inactive, 1 : active
|
||||
|
||||
uint8_t ep_notif;
|
||||
uint8_t ep_in;
|
||||
uint8_t ep_out;
|
||||
uint16_t ep_size; // bulk endpoint max packet size (IN and OUT assumed equal)
|
||||
uint8_t ep_notif;
|
||||
|
||||
bool ecm_mode;
|
||||
|
||||
@ -361,7 +361,7 @@ bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
|
||||
/* data transmission finished */
|
||||
if (ep_addr == _netd_itf.ep_in) {
|
||||
/* TinyUSB requires the class driver to implement ZLP (since ZLP usage is class-specific) */
|
||||
if (xferred_bytes && (0 == (xferred_bytes % _netd_itf.ep_size))) {
|
||||
if (xferred_bytes > 0 && 0 == (xferred_bytes & (_netd_itf.ep_size-1))) {
|
||||
do_in_xfer(NULL, 0); /* a ZLP is needed */
|
||||
} else {
|
||||
/* we're finally finished */
|
||||
|
||||
@ -342,7 +342,7 @@ static bool xmit_insert_required_zlp(uint8_t rhport, uint32_t xferred_bytes) {
|
||||
TU_LOG_DRV("xmit_insert_required_zlp(%d,%ld)\n", rhport, xferred_bytes);
|
||||
|
||||
uint16_t const ep_size = ncm_interface.ep_size;
|
||||
if (xferred_bytes == 0 || xferred_bytes % ep_size != 0) {
|
||||
if (xferred_bytes == 0 || (xferred_bytes & (ep_size-1)) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user