Datasheet
}
return error;
}
usb_status_t USB_DeviceCdcVcomConfigureEndpointStatus(usb_device_handle handle, uint8_t ep,
uint8_t status)
{
usb_status_t error = kStatus_USB_Error;
uint8_t i;
if (status)
{
for(i = 0; i < USB_DEVICE_CONFIG_CDC_ACM; i++)
{
if ((g_CdcVcomDicBulkInEndpoint[i] == (ep & USB_ENDPOINT_NUMBER_MASK)) &&
(ep & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK))
{
error = USB_DeviceStallEndpoint(handle, ep);
}
else if ((g_CdcVcomDicBulkOutEndpoint[i] == (ep & USB_ENDPOINT_NUMBER_MASK)) &&
ep & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK))
{
error = USB_DeviceStallEndpoint(handle, ep);
}
}
}
else
{
for(i = 0; i < USB_DEVICE_CONFIG_CDC_ACM; i++)
{
if ((g_CdcVcomDicBulkInEndpoint[i] == (ep & USB_ENDPOINT_NUMBER_MASK)) &&
(ep & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK))
{
error = USB_DeviceUnstallEndpoint(handle, ep);
}
else if ((g_CdcVcomDicBulkOutEndpoint[i] == (ep & USB_ENDPOINT_NUMBER_MASK)) &&
(ep & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK))
{
error = USB_DeviceUnstallEndpoint(handle, ep);
}
}
}
return error;
}
There is a lot code in fact can be replaced by loop, It is a key step to make automatic composite class for application. Other similar
code is not listed here, Refer to the code released with this application note for more details.
6.3.2 Remove unnecessary settings
The following settings can be merged, as in most cases, user do not need to tune the parameters at all. Even in some special
case that some users need to tune the parameters, it is also supported in runtime initialization.
/* Packet size. */
#define HS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE (16)
#define FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE (16)
#define HS_CDC_VCOM_INTERRUPT_IN_INTERVAL (0x07) /* 2^(7-1) = 8ms */
#define FS_CDC_VCOM_INTERRUPT_IN_INTERVAL (0x08)
NXP Semiconductors
Key Steps
USB to Multi VCOM on K32L2 Series MCU, Rev. 0, November 2019
Application Note 20 / 25