Add svn:eol-style property to source files, so that the line endings are correctly...
[pub/USBasp.git] / Demos / Device / LowLevel / DualVirtualSerial / DualVirtualSerial.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Header file for DualVirtualSerial.c.
34 */
35
36 #ifndef _DUAL_VIRTUALSERIAL_H_
37 #define _DUAL_VIRTUALSERIAL_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <avr/wdt.h>
42 #include <avr/power.h>
43 #include <avr/interrupt.h>
44 #include <string.h>
45
46 #include "Descriptors.h"
47
48 #include <LUFA/Version.h>
49 #include <LUFA/Drivers/USB/USB.h>
50 #include <LUFA/Drivers/Board/Joystick.h>
51 #include <LUFA/Drivers/Board/LEDs.h>
52
53 /* Macros: */
54 /** CDC Class specific request to get the current virtual serial port configuration settings. */
55 #define REQ_GetLineEncoding 0x21
56
57 /** CDC Class specific request to set the current virtual serial port configuration settings. */
58 #define REQ_SetLineEncoding 0x20
59
60 /** CDC Class specific request to set the current virtual serial port handshake line states. */
61 #define REQ_SetControlLineState 0x22
62
63 /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
64 #define LEDMASK_USB_NOTREADY LEDS_LED1
65
66 /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
67 #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
68
69 /** LED mask for the library LED driver, to indicate that the USB interface is ready. */
70 #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
71
72 /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
73 #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
74
75 /* Type Defines: */
76 /** Type define for the virtual serial port line encoding settings, for storing the current USART configuration
77 * as set by the host via a class specific request.
78 */
79 typedef struct
80 {
81 uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second */
82 uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the
83 * CDCDevice_CDC_LineCodingFormats_t enum
84 */
85 uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the
86 * CDCDevice_LineCodingParity_t enum
87 */
88 uint8_t DataBits; /**< Bits of data per character of the virtual serial port */
89 } CDC_Line_Coding_t;
90
91 /* Enums: */
92 /** Enum for the possible line encoding formats of a virtual serial port. */
93 enum CDCDevice_CDC_LineCodingFormats_t
94 {
95 OneStopBit = 0, /**< Each frame contains one stop bit */
96 OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
97 TwoStopBits = 2, /**< Each frame contains two stop bits */
98 };
99
100 /** Enum for the possible line encoding parity settings of a virtual serial port. */
101 enum CDCDevice_LineCodingParity_t
102 {
103 Parity_None = 0, /**< No parity bit mode on each frame */
104 Parity_Odd = 1, /**< Odd parity bit mode on each frame */
105 Parity_Even = 2, /**< Even parity bit mode on each frame */
106 Parity_Mark = 3, /**< Mark parity bit mode on each frame */
107 Parity_Space = 4, /**< Space parity bit mode on each frame */
108 };
109
110 /* Function Prototypes: */
111 void CDC1_Task(void);
112 void CDC2_Task(void);
113 void SetupHardware(void);
114
115 void EVENT_USB_Device_Connect(void);
116 void EVENT_USB_Device_Disconnect(void);
117 void EVENT_USB_Device_ConfigurationChanged(void);
118 void EVENT_USB_Device_UnhandledControlRequest(void);
119
120 #endif