aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/ClassDriver/USBtoSerial
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
commitf896c00c48f04fb9273555ab8d9b1af99f865d25 (patch)
treeb76827a0467c77ddeb30e11748c02a4f53779a14 /Demos/Device/ClassDriver/USBtoSerial
parente338cb6f329d6bf948abad88637f81436ee90daf (diff)
downloadlufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.gz
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.bz2
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.zip
Break device mode class driver interfaces into seperate config and state structs which are then combined, for clarity. Move device mode class driver interfaces back into the device mode class driver headers from the common class headers to make room for host class interfaces.
Diffstat (limited to 'Demos/Device/ClassDriver/USBtoSerial')
-rw-r--r--Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c61
-rw-r--r--Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h2
2 files changed, 41 insertions, 22 deletions
diff --git a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c
index dbe21c21c..a2ba253d2 100644
--- a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c
+++ b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.c
@@ -46,18 +46,26 @@ RingBuff_t Tx_Buffer;
* passed to all CDC Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another.
*/
-USB_ClassInfo_CDC_t VirtualSerial_CDC_Interface =
+USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
{
- .ControlInterfaceNumber = 0,
+ .Config =
+ {
+ .ControlInterfaceNumber = 0,
- .DataINEndpointNumber = CDC_TX_EPNUM,
- .DataINEndpointSize = CDC_TXRX_EPSIZE,
+ .DataINEndpointNumber = CDC_TX_EPNUM,
+ .DataINEndpointSize = CDC_TXRX_EPSIZE,
- .DataOUTEndpointNumber = CDC_RX_EPNUM,
- .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
+ .DataOUTEndpointNumber = CDC_RX_EPNUM,
+ .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
- .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
- .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
+ .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
+ },
+
+ .State =
+ {
+ // Leave all state values to their defaults
+ }
};
/** Main program entry point. This routine contains the overall program flow, including initial
@@ -152,27 +160,38 @@ ISR(USART1_RX_vect, ISR_BLOCK)
*
* \param CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced
*/
-void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo)
+void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo)
{
uint8_t ConfigMask = 0;
- if (CDCInterfaceInfo->LineEncoding.ParityType == CDC_PARITY_Odd)
- ConfigMask = ((1 << UPM11) | (1 << UPM10));
- else if (CDCInterfaceInfo->LineEncoding.ParityType == CDC_PARITY_Even)
- ConfigMask = (1 << UPM11);
+ switch (CDCInterfaceInfo->State.LineEncoding.ParityType)
+ {
+ case CDC_PARITY_Odd:
+ ConfigMask = ((1 << UPM11) | (1 << UPM10));
+ break;
+ case CDC_PARITY_Even:
+ ConfigMask = (1 << UPM11);
+ break;
+ }
- if (CDCInterfaceInfo->LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits)
+ if (CDCInterfaceInfo->State.LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits)
ConfigMask |= (1 << USBS1);
- if (CDCInterfaceInfo->LineEncoding.DataBits == 6)
- ConfigMask |= (1 << UCSZ10);
- else if (CDCInterfaceInfo->LineEncoding.DataBits == 7)
- ConfigMask |= (1 << UCSZ11);
- else if (CDCInterfaceInfo->LineEncoding.DataBits == 8)
- ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10));
+ switch (CDCInterfaceInfo->State.LineEncoding.DataBits)
+ {
+ case 6:
+ ConfigMask |= (1 << UCSZ10);
+ break;
+ case 7:
+ ConfigMask |= (1 << UCSZ11);
+ break;
+ case 8:
+ ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10));
+ break;
+ }
UCSR1A = (1 << U2X1);
UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1));
UCSR1C = ConfigMask;
- UBRR1 = SERIAL_2X_UBBRVAL((uint16_t)CDCInterfaceInfo->LineEncoding.BaudRateBPS);
+ UBRR1 = SERIAL_2X_UBBRVAL((uint16_t)CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);
}
diff --git a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h
index 8aa29b6b4..d0d4edb6c 100644
--- a/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h
+++ b/Demos/Device/ClassDriver/USBtoSerial/USBtoSerial.h
@@ -74,6 +74,6 @@
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
- void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
+ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo);
#endif