diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-08 10:06:49 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-08 10:06:49 +0000 |
commit | bde64666fbdda0a275344c0e5e5175f770be516d (patch) | |
tree | f12e90fcf41f5ca163a9b33a40fc7e5747e2a428 | |
parent | e6881fd166586793a5a90effeefe4188092f383b (diff) | |
download | lufa-bde64666fbdda0a275344c0e5e5175f770be516d.tar.gz lufa-bde64666fbdda0a275344c0e5e5175f770be516d.tar.bz2 lufa-bde64666fbdda0a275344c0e5e5175f770be516d.zip |
Finished CDC device class driver documentation.
-rw-r--r-- | Bootloaders/DFU/BootloaderDFU.c | 6 | ||||
-rw-r--r-- | LUFA/ChangeLog.txt | 5 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.c | 9 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.h | 38 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.h | 2 |
5 files changed, 54 insertions, 6 deletions
diff --git a/Bootloaders/DFU/BootloaderDFU.c b/Bootloaders/DFU/BootloaderDFU.c index 1850803d4..6da741e39 100644 --- a/Bootloaders/DFU/BootloaderDFU.c +++ b/Bootloaders/DFU/BootloaderDFU.c @@ -462,8 +462,10 @@ static void DiscardFillerBytes(uint8_t NumberOfBytes) /* Wait until next data packet received */
while (!(Endpoint_IsOUTReceived()));
}
-
- Endpoint_Discard_Byte();
+ else
+ {
+ Endpoint_Discard_Byte();
+ }
}
}
diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt index 7e37ac45b..0eea9c43c 100644 --- a/LUFA/ChangeLog.txt +++ b/LUFA/ChangeLog.txt @@ -5,13 +5,12 @@ */
========== TODO: ===========
- - Fix bootloaders - make compatible with smaller USB AVRS (USB_IsConnected)
- Document new device class drivers
- - Made new host class drivers
+ - Make new host class drivers
- Document new host class drivers
- Convert Host mode demos to class drivers
- - Convert Host mode demos to schedulerless
- Add standardized descriptor names to class driver structures, controlled by USE_NONSTANDARD_DESCRIPTOR_NAMES
+ - Add multiple-report HID demo to the library
============================
/** \page Page_ChangeLog Project Changelog
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c index dface2a6d..c551fb769 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.c +++ b/LUFA/Drivers/USB/Class/Device/CDC.c @@ -130,6 +130,9 @@ void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo) void USB_CDC_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length)
{
+ if (!(USB_IsConnected))
+ return;
+
Endpoint_SelectEndpoint(CDCInterfaceInfo->DataINEndpointNumber);
Endpoint_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
}
@@ -159,6 +162,9 @@ uint16_t USB_CDC_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo) uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo)
{
+ if (!(USB_IsConnected))
+ return 0;
+
Endpoint_SelectEndpoint(CDCInterfaceInfo->DataOUTEndpointNumber);
uint8_t DataByte = Endpoint_Read_Byte();
@@ -171,6 +177,9 @@ uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo) void USB_CDC_SendSerialLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask)
{
+ if (!(USB_IsConnected))
+ return;
+
Endpoint_SelectEndpoint(CDCInterfaceInfo->NotificationEndpointNumber);
USB_Request_Header_t Notification = (USB_Request_Header_t)
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.h b/LUFA/Drivers/USB/Class/Device/CDC.h index ee9e3767d..feb7ff24b 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.h +++ b/LUFA/Drivers/USB/Class/Device/CDC.h @@ -234,10 +234,48 @@ */
void EVENT_USB_CDC_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
+ /** 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.
+ *
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param Data Pointer to the string to send to the host
+ * \param Length Size in bytes of the string to send to the host
+ */
void USB_CDC_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length);
+
+ /** 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.
+ *
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param Data Byte of data to send to the host
+ */
void USB_CDC_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data);
+
+ /** Determines the number of bytes received by the CDC interface from the host, waiting to be read.
+ *
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ *
+ * \return Total number of buffered bytes received from the host
+ */
uint16_t USB_CDC_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
+
+ /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function
+ * returns 0. The USB_CDC_BytesReceived() function should be queried before data is recieved to ensure that no data
+ * underflow occurs.
+ *
+ * \param 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
+ */
uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
+
+ /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial control
+ * lines (DCD, DSR, etc.) have changed states, or to give BREAK notfications to the host. Line states persist until they are
+ * cleared via a second notification.
+ *
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
+ * \param LineStateMask Mask of CDC_CONTROL_LINE_IN_* masks giving the current control line states
+ */
void USB_CDC_SendSerialLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask);
/* Disable C linkage for C++ Compilers: */
diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index f863f811d..e812a39c7 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -115,7 +115,7 @@ uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint */
uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint */
- uint8_t ReportINBufferSize;
+ uint8_t ReportINBufferSize; /**< Size of the largest possible report to send to the host, for buffer allocation purposes */
bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode */
uint16_t IdleCount; /**< Report idle period, in ms, set by the host */
|