X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/d4ca7fb44c7d326b96cf391f0275dc323dbe24de..03ee87b35abdb8b92e8b55ec040fa943f9a6786c:/LUFA/Drivers/USB/Class/Device/CDC.h diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index 4982b0929..d248868cd 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted @@ -38,6 +38,23 @@ * \section Module Description * Device Mode USB Class driver framework interface, for the CDC USB Class driver. * + * \note There are several major drawbacks to the CDC-ACM standard USB class, however + * it is very standardized and thus usually available as a built-in driver on + * most platforms, and so is a better choice than a proprietary serial class. + * + * One major issue with CDC-ACM is that it requires two Interface descriptors, + * which will upset most hosts when part of a multi-function "Composite" USB + * device, as each interface will be loaded into a separate driver instance. To + * conbat this, you should use the "Interface Association Descriptor" addendum to + * the USB standard which is available on most OSes when creating Composite devices. + * + * Another major oversight is that there is no mechanism for the host to notify the + * device that there is a data sink on the host side ready to accept data. This + * means that the device may try to send data while the host isn't listening, causing + * lengthy blocking timeouts in the transmission routines. To combat this, it is + * recommended that the virtual serial line DTR (Data Terminal Ready) be used where + * possible to determine if a host application is ready for data. + * * @{ */ @@ -155,7 +172,12 @@ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); /** Sends a given string to the attached USB host, if connected. If a host is not connected when the function is called, the - * string is discarded. + * string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the + * \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be + * packed into a single endpoint packet, increasing data throughput. + * + * \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or + * the call will fail. * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state * \param[in] Data Pointer to the string to send to the host @@ -167,7 +189,12 @@ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the - * byte is discarded. + * byte is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the + * \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be + * packed into a single endpoint packet, increasing data throughput. + * + * \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or + * the call will fail. * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state * \param[in] Data Byte of data to send to the host @@ -178,6 +205,9 @@ /** Determines the number of bytes received by the CDC interface from the host, waiting to be read. * + * \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or + * the call will fail. + * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state * * \return Total number of buffered bytes received from the host @@ -188,6 +218,9 @@ * returns 0. The \ref CDC_Device_BytesReceived() function should be queried before data is received to ensure that no data * underflow occurs. * + * \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or + * the call will fail. + * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state * * \return Next received byte from the host, or 0 if no data received @@ -196,6 +229,9 @@ /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared. * + * \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or + * the call will fail. + * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state * * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum @@ -207,6 +243,9 @@ * until they are cleared via a second notification. This should be called each time the CDC class driver's * ControlLineStates.DeviceToHost value is updated to push the new states to the USB host. * + * \note This function must only be called when the Device state machine is in the DEVICE_STATE_Configured state or + * the call will fail. + * * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state */ void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);