mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
add fs & hs config for cdc_msc_freertos, midi_test, msc_dual_lun
This commit is contained in:
parent
ed065691ef
commit
fea6fb73a1
@ -114,7 +114,7 @@ enum
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t const desc_configuration[] =
|
uint8_t const desc_fs_configuration[] =
|
||||||
{
|
{
|
||||||
// Config number, interface count, string index, total length, attribute, power in mA
|
// Config number, interface count, string index, total length, attribute, power in mA
|
||||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||||
@ -123,9 +123,22 @@ uint8_t const desc_configuration[] =
|
|||||||
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
|
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
|
||||||
|
|
||||||
// Interface number, string index, EP Out & EP In address, EP size
|
// Interface number, string index, EP Out & EP In address, EP size
|
||||||
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
|
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if TUD_OPT_HIGH_SPEED
|
||||||
|
uint8_t const desc_hs_configuration[] =
|
||||||
|
{
|
||||||
|
// Config number, interface count, string index, total length, attribute, power in mA
|
||||||
|
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||||
|
|
||||||
|
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
|
||||||
|
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 512),
|
||||||
|
|
||||||
|
// Interface number, string index, EP Out & EP In address, EP size
|
||||||
|
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512),
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
||||||
// Application return pointer to descriptor
|
// Application return pointer to descriptor
|
||||||
@ -133,7 +146,13 @@ uint8_t const desc_configuration[] =
|
|||||||
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
||||||
{
|
{
|
||||||
(void) index; // for multiple configurations
|
(void) index; // for multiple configurations
|
||||||
return desc_configuration;
|
|
||||||
|
#if TUD_OPT_HIGH_SPEED
|
||||||
|
// Although we are highspeed, host may be fullspeed.
|
||||||
|
return (tud_speed_get() == TUSB_SPEED_HIGH ) ? desc_hs_configuration : desc_fs_configuration;
|
||||||
|
#else
|
||||||
|
return desc_fs_configuration;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -88,22 +88,39 @@ enum
|
|||||||
#define EPNUM_MIDI 0x01
|
#define EPNUM_MIDI 0x01
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t const desc_configuration[] =
|
uint8_t const desc_fs_configuration[] =
|
||||||
{
|
{
|
||||||
// Config number, interface count, string index, total length, attribute, power in mA
|
// Config number, interface count, string index, total length, attribute, power in mA
|
||||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||||
|
|
||||||
// Interface number, string index, EP Out & EP In address, EP size
|
// Interface number, string index, EP Out & EP In address, EP size
|
||||||
TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, TUD_OPT_HIGH_SPEED ? 512 : 64)
|
TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 64)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if TUD_OPT_HIGH_SPEED
|
||||||
|
uint8_t const desc_fs_configuration[] =
|
||||||
|
{
|
||||||
|
// Config number, interface count, string index, total length, attribute, power in mA
|
||||||
|
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||||
|
|
||||||
|
// Interface number, string index, EP Out & EP In address, EP size
|
||||||
|
TUD_MIDI_DESCRIPTOR(ITF_NUM_MIDI, 0, EPNUM_MIDI, 0x80 | EPNUM_MIDI, 512)
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
||||||
// Application return pointer to descriptor
|
// Application return pointer to descriptor
|
||||||
// Descriptor contents must exist long enough for transfer to complete
|
// Descriptor contents must exist long enough for transfer to complete
|
||||||
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
||||||
{
|
{
|
||||||
(void) index; // for multiple configurations
|
(void) index; // for multiple configurations
|
||||||
return desc_configuration;
|
|
||||||
|
#if TUD_OPT_HIGH_SPEED
|
||||||
|
// Although we are highspeed, host may be fullspeed.
|
||||||
|
return (tud_speed_get() == TUSB_SPEED_HIGH ) ? desc_hs_configuration : desc_fs_configuration;
|
||||||
|
#else
|
||||||
|
return desc_fs_configuration;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -96,22 +96,39 @@ enum
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t const desc_configuration[] =
|
uint8_t const desc_fs_configuration[] =
|
||||||
{
|
{
|
||||||
// Config number, interface count, string index, total length, attribute, power in mA
|
// Config number, interface count, string index, total length, attribute, power in mA
|
||||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||||
|
|
||||||
// Interface number, string index, EP Out & EP In address, EP size
|
// Interface number, string index, EP Out & EP In address, EP size
|
||||||
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
|
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if TUD_OPT_HIGH_SPEED
|
||||||
|
uint8_t const desc_hs_configuration[] =
|
||||||
|
{
|
||||||
|
// Config number, interface count, string index, total length, attribute, power in mA
|
||||||
|
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||||
|
|
||||||
|
// Interface number, string index, EP Out & EP In address, EP size
|
||||||
|
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 512),
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
// Invoked when received GET CONFIGURATION DESCRIPTOR
|
||||||
// Application return pointer to descriptor
|
// Application return pointer to descriptor
|
||||||
// Descriptor contents must exist long enough for transfer to complete
|
// Descriptor contents must exist long enough for transfer to complete
|
||||||
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
|
||||||
{
|
{
|
||||||
(void) index; // for multiple configurations
|
(void) index; // for multiple configurations
|
||||||
return desc_configuration;
|
|
||||||
|
#if TUD_OPT_HIGH_SPEED
|
||||||
|
// Although we are highspeed, host may be fullspeed.
|
||||||
|
return (tud_speed_get() == TUSB_SPEED_HIGH ) ? desc_hs_configuration : desc_fs_configuration;
|
||||||
|
#else
|
||||||
|
return desc_fs_configuration;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
// Class Driver Configuration
|
// Class Driver Configuration
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#ifndef CFG_TUD_CDC_EP_BUFSIZE
|
#ifndef CFG_TUD_CDC_EP_BUFSIZE
|
||||||
#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
|
#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -67,8 +67,8 @@ typedef struct
|
|||||||
uint8_t read_target_length;
|
uint8_t read_target_length;
|
||||||
|
|
||||||
// Endpoint Transfer buffer
|
// Endpoint Transfer buffer
|
||||||
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_MIDI_EPSIZE];
|
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_MIDI_EP_BUFSIZE];
|
||||||
CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUD_MIDI_EPSIZE];
|
CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUD_MIDI_EP_BUFSIZE];
|
||||||
|
|
||||||
} midid_interface_t;
|
} midid_interface_t;
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ static bool maybe_transmit(midid_interface_t* midi, uint8_t itf_index)
|
|||||||
// skip if previous transfer not complete
|
// skip if previous transfer not complete
|
||||||
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, midi->ep_in) );
|
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, midi->ep_in) );
|
||||||
|
|
||||||
uint16_t count = tu_fifo_read_n(&midi->tx_ff, midi->epin_buf, CFG_TUD_MIDI_EPSIZE);
|
uint16_t count = tu_fifo_read_n(&midi->tx_ff, midi->epin_buf, CFG_TUD_MIDI_EP_BUFSIZE);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, midi->ep_in, midi->epin_buf, count) );
|
TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, midi->ep_in, midi->epin_buf, count) );
|
||||||
@ -359,7 +359,7 @@ uint16_t midid_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for incoming data
|
// Prepare for incoming data
|
||||||
if ( !usbd_edpt_xfer(rhport, p_midi->ep_out, p_midi->epout_buf, CFG_TUD_MIDI_EPSIZE) )
|
if ( !usbd_edpt_xfer(rhport, p_midi->ep_out, p_midi->epout_buf, CFG_TUD_MIDI_EP_BUFSIZE) )
|
||||||
{
|
{
|
||||||
TU_LOG1_FAILED();
|
TU_LOG1_FAILED();
|
||||||
TU_BREAKPOINT();
|
TU_BREAKPOINT();
|
||||||
@ -404,7 +404,7 @@ bool midid_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32
|
|||||||
midi_rx_done_cb(p_midi, p_midi->epout_buf, xferred_bytes);
|
midi_rx_done_cb(p_midi, p_midi->epout_buf, xferred_bytes);
|
||||||
|
|
||||||
// prepare for next
|
// prepare for next
|
||||||
TU_ASSERT( usbd_edpt_xfer(rhport, p_midi->ep_out, p_midi->epout_buf, CFG_TUD_MIDI_EPSIZE), false );
|
TU_ASSERT( usbd_edpt_xfer(rhport, p_midi->ep_out, p_midi->epout_buf, CFG_TUD_MIDI_EP_BUFSIZE), false );
|
||||||
} else if ( ep_addr == p_midi->ep_in ) {
|
} else if ( ep_addr == p_midi->ep_in ) {
|
||||||
maybe_transmit(p_midi, itf);
|
maybe_transmit(p_midi, itf);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
// Class Driver Configuration
|
// Class Driver Configuration
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#ifndef CFG_TUD_MIDI_EPSIZE
|
#ifndef CFG_TUD_MIDI_EPSIZE
|
||||||
#define CFG_TUD_MIDI_EPSIZE 64
|
#define CFG_TUD_MIDI_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user