aboutsummaryrefslogtreecommitdiffstats
path: root/Bootloaders/CDC/BootloaderCDC.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-09-28 13:27:19 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-09-28 13:27:19 +0000
commitb2a30cd48a0621b360d23dd430c646d22e943d09 (patch)
tree99cea070a86b80281a4f4c0d45b3fb3c776528b0 /Bootloaders/CDC/BootloaderCDC.c
parent713670043a1edb714461fc83c2b8817f3db99961 (diff)
downloadlufa-b2a30cd48a0621b360d23dd430c646d22e943d09.tar.gz
lufa-b2a30cd48a0621b360d23dd430c646d22e943d09.tar.bz2
lufa-b2a30cd48a0621b360d23dd430c646d22e943d09.zip
Added CDC functional descriptor structs to the Low Level CDC demos and CDC class bootloader, to improve the readability of the descriptors.
Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev).
Diffstat (limited to 'Bootloaders/CDC/BootloaderCDC.c')
-rw-r--r--Bootloaders/CDC/BootloaderCDC.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/Bootloaders/CDC/BootloaderCDC.c b/Bootloaders/CDC/BootloaderCDC.c
index cfc040f8b..234b5ce88 100644
--- a/Bootloaders/CDC/BootloaderCDC.c
+++ b/Bootloaders/CDC/BootloaderCDC.c
@@ -36,6 +36,14 @@
#define INCLUDE_FROM_BOOTLOADERCDC_C
#include "BootloaderCDC.h"
+/** Contains the current baud rate and other settings of the first virtual serial port. This must be retained as some
+ * operating systems will not open the port unless the settings can be set successfully.
+ */
+CDC_Line_Coding_t LineEncoding = { .BaudRateBPS = 0,
+ .CharFormat = OneStopBit,
+ .ParityType = Parity_None,
+ .DataBits = 8 };
+
/** Current address counter. This stores the current address of the FLASH or EEPROM as set by the host,
* and is used when reading or writing to the AVRs memory (either FLASH or EEPROM depending on the issued
* command.)
@@ -113,6 +121,40 @@ void EVENT_USB_Device_ConfigurationChanged(void)
ENDPOINT_BANK_SINGLE);
}
+/** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific
+ * control requests that are not handled internally by the USB library (including the CDC control commands,
+ * which are all issued via the control endpoint), so that they can be handled appropriately for the application.
+ */
+void EVENT_USB_Device_UnhandledControlRequest(void)
+{
+ /* Process CDC specific control requests */
+ switch (USB_ControlRequest.bRequest)
+ {
+ case REQ_GetLineEncoding:
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
+ {
+ Endpoint_ClearSETUP();
+
+ /* Write the line coding data to the control endpoint */
+ Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
+ Endpoint_ClearOUT();
+ }
+
+ break;
+ case REQ_SetLineEncoding:
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
+ {
+ Endpoint_ClearSETUP();
+
+ /* Read the line coding data in from the host into the global struct */
+ Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
+ Endpoint_ClearIN();
+ }
+
+ break;
+ }
+}
+
/** Reads or writes a block of EEPROM or FLASH memory to or from the appropriate CDC data endpoint, depending
* on the AVR910 protocol command issued.
*